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:
parent
72de95a7e1
commit
5d6ba4301d
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue