diff --git a/driver/vm.go b/driver/vm.go index 5a307a0ee..28d8a3c0d 100644 --- a/driver/vm.go +++ b/driver/vm.go @@ -47,6 +47,7 @@ type CreateConfig struct { ResourcePool string Datastore string GuestOS string // example: otherGuest + Network string // "" for default network Overwrite bool } @@ -109,7 +110,7 @@ func (d *Driver) CreateVM(config *CreateConfig) (*VirtualMachine, error) { if err != nil { return nil, err } - devices, err = addNetwork(d, devices) + devices, err = addNetwork(d, devices, config) if err != nil { return nil, err } @@ -394,8 +395,8 @@ func addDisk(d *Driver, devices object.VirtualDeviceList, config *CreateConfig) return devices, nil } -func addNetwork(d *Driver, devices object.VirtualDeviceList) (object.VirtualDeviceList, error) { - network, err := d.finder.DefaultNetwork(d.ctx) +func addNetwork(d *Driver, devices object.VirtualDeviceList, config *CreateConfig) (object.VirtualDeviceList, error) { + network, err := d.finder.NetworkOrDefault(d.ctx, config.Network) if err != nil { return nil, err } diff --git a/iso/step_create.go b/iso/step_create.go index c47e9fb8d..b1d5232c6 100644 --- a/iso/step_create.go +++ b/iso/step_create.go @@ -20,6 +20,7 @@ type CreateConfig struct { ResourcePool string `mapstructure:"resource_pool"` Datastore string `mapstructure:"datastore"` GuestOSType string `mapstructure:"guest_os_type"` + Network string `mapstructure:"network"` } func (c *CreateConfig) Prepare() []error { @@ -75,6 +76,7 @@ func (s *StepCreateVM) Run(state multistep.StateBag) multistep.StepAction { ResourcePool: s.config.ResourcePool, Datastore: s.config.Datastore, GuestOS: s.config.GuestOSType, + Network: s.config.Network, }) if err != nil {