mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-31 01:35:56 +08:00
ucloud add method GetSecurityGroupIds
This commit is contained in:
@@ -339,7 +339,7 @@ func (self *SServerSkuManager) ValidateCreateData(ctx context.Context,
|
||||
if !exists {
|
||||
return nil, httperrors.NewInputParameterError("instance_type_category %s is invalid", category)
|
||||
}
|
||||
data.Add(jsonutils.NewString(category),"local_category")
|
||||
data.Add(jsonutils.NewString(category), "local_category")
|
||||
|
||||
data.Set("instance_type_family", jsonutils.NewString(family))
|
||||
// 格式 ecs.g1.c1m1
|
||||
|
||||
@@ -50,6 +50,20 @@ type SInstance struct {
|
||||
BootDiskState string `json:"BootDiskState"`
|
||||
}
|
||||
|
||||
func (self *SInstance) GetSecurityGroupIds() []string {
|
||||
secgroups, err := self.GetSecurityGroups()
|
||||
if err != nil {
|
||||
log.Errorf(err.Error())
|
||||
}
|
||||
|
||||
secgroupIds := make([]string, 0)
|
||||
for _, secgroup := range secgroups {
|
||||
secgroupIds = append(secgroupIds, secgroup.GetId())
|
||||
}
|
||||
|
||||
return secgroupIds
|
||||
}
|
||||
|
||||
func (self *SInstance) GetProjectId() string {
|
||||
return self.host.zone.region.client.projectId
|
||||
}
|
||||
@@ -154,15 +168,6 @@ func (self *SInstance) GetMetadata() *jsonutils.JSONDict {
|
||||
}
|
||||
}
|
||||
|
||||
secgroups, err := self.GetSecurityGroups()
|
||||
if err != nil {
|
||||
log.Errorf(err.Error())
|
||||
}
|
||||
secgroupIds := jsonutils.NewArray()
|
||||
for _, secgroup := range secgroups {
|
||||
secgroupIds.Add(jsonutils.NewString(secgroup.GetId()))
|
||||
}
|
||||
data.Add(secgroupIds, "secgroupIds")
|
||||
return data
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user