Merge pull request #6041 from Xeite/f-add-instance-name

builder/openstack: Add instance_name config to OpenStack builder
This commit is contained in:
Rickard von Essen 2018-04-23 08:47:50 +02:00 committed by GitHub
commit a2a593759e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -52,6 +52,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
return nil, errs return nil, errs
} }
// By default, instance name is same as image name
if b.config.InstanceName == "" {
b.config.InstanceName = b.config.ImageName
}
log.Println(common.ScrubConfig(b.config, b.config.Password)) log.Println(common.ScrubConfig(b.config, b.config.Password))
return nil, nil return nil, nil
} }
@ -82,7 +87,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
SSHAgentAuth: b.config.RunConfig.Comm.SSHAgentAuth, SSHAgentAuth: b.config.RunConfig.Comm.SSHAgentAuth,
}, },
&StepRunSourceServer{ &StepRunSourceServer{
Name: b.config.ImageName, Name: b.config.InstanceName,
SourceImage: b.config.SourceImage, SourceImage: b.config.SourceImage,
SourceImageName: b.config.SourceImageName, SourceImageName: b.config.SourceImageName,
SecurityGroups: b.config.SecurityGroups, SecurityGroups: b.config.SecurityGroups,

View File

@ -30,6 +30,7 @@ type RunConfig struct {
Networks []string `mapstructure:"networks"` Networks []string `mapstructure:"networks"`
UserData string `mapstructure:"user_data"` UserData string `mapstructure:"user_data"`
UserDataFile string `mapstructure:"user_data_file"` UserDataFile string `mapstructure:"user_data_file"`
InstanceName string `mapstructure:"instance_name"`
InstanceMetadata map[string]string `mapstructure:"instance_metadata"` InstanceMetadata map[string]string `mapstructure:"instance_metadata"`
ConfigDrive bool `mapstructure:"config_drive"` ConfigDrive bool `mapstructure:"config_drive"`

View File

@ -118,6 +118,9 @@ builder.
- `metadata` (object of key/value strings) - Glance metadata that will be - `metadata` (object of key/value strings) - Glance metadata that will be
applied to the image. applied to the image.
- `instance_name` (string) - Name that is applied to the server instance
created by Packer. If this isn't specified, the default is same as `image_name`.
- `instance_metadata` (object of key/value strings) - Metadata that is - `instance_metadata` (object of key/value strings) - Metadata that is
applied to the server instance created by Packer. Also called server applied to the server instance created by Packer. Also called server
properties in some documentation. The strings have a max size of 255 bytes properties in some documentation. The strings have a max size of 255 bytes