MCPcopy Create free account
hub / github.com/cloudfoundry/bosh-agent / SetupHostname

Method SetupHostname

platform/linux_platform.go:567–598  ·  view source on GitHub ↗
(hostname string)

Source from the content-addressed store, hash-verified

565}
566
567func (p linux) SetupHostname(hostname string) error {
568 if p.state.Linux.HostsConfigured {
569 return nil
570 }
571
572 _, _, _, err := p.cmdRunner.RunCommand("hostname", hostname)
573 if err != nil {
574 return bosherr.WrapError(err, "Setting hostname")
575 }
576
577 err = p.fs.WriteFileString("/etc/hostname", hostname)
578 if err != nil {
579 return bosherr.WrapError(err, "Writing to /etc/hostname")
580 }
581
582 buffer, err := p.generateDefaultEtcHosts(hostname)
583 if err != nil {
584 return err
585 }
586 err = p.fs.WriteFile("/etc/hosts", buffer.Bytes())
587 if err != nil {
588 return bosherr.WrapError(err, "Writing to /etc/hosts")
589 }
590
591 p.state.Linux.HostsConfigured = true
592 err = p.state.SaveState()
593 if err != nil {
594 return bosherr.WrapError(err, "Setting up hostname")
595 }
596
597 return nil
598}
599
600func (p linux) SetupLogrotate(groupName, basePath, size string) (err error) {
601 buffer := bytes.NewBuffer([]byte{})

Callers

nothing calls this directly

Calls 3

RunCommandMethod · 0.65
SaveStateMethod · 0.45

Tested by

no test coverage detected