Ensure required LockingMode parameter is set on VIF and fail the packer build if vif is failed to be created

This commit is contained in:
Dom Del Nano 2021-01-02 23:09:19 -08:00
parent ee25c7b42b
commit 04120e891a
2 changed files with 7 additions and 11 deletions

View File

@ -609,22 +609,17 @@ func (self *VM) SetPlatform(params map[string]string) (err error) {
}
func ConnectNetwork(c *Connection, networkRef xenapi.NetworkRef, vmRef xenapi.VMRef, device string) (*xenapi.VIFRef, error) {
// Create the VIF
// vif_rec["other_config"] = make(xmlrpc.Struct)
// vif_rec["qos_algorithm_params"] = make(xmlrpc.Struct)
vif, err := c.client.VIF.Create(c.session, xenapi.VIFRecord{
Network: networkRef,
VM: vmRef,
MAC: "",
Device: device,
MTU: 1504,
QosAlgorithmType: "",
Network: networkRef,
VM: vmRef,
Device: device,
LockingMode: xenapi.VifLockingModeNetworkDefault,
})
if err != nil {
return nil, err
}
log.Printf("Created the following VIF: %s", vif)
return &vif, nil
}

View File

@ -170,7 +170,8 @@ func (self *stepCreateInstance) Run(state multistep.StateBag) multistep.StepActi
_, err = xscommon.ConnectNetwork(c, network, instance, "0")
if err != nil {
ui.Say(err.Error())
ui.Error(fmt.Sprintf("Failed to create VIF with error: %v", err))
return multistep.ActionHalt
}
} else {