cloudstack: some updates after review

This commit is contained in:
Rickard von Essen 2017-07-14 11:09:21 +02:00
parent 44089b2f55
commit 62dac4a168
No known key found for this signature in database
GPG Key ID: E0C0327388876CBA
2 changed files with 2 additions and 12 deletions

View File

@ -62,7 +62,7 @@ func (s *stepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
// Retrieve the zone object.
zone, _, err := client.Zone.GetZoneByID(config.Zone)
if err != nil {
err := fmt.Errorf("Failed to get Zone by ID: %s - %s", config.Zone, err)
err := fmt.Errorf("Failed to get zone %s by ID: %s", config.Zone, err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
@ -96,7 +96,6 @@ func (s *stepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
ud, err := s.generateUserData(config.UserData, config.HTTPGetOnly)
if err != nil {
err := fmt.Errorf("Failed to interpolate user_data: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt

View File

@ -26,7 +26,6 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
if config.Project != "" && !isUUID(config.Project) {
config.Project, _, err = client.Project.GetProjectID(config.Project)
if err != nil {
ui.Error(err.Error())
errs = packer.MultiErrorAppend(errs, &retrieveErr{"project", config.Project, err})
}
}
@ -34,7 +33,6 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
if config.UserDataFile != "" {
userdata, err := ioutil.ReadFile(config.UserDataFile)
if err != nil {
ui.Error(err.Error())
errs = packer.MultiErrorAppend(errs, fmt.Errorf("problem reading user data file: %s", err))
}
config.UserData = string(userdata)
@ -43,7 +41,6 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
if !isUUID(config.Zone) {
config.Zone, _, err = client.Zone.GetZoneID(config.Zone)
if err != nil {
ui.Error(err.Error())
errs = packer.MultiErrorAppend(errs, &retrieveErr{"zone", config.Zone, err})
}
}
@ -52,7 +49,6 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
if config.DiskOffering != "" && !isUUID(config.DiskOffering) {
config.DiskOffering, _, err = client.DiskOffering.GetDiskOfferingID(config.DiskOffering)
if err != nil {
ui.Error(err.Error())
errs = packer.MultiErrorAppend(errs, &retrieveErr{"disk offering", config.DiskOffering, err})
}
}
@ -70,7 +66,6 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
ipAddrs, err := client.Address.ListPublicIpAddresses(p)
if err != nil {
ui.Error(err.Error())
errs = packer.MultiErrorAppend(errs, &retrieveErr{"IP address", config.PublicIPAddress, err})
}
if err == nil && ipAddrs.Count != 1 {
@ -84,7 +79,6 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
if !isUUID(config.Network) {
config.Network, _, err = client.Network.GetNetworkID(config.Network, cloudstack.WithProject(config.Project))
if err != nil {
ui.Error(err.Error())
errs = packer.MultiErrorAppend(errs, &retrieveErr{"network", config.Network, err})
}
}
@ -92,7 +86,6 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
if !isUUID(config.ServiceOffering) {
config.ServiceOffering, _, err = client.ServiceOffering.GetServiceOfferingID(config.ServiceOffering)
if err != nil {
ui.Error(err.Error())
errs = packer.MultiErrorAppend(errs, &retrieveErr{"service offering", config.ServiceOffering, err})
}
}
@ -103,7 +96,6 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
} else {
config.instanceSource, _, err = client.ISO.GetIsoID(config.SourceISO, "executable", config.Zone)
if err != nil {
ui.Error(err.Error())
errs = packer.MultiErrorAppend(errs, &retrieveErr{"ISO", config.SourceISO, err})
}
}
@ -115,7 +107,6 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
} else {
config.instanceSource, _, err = client.Template.GetTemplateID(config.SourceTemplate, "executable", config.Zone)
if err != nil {
ui.Error(err.Error())
errs = packer.MultiErrorAppend(errs, &retrieveErr{"template", config.SourceTemplate, err})
}
}
@ -127,7 +118,6 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
types, err := client.GuestOS.ListOsTypes(p)
if err != nil {
ui.Error(err.Error())
errs = packer.MultiErrorAppend(errs, &retrieveErr{"OS type", config.TemplateOS, err})
}
if err == nil && types.Count != 1 {
@ -144,6 +134,7 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction {
// nil interface.
if errs != nil && len(errs.Errors) > 0 {
state.Put("error", errs)
ui.Error(errs.Error())
return multistep.ActionHalt
}