mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Azure stop默认使用deallocate
This commit is contained in:
@@ -543,7 +543,7 @@ func (self *SInstance) RebuildRoot(imageId string, passwd string, publicKey stri
|
||||
|
||||
func (region *SRegion) ReplaceSystemDisk(instanceId, imageId, passwd, publicKey string, sysSizeGB int32) (string, error) {
|
||||
log.Debugf("ReplaceSystemDisk %s image: %s", instanceId, imageId)
|
||||
if err := region.DeallocateVM(instanceId); err != nil {
|
||||
if err := region.deallocateVM(instanceId); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if instance, err := region.GetInstance(instanceId); err != nil {
|
||||
@@ -792,16 +792,18 @@ func (self *SInstance) StopVM(isForce bool) error {
|
||||
}
|
||||
|
||||
func (self *SRegion) StopVM(instanceId string, isForce bool) error {
|
||||
return self.doStopVM(instanceId, isForce)
|
||||
return self.deallocateVM(instanceId)
|
||||
}
|
||||
|
||||
func (self *SRegion) DeallocateVM(instanceId string) error {
|
||||
func (self *SRegion) deallocateVM(instanceId string) error {
|
||||
_, resourceGroup, instanceName := pareResourceGroupWithName(instanceId, INSTANCE_RESOURCE)
|
||||
computeClient := compute.NewVirtualMachinesClientWithBaseURI(self.client.baseUrl, self.client.subscriptionId)
|
||||
computeClient.Authorizer = self.client.authorizer
|
||||
if result, err := computeClient.PowerOff(context.Background(), resourceGroup, instanceName); err != nil {
|
||||
result, err := computeClient.Deallocate(context.Background(), resourceGroup, instanceName)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if err := result.WaitForCompletion(context.Background(), computeClient.Client); err != nil {
|
||||
}
|
||||
if err := result.WaitForCompletion(context.Background(), computeClient.Client); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -71,8 +71,8 @@ func init() {
|
||||
return cli.DeleteVM(args.ID)
|
||||
})
|
||||
|
||||
shellutils.R(&InstanceOptions{}, "instance-deallocate", "Deallocate intance", func(cli *azure.SRegion, args *InstanceOptions) error {
|
||||
return cli.DeallocateVM(args.ID)
|
||||
shellutils.R(&InstanceOptions{}, "instance-stop", "Stop intance", func(cli *azure.SRegion, args *InstanceOptions) error {
|
||||
return cli.StopVM(args.ID, true)
|
||||
})
|
||||
|
||||
type InstanceRebuildOptions struct {
|
||||
|
||||
Reference in New Issue
Block a user