diff --git a/README.md b/README.md index a5ce429..ac16d54 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ See complete Ubuntu, Windows, and macOS templates in the [examples folder](https ### VM Location * `vm_name`(string) - Name of the new VM to create. +* `notes`(string) - Add some notes. * `folder`(string) - VM folder to create the VM in. * `host`(string) - ESXi host where target VM is created. A full path must be specified if the host is in a folder. For example `folder/host`. See the `Specifying Clusters and Hosts` section above for more details. * `cluster`(string) - ESXi cluster where target VM is created. See [Working with Clusters](#working-with-clusters) section. diff --git a/clone/step_clone.go b/clone/step_clone.go index ecec2ee..07f65f2 100644 --- a/clone/step_clone.go +++ b/clone/step_clone.go @@ -13,6 +13,7 @@ type CloneConfig struct { Template string `mapstructure:"template"` DiskSize int64 `mapstructure:"disk_size"` LinkedClone bool `mapstructure:"linked_clone"` + Notes string `mapstructure:"notes"` } func (c *CloneConfig) Prepare() []error { @@ -54,6 +55,7 @@ func (s *StepCloneVM) Run(ctx context.Context, state multistep.StateBag) multist ResourcePool: s.Location.ResourcePool, Datastore: s.Location.Datastore, LinkedClone: s.Config.LinkedClone, + Annotation: s.Config.Notes, }) if err != nil { state.Put("error", err) diff --git a/driver/vm.go b/driver/vm.go index 44ac69b..286b951 100644 --- a/driver/vm.go +++ b/driver/vm.go @@ -24,6 +24,7 @@ type CloneConfig struct { ResourcePool string Datastore string LinkedClone bool + Annotation string } type HardwareConfig struct { @@ -219,6 +220,12 @@ func (template *VirtualMachine) Clone(ctx context.Context, config *CloneConfig) cloneSpec.Snapshot = tpl.Snapshot.CurrentSnapshot } + if config.Annotation != "" { + var configSpec types.VirtualMachineConfigSpec + configSpec.Annotation = config.Annotation + cloneSpec.Config = &configSpec + } + task, err := template.vm.Clone(template.driver.ctx, folder.folder, config.Name, cloneSpec) if err != nil { return nil, err diff --git a/iso/step_create.go b/iso/step_create.go index 1a05a59..a580103 100644 --- a/iso/step_create.go +++ b/iso/step_create.go @@ -21,6 +21,8 @@ type CreateConfig struct { Network string `mapstructure:"network"` NetworkCard string `mapstructure:"network_card"` USBController bool `mapstructure:"usb_controller"` + + Notes string `mapstructure:"notes"` } func (c *CreateConfig) Prepare() []error { @@ -67,6 +69,7 @@ func (s *StepCreateVM) Run(_ context.Context, state multistep.StateBag) multiste USBController: s.Config.USBController, Version: s.Config.Version, Firmware: s.Config.Firmware, + Annotation: s.Config.Notes, }) if err != nil { state.Put("error", fmt.Errorf("error creating vm: %v", err))