Merge pull request #11808 from ioito/hotfix/qx-openstack-vm-hostid

fix(region): avoid get openstack hostid panic
This commit is contained in:
Zexi Li
2021-08-05 17:18:27 +08:00
committed by GitHub
+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
}