CP-18743: refine type of NetworkNames & remove unused code
Signed-off-by: kunm <kun.ma@citrix.com>
This commit is contained in:
parent
fe921b417d
commit
f79980553f
@ -84,6 +84,8 @@ A brief explanation of what the config parameters mean:
|
|||||||
* `ssh_username` - the username set by the installer for the instance.
|
* `ssh_username` - the username set by the installer for the instance.
|
||||||
* `ssh_password` - the password set by the installer for the instance.
|
* `ssh_password` - the password set by the installer for the instance.
|
||||||
* `boot_command` - a list of commands to be sent to the instance over VNC.
|
* `boot_command` - a list of commands to be sent to the instance over VNC.
|
||||||
|
* `vm_other_config` - a map of string to string for setting vm's other-config.
|
||||||
|
* `network_names` - a list of network name for the VIFs to connect with.
|
||||||
|
|
||||||
Note, the `http_directory` parameter is only required if you
|
Note, the `http_directory` parameter is only required if you
|
||||||
want Packer to serve up files over HTTP. In this example, the templated variables
|
want Packer to serve up files over HTTP. In this example, the templated variables
|
||||||
|
@ -22,7 +22,7 @@ type CommonConfig struct {
|
|||||||
VMDescription string `mapstructure:"vm_description"`
|
VMDescription string `mapstructure:"vm_description"`
|
||||||
SrName string `mapstructure:"sr_name"`
|
SrName string `mapstructure:"sr_name"`
|
||||||
FloppyFiles []string `mapstructure:"floppy_files"`
|
FloppyFiles []string `mapstructure:"floppy_files"`
|
||||||
NetworkNames map[string]string `mapstructure:"network_names"`
|
NetworkNames []string `mapstructure:"network_names"`
|
||||||
|
|
||||||
HostPortMin uint `mapstructure:"host_port_min"`
|
HostPortMin uint `mapstructure:"host_port_min"`
|
||||||
HostPortMax uint `mapstructure:"host_port_max"`
|
HostPortMax uint `mapstructure:"host_port_max"`
|
||||||
|
@ -53,88 +53,6 @@ func (self *stepImportInstance) Run(state multistep.StateBag) multistep.StepActi
|
|||||||
|
|
||||||
instance := xsclient.VM(*result)
|
instance := xsclient.VM(*result)
|
||||||
|
|
||||||
/*
|
|
||||||
err = instance.SetStaticMemoryRange(config.VMMemory*1024*1024, config.VMMemory*1024*1024)
|
|
||||||
if err != nil {
|
|
||||||
ui.Error(fmt.Sprintf("Error setting VM memory=%d: %s", config.VMMemory*1024*1024, err.Error()))
|
|
||||||
return multistep.ActionHalt
|
|
||||||
}
|
|
||||||
|
|
||||||
instance.SetPlatform(config.PlatformArgs)
|
|
||||||
if err != nil {
|
|
||||||
ui.Error(fmt.Sprintf("Error setting VM platform: %s", err.Error()))
|
|
||||||
return multistep.ActionHalt
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect Network
|
|
||||||
|
|
||||||
var network *xscommon.Network
|
|
||||||
|
|
||||||
if config.NetworkName == "" {
|
|
||||||
// No network has be specified. Use the management interface
|
|
||||||
network = new(xscommon.Network)
|
|
||||||
network.Ref = ""
|
|
||||||
network.Client = &client
|
|
||||||
|
|
||||||
pifs, err := client.GetPIFs()
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ui.Error(fmt.Sprintf("Error getting PIFs: %s", err.Error()))
|
|
||||||
return multistep.ActionHalt
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, pif := range pifs {
|
|
||||||
pif_rec, err := pif.GetRecord()
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ui.Error(fmt.Sprintf("Error getting PIF record: %s", err.Error()))
|
|
||||||
return multistep.ActionHalt
|
|
||||||
}
|
|
||||||
|
|
||||||
if pif_rec["management"].(bool) {
|
|
||||||
network.Ref = pif_rec["network"].(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if network.Ref == "" {
|
|
||||||
ui.Error("Error: couldn't find management network. Aborting.")
|
|
||||||
return multistep.ActionHalt
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Look up the network by it's name label
|
|
||||||
|
|
||||||
networks, err := client.GetNetworkByNameLabel(config.NetworkName)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ui.Error(fmt.Sprintf("Error occured getting Network by name-label: %s", err.Error()))
|
|
||||||
return multistep.ActionHalt
|
|
||||||
}
|
|
||||||
|
|
||||||
switch {
|
|
||||||
case len(networks) == 0:
|
|
||||||
ui.Error(fmt.Sprintf("Couldn't find a network with the specified name-label '%s'. Aborting.", config.NetworkName))
|
|
||||||
return multistep.ActionHalt
|
|
||||||
case len(networks) > 1:
|
|
||||||
ui.Error(fmt.Sprintf("Found more than one network with the name '%s'. The name must be unique. Aborting.", config.NetworkName))
|
|
||||||
return multistep.ActionHalt
|
|
||||||
}
|
|
||||||
|
|
||||||
network = networks[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ui.Say(err.Error())
|
|
||||||
}
|
|
||||||
_, err = instance.ConnectNetwork(network, "0")
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
ui.Say(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
instanceId, err := instance.GetUuid()
|
instanceId, err := instance.GetUuid()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ui.Error(fmt.Sprintf("Unable to get VM UUID: %s", err.Error()))
|
ui.Error(fmt.Sprintf("Unable to get VM UUID: %s", err.Error()))
|
||||||
|
Loading…
Reference in New Issue
Block a user