Skip to content

Commit

Permalink
Add function that Unmount Cloud ISO if not needed (#131)
Browse files Browse the repository at this point in the history
* Add function that Unmount Cloud ISO if not needed

* Refactor function
  • Loading branch information
mcbenjemaa committed Mar 22, 2024
1 parent 893e647 commit 0a31b09
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions virtual_machine.go
Expand Up @@ -643,3 +643,22 @@ func (v *VirtualMachine) ConvertToTemplate(ctx context.Context) (task *Task, err
}
return NewTask(upid, v.client), nil
}

func (v *VirtualMachine) UnmountCloudInitISO(ctx context.Context, device string) error {
if !v.HasTag(MakeTag(TagCloudInit)) {
return nil
}

_, err := v.Config(ctx, VirtualMachineOption{
Name: device,
Value: "none,media=cdrom",
})
if err != nil {
return err
}

if _, err = v.deleteCloudInitISO(ctx); err != nil {
return err
}
return nil
}

0 comments on commit 0a31b09

Please sign in to comment.