@@ -269,8 +269,13 @@ func resourceVSphereVirtualMachineCreate(d *schema.ResourceData, meta interface{
269269 }
270270
271271 if vL , ok := d .GetOk ("custom_configuration_parameters" ); ok {
272- if custom_configs , ok := vL .(map [string ]types.AnyType ); ok {
273- vm .customConfigurations = custom_configs
272+ if custom_configs , ok := vL .(map [string ]interface {}); ok {
273+ custom := make (map [string ]types.AnyType )
274+ for k ,v := range custom_configs {
275+ custom [k ] = v
276+ }
277+ vm .customConfigurations = custom
278+ log .Printf ("[DEBUG] custom_configuration_parameters init: %v" , vm .customConfigurations )
274279 }
275280 }
276281
@@ -432,14 +437,21 @@ func resourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{})
432437 d .Set ("memory" , mvm .Summary .Config .MemorySizeMB )
433438 d .Set ("cpu" , mvm .Summary .Config .NumCpu )
434439
435- if len (mvm .Config .ExtraConfig ) > 0 {
440+ log .Printf ("[DEBUG] ===============================" )
441+ //log.Printf("[DEBUG] Get extra config ===============================")
442+ //log.Printf("[DEBUG] Get extra config %v", mvm.Config)
443+ //log.Printf("[DEBUG] Get extra config %v", mvm.Config.ExtraConfig)
444+ if mvm .Config != nil && mvm .Config .ExtraConfig != nil && len (mvm .Config .ExtraConfig ) > 0 {
445+ log .Printf ("[DEBUG] reading custom configs" )
436446 custom_configs := make (map [string ]types.AnyType )
437447 for _ , v := range mvm .Config .ExtraConfig {
438448 value := v .GetOptionValue ()
439449 custom_configs [value .Key ] = value .Value
450+ log .Printf ("[DEBUG] reading custom configs %s,%s" ,value .Key , value .Value )
440451 }
441452 d .Set ("custom_configuration_parameters" , custom_configs )
442453 }
454+ log .Printf ("[DEBUG] ===============================" )
443455 d .Set ("datastore" , rootDatastore )
444456
445457 // Initialize the connection info
@@ -825,6 +837,7 @@ func (vm *virtualMachine) createVirtualMachine(c *govmomi.Client) error {
825837 log .Printf ("[DEBUG] virtual machine config spec: %v" , configSpec )
826838
827839 // make ExtraConfig
840+ log .Printf ("[DEBUG] virtual machine Extra Config spec start" )
828841 if len (vm .customConfigurations ) > 0 {
829842 var ov []types.BaseOptionValue
830843 for k , v := range vm .customConfigurations {
@@ -834,6 +847,7 @@ func (vm *virtualMachine) createVirtualMachine(c *govmomi.Client) error {
834847 Key : key ,
835848 Value : & value ,
836849 }
850+ log .Printf ("[DEBUG] virtual machine Extra Config spec: %s,%s" , k ,v )
837851 ov = append (ov , & o )
838852 }
839853 configSpec .ExtraConfig = ov
@@ -1041,6 +1055,8 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error {
10411055 }
10421056 log .Printf ("[DEBUG] virtual machine config spec: %v" , configSpec )
10431057
1058+ log .Printf ("[DEBUG] starting extra custom config spec: %v" , vm .customConfigurations )
1059+
10441060 // make ExtraConfig
10451061 if len (vm .customConfigurations ) > 0 {
10461062 var ov []types.BaseOptionValue
@@ -1149,5 +1165,6 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error {
11491165 return err
11501166 }
11511167 }
1168+ log .Printf ("[DEBUG] virtual machine config spec: %v" , configSpec )
11521169 return nil
11531170}
0 commit comments