grammar fixes.
This commit is contained in:
parent
fdfd01eaea
commit
2fd41f4707
@ -14,9 +14,9 @@ func message(state multistep.StateBag, module string) {
|
|||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
|
|
||||||
if cancelled || halted {
|
if cancelled || halted {
|
||||||
ui.Say(fmt.Sprintf("Delete the %s because cancellation or error...", module))
|
ui.Say(fmt.Sprintf("Deleting %s because of cancellation or error...", module))
|
||||||
} else {
|
} else {
|
||||||
ui.Say(fmt.Sprintf("Clean the created %s", module))
|
ui.Say(fmt.Sprintf("Cleaning up '%s'", module))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,14 +66,14 @@ func (s *setpConfigAlicloudEIP) Cleanup(state multistep.StateBag) {
|
|||||||
message(state, "EIP")
|
message(state, "EIP")
|
||||||
|
|
||||||
if err := client.UnassociateEipAddress(s.allocatedId, instance.InstanceId); err != nil {
|
if err := client.UnassociateEipAddress(s.allocatedId, instance.InstanceId); err != nil {
|
||||||
ui.Say(fmt.Sprintf("Unassociating eip failed."))
|
ui.Say(fmt.Sprintf("Failed to unassociate eip."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := client.WaitForEip(common.Region(s.RegionId), s.allocatedId, ecs.EipStatusAvailable, ALICLOUD_DEFAULT_SHORT_TIMEOUT); err != nil {
|
if err := client.WaitForEip(common.Region(s.RegionId), s.allocatedId, ecs.EipStatusAvailable, ALICLOUD_DEFAULT_SHORT_TIMEOUT); err != nil {
|
||||||
ui.Say(fmt.Sprintf("Timeout while unassociating eip."))
|
ui.Say(fmt.Sprintf("Timeout while unassociating eip."))
|
||||||
}
|
}
|
||||||
if err := client.ReleaseEipAddress(s.allocatedId); err != nil {
|
if err := client.ReleaseEipAddress(s.allocatedId); err != nil {
|
||||||
ui.Say(fmt.Sprintf("Releasing eip failed."))
|
ui.Say(fmt.Sprintf("Failed to release eip."))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func (s *StepConfigAlicloudKeyPair) Run(state multistep.StateBag) multistep.Step
|
|||||||
}
|
}
|
||||||
|
|
||||||
if s.SSHAgentAuth && s.KeyPairName == "" {
|
if s.SSHAgentAuth && s.KeyPairName == "" {
|
||||||
ui.Say("Using SSH Agent with key pair in Source AlicloudImage")
|
ui.Say("Using SSH Agent with key pair in source image")
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ func (s *StepConfigAlicloudKeyPair) Run(state multistep.StateBag) multistep.Step
|
|||||||
|
|
||||||
client := state.Get("client").(*ecs.Client)
|
client := state.Get("client").(*ecs.Client)
|
||||||
|
|
||||||
ui.Say(fmt.Sprintf("Start creating temporary keypair: %s", s.TemporaryKeyPairName))
|
ui.Say(fmt.Sprintf("Creating temporary keypair: %s", s.TemporaryKeyPairName))
|
||||||
keyResp, err := client.CreateKeyPair(&ecs.CreateKeyPairArgs{
|
keyResp, err := client.CreateKeyPair(&ecs.CreateKeyPairArgs{
|
||||||
KeyPairName: s.TemporaryKeyPairName,
|
KeyPairName: s.TemporaryKeyPairName,
|
||||||
RegionId: common.Region(s.RegionId),
|
RegionId: common.Region(s.RegionId),
|
||||||
|
@ -25,7 +25,7 @@ func (s *stepConfigAlicloudPublicIP) Run(state multistep.StateBag) multistep.Ste
|
|||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
s.publicIPAdress = ipaddress
|
s.publicIPAdress = ipaddress
|
||||||
ui.Say(fmt.Sprintf("allocated public ip address %s", ipaddress))
|
ui.Say(fmt.Sprintf("Allocated public ip address %s.", ipaddress))
|
||||||
state.Put("ipaddress", ipaddress)
|
state.Put("ipaddress", ipaddress)
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func (s *stepConfigAlicloudSecurityGroup) Run(state multistep.StateBag) multiste
|
|||||||
|
|
||||||
}
|
}
|
||||||
var securityGroupId string
|
var securityGroupId string
|
||||||
ui.Say("Start creating security groups...")
|
ui.Say("Creating security groups...")
|
||||||
if networkType == VpcNet {
|
if networkType == VpcNet {
|
||||||
vpcId := state.Get("vpcid").(string)
|
vpcId := state.Get("vpcid").(string)
|
||||||
securityGroupId, err = client.CreateSecurityGroup(&ecs.CreateSecurityGroupArgs{
|
securityGroupId, err = client.CreateSecurityGroup(&ecs.CreateSecurityGroupArgs{
|
||||||
@ -76,7 +76,7 @@ func (s *stepConfigAlicloudSecurityGroup) Run(state multistep.StateBag) multiste
|
|||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Say(fmt.Sprintf("Create security group failed %s", err))
|
ui.Say(fmt.Sprintf("Failed creating security group %s.", err))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
state.Put("securitygroupid", securityGroupId)
|
state.Put("securitygroupid", securityGroupId)
|
||||||
|
@ -45,7 +45,7 @@ func (s *stepConfigAlicloudVPC) Run(state multistep.StateBag) multistep.StepActi
|
|||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
|
|
||||||
}
|
}
|
||||||
ui.Say("Start create vpc")
|
ui.Say("Creating vpc")
|
||||||
vpc, err := client.CreateVpc(&ecs.CreateVpcArgs{
|
vpc, err := client.CreateVpc(&ecs.CreateVpcArgs{
|
||||||
RegionId: common.Region(config.AlicloudRegion),
|
RegionId: common.Region(config.AlicloudRegion),
|
||||||
CidrBlock: s.CidrBlock,
|
CidrBlock: s.CidrBlock,
|
||||||
@ -53,13 +53,13 @@ func (s *stepConfigAlicloudVPC) Run(state multistep.StateBag) multistep.StepActi
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Say(fmt.Sprintf("Create vpc failed %s", err))
|
ui.Say(fmt.Sprintf("Failed creating vpc: %s", err))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
err = client.WaitForVpcAvailable(common.Region(config.AlicloudRegion), vpc.VpcId, ALICLOUD_DEFAULT_SHORT_TIMEOUT)
|
err = client.WaitForVpcAvailable(common.Region(config.AlicloudRegion), vpc.VpcId, ALICLOUD_DEFAULT_SHORT_TIMEOUT)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Say(fmt.Sprintf("Failed waiting for vpc to become available %s", err))
|
ui.Say(fmt.Sprintf("Failed waiting for vpc to become available: %s", err))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,18 +80,18 @@ func (s *stepConfigAlicloudVSwitch) Run(state multistep.StateBag) multistep.Step
|
|||||||
if len(instanceTypes) > 0 {
|
if len(instanceTypes) > 0 {
|
||||||
ui.Say(fmt.Sprintf("The instance type %s isn't available in this region."+
|
ui.Say(fmt.Sprintf("The instance type %s isn't available in this region."+
|
||||||
"\n You can either change the instance to one of following: %v \n"+
|
"\n You can either change the instance to one of following: %v \n"+
|
||||||
"or choose another region", config.InstanceType, instanceTypes))
|
"or choose another region.", config.InstanceType, instanceTypes))
|
||||||
|
|
||||||
state.Put("error", fmt.Errorf("The instance type %s isn't available in this region."+
|
state.Put("error", fmt.Errorf("The instance type %s isn't available in this region."+
|
||||||
"\n You can either change the instance to one of following: %v \n"+
|
"\n You can either change the instance to one of following: %v \n"+
|
||||||
"or choose another region", config.InstanceType, instanceTypes))
|
"or choose another region.", config.InstanceType, instanceTypes))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
} else {
|
} else {
|
||||||
ui.Say(fmt.Sprintf("The instance type %s isn't available in this region."+
|
ui.Say(fmt.Sprintf("The instance type %s isn't available in this region."+
|
||||||
"\n You can change to other regions \n", config.InstanceType))
|
"\n You can change to other regions.", config.InstanceType))
|
||||||
|
|
||||||
state.Put("error", fmt.Errorf("The instance type %s isn't available in this region."+
|
state.Put("error", fmt.Errorf("The instance type %s isn't available in this region."+
|
||||||
"\n You can change to other regions \n", config.InstanceType))
|
"\n You can change to other regions.", config.InstanceType))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ func (s *stepConfigAlicloudVSwitch) Run(state multistep.StateBag) multistep.Step
|
|||||||
if config.CidrBlock == "" {
|
if config.CidrBlock == "" {
|
||||||
s.CidrBlock = "172.16.0.0/24" //use the default CirdBlock
|
s.CidrBlock = "172.16.0.0/24" //use the default CirdBlock
|
||||||
}
|
}
|
||||||
ui.Say("Start creating vswitch...")
|
ui.Say("Creating vswitch...")
|
||||||
vswitchId, err := client.CreateVSwitch(&ecs.CreateVSwitchArgs{
|
vswitchId, err := client.CreateVSwitch(&ecs.CreateVSwitchArgs{
|
||||||
CidrBlock: s.CidrBlock,
|
CidrBlock: s.CidrBlock,
|
||||||
ZoneId: s.ZoneId,
|
ZoneId: s.ZoneId,
|
||||||
|
@ -43,7 +43,7 @@ func (s *stepCreateAlicloudInstance) Run(state multistep.StateBag) multistep.Ste
|
|||||||
if password == "" && config.Comm.WinRMPassword != "" {
|
if password == "" && config.Comm.WinRMPassword != "" {
|
||||||
password = config.Comm.WinRMPassword
|
password = config.Comm.WinRMPassword
|
||||||
}
|
}
|
||||||
ui.Say("Start creating alicloud instance")
|
ui.Say("Creating instance.")
|
||||||
if network_type == VpcNet {
|
if network_type == VpcNet {
|
||||||
userData, err := s.getUserData(state)
|
userData, err := s.getUserData(state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -127,7 +127,7 @@ func (s *stepCreateAlicloudInstance) Cleanup(state multistep.StateBag) {
|
|||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
err := client.DeleteInstance(s.instance.InstanceId)
|
err := client.DeleteInstance(s.instance.InstanceId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ui.Say(fmt.Sprintf("Cleaning instance %s failed ", s.instance.InstanceId))
|
ui.Say(fmt.Sprintf("Failed to clean up instance %s: ", s.instance.InstanceId, err.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ func (s *stepDeleteAlicloudImageSnapshots) Run(state multistep.StateBag) multist
|
|||||||
client := state.Get("client").(*ecs.Client)
|
client := state.Get("client").(*ecs.Client)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
config := state.Get("config").(Config)
|
config := state.Get("config").(Config)
|
||||||
ui.Say("Start delete alicloud image snapshots")
|
ui.Say("Deleting image snapshots.")
|
||||||
// Check for force delete
|
// Check for force delete
|
||||||
if s.AlicloudImageForceDetele {
|
if s.AlicloudImageForceDetele {
|
||||||
images, _, err := client.DescribeImages(&ecs.DescribeImagesArgs{
|
images, _, err := client.DescribeImages(&ecs.DescribeImagesArgs{
|
||||||
@ -32,7 +32,7 @@ func (s *stepDeleteAlicloudImageSnapshots) Run(state multistep.StateBag) multist
|
|||||||
}
|
}
|
||||||
for _, image := range images {
|
for _, image := range images {
|
||||||
if image.ImageOwnerAlias != string(ecs.ImageOwnerSelf) {
|
if image.ImageOwnerAlias != string(ecs.ImageOwnerSelf) {
|
||||||
log.Printf("Only can delete the instance based on customized images %s ", image.ImageId)
|
log.Printf("You can only delete instances based on customized images %s ", image.ImageId)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err = client.DeleteImage(common.Region(config.AlicloudRegion), image.ImageId)
|
err = client.DeleteImage(common.Region(config.AlicloudRegion), image.ImageId)
|
||||||
|
@ -20,7 +20,7 @@ func (s *stepMountAlicloudDisk) Run(state multistep.StateBag) multistep.StepActi
|
|||||||
if len(config.ECSImagesDiskMappings) == 0 {
|
if len(config.ECSImagesDiskMappings) == 0 {
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
ui.Say("Start mounting Disks")
|
ui.Say("Mounting disks.")
|
||||||
disks, _, err := client.DescribeDisks(&ecs.DescribeDisksArgs{InstanceId: instance.InstanceId,
|
disks, _, err := client.DescribeDisks(&ecs.DescribeDisksArgs{InstanceId: instance.InstanceId,
|
||||||
RegionId: instance.RegionId})
|
RegionId: instance.RegionId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -50,7 +50,7 @@ func (s *stepMountAlicloudDisk) Run(state multistep.StateBag) multistep.StepActi
|
|||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui.Say("Finished mounting disks")
|
ui.Say("Finished mounting disks.")
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,13 +17,13 @@ type stepPreValidate struct {
|
|||||||
func (s *stepPreValidate) Run(state multistep.StateBag) multistep.StepAction {
|
func (s *stepPreValidate) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
if s.ForceDelete {
|
if s.ForceDelete {
|
||||||
ui.Say("Force delete flag found, skipping prevalidating alicloud image name")
|
ui.Say("Force delete flag found, skipping prevalidating image name.")
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
client := state.Get("client").(*ecs.Client)
|
client := state.Get("client").(*ecs.Client)
|
||||||
config := state.Get("config").(Config)
|
config := state.Get("config").(Config)
|
||||||
ui.Say("Prevalidating alicloud image name...")
|
ui.Say("Prevalidating image name...")
|
||||||
images, _, err := client.DescribeImages(&ecs.DescribeImagesArgs{
|
images, _, err := client.DescribeImages(&ecs.DescribeImagesArgs{
|
||||||
ImageName: s.AlicloudDestImageName,
|
ImageName: s.AlicloudDestImageName,
|
||||||
RegionId: common.Region(config.AlicloudRegion)})
|
RegionId: common.Region(config.AlicloudRegion)})
|
||||||
|
@ -58,17 +58,14 @@ func (s *setpRegionCopyAlicloudImage) Cleanup(state multistep.StateBag) {
|
|||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
client := state.Get("client").(*ecs.Client)
|
client := state.Get("client").(*ecs.Client)
|
||||||
alicloudImages := state.Get("alicloudimages").(map[string]string)
|
alicloudImages := state.Get("alicloudimages").(map[string]string)
|
||||||
ui.Say(fmt.Sprintf("Cancel copy image because cancellation or error..."))
|
ui.Say(fmt.Sprintf("Stopping copy image because cancellation or error..."))
|
||||||
for copyedRegionId, copyedImageId := range alicloudImages {
|
for copyedRegionId, copyedImageId := range alicloudImages {
|
||||||
if copyedRegionId == s.RegionId {
|
if copyedRegionId == s.RegionId {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := client.CancelCopyImage(common.Region(copyedRegionId), copyedImageId); err != nil {
|
if err := client.CancelCopyImage(common.Region(copyedRegionId), copyedImageId); err != nil {
|
||||||
ui.Say(fmt.Sprintf("Cancel copy image has error %v", err))
|
ui.Say(fmt.Sprintf("Error cancelling copy image: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ func (s *stepRunAlicloudInstance) Run(state multistep.StateBag) multistep.StepAc
|
|||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
ui.Say("Alcoud instance starting")
|
ui.Say("Starting instance.")
|
||||||
err = client.WaitForInstance(instance.InstanceId, ecs.Running, ALICLOUD_DEFAULT_TIMEOUT)
|
err = client.WaitForInstance(instance.InstanceId, ecs.Running, ALICLOUD_DEFAULT_TIMEOUT)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Timeout waiting for instance to start: %s", err)
|
err := fmt.Errorf("Timeout waiting for instance to start: %s", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user