diff --git a/cmd/climc/shell/images.go b/cmd/climc/shell/images.go index 4f0ba0e672..ac82bc6d50 100644 --- a/cmd/climc/shell/images.go +++ b/cmd/climc/shell/images.go @@ -211,29 +211,29 @@ func init() { } R(&ImageUpdateOptions{}, "image-update", "Update images meta infomation", func(s *mcclient.ClientSession, args *ImageUpdateOptions) error { - img, e := modules.Images.Get(s, args.ID, nil) + /* img, e := modules.Images.Get(s, args.ID, nil) if e != nil { return e } idstr, e := img.GetString("id") if e != nil { return e - } + }*/ params := jsonutils.NewDict() - properties, _ := img.Get("properties") + /* properties, _ := img.Get("properties") if properties != nil { params.Add(properties, "properties") - } + }*/ if len(args.Name) > 0 { params.Add(jsonutils.NewString(args.Name), "name") } - e = addImageOptionalOptions(s, params, args.ImageOptionalOptions) - if e != nil { - return e + err := addImageOptionalOptions(s, params, args.ImageOptionalOptions) + if err != nil { + return err } - img, e = modules.Images.Update(s, idstr, params) - if e != nil { - return e + img, err := modules.Images.Update(s, args.ID, params) + if err != nil { + return err } printObject(img) return nil diff --git a/cmd/climc/shell/quotas.go b/cmd/climc/shell/quotas.go index b601988fe0..6f98e5004c 100644 --- a/cmd/climc/shell/quotas.go +++ b/cmd/climc/shell/quotas.go @@ -12,6 +12,7 @@ type QuotaBaseOptions struct { Storage int64 `help:"Storage size in MB"` Port int64 `help:"Internal NIC count"` Eport int64 `help:"External NIC count"` + Eip int64 `help:"Elastic IP count"` Bw int64 `help:"Internal bandwidth in Mbps"` Ebw int64 `help:"External bandwidth in Mbps"` Image int64 `help:"Template count"` @@ -38,6 +39,9 @@ func quotaArgs2Params(args *QuotaBaseOptions) *jsonutils.JSONDict { if args.Eport > 0 { params.Add(jsonutils.NewInt(args.Eport), "eport") } + if args.Eip > 0 { + params.Add(jsonutils.NewInt(args.Eip), "eip") + } if args.Bw > 0 { params.Add(jsonutils.NewInt(args.Bw), "bw") } diff --git a/pkg/cloudprovider/resources.go b/pkg/cloudprovider/resources.go index e9d9322122..0b29100c9b 100644 --- a/pkg/cloudprovider/resources.go +++ b/pkg/cloudprovider/resources.go @@ -39,7 +39,7 @@ type ICloudRegion interface { CreateIVpc(name string, desc string, cidr string) (ICloudVpc, error) - CreateEIP(bwMbps int) (ICloudEIP, error) + CreateEIP(bwMbps int, chargeType string) (ICloudEIP, error) GetIEipById(id string) (ICloudEIP, error) diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index 34e5bb93d0..723f40b45a 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -996,6 +996,11 @@ func (self *SGuest) moreExtraInfo(extra *jsonutils.JSONDict) *jsonutils.JSONDict extra.Add(jsonutils.NewString(region.ExternalId), "region_external_id") } } + + host := self.GetHost() + if host != nil && len(host.ManagerId) > 0 { + extra.Add(jsonutils.NewString(host.ManagerId), "manager_id") + } } return extra } diff --git a/pkg/compute/options/options.go b/pkg/compute/options/options.go index df6f2894f7..dcd90d990d 100644 --- a/pkg/compute/options/options.go +++ b/pkg/compute/options/options.go @@ -35,7 +35,7 @@ type ComputeOptions struct { DefaultMemoryQuota int `default:"51200" help:"Common memory quota per tenant in MB, default 50G"` DefaultStorageQuota int `default:"3072000" help:"Common storage quota per tenant in MB, default 3000G"` DefaultPortQuota int `default:"50" help:"Common network port quota per tenant, default 50"` - DefaultEipQuota int `default:"5" help:"Common floating IP quota per tenant, default 0"` + DefaultEipQuota int `default:"10" help:"Common floating IP quota per tenant, default 10"` DefaultEportQuota int `default:"50" help:"Common exit network port quota per tenant, default 50"` DefaultBwQuota int `default:"500000" help:"Common network port bandwidth in mbps quota per tenant, default 50*10Gbps"` DefaultEbwQuota int `default:"1000" help:"Common exit network port bandwidth quota per tenant, default 1Gbps"` diff --git a/pkg/compute/tasks/eip_allocate_task.go b/pkg/compute/tasks/eip_allocate_task.go index 2183de8f76..1f59da6c2e 100644 --- a/pkg/compute/tasks/eip_allocate_task.go +++ b/pkg/compute/tasks/eip_allocate_task.go @@ -32,7 +32,7 @@ func (self *EipAllocateTask) OnInit(ctx context.Context, obj db.IStandaloneModel return } - extEip, err := iregion.CreateEIP(eip.Bandwidth) + extEip, err := iregion.CreateEIP(eip.Bandwidth, eip.ChargeType) if err != nil { msg := fmt.Sprintf("create eip fail %s", err) eip.SetStatus(self.UserCred, models.EIP_STATUS_ALLOCATE_FAIL, msg) diff --git a/pkg/mcclient/modules/mod_images.go b/pkg/mcclient/modules/mod_images.go index ae06aff2ab..76356af376 100644 --- a/pkg/mcclient/modules/mod_images.go +++ b/pkg/mcclient/modules/mod_images.go @@ -484,7 +484,29 @@ func (this *ImageManager) _create(s *mcclient.ClientSession, params jsonutils.JS } func (this *ImageManager) Update(s *mcclient.ClientSession, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) { - return this._update(s, id, params, nil) + img, err := this.Get(s, id, nil) + if err != nil { + return nil, err + } + idstr, err := img.GetString("id") + if err != nil { + return nil, err + } + properties, _ := img.Get("properties") + if properties != nil { + propDict := properties.(*jsonutils.JSONDict) + propMap, _ := propDict.GetMap() + if propMap != nil { + paramsDict := params.(*jsonutils.JSONDict) + for k, val := range propMap { + if !paramsDict.Contains("properties", k) { + paramsDict.Add(val, "properties", k) + } + } + } + } + + return this._update(s, idstr, params, nil) } func (this *ImageManager) _update(s *mcclient.ClientSession, id string, params jsonutils.JSONObject, body io.Reader) (jsonutils.JSONObject, error) { diff --git a/pkg/util/aliyun/eip.go b/pkg/util/aliyun/eip.go index a57b636335..4378fdfa6b 100644 --- a/pkg/util/aliyun/eip.go +++ b/pkg/util/aliyun/eip.go @@ -243,8 +243,15 @@ func (region *SRegion) AllocateEIP(bwMbps int, chargeType TInternetChargeType) ( return region.GetEip(eipId) } -func (region *SRegion) CreateEIP(bwMbps int) (cloudprovider.ICloudEIP, error) { - eip, err := region.AllocateEIP(bwMbps, InternetChargeByTraffic) +func (region *SRegion) CreateEIP(bwMbps int, chargeType string) (cloudprovider.ICloudEIP, error) { + var ctype TInternetChargeType + switch chargeType { + case models.EIP_CHARGE_TYPE_BY_TRAFFIC: + ctype = InternetChargeByTraffic + case models.EIP_CHARGE_TYPE_BY_BANDWIDTH: + ctype = InternetChargeByBandwidth + } + eip, err := region.AllocateEIP(bwMbps, ctype) return eip, err }