Merge pull request #6570 from cb-oath/openstack-builder-ports

add support for ports to the OpenStack builder
This commit is contained in:
Rickard von Essen 2018-08-15 13:35:48 +02:00 committed by GitHub
commit 9e9f0d2ab9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 3 deletions

1
builder/openstack/builder.go Executable file → Normal file
View File

@ -92,6 +92,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
SourceImageName: b.config.SourceImageName, SourceImageName: b.config.SourceImageName,
SecurityGroups: b.config.SecurityGroups, SecurityGroups: b.config.SecurityGroups,
Networks: b.config.Networks, Networks: b.config.Networks,
Ports: b.config.Ports,
AvailabilityZone: b.config.AvailabilityZone, AvailabilityZone: b.config.AvailabilityZone,
UserData: b.config.UserData, UserData: b.config.UserData,
UserDataFile: b.config.UserDataFile, UserDataFile: b.config.UserDataFile,

View File

@ -28,6 +28,7 @@ type RunConfig struct {
ReuseIps bool `mapstructure:"reuse_ips"` ReuseIps bool `mapstructure:"reuse_ips"`
SecurityGroups []string `mapstructure:"security_groups"` SecurityGroups []string `mapstructure:"security_groups"`
Networks []string `mapstructure:"networks"` Networks []string `mapstructure:"networks"`
Ports []string `mapstructure:"ports"`
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"` InstanceName string `mapstructure:"instance_name"`

View File

@ -18,6 +18,7 @@ type StepRunSourceServer struct {
SourceImageName string SourceImageName string
SecurityGroups []string SecurityGroups []string
Networks []string Networks []string
Ports []string
AvailabilityZone string AvailabilityZone string
UserData string UserData string
UserDataFile string UserDataFile string
@ -39,9 +40,13 @@ func (s *StepRunSourceServer) Run(_ context.Context, state multistep.StateBag) m
return multistep.ActionHalt return multistep.ActionHalt
} }
networks := make([]servers.Network, len(s.Networks)) networks := make([]servers.Network, len(s.Networks)+len(s.Ports))
for i, networkUuid := range s.Networks { i := 0
networks[i].UUID = networkUuid for ; i < len(s.Ports); i++ {
networks[i].Port = s.Ports[i]
}
for ; i < len(networks); i++ {
networks[i].UUID = s.Networks[i]
} }
userData := []byte(s.UserData) userData := []byte(s.UserData)

View File

@ -139,6 +139,9 @@ builder.
- `networks` (array of strings) - A list of networks by UUID to attach to - `networks` (array of strings) - A list of networks by UUID to attach to
this instance. this instance.
- `ports` (array of strings) - A list of ports by UUID to attach to
this instance.
- `rackconnect_wait` (boolean) - For rackspace, whether or not to wait for - `rackconnect_wait` (boolean) - For rackspace, whether or not to wait for
Rackconnect to assign the machine an IP address before connecting via SSH. Rackconnect to assign the machine an IP address before connecting via SSH.
Defaults to false. Defaults to false.