Fix the code according PR review
This commit is contained in:
parent
5e44a28a42
commit
b420c0fe0c
|
@ -9,12 +9,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
ssh_time_out = 60000000000
|
|
||||||
default_port = 22
|
|
||||||
default_comm_type = "ssh"
|
|
||||||
)
|
|
||||||
|
|
||||||
type RunConfig struct {
|
type RunConfig struct {
|
||||||
AssociatePublicIpAddress bool `mapstructure:"associate_public_ip_address"`
|
AssociatePublicIpAddress bool `mapstructure:"associate_public_ip_address"`
|
||||||
ZoneId string `mapstructure:"zone_id"`
|
ZoneId string `mapstructure:"zone_id"`
|
||||||
|
@ -51,18 +45,6 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID())
|
c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID())
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Comm.Type == "" {
|
|
||||||
c.Comm.Type = default_comm_type
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.Comm.SSHTimeout == 0 {
|
|
||||||
c.Comm.SSHTimeout = ssh_time_out
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.Comm.SSHPort == 0 {
|
|
||||||
c.Comm.SSHPort = default_port
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
errs := c.Comm.Prepare(ctx)
|
errs := c.Comm.Prepare(ctx)
|
||||||
if c.AlicloudSourceImage == "" {
|
if c.AlicloudSourceImage == "" {
|
||||||
|
|
|
@ -81,158 +81,98 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
state.Put("ui", ui)
|
state.Put("ui", ui)
|
||||||
state.Put("networktype", b.chooseNetworkType())
|
state.Put("networktype", b.chooseNetworkType())
|
||||||
var steps []multistep.Step
|
var steps []multistep.Step
|
||||||
|
|
||||||
|
// Build the steps
|
||||||
|
steps = []multistep.Step{
|
||||||
|
&stepPreValidate{
|
||||||
|
AlicloudDestImageName: b.config.AlicloudImageName,
|
||||||
|
ForceDelete: b.config.AlicloudImageForceDetele,
|
||||||
|
},
|
||||||
|
&stepCheckAlicloudSourceImage{
|
||||||
|
SourceECSImageId: b.config.AlicloudSourceImage,
|
||||||
|
},
|
||||||
|
&StepConfigAlicloudKeyPair{
|
||||||
|
Debug: b.config.PackerDebug,
|
||||||
|
KeyPairName: b.config.SSHKeyPairName,
|
||||||
|
PrivateKeyFile: b.config.Comm.SSHPrivateKey,
|
||||||
|
PublicKeyFile: b.config.PublicKey,
|
||||||
|
TemporaryKeyPairName: b.config.TemporaryKeyPairName,
|
||||||
|
},
|
||||||
|
}
|
||||||
if b.chooseNetworkType() == VpcNet {
|
if b.chooseNetworkType() == VpcNet {
|
||||||
// Build the steps
|
steps = append(steps,
|
||||||
steps = []multistep.Step{
|
|
||||||
&stepPreValidate{
|
|
||||||
AlicloudDestImageName: b.config.AlicloudImageName,
|
|
||||||
ForceDelete: b.config.AlicloudImageForceDetele,
|
|
||||||
},
|
|
||||||
&stepCheckAlicloudSourceImage{
|
|
||||||
SourceECSImageId: b.config.AlicloudSourceImage,
|
|
||||||
},
|
|
||||||
&StepConfigAlicloudKeyPair{
|
|
||||||
Debug: b.config.PackerDebug,
|
|
||||||
KeyPairName: b.config.SSHKeyPairName,
|
|
||||||
PrivateKeyFile: b.config.Comm.SSHPrivateKey,
|
|
||||||
PublicKeyFile: b.config.PublicKey,
|
|
||||||
TemporaryKeyPairName: b.config.TemporaryKeyPairName,
|
|
||||||
},
|
|
||||||
&stepConfigAlicloudVPC{
|
&stepConfigAlicloudVPC{
|
||||||
VpcId: b.config.VpcId,
|
VpcId: b.config.VpcId,
|
||||||
CidrBlock: b.config.CidrBlock,
|
CidrBlock: b.config.CidrBlock,
|
||||||
VpcName: b.config.VpcName,
|
VpcName: b.config.VpcName,
|
||||||
},
|
},
|
||||||
&stepConfigAlicloudVSwithc{
|
&stepConfigAlicloudVSwitch{
|
||||||
VSwitchId: b.config.VSwitchId,
|
VSwitchId: b.config.VSwitchId,
|
||||||
ZoneId: b.config.ZoneId,
|
ZoneId: b.config.ZoneId,
|
||||||
CidrBlock: b.config.CidrBlock,
|
CidrBlock: b.config.CidrBlock,
|
||||||
VSwitchName: b.config.VSwitchName,
|
VSwitchName: b.config.VSwitchName,
|
||||||
},
|
})
|
||||||
&stepConfigAlicloudSecurityGroup{
|
|
||||||
SecurityGroupId: b.config.SecurityGroupId,
|
|
||||||
SecurityGroupName: b.config.SecurityGroupId,
|
|
||||||
RegionId: b.config.AlicloudRegion,
|
|
||||||
},
|
|
||||||
&stepCreateAlicloudInstance{
|
|
||||||
IOOptimized: b.config.IOOptimized,
|
|
||||||
InstanceType: b.config.InstanceType,
|
|
||||||
UserData: b.config.UserData,
|
|
||||||
UserDataFile: b.config.UserDataFile,
|
|
||||||
RegionId: b.config.AlicloudRegion,
|
|
||||||
InternetChargeType: b.config.InternetChargeType,
|
|
||||||
InternetMaxBandwidthOut: b.config.InternetMaxBandwidthOut,
|
|
||||||
InstnaceName: b.config.InstanceName,
|
|
||||||
ZoneId: b.config.ZoneId,
|
|
||||||
},
|
|
||||||
&setpConfigAlicloudEIP{
|
|
||||||
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
|
|
||||||
RegionId: b.config.AlicloudRegion,
|
|
||||||
},
|
|
||||||
&stepRunAlicloudInstance{},
|
|
||||||
&stepMountAlicloudDisk{},
|
|
||||||
&communicator.StepConnect{
|
|
||||||
Config: &b.config.RunConfig.Comm,
|
|
||||||
Host: SSHHost(
|
|
||||||
client,
|
|
||||||
b.config.SSHPrivateIp),
|
|
||||||
SSHConfig: SSHConfig(
|
|
||||||
b.config.RunConfig.Comm.SSHAgentAuth,
|
|
||||||
b.config.RunConfig.Comm.SSHUsername,
|
|
||||||
b.config.RunConfig.Comm.SSHPassword),
|
|
||||||
},
|
|
||||||
&common.StepProvision{},
|
|
||||||
&stepStopAlicloudInstance{
|
|
||||||
ForceStop: b.config.ForceStopInstance,
|
|
||||||
},
|
|
||||||
&stepDeleteAlicloudImageSnapshots{
|
|
||||||
AlicloudImageForceDeteleSnapshots: b.config.AlicloudImageForceDeteleSnapshots,
|
|
||||||
AlicloudImageForceDetele: b.config.AlicloudImageForceDetele,
|
|
||||||
AlicloudImageName: b.config.AlicloudImageName,
|
|
||||||
},
|
|
||||||
&stepCreateAlicloudImage{},
|
|
||||||
&setpRegionCopyAlicloudImage{
|
|
||||||
AlicloudImageDestinationRegions: b.config.AlicloudImageDestinationRegions,
|
|
||||||
AlicloudImageDestinationNames: b.config.AlicloudImageDestinationNames,
|
|
||||||
RegionId: b.config.AlicloudRegion,
|
|
||||||
},
|
|
||||||
&setpShareAlicloudImage{
|
|
||||||
AlicloudImageShareAccounts: b.config.AlicloudImageShareAccounts,
|
|
||||||
AlicloudImageUNShareAccounts: b.config.AlicloudImageUNShareAccounts,
|
|
||||||
RegionId: b.config.AlicloudRegion,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Build the steps
|
|
||||||
steps = []multistep.Step{
|
|
||||||
&stepPreValidate{
|
|
||||||
AlicloudDestImageName: b.config.AlicloudImageName,
|
|
||||||
ForceDelete: b.config.AlicloudImageForceDetele,
|
|
||||||
},
|
|
||||||
&stepCheckAlicloudSourceImage{
|
|
||||||
SourceECSImageId: b.config.AlicloudSourceImage,
|
|
||||||
},
|
|
||||||
&StepConfigAlicloudKeyPair{
|
|
||||||
Debug: b.config.PackerDebug,
|
|
||||||
KeyPairName: b.config.SSHKeyPairName,
|
|
||||||
PrivateKeyFile: b.config.Comm.SSHPrivateKey,
|
|
||||||
PublicKeyFile: b.config.PublicKey,
|
|
||||||
TemporaryKeyPairName: b.config.TemporaryKeyPairName,
|
|
||||||
},
|
|
||||||
&stepConfigAlicloudSecurityGroup{
|
|
||||||
SecurityGroupId: b.config.SecurityGroupId,
|
|
||||||
SecurityGroupName: b.config.SecurityGroupId,
|
|
||||||
RegionId: b.config.AlicloudRegion,
|
|
||||||
},
|
|
||||||
&stepCreateAlicloudInstance{
|
|
||||||
IOOptimized: b.config.IOOptimized,
|
|
||||||
InstanceType: b.config.InstanceType,
|
|
||||||
UserData: b.config.UserData,
|
|
||||||
UserDataFile: b.config.UserDataFile,
|
|
||||||
RegionId: b.config.AlicloudRegion,
|
|
||||||
InternetChargeType: b.config.InternetChargeType,
|
|
||||||
InternetMaxBandwidthOut: b.config.InternetMaxBandwidthOut,
|
|
||||||
InstnaceName: b.config.InstanceName,
|
|
||||||
ZoneId: b.config.ZoneId,
|
|
||||||
},
|
|
||||||
&stepConfigAlicloudPublicIP{
|
|
||||||
RegionId: b.config.AlicloudRegion,
|
|
||||||
},
|
|
||||||
&stepRunAlicloudInstance{},
|
|
||||||
&stepMountAlicloudDisk{},
|
|
||||||
&communicator.StepConnect{
|
|
||||||
Config: &b.config.RunConfig.Comm,
|
|
||||||
Host: SSHHost(
|
|
||||||
client,
|
|
||||||
b.config.SSHPrivateIp),
|
|
||||||
SSHConfig: SSHConfig(
|
|
||||||
b.config.RunConfig.Comm.SSHAgentAuth,
|
|
||||||
b.config.RunConfig.Comm.SSHUsername,
|
|
||||||
b.config.RunConfig.Comm.SSHPassword),
|
|
||||||
},
|
|
||||||
&common.StepProvision{},
|
|
||||||
&stepStopAlicloudInstance{
|
|
||||||
ForceStop: b.config.ForceStopInstance,
|
|
||||||
},
|
|
||||||
&stepDeleteAlicloudImageSnapshots{
|
|
||||||
AlicloudImageForceDeteleSnapshots: b.config.AlicloudImageForceDeteleSnapshots,
|
|
||||||
AlicloudImageForceDetele: b.config.AlicloudImageForceDetele,
|
|
||||||
AlicloudImageName: b.config.AlicloudImageName,
|
|
||||||
},
|
|
||||||
&stepCreateAlicloudImage{},
|
|
||||||
&setpRegionCopyAlicloudImage{
|
|
||||||
AlicloudImageDestinationRegions: b.config.AlicloudImageDestinationRegions,
|
|
||||||
AlicloudImageDestinationNames: b.config.AlicloudImageDestinationNames,
|
|
||||||
RegionId: b.config.AlicloudRegion,
|
|
||||||
},
|
|
||||||
&setpShareAlicloudImage{
|
|
||||||
AlicloudImageShareAccounts: b.config.AlicloudImageShareAccounts,
|
|
||||||
AlicloudImageUNShareAccounts: b.config.AlicloudImageUNShareAccounts,
|
|
||||||
RegionId: b.config.AlicloudRegion,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
steps = append(steps,
|
||||||
|
&stepConfigAlicloudSecurityGroup{
|
||||||
|
SecurityGroupId: b.config.SecurityGroupId,
|
||||||
|
SecurityGroupName: b.config.SecurityGroupId,
|
||||||
|
RegionId: b.config.AlicloudRegion,
|
||||||
|
},
|
||||||
|
&stepCreateAlicloudInstance{
|
||||||
|
IOOptimized: b.config.IOOptimized,
|
||||||
|
InstanceType: b.config.InstanceType,
|
||||||
|
UserData: b.config.UserData,
|
||||||
|
UserDataFile: b.config.UserDataFile,
|
||||||
|
RegionId: b.config.AlicloudRegion,
|
||||||
|
InternetChargeType: b.config.InternetChargeType,
|
||||||
|
InternetMaxBandwidthOut: b.config.InternetMaxBandwidthOut,
|
||||||
|
InstnaceName: b.config.InstanceName,
|
||||||
|
ZoneId: b.config.ZoneId,
|
||||||
|
})
|
||||||
|
if b.chooseNetworkType() == VpcNet {
|
||||||
|
steps = append(steps, &setpConfigAlicloudEIP{
|
||||||
|
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
|
||||||
|
RegionId: b.config.AlicloudRegion,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
steps = append(steps, &stepConfigAlicloudPublicIP{
|
||||||
|
RegionId: b.config.AlicloudRegion,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
steps = append(steps,
|
||||||
|
&stepRunAlicloudInstance{},
|
||||||
|
&stepMountAlicloudDisk{},
|
||||||
|
&communicator.StepConnect{
|
||||||
|
Config: &b.config.RunConfig.Comm,
|
||||||
|
Host: SSHHost(
|
||||||
|
client,
|
||||||
|
b.config.SSHPrivateIp),
|
||||||
|
SSHConfig: SSHConfig(
|
||||||
|
b.config.RunConfig.Comm.SSHAgentAuth,
|
||||||
|
b.config.RunConfig.Comm.SSHUsername,
|
||||||
|
b.config.RunConfig.Comm.SSHPassword),
|
||||||
|
},
|
||||||
|
&common.StepProvision{},
|
||||||
|
&stepStopAlicloudInstance{
|
||||||
|
ForceStop: b.config.ForceStopInstance,
|
||||||
|
},
|
||||||
|
&stepDeleteAlicloudImageSnapshots{
|
||||||
|
AlicloudImageForceDeteleSnapshots: b.config.AlicloudImageForceDeteleSnapshots,
|
||||||
|
AlicloudImageForceDetele: b.config.AlicloudImageForceDetele,
|
||||||
|
AlicloudImageName: b.config.AlicloudImageName,
|
||||||
|
},
|
||||||
|
&stepCreateAlicloudImage{},
|
||||||
|
&setpRegionCopyAlicloudImage{
|
||||||
|
AlicloudImageDestinationRegions: b.config.AlicloudImageDestinationRegions,
|
||||||
|
AlicloudImageDestinationNames: b.config.AlicloudImageDestinationNames,
|
||||||
|
RegionId: b.config.AlicloudRegion,
|
||||||
|
},
|
||||||
|
&setpShareAlicloudImage{
|
||||||
|
AlicloudImageShareAccounts: b.config.AlicloudImageShareAccounts,
|
||||||
|
AlicloudImageUNShareAccounts: b.config.AlicloudImageUNShareAccounts,
|
||||||
|
RegionId: b.config.AlicloudRegion,
|
||||||
|
})
|
||||||
|
|
||||||
// Run!
|
// Run!
|
||||||
b.runner = common.NewRunner(steps, b.config.PackerConfig, ui)
|
b.runner = common.NewRunner(steps, b.config.PackerConfig, ui)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type stepConfigAlicloudVSwithc struct {
|
type stepConfigAlicloudVSwitch struct {
|
||||||
VSwitchId string
|
VSwitchId string
|
||||||
ZoneId string
|
ZoneId string
|
||||||
isCreate bool
|
isCreate bool
|
||||||
|
@ -18,7 +18,7 @@ type stepConfigAlicloudVSwithc struct {
|
||||||
VSwitchName string
|
VSwitchName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stepConfigAlicloudVSwithc) Run(state multistep.StateBag) multistep.StepAction {
|
func (s *stepConfigAlicloudVSwitch) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
client := state.Get("client").(*ecs.Client)
|
client := state.Get("client").(*ecs.Client)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
vpcId := state.Get("vpcid").(string)
|
vpcId := state.Get("vpcid").(string)
|
||||||
|
@ -42,7 +42,7 @@ func (s *stepConfigAlicloudVSwithc) Run(state multistep.StateBag) multistep.Step
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
s.isCreate = false
|
s.isCreate = false
|
||||||
message := fmt.Sprintf("The specific vswitch {%s} isn't exist.", s.VSwitchId)
|
message := fmt.Sprintf("The specific vswitch {%s} doesn't exist.", s.VSwitchId)
|
||||||
state.Put("error", errors.New(message))
|
state.Put("error", errors.New(message))
|
||||||
ui.Say(message)
|
ui.Say(message)
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
|
@ -52,7 +52,7 @@ func (s *stepConfigAlicloudVSwithc) Run(state multistep.StateBag) multistep.Step
|
||||||
|
|
||||||
zones, err := client.DescribeZones(common.Region(config.AlicloudRegion))
|
zones, err := client.DescribeZones(common.Region(config.AlicloudRegion))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ui.Say(fmt.Sprintf("Query avaiable zone failed: %s", err))
|
ui.Say(fmt.Sprintf("Query for available zones failed: %s", err))
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
@ -77,20 +77,20 @@ func (s *stepConfigAlicloudVSwithc) Run(state multistep.StateBag) multistep.Step
|
||||||
|
|
||||||
if s.ZoneId == "" {
|
if s.ZoneId == "" {
|
||||||
if len(instanceTypes) > 0 {
|
if len(instanceTypes) > 0 {
|
||||||
ui.Say(fmt.Sprintf("The instance Type %s isn't avaiable in this Region."+
|
ui.Say(fmt.Sprintf("The instance type %s isn't available in this region."+
|
||||||
"\n You can either change the instance 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 avaiable 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 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 avaiable in this Region."+
|
ui.Say(fmt.Sprintf("The instance type %s isn't available in this region."+
|
||||||
"\n You can change to other ragions \n", config.InstanceType))
|
"\n You can change to other regions \n", config.InstanceType))
|
||||||
|
|
||||||
state.Put("error", fmt.Errorf("The instance Type %s isn't avaiable in this Region."+
|
state.Put("error", fmt.Errorf("The instance type %s isn't available in this region."+
|
||||||
"\n You can change to other ragions \n", config.InstanceType))
|
"\n You can change to other regions \n", config.InstanceType))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ func (s *stepConfigAlicloudVSwithc) Run(state multistep.StateBag) multistep.Step
|
||||||
}
|
}
|
||||||
if err := client.WaitForVSwitchAvailable(vpcId, s.VSwitchId, ALICLOUD_DEFAULT_TIMEOUT); err != nil {
|
if err := client.WaitForVSwitchAvailable(vpcId, s.VSwitchId, ALICLOUD_DEFAULT_TIMEOUT); err != nil {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(fmt.Sprintf("Error waiting vswitch avaiable timeout: %v", err))
|
ui.Error(fmt.Sprintf("Timeout waiting for vswitch to become avaiable: %v", err))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
state.Put("vswitchid", vswitchId)
|
state.Put("vswitchid", vswitchId)
|
||||||
|
@ -121,7 +121,7 @@ func (s *stepConfigAlicloudVSwithc) Run(state multistep.StateBag) multistep.Step
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stepConfigAlicloudVSwithc) Cleanup(state multistep.StateBag) {
|
func (s *stepConfigAlicloudVSwitch) Cleanup(state multistep.StateBag) {
|
||||||
if !s.isCreate {
|
if !s.isCreate {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ func (s *stepCreateAlicloudImage) Run(state multistep.StateBag) multistep.StepAc
|
||||||
Description: config.AlicloudImageDescription})
|
Description: config.AlicloudImageDescription})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error create alicloud images: %s", err)
|
err := fmt.Errorf("Error creating alicloud images: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
|
|
|
@ -146,7 +146,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("Clean instance %s failed ", s.instance.InstanceId))
|
ui.Say(fmt.Sprintf("Cleaning instance: %s failed ", s.instance.InstanceId))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (s *stepDeleteAlicloudImageSnapshots) Run(state multistep.StateBag) multist
|
||||||
if s.AlicloudImageForceDeteleSnapshots {
|
if s.AlicloudImageForceDeteleSnapshots {
|
||||||
for _, diskDevice := range image.DiskDeviceMappings.DiskDeviceMapping {
|
for _, diskDevice := range image.DiskDeviceMappings.DiskDeviceMapping {
|
||||||
if err := client.DeleteSnapshot(diskDevice.SnapshotId); err != nil {
|
if err := client.DeleteSnapshot(diskDevice.SnapshotId); err != nil {
|
||||||
err := fmt.Errorf("Delete ECS snapshots failed: %s", err)
|
err := fmt.Errorf("Deleting ECS snapshot failed: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
|
|
|
@ -42,13 +42,13 @@ func (s *stepMountAlicloudDisk) Run(state multistep.StateBag) multistep.StepActi
|
||||||
}
|
}
|
||||||
for _, disk := range disks {
|
for _, disk := range disks {
|
||||||
if err := client.WaitForDisk(instance.RegionId, disk.DiskId, ecs.DiskStatusInUse, ALICLOUD_DEFAULT_SHORT_TIMEOUT); err != nil {
|
if err := client.WaitForDisk(instance.RegionId, disk.DiskId, ecs.DiskStatusInUse, ALICLOUD_DEFAULT_SHORT_TIMEOUT); err != nil {
|
||||||
err := fmt.Errorf("Error waiting mount alicloud disks failed: %s", err)
|
err := fmt.Errorf("Timeout waiting for mount of alicloud disk: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui.Say("Finish mounting Disks")
|
ui.Say("Finish mounting disks")
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
package slb
|
||||||
|
|
||||||
|
import "github.com/denverdino/aliyungo/common"
|
||||||
|
|
||||||
|
type CreateRulesResponse struct {
|
||||||
|
common.Response
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateRulesArgs struct {
|
||||||
|
RegionId common.Region
|
||||||
|
LoadBalancerId string
|
||||||
|
ListenerPort int
|
||||||
|
RuleList string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Rule struct {
|
||||||
|
RuleId string
|
||||||
|
RuleName string
|
||||||
|
Domain string
|
||||||
|
Url string
|
||||||
|
VServerGroupId string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create forward rules
|
||||||
|
//
|
||||||
|
// You can read doc at https://help.aliyun.com/document_detail/35226.html?spm=5176.doc35226.6.671.625Omh
|
||||||
|
func (client *Client) CreateRules(args *CreateRulesArgs) error {
|
||||||
|
response := CreateRulesResponse{}
|
||||||
|
err := client.Invoke("CreateRules", args, &response)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteRulesArgs struct {
|
||||||
|
RegionId common.Region
|
||||||
|
RuleIds string
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteRulesResponse struct {
|
||||||
|
common.Response
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete forward rules
|
||||||
|
//
|
||||||
|
// You can read doc at https://help.aliyun.com/document_detail/35227.html?spm=5176.doc35226.6.672.6iNBtR
|
||||||
|
func (client *Client) DeleteRules(args *DeleteRulesArgs) error {
|
||||||
|
response := DeleteRulesResponse{}
|
||||||
|
err := client.Invoke("DeleteRules", args, &response)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetRuleArgs struct {
|
||||||
|
RegionId common.Region
|
||||||
|
RuleId string
|
||||||
|
VServerGroupId string
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetRuleResponse struct {
|
||||||
|
common.Response
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify forward rules
|
||||||
|
//
|
||||||
|
// You can read doc at https://help.aliyun.com/document_detail/35228.html?spm=5176.doc35227.6.673.rq40a9
|
||||||
|
func (client *Client) SetRule(args *SetRuleArgs) error {
|
||||||
|
response := SetRuleResponse{}
|
||||||
|
err := client.Invoke("SetRule", args, &response)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type DescribeRuleAttributeArgs struct {
|
||||||
|
RegionId common.Region
|
||||||
|
RuleId string
|
||||||
|
}
|
||||||
|
|
||||||
|
type DescribeRuleAttributeResponse struct {
|
||||||
|
common.Response
|
||||||
|
LoadBalancerId string
|
||||||
|
ListenerPort int
|
||||||
|
Rule
|
||||||
|
}
|
||||||
|
|
||||||
|
// Describe rule
|
||||||
|
//
|
||||||
|
// You can read doc at https://help.aliyun.com/document_detail/35229.html?spm=5176.doc35226.6.674.DRJeKJ
|
||||||
|
func (client *Client) DescribeRuleAttribute(args *DescribeRuleAttributeArgs) (*DescribeRuleAttributeResponse, error) {
|
||||||
|
response := &DescribeRuleAttributeResponse{}
|
||||||
|
err := client.Invoke("DescribeRuleAttribute", args, response)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type DescribeRulesArgs struct {
|
||||||
|
RegionId common.Region
|
||||||
|
LoadBalancerId string
|
||||||
|
ListenerPort int
|
||||||
|
}
|
||||||
|
|
||||||
|
type DescribeRulesResponse struct {
|
||||||
|
common.Response
|
||||||
|
Rules struct {
|
||||||
|
Rule []Rule
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Describe rule
|
||||||
|
//
|
||||||
|
// You can read doc at https://help.aliyun.com/document_detail/35229.html?spm=5176.doc35226.6.674.DRJeKJ
|
||||||
|
func (client *Client) DescribeRules(args *DescribeRulesArgs) (*DescribeRulesResponse, error) {
|
||||||
|
response := &DescribeRulesResponse{}
|
||||||
|
err := client.Invoke("DescribeRules", args, response)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return response, nil
|
||||||
|
}
|
Binary file not shown.
|
@ -11,8 +11,8 @@
|
||||||
{
|
{
|
||||||
"checksumSHA1": "e6yzSIwLwJV0tb2YQupLL0FO1BM=",
|
"checksumSHA1": "e6yzSIwLwJV0tb2YQupLL0FO1BM=",
|
||||||
"path": "github.com/denverdino/aliyungo/common",
|
"path": "github.com/denverdino/aliyungo/common",
|
||||||
"revision": "5b4f72bfcf17a2e6ec8238708bd161a2413e97e6",
|
"revision": "019da4915136cd9fed94064a0604321d9bc09245",
|
||||||
"revisionTime": "2017-02-01T08:56:36Z"
|
"revisionTime": "2017-02-23T07:38:06Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "YLooG/WAFF61eBUxg/R5cpfi5DE=",
|
"checksumSHA1": "YLooG/WAFF61eBUxg/R5cpfi5DE=",
|
||||||
|
@ -21,16 +21,16 @@
|
||||||
"revisionTime": "2017-02-23T07:38:06Z"
|
"revisionTime": "2017-02-23T07:38:06Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "QlA7zv05k7HWeR3tg4uHqIlFcg8=",
|
"checksumSHA1": "mF2UQ4+NJrPUZkm1RNa9Kxr2U0s=",
|
||||||
"path": "github.com/denverdino/aliyungo/slb",
|
"path": "github.com/denverdino/aliyungo/slb",
|
||||||
"revision": "5b4f72bfcf17a2e6ec8238708bd161a2413e97e6",
|
"revision": "019da4915136cd9fed94064a0604321d9bc09245",
|
||||||
"revisionTime": "2017-02-01T08:56:36Z"
|
"revisionTime": "2017-02-23T07:38:06Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "Lp0KtT7ycgq31ox3Uzhpxyw0U+Y=",
|
"checksumSHA1": "Lp0KtT7ycgq31ox3Uzhpxyw0U+Y=",
|
||||||
"path": "github.com/denverdino/aliyungo/util",
|
"path": "github.com/denverdino/aliyungo/util",
|
||||||
"revision": "5b4f72bfcf17a2e6ec8238708bd161a2413e97e6",
|
"revision": "019da4915136cd9fed94064a0604321d9bc09245",
|
||||||
"revisionTime": "2017-02-01T08:56:36Z"
|
"revisionTime": "2017-02-23T07:38:06Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "/WG++Jij8INZ80tER+FAiIDMmws=",
|
"checksumSHA1": "/WG++Jij8INZ80tER+FAiIDMmws=",
|
||||||
|
|
|
@ -9,7 +9,7 @@ page_title: Alicloud Image Builder
|
||||||
|
|
||||||
Type: `alicloud-ecs`
|
Type: `alicloud-ecs`
|
||||||
|
|
||||||
Alicloud Packer builder plugin provide the capability to build customized images based on the existing base images.
|
Alicloud Packer builder plugin provide the capability to build customized images based on an existing base images.
|
||||||
|
|
||||||
## Configuration Reference
|
## Configuration Reference
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<li>
|
<li>
|
||||||
<h4>Builders</h4>
|
<h4>Builders</h4>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="/docs/builders/alicloud.html">Alicloud Image</a></li>
|
<li><a href="/docs/builders/alicloud-ecs.html">Alicloud Image</a></li>
|
||||||
<li><a href="/docs/builders/amazon.html">Amazon EC2 (AMI)</a></li>
|
<li><a href="/docs/builders/amazon.html">Amazon EC2 (AMI)</a></li>
|
||||||
<li><a href="/docs/builders/azure-arm.html">Azure Resource Manager</a></li>
|
<li><a href="/docs/builders/azure-arm.html">Azure Resource Manager</a></li>
|
||||||
<li><a href="/docs/builders/cloudstack.html">CloudStack</a></li>
|
<li><a href="/docs/builders/cloudstack.html">CloudStack</a></li>
|
||||||
|
|
Loading…
Reference in New Issue