Merge pull request #4196 from kristinn/create-disk-before-startup
provider/vsphere: Create and attach additional disks before bootup.
This commit is contained in:
commit
5630f9581f
|
@ -294,7 +294,7 @@ func resourceVSphereVirtualMachineCreate(d *schema.ResourceData, meta interface{
|
||||||
if vL, ok := d.GetOk("custom_configuration_parameters"); ok {
|
if vL, ok := d.GetOk("custom_configuration_parameters"); ok {
|
||||||
if custom_configs, ok := vL.(map[string]interface{}); ok {
|
if custom_configs, ok := vL.(map[string]interface{}); ok {
|
||||||
custom := make(map[string]types.AnyType)
|
custom := make(map[string]types.AnyType)
|
||||||
for k,v := range custom_configs {
|
for k, v := range custom_configs {
|
||||||
custom[k] = v
|
custom[k] = v
|
||||||
}
|
}
|
||||||
vm.customConfigurations = custom
|
vm.customConfigurations = custom
|
||||||
|
@ -775,7 +775,7 @@ func findDatastore(c *govmomi.Client, sps types.StoragePlacementSpec) (*object.D
|
||||||
return datastore, nil
|
return datastore, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// createVirtualMchine creates a new VirtualMachine.
|
// createVirtualMachine creates a new VirtualMachine.
|
||||||
func (vm *virtualMachine) createVirtualMachine(c *govmomi.Client) error {
|
func (vm *virtualMachine) createVirtualMachine(c *govmomi.Client) error {
|
||||||
dc, err := getDatacenter(c, vm.datacenter)
|
dc, err := getDatacenter(c, vm.datacenter)
|
||||||
|
|
||||||
|
@ -859,7 +859,7 @@ func (vm *virtualMachine) createVirtualMachine(c *govmomi.Client) error {
|
||||||
Key: key,
|
Key: key,
|
||||||
Value: &value,
|
Value: &value,
|
||||||
}
|
}
|
||||||
log.Printf("[DEBUG] virtual machine Extra Config spec: %s,%s", k,v)
|
log.Printf("[DEBUG] virtual machine Extra Config spec: %s,%s", k, v)
|
||||||
ov = append(ov, &o)
|
ov = append(ov, &o)
|
||||||
}
|
}
|
||||||
configSpec.ExtraConfig = ov
|
configSpec.ExtraConfig = ov
|
||||||
|
@ -942,7 +942,7 @@ func (vm *virtualMachine) createVirtualMachine(c *govmomi.Client) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// deployVirtualMchine deploys a new VirtualMachine.
|
// deployVirtualMachine deploys a new VirtualMachine.
|
||||||
func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error {
|
func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error {
|
||||||
dc, err := getDatacenter(c, vm.datacenter)
|
dc, err := getDatacenter(c, vm.datacenter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1178,6 +1178,14 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error {
|
||||||
}
|
}
|
||||||
log.Printf("[DEBUG]VM customization finished")
|
log.Printf("[DEBUG]VM customization finished")
|
||||||
|
|
||||||
|
for i := 1; i < len(vm.hardDisks); i++ {
|
||||||
|
err = addHardDisk(newVM, vm.hardDisks[i].size, vm.hardDisks[i].iops, "eager_zeroed")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Printf("[DEBUG] virtual machine config spec: %v", configSpec)
|
||||||
|
|
||||||
newVM.PowerOn(context.TODO())
|
newVM.PowerOn(context.TODO())
|
||||||
|
|
||||||
ip, err := newVM.WaitForIP(context.TODO())
|
ip, err := newVM.WaitForIP(context.TODO())
|
||||||
|
@ -1186,12 +1194,5 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error {
|
||||||
}
|
}
|
||||||
log.Printf("[DEBUG] ip address: %v", ip)
|
log.Printf("[DEBUG] ip address: %v", ip)
|
||||||
|
|
||||||
for i := 1; i < len(vm.hardDisks); i++ {
|
|
||||||
err = addHardDisk(newVM, vm.hardDisks[i].size, vm.hardDisks[i].iops, "eager_zeroed")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.Printf("[DEBUG] virtual machine config spec: %v", configSpec)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue