Commit 5d32a1f6 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/openstack: use IP not FixedIP

parent 590177ea
...@@ -23,8 +23,8 @@ func SSHAddress( ...@@ -23,8 +23,8 @@ func SSHAddress(
// If we have a floating IP, use that // If we have a floating IP, use that
ip := state.Get("access_ip").(*floatingip.FloatingIP) ip := state.Get("access_ip").(*floatingip.FloatingIP)
if ip != nil && ip.FixedIP != "" { if ip != nil && ip.IP != "" {
return fmt.Sprintf("%s:%d", ip.FixedIP, port), nil return fmt.Sprintf("%s:%d", ip.IP, port), nil
} }
if s.AccessIPv4 != "" { if s.AccessIPv4 != "" {
......
...@@ -27,13 +27,14 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction { ...@@ -27,13 +27,14 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt return multistep.ActionHalt
} }
var instanceIp *floatingip.FloatingIP var instanceIp floatingip.FloatingIP
// This is here in case we error out before putting instanceIp into the // This is here in case we error out before putting instanceIp into the
// statebag below, because it is requested by Cleanup() // statebag below, because it is requested by Cleanup()
state.Put("access_ip", instanceIp) state.Put("access_ip", &instanceIp)
if s.FloatingIp != "" { if s.FloatingIp != "" {
*instanceIp = floatingip.FloatingIP{FixedIP: s.FloatingIp} instanceIp.IP = s.FloatingIp
} else if s.FloatingIpPool != "" { } else if s.FloatingIpPool != "" {
newIp, err := floatingip.Create(client, floatingip.CreateOpts{ newIp, err := floatingip.Create(client, floatingip.CreateOpts{
Pool: s.FloatingIpPool, Pool: s.FloatingIpPool,
...@@ -45,26 +46,26 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction { ...@@ -45,26 +46,26 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt return multistep.ActionHalt
} }
*instanceIp = *newIp instanceIp = *newIp
ui.Say(fmt.Sprintf("Created temporary floating IP %s...", instanceIp.FixedIP)) ui.Say(fmt.Sprintf("Created temporary floating IP %s...", instanceIp.IP))
} }
if instanceIp != nil && instanceIp.FixedIP != "" { if instanceIp.IP != "" {
err := floatingip.Associate(client, server.ID, instanceIp.FixedIP).ExtractErr() err := floatingip.Associate(client, server.ID, instanceIp.IP).ExtractErr()
if err != nil { if err != nil {
err := fmt.Errorf( err := fmt.Errorf(
"Error associating floating IP %s with instance.", "Error associating floating IP %s with instance.",
instanceIp.FixedIP) instanceIp.IP)
state.Put("error", err) state.Put("error", err)
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt
} }
ui.Say(fmt.Sprintf( ui.Say(fmt.Sprintf(
"Added floating IP %s to instance...", instanceIp.FixedIP)) "Added floating IP %s to instance...", instanceIp.IP))
} }
state.Put("access_ip", instanceIp) state.Put("access_ip", &instanceIp)
return multistep.ActionContinue return multistep.ActionContinue
} }
...@@ -77,17 +78,17 @@ func (s *StepAllocateIp) Cleanup(state multistep.StateBag) { ...@@ -77,17 +78,17 @@ func (s *StepAllocateIp) Cleanup(state multistep.StateBag) {
client, err := config.computeV2Client() client, err := config.computeV2Client()
if err != nil { if err != nil {
ui.Error(fmt.Sprintf( ui.Error(fmt.Sprintf(
"Error deleting temporary floating IP %s", instanceIp.FixedIP)) "Error deleting temporary floating IP %s", instanceIp.IP))
return return
} }
if s.FloatingIpPool != "" && instanceIp.ID != "" { if s.FloatingIpPool != "" && instanceIp.ID != "" {
if err := floatingip.Delete(client, instanceIp.ID).ExtractErr(); err != nil { if err := floatingip.Delete(client, instanceIp.ID).ExtractErr(); err != nil {
ui.Error(fmt.Sprintf( ui.Error(fmt.Sprintf(
"Error deleting temporary floating IP %s", instanceIp.FixedIP)) "Error deleting temporary floating IP %s", instanceIp.IP))
return return
} }
ui.Say(fmt.Sprintf("Deleted temporary floating IP %s", instanceIp.FixedIP)) ui.Say(fmt.Sprintf("Deleted temporary floating IP %s", instanceIp.IP))
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment