Tolerate Flavor information for computing instance type

Current devstack seems to return "id", and an upcoming change using
nova's microversion will be returning "original_name":
https://blueprints.launchpad.net/nova/+spec/instance-flavor-api

So let's just inspect what is present and use that to figure out
the instance type.
pull/6/head
Davanum Srinivas 2017-07-19 16:06:49 -04:00
parent ebf24c14a9
commit c197e6238d
1 changed files with 10 additions and 12 deletions

View File

@ -188,19 +188,17 @@ func (i *Instances) InstanceType(name types.NodeName) (string, error) {
}
func srvInstanceType(srv *servers.Server) (string, error) {
val, ok := srv.Flavor["name"]
if !ok {
return "", fmt.Errorf("flavor name not present in server info")
keys := []string{"name", "id", "original_name"}
for _, key := range keys {
val, found := srv.Flavor[key]
if found {
flavor, ok := val.(string)
if ok {
return flavor, nil
}
}
}
flavor, ok := val.(string)
if !ok {
return "", fmt.Errorf("flavor name is not a string")
}
return flavor, nil
return "", fmt.Errorf("flavor name/id not found")
}
func instanceIDFromProviderID(providerID string) (instanceID string, err error) {