Debian Codegraph @

api/v0/mesosutil/node.go

raw symbols SCIP
1 package mesosutil
2
3 import (
4 "os"
5 "os/exec"
6 "strings"
7
8 log "github.com/golang/glog"
9 )
10
11 //TODO(jdef) copied from kubernetes/pkg/util/node.go
12 func GetHostname(hostnameOverride string) string {
13 hostname := hostnameOverride
14 if hostname == "" {
15 // Note: We use exec here instead of os.Hostname() because we
16 // want the FQDN, and this is the easiest way to get it.
17 fqdn, err := exec.Command("hostname", "-f").Output()
18 if err != nil || len(fqdn) == 0 {
19 log.Errorf("Couldn't determine hostname fqdn, failing back to hostname: %v", err)
20 hostname, err = os.Hostname()
21 if err != nil {
22 log.Fatalf("Error getting hostname: %v", err)
23 }
24 } else {
25 hostname = string(fqdn)
26 }
27 }
28 return strings.TrimSpace(hostname)
29 }