OpenStack builder: fix floating_ip_pool validation

Only use "floating_ip_pool" if "floating_ip_network" wasn't set.
Update unit test for the OpenStack builder parameters.
This commit is contained in:
Andrei Ozerov 2018-08-17 00:15:18 +03:00
parent 72de95a7e1
commit 5d6ba4301d
2 changed files with 13 additions and 3 deletions

View File

@ -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
}

View File

@ -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)
}
}