cloudstack: Updated after review (2)

This commit is contained in:
Rickard von Essen 2017-07-27 21:32:47 +02:00
parent 2fea167294
commit 858f1227af
No known key found for this signature in database
GPG Key ID: E0C0327388876CBA
1 changed files with 25 additions and 17 deletions

View File

@ -62,7 +62,14 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
}
}
if config.PublicIPAddress != "" && !isUUID(config.PublicIPAddress) {
if config.PublicIPAddress != "" {
if isUUID(config.PublicIPAddress) {
ip, _, err := client.Address.GetPublicIpAddressByID(config.PublicIPAddress)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed to retrieve IP address: %s", err))
}
state.Put("ipaddress", ip.Ipaddress)
} else {
// Save the public IP address before replacing it with it's UUID.
state.Put("ipaddress", config.PublicIPAddress)
@ -84,6 +91,7 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
config.PublicIPAddress = ipAddrs.PublicIpAddresses[0].Id
}
}
}
if !isUUID(config.Network) {
config.Network, _, err = client.Network.GetNetworkID(config.Network, cloudstack.WithProject(config.Project))