flags := flag.NewFlagSet("", flag.ContinueOnError)
flags.SetOutput(stderr)
configFile := flags.String("config", arvados.DefaultConfigFile, "Site configuration `file`")
+ hostName := flags.String("host", "", "Host profile `name` to use in SystemNodes config (if blank, use hostname reported by OS)")
err = flags.Parse(args)
if err == flag.ErrHelp {
err = nil
if err != nil {
return 1
}
- node, err := cluster.GetThisSystemNode()
+ node, err := cluster.GetSystemNode(*hostName)
if err != nil {
return 1
}
// GetThisSystemNode returns a SystemNode for the node we're running
// on right now.
func (cc *Cluster) GetThisSystemNode() (*SystemNode, error) {
- hostname, err := os.Hostname()
- if err != nil {
- return nil, err
- }
- return cc.GetSystemNode(hostname)
+ return cc.GetSystemNode("")
}
// GetSystemNode returns a SystemNode for the given hostname. An error
// is returned if the appropriate configuration can't be determined
-// (e.g., this does not appear to be a system node).
+// (e.g., this does not appear to be a system node). If node is empty,
+// use the OS-reported hostname.
func (cc *Cluster) GetSystemNode(node string) (*SystemNode, error) {
+ if node == "" {
+ hostname, err := os.Hostname()
+ if err != nil {
+ return nil, err
+ }
+ node = hostname
+ }
if cfg, ok := cc.SystemNodes[node]; ok {
return &cfg, nil
}