Commit 9a8c6db4 authored by Davanum Srinivas's avatar Davanum Srinivas

Split out the hostname when default dhcp_domain is used in nova.conf

When /etc/nova/nova.conf does not have specify dhcp_domain to empty string, a default string of '.novalocal' is returned by the meta data service. So we need to just split the string and pick the first one in the array. ``` $ curl http://169.254.169.254/latest/meta-data/hostname testvm-1.novalocal $ curl http://169.254.169.254/latest/meta-data/public-hostname testvm-1.novalocal $ curl http://169.254.169.254/latest/meta-data/local-hostname testvm-1.novalocal ```
parent 76ffe9e8
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"context" "context"
"fmt" "fmt"
"regexp" "regexp"
"strings"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud"
...@@ -60,7 +61,7 @@ func (i *Instances) CurrentNodeName(ctx context.Context, hostname string) (types ...@@ -60,7 +61,7 @@ func (i *Instances) CurrentNodeName(ctx context.Context, hostname string) (types
if err != nil { if err != nil {
return "", err return "", err
} }
return types.NodeName(md.Hostname), nil return types.NodeName(strings.Split(md.Hostname, ".")[0]), nil
} }
// AddSSHKeyToAllInstances is not implemented for OpenStack // AddSSHKeyToAllInstances is not implemented for OpenStack
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment