mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
temp commit
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
@@ -344,12 +343,12 @@ func (self *SQcloudGuestDriver) RequestSyncConfigOnHost(ctx context.Context, gue
|
||||
return nil, err
|
||||
}
|
||||
for _, disk := range removed {
|
||||
if err := iVM.DetachDisk(disk.GetId()); err != nil {
|
||||
if err := iVM.DetachDisk(ctx, disk.GetId()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
for _, disk := range added {
|
||||
if err := iVM.AttachDisk(disk.ExternalId); err != nil {
|
||||
if err := iVM.AttachDisk(ctx, disk.ExternalId); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ const (
|
||||
)
|
||||
|
||||
type SBillingResourceBase struct {
|
||||
BillingType string `width:"36" charset:"ascii" nullable:"true" default:"postpaid" list:"user" create:"optional"`
|
||||
ExpiredAt time.Time `nullable:"true" list:"user" create:"optional"`
|
||||
BillingType string `width:"36" charset:"ascii" nullable:"true" default:"postpaid" list:"user" create:"admin_optional"`
|
||||
ExpiredAt time.Time `nullable:"true" list:"user" create:"admin_optional"`
|
||||
}
|
||||
|
||||
func (self *SBillingResourceBase) GetChargeType() string {
|
||||
|
||||
@@ -1109,6 +1109,9 @@ func (self *SGuest) PerformChangeConfig(ctx context.Context, userCred mcclient.T
|
||||
return nil, httperrors.NewBadRequestError("Params vcpu_count parse error")
|
||||
}
|
||||
addCpu = int(nVcpu - int64(self.VcpuCount))
|
||||
if addCpu < 0 {
|
||||
addCpu = 0
|
||||
}
|
||||
}
|
||||
vmemSize, err := data.GetString("vmem_size")
|
||||
if err == nil {
|
||||
@@ -1124,6 +1127,9 @@ func (self *SGuest) PerformChangeConfig(ctx context.Context, userCred mcclient.T
|
||||
return nil, httperrors.NewBadRequestError("Params vmem_size parse error")
|
||||
}
|
||||
addMem = nVmem - self.VmemSize
|
||||
if addMem < 0 {
|
||||
addMem = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package aws
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
|
||||
"yunion.io/x/log"
|
||||
)
|
||||
|
||||
func (self *SRegion) GetReservedInstance() error {
|
||||
params := &ec2.DescribeReservedInstancesInput{}
|
||||
res, err := self.ec2Client.DescribeReservedInstances(params)
|
||||
if err != nil {
|
||||
log.Errorf("DescribeReservedInstances fail %s", err)
|
||||
return err
|
||||
}
|
||||
log.Debugf("%#v", res)
|
||||
return nil
|
||||
}
|
||||
|
||||
type SReservedHostOffering struct {
|
||||
Duration int
|
||||
HourlyPrice float64
|
||||
InstanceFamily string
|
||||
OfferingId string
|
||||
PaymentOption string
|
||||
UpfrontPrice float64
|
||||
}
|
||||
|
||||
func (self *SRegion) GetReservedHostOfferings() error {
|
||||
res, err := self.ec2Client.DescribeHostReservationOfferings(nil)
|
||||
if err != nil {
|
||||
log.Errorf("DescribeHostReservationOfferings fail %s", err)
|
||||
return err
|
||||
}
|
||||
log.Debugf("%#v", res)
|
||||
return nil
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
"context"
|
||||
"yunion.io/x/onecloud/pkg/util/aws"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
)
|
||||
@@ -134,7 +135,8 @@ func init() {
|
||||
}
|
||||
|
||||
shellutils.R(&InstanceRebuildRootOptions{}, "instance-rebuild-root", "Reinstall virtual server system image", func(cli *aws.SRegion, args *InstanceRebuildRootOptions) error {
|
||||
diskID, err := cli.ReplaceSystemDisk(args.ID, args.Image, args.Size)
|
||||
ctx := context.Background()
|
||||
diskID, err := cli.ReplaceSystemDisk(ctx, args.ID, args.Image, args.Size)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/util/aws"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ReservedInstanceListOptions struct {
|
||||
Id []string `help:"IDs of instances to show"`
|
||||
Zone string `help:"Zone ID"`
|
||||
Limit int `help:"page size"`
|
||||
Offset int `help:"page offset"`
|
||||
}
|
||||
shellutils.R(&ReservedInstanceListOptions{}, "reserved-instance-list", "List intances", func(cli *aws.SRegion, args *ReservedInstanceListOptions) error {
|
||||
e := cli.GetReservedInstance()
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
e = cli.GetReservedHostOfferings()
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user