diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index c505233bb..2938d67c0 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -115,9 +115,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe Wait: b.config.RackconnectWait, }, &StepAllocateIp{ - FloatingNetwork: b.config.FloatingNetwork, - FloatingIP: b.config.FloatingIP, - ReuseIPs: b.config.ReuseIPs, + FloatingIPNetwork: b.config.FloatingIPNetwork, + FloatingIP: b.config.FloatingIP, + ReuseIPs: b.config.ReuseIPs, }, &communicator.StepConnect{ Config: &b.config.RunConfig.Comm, diff --git a/builder/openstack/run_config.go b/builder/openstack/run_config.go index 1b2f209c8..ad9fa41aa 100644 --- a/builder/openstack/run_config.go +++ b/builder/openstack/run_config.go @@ -18,24 +18,27 @@ type RunConfig struct { SSHInterface string `mapstructure:"ssh_interface"` SSHIPVersion string `mapstructure:"ssh_ip_version"` - SourceImage string `mapstructure:"source_image"` - SourceImageName string `mapstructure:"source_image_name"` - Flavor string `mapstructure:"flavor"` - AvailabilityZone string `mapstructure:"availability_zone"` - RackconnectWait bool `mapstructure:"rackconnect_wait"` - FloatingNetwork string `mapstructure:"floating_network"` - FloatingIP string `mapstructure:"floating_ip"` - ReuseIPs bool `mapstructure:"reuse_ips"` - SecurityGroups []string `mapstructure:"security_groups"` - Networks []string `mapstructure:"networks"` - Ports []string `mapstructure:"ports"` - UserData string `mapstructure:"user_data"` - UserDataFile string `mapstructure:"user_data_file"` - InstanceName string `mapstructure:"instance_name"` - InstanceMetadata map[string]string `mapstructure:"instance_metadata"` + SourceImage string `mapstructure:"source_image"` + SourceImageName string `mapstructure:"source_image_name"` + Flavor string `mapstructure:"flavor"` + AvailabilityZone string `mapstructure:"availability_zone"` + RackconnectWait bool `mapstructure:"rackconnect_wait"` + FloatingIPNetwork string `mapstructure:"floating_ip_network"` + FloatingIP string `mapstructure:"floating_ip"` + ReuseIPs bool `mapstructure:"reuse_ips"` + SecurityGroups []string `mapstructure:"security_groups"` + Networks []string `mapstructure:"networks"` + Ports []string `mapstructure:"ports"` + UserData string `mapstructure:"user_data"` + UserDataFile string `mapstructure:"user_data_file"` + InstanceName string `mapstructure:"instance_name"` + InstanceMetadata map[string]string `mapstructure:"instance_metadata"` ConfigDrive bool `mapstructure:"config_drive"` + // Used for BC, value will be passed to the "floating_ip_network" + FloatingIPPool string `mapstructure:"floating_ip_pool"` + UseBlockStorageVolume bool `mapstructure:"use_blockstorage_volume"` VolumeName string `mapstructure:"volume_name"` VolumeType string `mapstructure:"volume_type"` @@ -57,6 +60,10 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID()) } + if c.FloatingIPPool != "" { + c.FloatingIPNetwork = c.FloatingIPPool + } + // Validation errs := c.Comm.Prepare(ctx) diff --git a/builder/openstack/run_config_test.go b/builder/openstack/run_config_test.go index b20e832d8..1f9960e27 100644 --- a/builder/openstack/run_config_test.go +++ b/builder/openstack/run_config_test.go @@ -101,11 +101,19 @@ func TestRunConfigPrepare_BlockStorage(t *testing.T) { } c.VolumeName = "PackerVolume" - if err := c.Prepare(nil); len(err) != 0 { - t.Fatalf("err: %s", err) - } - if c.VolumeName != "PackerVolume" { t.Fatalf("invalid value: %s", c.VolumeName) } } + +func TestRunConfigPrepare_FloatingIPPoolCompat(t *testing.T) { + c := testRunConfig() + c.FloatingIPPool = "uuid" + if err := c.Prepare(nil); len(err) != 0 { + t.Fatalf("err: %s", err) + } + + if c.FloatingIPNetwork != "uuid" { + t.Fatalf("invalid value: %s", c.FloatingIPNetwork) + } +} diff --git a/builder/openstack/step_allocate_ip.go b/builder/openstack/step_allocate_ip.go index b5a517680..7c864ca7a 100644 --- a/builder/openstack/step_allocate_ip.go +++ b/builder/openstack/step_allocate_ip.go @@ -11,9 +11,9 @@ import ( ) type StepAllocateIp struct { - FloatingNetwork string - FloatingIP string - ReuseIPs bool + FloatingIPNetwork string + FloatingIP string + ReuseIPs bool } func (s *StepAllocateIp) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { @@ -77,7 +77,7 @@ func (s *StepAllocateIp) Run(_ context.Context, state multistep.StateBag) multis if instanceIP.ID == "" { // Search for the external network that can be used for the floating IPs if // user hasn't provided any. - floatingNetwork := s.FloatingNetwork + floatingNetwork := s.FloatingIPNetwork if floatingNetwork == "" { ui.Say(fmt.Sprintf("Searching for the external network...")) externalNetwork, err := FindExternalNetwork(networkClient)