fix(region): avoid get openstack hostid panic

This commit is contained in:
Qu Xuan
2021-08-05 14:17:56 +08:00
parent e685e1eacf
commit 6632d5f14d
+10
View File
@@ -202,6 +202,16 @@ func (region *SRegion) GetIVMById(id string) (cloudprovider.ICloudVM, error) {
if err != nil {
return nil, errors.Wrapf(err, "GetInstance(%s)", id)
}
hosts, err := region.GetIHosts()
if err != nil {
return nil, err
}
for i := range hosts {
host := hosts[i].(*SHypervisor)
if instance.HypervisorHostname == host.HypervisorHostname {
instance.host = host
}
}
return instance, nil
}