Skip to content

Commit

Permalink
implement disk image-type validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxtof committed Jan 7, 2022
1 parent b9e9d89 commit 83e4fe4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion machine/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ func (d *NutanixDriver) Create() error {
for _, image := range images.Entities {
if *image.Status.Name == d.Image {

log.Infof("Image %s find with UUID: %s", *image.Status.Name, *image.Metadata.UUID)

if *image.Status.Resources.ImageType != "DISK_IMAGE" {
log.Errorf("Image %s is not a disk template", d.Image)
return fmt.Errorf("image %s is not a disk template", d.Image)
}

if d.ImageSize > 0 {
newSize := int64(d.ImageSize * 1024)
n := &v3.VMDisk{
Expand All @@ -212,7 +219,6 @@ func (d *NutanixDriver) Create() error {
res.DiskList = append(res.DiskList, n)
}

log.Infof("Image %s find with UUID: %s", *image.Status.Name, *image.Metadata.UUID)
break
}
}
Expand All @@ -222,6 +228,7 @@ func (d *NutanixDriver) Create() error {
return fmt.Errorf("image %s not found", d.Image)
}

// Add additional disks
if len(d.StorageContainer) != 0 && d.DiskSize > 0 {
n := &v3.VMDisk{
DiskSizeBytes: utils.Int64Ptr(int64(d.DiskSize) * 1024 * 1024 * 1024),
Expand Down

0 comments on commit 83e4fe4

Please sign in to comment.