同步azure项目

This commit is contained in:
屈轩
2019-03-04 17:48:08 +08:00
parent 86f0b91db6
commit 31d7f04f82
11 changed files with 21 additions and 10 deletions
-1
View File
@@ -20,7 +20,6 @@ func init() {
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
result, err := modules.Cloudproviders.List(s, params)
+12
View File
@@ -769,6 +769,15 @@ func (self *SAzureClient) QueryAccountBalance() (*SAccountBalance, error) {
return nil, cloudprovider.ErrNotImplemented
}
func getResourceGroup(id string) string {
if info := strings.Split(id, "/resourceGroups/"); len(info) == 2 {
if resourcegroupInfo := strings.Split(info[1], "/"); len(resourcegroupInfo) > 0 {
return strings.ToLower(resourcegroupInfo[0])
}
}
return ""
}
func (self *SAzureClient) GetIProjects() ([]cloudprovider.ICloudProject, error) {
resourceGroups := []SResourceGroup{}
if err := self.List("resourcegroups", &resourceGroups); err != nil {
@@ -776,6 +785,9 @@ func (self *SAzureClient) GetIProjects() ([]cloudprovider.ICloudProject, error)
}
iprojects := []cloudprovider.ICloudProject{}
for i := 0; i < len(resourceGroups); i++ {
if groupInfo := strings.Split(resourceGroups[i].ID, "/"); len(groupInfo) > 0 {
resourceGroups[i].ID = strings.ToLower(groupInfo[len(groupInfo)-1])
}
iprojects = append(iprojects, &resourceGroups[i])
}
return iprojects, nil
+1 -1
View File
@@ -153,5 +153,5 @@ func (self *SClassicEipAddress) GetExpiredAt() time.Time {
}
func (self *SClassicEipAddress) GetProjectId() string {
return ""
return getResourceGroup(self.ID)
}
+1 -1
View File
@@ -537,5 +537,5 @@ func (self *SClassicInstance) Renew(bc billing.SBillingCycle) error {
}
func (self *SClassicInstance) GetProjectId() string {
return ""
return getResourceGroup(self.ID)
}
+1 -1
View File
@@ -361,5 +361,5 @@ func (region *SRegion) syncClassicSecurityGroup(secgroupId, name, desc string, r
}
func (self *SClassicSecurityGroup) GetProjectId() string {
return ""
return getResourceGroup(self.ID)
}
+1 -1
View File
@@ -343,5 +343,5 @@ func (self *SDisk) Rebuild(ctx context.Context) error {
}
func (self *SDisk) GetProjectId() string {
return ""
return getResourceGroup(self.ID)
}
+1 -1
View File
@@ -244,5 +244,5 @@ func (self *SEipAddress) GetExpiredAt() time.Time {
}
func (self *SEipAddress) GetProjectId() string {
return ""
return getResourceGroup(self.ID)
}
+1 -1
View File
@@ -1045,5 +1045,5 @@ func (self *SInstance) Renew(bc billing.SBillingCycle) error {
}
func (self *SInstance) GetProjectId() string {
return ""
return getResourceGroup(self.ID)
}
+1 -1
View File
@@ -114,5 +114,5 @@ func (self *SNetwork) GetAllocTimeoutSeconds() int {
}
func (self *SNetwork) GetProjectId() string {
return ""
return getResourceGroup(self.ID)
}
+1 -1
View File
@@ -489,5 +489,5 @@ func (region *SRegion) AssiginSecurityGroup(instanceId, secgroupId string) error
}
func (self *SSecurityGroup) GetProjectId() string {
return ""
return getResourceGroup(self.ID)
}
+1 -1
View File
@@ -174,5 +174,5 @@ func (self *SSnapshot) GetDiskType() string {
}
func (self *SSnapshot) GetProjectId() string {
return ""
return getResourceGroup(self.ID)
}