Commit c197e623 authored by Davanum Srinivas's avatar Davanum Srinivas

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