'notes' option (#185)
This commit is contained in:
parent
e21ff3fe47
commit
e929b193e0
|
@ -48,6 +48,7 @@ See complete Ubuntu, Windows, and macOS templates in the [examples folder](https
|
||||||
### VM Location
|
### VM Location
|
||||||
|
|
||||||
* `vm_name`(string) - Name of the new VM to create.
|
* `vm_name`(string) - Name of the new VM to create.
|
||||||
|
* `notes`(string) - Add some notes.
|
||||||
* `folder`(string) - VM folder to create the VM in.
|
* `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.
|
* `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.
|
* `cluster`(string) - ESXi cluster where target VM is created. See [Working with Clusters](#working-with-clusters) section.
|
||||||
|
|
|
@ -13,6 +13,7 @@ type CloneConfig struct {
|
||||||
Template string `mapstructure:"template"`
|
Template string `mapstructure:"template"`
|
||||||
DiskSize int64 `mapstructure:"disk_size"`
|
DiskSize int64 `mapstructure:"disk_size"`
|
||||||
LinkedClone bool `mapstructure:"linked_clone"`
|
LinkedClone bool `mapstructure:"linked_clone"`
|
||||||
|
Notes string `mapstructure:"notes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloneConfig) Prepare() []error {
|
func (c *CloneConfig) Prepare() []error {
|
||||||
|
@ -54,6 +55,7 @@ func (s *StepCloneVM) Run(ctx context.Context, state multistep.StateBag) multist
|
||||||
ResourcePool: s.Location.ResourcePool,
|
ResourcePool: s.Location.ResourcePool,
|
||||||
Datastore: s.Location.Datastore,
|
Datastore: s.Location.Datastore,
|
||||||
LinkedClone: s.Config.LinkedClone,
|
LinkedClone: s.Config.LinkedClone,
|
||||||
|
Annotation: s.Config.Notes,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
|
|
@ -24,6 +24,7 @@ type CloneConfig struct {
|
||||||
ResourcePool string
|
ResourcePool string
|
||||||
Datastore string
|
Datastore string
|
||||||
LinkedClone bool
|
LinkedClone bool
|
||||||
|
Annotation string
|
||||||
}
|
}
|
||||||
|
|
||||||
type HardwareConfig struct {
|
type HardwareConfig struct {
|
||||||
|
@ -219,6 +220,12 @@ func (template *VirtualMachine) Clone(ctx context.Context, config *CloneConfig)
|
||||||
cloneSpec.Snapshot = tpl.Snapshot.CurrentSnapshot
|
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)
|
task, err := template.vm.Clone(template.driver.ctx, folder.folder, config.Name, cloneSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -21,6 +21,8 @@ type CreateConfig struct {
|
||||||
Network string `mapstructure:"network"`
|
Network string `mapstructure:"network"`
|
||||||
NetworkCard string `mapstructure:"network_card"`
|
NetworkCard string `mapstructure:"network_card"`
|
||||||
USBController bool `mapstructure:"usb_controller"`
|
USBController bool `mapstructure:"usb_controller"`
|
||||||
|
|
||||||
|
Notes string `mapstructure:"notes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CreateConfig) Prepare() []error {
|
func (c *CreateConfig) Prepare() []error {
|
||||||
|
@ -67,6 +69,7 @@ func (s *StepCreateVM) Run(_ context.Context, state multistep.StateBag) multiste
|
||||||
USBController: s.Config.USBController,
|
USBController: s.Config.USBController,
|
||||||
Version: s.Config.Version,
|
Version: s.Config.Version,
|
||||||
Firmware: s.Config.Firmware,
|
Firmware: s.Config.Firmware,
|
||||||
|
Annotation: s.Config.Notes,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.Put("error", fmt.Errorf("error creating vm: %v", err))
|
state.Put("error", fmt.Errorf("error creating vm: %v", err))
|
||||||
|
|
Loading…
Reference in New Issue