diff --git a/builder/openstack/run_config.go b/builder/openstack/run_config.go index ad9fa41aa..b98b65ea8 100644 --- a/builder/openstack/run_config.go +++ b/builder/openstack/run_config.go @@ -60,7 +60,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID()) } - if c.FloatingIPPool != "" { + if c.FloatingIPPool != "" && c.FloatingIPNetwork == "" { c.FloatingIPNetwork = c.FloatingIPPool } diff --git a/builder/openstack/run_config_test.go b/builder/openstack/run_config_test.go index 1f9960e27..6ce0cf602 100644 --- a/builder/openstack/run_config_test.go +++ b/builder/openstack/run_config_test.go @@ -108,12 +108,22 @@ func TestRunConfigPrepare_BlockStorage(t *testing.T) { func TestRunConfigPrepare_FloatingIPPoolCompat(t *testing.T) { c := testRunConfig() - c.FloatingIPPool = "uuid" + c.FloatingIPPool = "uuid1" if err := c.Prepare(nil); len(err) != 0 { t.Fatalf("err: %s", err) } - if c.FloatingIPNetwork != "uuid" { + if c.FloatingIPNetwork != "uuid1" { + t.Fatalf("invalid value: %s", c.FloatingIPNetwork) + } + + c.FloatingIPNetwork = "uuid2" + c.FloatingIPPool = "uuid3" + if err := c.Prepare(nil); len(err) != 0 { + t.Fatalf("err: %s", err) + } + + if c.FloatingIPNetwork != "uuid2" { t.Fatalf("invalid value: %s", c.FloatingIPNetwork) } }