OpenStack builder: update floating IP params
Rename "floating_network" to the "floating_ip_network". Return old "floating_ip_pool" parameter for backward compatibility with old configuration files. It's value will be passed to the "floating_ip_network" parameter.
This commit is contained in:
parent
0eef9b4292
commit
c9047cbfbe
|
@ -115,7 +115,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
Wait: b.config.RackconnectWait,
|
||||
},
|
||||
&StepAllocateIp{
|
||||
FloatingNetwork: b.config.FloatingNetwork,
|
||||
FloatingIPNetwork: b.config.FloatingIPNetwork,
|
||||
FloatingIP: b.config.FloatingIP,
|
||||
ReuseIPs: b.config.ReuseIPs,
|
||||
},
|
||||
|
|
|
@ -23,7 +23,7 @@ type RunConfig struct {
|
|||
Flavor string `mapstructure:"flavor"`
|
||||
AvailabilityZone string `mapstructure:"availability_zone"`
|
||||
RackconnectWait bool `mapstructure:"rackconnect_wait"`
|
||||
FloatingNetwork string `mapstructure:"floating_network"`
|
||||
FloatingIPNetwork string `mapstructure:"floating_ip_network"`
|
||||
FloatingIP string `mapstructure:"floating_ip"`
|
||||
ReuseIPs bool `mapstructure:"reuse_ips"`
|
||||
SecurityGroups []string `mapstructure:"security_groups"`
|
||||
|
@ -36,6 +36,9 @@ type RunConfig struct {
|
|||
|
||||
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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
type StepAllocateIp struct {
|
||||
FloatingNetwork string
|
||||
FloatingIPNetwork string
|
||||
FloatingIP string
|
||||
ReuseIPs bool
|
||||
}
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue