Skip to content

Commit

Permalink
fix: 避免openstack以镜像做系统盘创建失败
Browse files Browse the repository at this point in the history
  • Loading branch information
Qu Xuan committed May 22, 2020
1 parent 4561da4 commit b31922a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/multicloud/openstack/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,18 @@ func (host *SHost) CreateVM(desc *cloudprovider.SManagedVMCreateConfig) (cloudpr
"destination_type": "volume",
"delete_on_termination": true,
})
} else {
BlockDeviceMappingV2 = append(BlockDeviceMappingV2, map[string]interface{}{
"boot_index": 0,
"uuid": image.ID,
"source_type": "image",
"destination_type": "local",
"delete_on_termination": true,
})
}

var _disk *SDisk
for _, disk := range desc.DataDisks {
for index, disk := range desc.DataDisks {
istorage, err := host.zone.GetIStorageById(disk.StorageExternalId)
if err != nil {
return nil, errors.Wrapf(err, "GetIStorageById(%s)", disk.StorageExternalId)
Expand All @@ -249,6 +257,7 @@ func (host *SHost) CreateVM(desc *cloudprovider.SManagedVMCreateConfig) (cloudpr
"source_type": "volume",
"destination_type": "volume",
"delete_on_termination": true,
"boot_index": index + 1,
"uuid": _disk.ID,
}

Expand Down

0 comments on commit b31922a

Please sign in to comment.