diff options
Diffstat (limited to 'vendor/github.com/mitchellh/packer/builder/cloudstack/config.go')
-rw-r--r-- | vendor/github.com/mitchellh/packer/builder/cloudstack/config.go | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/vendor/github.com/mitchellh/packer/builder/cloudstack/config.go b/vendor/github.com/mitchellh/packer/builder/cloudstack/config.go index 5d6e9da0..7a617c6c 100644 --- a/vendor/github.com/mitchellh/packer/builder/cloudstack/config.go +++ b/vendor/github.com/mitchellh/packer/builder/cloudstack/config.go @@ -27,23 +27,26 @@ type Config struct { HTTPGetOnly bool `mapstructure:"http_get_only"` SSLNoVerify bool `mapstructure:"ssl_no_verify"` - CIDRList []string `mapstructure:"cidr_list"` - DiskOffering string `mapstructure:"disk_offering"` - DiskSize int64 `mapstructure:"disk_size"` - Expunge bool `mapstructure:"expunge"` - Hypervisor string `mapstructure:"hypervisor"` - InstanceName string `mapstructure:"instance_name"` - Keypair string `mapstructure:"keypair"` - Network string `mapstructure:"network"` - Project string `mapstructure:"project"` - PublicIPAddress string `mapstructure:"public_ip_address"` - ServiceOffering string `mapstructure:"service_offering"` - SourceTemplate string `mapstructure:"source_template"` - SourceISO string `mapstructure:"source_iso"` - UserData string `mapstructure:"user_data"` - UserDataFile string `mapstructure:"user_data_file"` - UseLocalIPAddress bool `mapstructure:"use_local_ip_address"` - Zone string `mapstructure:"zone"` + CIDRList []string `mapstructure:"cidr_list"` + CreateSecurityGroup bool `mapstructure:"create_security_group"` + DiskOffering string `mapstructure:"disk_offering"` + DiskSize int64 `mapstructure:"disk_size"` + Expunge bool `mapstructure:"expunge"` + Hypervisor string `mapstructure:"hypervisor"` + InstanceName string `mapstructure:"instance_name"` + Keypair string `mapstructure:"keypair"` + Network string `mapstructure:"network"` + Project string `mapstructure:"project"` + PublicIPAddress string `mapstructure:"public_ip_address"` + SecurityGroups []string `mapstructure:"security_groups"` + ServiceOffering string `mapstructure:"service_offering"` + SourceISO string `mapstructure:"source_iso"` + SourceTemplate string `mapstructure:"source_template"` + TemporaryKeypairName string `mapstructure:"temporary_keypair_name"` + UseLocalIPAddress bool `mapstructure:"use_local_ip_address"` + UserData string `mapstructure:"user_data"` + UserDataFile string `mapstructure:"user_data_file"` + Zone string `mapstructure:"zone"` TemplateName string `mapstructure:"template_name"` TemplateDisplayText string `mapstructure:"template_display_text"` @@ -55,9 +58,7 @@ type Config struct { TemplateScalable bool `mapstructure:"template_scalable"` TemplateTag string `mapstructure:"template_tag"` - ctx interpolate.Context - hostAddress string // The host address used by the communicators. - instanceSource string // This can be either a template ID or an ISO ID. + ctx interpolate.Context } // NewConfig parses and validates the given config. @@ -98,7 +99,7 @@ func NewConfig(raws ...interface{}) (*Config, error) { c.AsyncTimeout = 30 * time.Minute } - if len(c.CIDRList) == 0 && !c.UseLocalIPAddress { + if len(c.CIDRList) == 0 { c.CIDRList = []string{"0.0.0.0/0"} } @@ -120,6 +121,14 @@ func NewConfig(raws ...interface{}) (*Config, error) { c.TemplateDisplayText = c.TemplateName } + // If we are not given an explicit keypair, ssh_password or ssh_private_key_file, + // then create a temporary one, but only if the temporary_keypair_name has not + // been provided. + if c.Keypair == "" && c.TemporaryKeypairName == "" && + c.Comm.SSHPrivateKey == "" && c.Comm.SSHPassword == "" { + c.TemporaryKeypairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID()) + } + // Process required parameters. if c.APIURL == "" { errs = packer.MultiErrorAppend(errs, errors.New("a api_url must be specified")) @@ -137,6 +146,10 @@ func NewConfig(raws ...interface{}) (*Config, error) { errs = packer.MultiErrorAppend(errs, errors.New("a network must be specified")) } + if c.CreateSecurityGroup && !c.Expunge { + errs = packer.MultiErrorAppend(errs, errors.New("auto creating a temporary security group requires expunge")) + } + if c.ServiceOffering == "" { errs = packer.MultiErrorAppend(errs, errors.New("a service_offering must be specified")) } |