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,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,
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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,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)
|
||||
|
|
Loading…
Reference in New Issue