Skip to content

Commit

Permalink
BCC support deploySetIds
Browse files Browse the repository at this point in the history
  • Loading branch information
duanliguo committed Apr 2, 2021
1 parent 1f074ea commit 2e7022a
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 50 deletions.
4 changes: 4 additions & 0 deletions doc/BCC.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ args := &api.CreateInstanceArgs{
Tags []model.TagModel tags
// 指定实例所在的部署集id
DeployId string "deployId"
// 指定实例所在的部署集id 列表
DeployIdList []string `json:"deployIdList"`
// 设置要绑定的密钥对ID
KeypairId string "keypairId"
// 设置要绑定的自动快照策略ID
Expand Down Expand Up @@ -413,6 +415,8 @@ createInstanceBySpecArgs := &api.CreateInstanceBySpecArgs{
AutoRenewTime int autoRenewTime
// cds是否自动续费 是:true 否:false
CdsAutoRenew bool cdsAutoRenew
// 指定实例所在的部署集id 列表
DeployIdList []string `json:"deployIdList"`
// 待创建实例指定的标签是否需要和已有标签键进行关联,默认为false。注意值为true时要保证该标签键已存在
RelationTag bool relationTag
// 待创建的标签列表
Expand Down
56 changes: 56 additions & 0 deletions services/bcc/api/deploySet.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,54 @@ func GetDeploySet(cli bce.Client, deploySetId string) (*DeploySetResult, error)
return jsonBody, nil
}

//func UpdateInstanceDeploy(cli bce.Client, clientToken string, reqBody *bce.Body) error {
// // Build the request
// req := &bce.BceRequest{}
// req.SetUri(getUpdateInstanceDeployUri())
// req.SetMethod(http.POST)
// req.SetBody(reqBody)
//
// if clientToken != "" {
// req.SetParam("clientToken", clientToken)
// }
//
// // Send request and get response
// resp := &bce.BceResponse{}
// if err := cli.SendRequest(req, resp); err != nil {
// return err
// }
// if resp.IsFail() {
// return resp.ServiceError()
// }
//
// defer func() { resp.Body().Close() }()
// return nil
//}
//
//func DelInstanceDeploy(cli bce.Client, clientToken string, reqBody *bce.Body) error {
// // Build the request
// req := &bce.BceRequest{}
// req.SetUri(getDelInstanceDeployUri())
// req.SetMethod(http.POST)
// req.SetBody(reqBody)
//
// if clientToken != "" {
// req.SetParam("clientToken", clientToken)
// }
//
// // Send request and get response
// resp := &bce.BceResponse{}
// if err := cli.SendRequest(req, resp); err != nil {
// return err
// }
// if resp.IsFail() {
// return resp.ServiceError()
// }
//
// defer func() { resp.Body().Close() }()
// return nil
//}

func getDeploySetCreateUri() string {
return URI_PREFIXV2 + REQUEST_INSTANCE_URI + REQUEST_DEPLOYSET_URI + REQUEST_CREATE_URI
}
Expand All @@ -201,3 +249,11 @@ func getDeploySetUriWithId(id string) string {
func getDeploySetUrl(id string) string {
return URI_PREFIXV2 + REQUEST_DEPLOYSET_URI + "/" + id
}

func getUpdateInstanceDeployUri() string {
return URI_PREFIXV2 + REQUEST_INSTANCE_URI + REQUEST_DEPLOYSET_URI + REQUEST_UPDATE_URI
}

func getDelInstanceDeployUri() string {
return URI_PREFIXV2 + REQUEST_INSTANCE_URI + REQUEST_DEPLOYSET_URI + REQUEST_DEL_URI
}
93 changes: 58 additions & 35 deletions services/bcc/api/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,41 +98,50 @@ const (

// Instance define instance model
type InstanceModel struct {
InstanceId string `json:"id"`
SerialNumber string `json:"serialNumber"`
InstanceName string `json:"name"`
Hostname string `json:"hostname"`
InstanceType InstanceType `json:"instanceType"`
Description string `json:"desc"`
Status InstanceStatus `json:"status"`
PaymentTiming string `json:"paymentTiming"`
CreationTime string `json:"createTime"`
ExpireTime string `json:"expireTime"`
PublicIP string `json:"publicIp"`
InternalIP string `json:"internalIp"`
CpuCount int `json:"cpuCount"`
GpuCard string `json:"gpuCard"`
FpgaCard string `json:"fpgaCard"`
CardCount string `json:"cardCount"`
MemoryCapacityInGB int `json:"memoryCapacityInGB"`
LocalDiskSizeInGB int `json:"localDiskSizeInGB"`
ImageId string `json:"imageId"`
NetworkCapacityInMbps int `json:"networkCapacityInMbps"`
PlacementPolicy string `json:"placementPolicy"`
ZoneName string `json:"zoneName"`
SubnetId string `json:"subnetId"`
VpcId string `json:"vpcId"`
AutoRenew bool `json:"autoRenew"`
KeypairId string `json:"keypairId"`
KeypairName string `json:"keypairName"`
DedicatedHostId string `json:"dedicatedHostId"`
Tags []model.TagModel `json:"tags"`
Ipv6 string `json:"ipv6"`
SwitchId string `json:"switchId"`
HostId string `json:"hostId"`
DeploysetId string `json:"deploysetId"`
RackId string `json:"rackId"`
NicInfo NicInfo `json:"nicInfo"`
InstanceId string `json:"id"`
SerialNumber string `json:"serialNumber"`
InstanceName string `json:"name"`
Hostname string `json:"hostname"`
InstanceType InstanceType `json:"instanceType"`
Description string `json:"desc"`
Status InstanceStatus `json:"status"`
PaymentTiming string `json:"paymentTiming"`
CreationTime string `json:"createTime"`
ExpireTime string `json:"expireTime"`
PublicIP string `json:"publicIp"`
InternalIP string `json:"internalIp"`
CpuCount int `json:"cpuCount"`
GpuCard string `json:"gpuCard"`
FpgaCard string `json:"fpgaCard"`
CardCount string `json:"cardCount"`
MemoryCapacityInGB int `json:"memoryCapacityInGB"`
LocalDiskSizeInGB int `json:"localDiskSizeInGB"`
ImageId string `json:"imageId"`
NetworkCapacityInMbps int `json:"networkCapacityInMbps"`
PlacementPolicy string `json:"placementPolicy"`
ZoneName string `json:"zoneName"`
SubnetId string `json:"subnetId"`
VpcId string `json:"vpcId"`
AutoRenew bool `json:"autoRenew"`
KeypairId string `json:"keypairId"`
KeypairName string `json:"keypairName"`
DedicatedHostId string `json:"dedicatedHostId"`
Tags []model.TagModel `json:"tags"`
Ipv6 string `json:"ipv6"`
SwitchId string `json:"switchId"`
HostId string `json:"hostId"`
DeploysetId string `json:"deploysetId"`
RackId string `json:"rackId"`
NicInfo NicInfo `json:"nicInfo"`
DeploySetList []DeploySetSimpleModel `json:"deploysetList"`
}

type DeploySetSimpleModel struct {
Strategy string `json:"strategy"`
Name string `json:"name"`
Desc string `json:"desc"`
DeploySetId string `json:"deploysetId"`
Concurrency int `json:"concurrency"`
}

type GetAllStocksResult struct {
Expand Down Expand Up @@ -272,6 +281,7 @@ type CreateInstanceArgs struct {
InternalIps []string `json:"internalIps,omitempty"`
ClientToken string `json:"-"`
RequestToken string `json:"requestToken"`
DeployIdList []string `json:"deployIdList"`
}

type CreateInstanceStockArgs struct {
Expand Down Expand Up @@ -355,6 +365,7 @@ type CreateInstanceBySpecArgs struct {
DeployId string `json:"deployId,omitempty"`
ClientToken string `json:"-"`
RequestToken string `json:"requestToken"`
DeployIdList []string `json:"deployIdList"`
}

type CreateInstanceV3Args struct {
Expand Down Expand Up @@ -1218,6 +1229,18 @@ type DeploySetResult struct {
InstanceList []AzIntstanceStatisDetail `json:"azIntstanceStatisList"`
}

type UpdateInstanceDeployArgs struct {
ClientToken string `json:"-"`
InstanceId string `json:"instanceId,omitempty"`
DeploySetIds []string `json:"deploysetIdList,omitempty"`
}

type DelInstanceDeployArgs struct {
ClientToken string `json:"-"`
InstanceIds []string `json:"instanceIdList,omitempty"`
DeploySetId string `json:"deployId,omitempty"`
}

type AzIntstanceStatisDetail struct {
ZoneName string `json:"zoneName"`
Count int `json:"instanceCount"`
Expand Down
2 changes: 2 additions & 0 deletions services/bcc/api/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const (
REQUEST_BATCHADDIP_URI = "/batchAddIp"
REQUEST_BATCHDELIP_URI = "/batchDelIp"
REQUEST_CREATE_URI = "/create"
REQUEST_UPDATE_URI = "/updateRelation"
REQUEST_DEL_URI = "/delRelation"
REQUEST_DEPLOYSET_URI = "/deployset"
REQUEST_IMAGE_URI = "/image"
REQUEST_IMAGE_SHAREDUSER_URI = "/sharedUsers"
Expand Down
38 changes: 37 additions & 1 deletion services/bcc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func (c *Client) BatchAddIP(args *api.BatchAddIpArgs) (*api.BatchAddIpResponse,
return nil, err
}

return api.BatchAddIp(c,args, body)
return api.BatchAddIp(c, args, body)
}

// BatchDelIP - Delete ips of instance
Expand Down Expand Up @@ -1214,6 +1214,42 @@ func (c *Client) GetDeploySet(deploySetId string) (*api.DeploySetResult, error)
return api.GetDeploySet(c, deploySetId)
}

// UpdateInstanceDeploySet - update deployset and instance relation
//
// PARAMS:
// - args: the arguments to update deployset and instance relation
// RETURNS:
// - error: nil if success otherwise the specific error
//func (c *Client) UpdateInstanceDeploySet(args *api.UpdateInstanceDeployArgs) (error, error) {
// jsonBytes, jsonErr := json.Marshal(args)
// if jsonErr != nil {
// return nil, jsonErr
// }
// body, err := bce.NewBodyFromBytes(jsonBytes)
// if err != nil {
// return nil, err
// }
// return api.UpdateInstanceDeploy(c, args.ClientToken, body), nil
//}

// DelInstanceDeploySet - delete deployset and instance relation
//
// PARAMS:
// - args: the arguments to delete deployset and instance relation
// RETURNS:
// - error: nil if success otherwise the specific error
//func (c *Client) DelInstanceDeploySet(args *api.DelInstanceDeployArgs) (error, error) {
// jsonBytes, jsonErr := json.Marshal(args)
// if jsonErr != nil {
// return nil, jsonErr
// }
// body, err := bce.NewBodyFromBytes(jsonBytes)
// if err != nil {
// return nil, err
// }
// return api.DelInstanceDeploy(c, args.ClientToken, body), nil
//}

// ResizeInstanceBySpec - resize a specific instance
//
// PARAMS:
Expand Down
Loading

0 comments on commit 2e7022a

Please sign in to comment.