mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
同步azure项目
This commit is contained in:
@@ -20,7 +20,6 @@ func init() {
|
||||
params, err = args.BaseListOptions.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
}
|
||||
result, err := modules.Cloudproviders.List(s, params)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -153,5 +153,5 @@ func (self *SClassicEipAddress) GetExpiredAt() time.Time {
|
||||
}
|
||||
|
||||
func (self *SClassicEipAddress) GetProjectId() string {
|
||||
return ""
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
@@ -537,5 +537,5 @@ func (self *SClassicInstance) Renew(bc billing.SBillingCycle) error {
|
||||
}
|
||||
|
||||
func (self *SClassicInstance) GetProjectId() string {
|
||||
return ""
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
@@ -361,5 +361,5 @@ func (region *SRegion) syncClassicSecurityGroup(secgroupId, name, desc string, r
|
||||
}
|
||||
|
||||
func (self *SClassicSecurityGroup) GetProjectId() string {
|
||||
return ""
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
@@ -343,5 +343,5 @@ func (self *SDisk) Rebuild(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (self *SDisk) GetProjectId() string {
|
||||
return ""
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
@@ -244,5 +244,5 @@ func (self *SEipAddress) GetExpiredAt() time.Time {
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetProjectId() string {
|
||||
return ""
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
@@ -1045,5 +1045,5 @@ func (self *SInstance) Renew(bc billing.SBillingCycle) error {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetProjectId() string {
|
||||
return ""
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
@@ -114,5 +114,5 @@ func (self *SNetwork) GetAllocTimeoutSeconds() int {
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetProjectId() string {
|
||||
return ""
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
@@ -489,5 +489,5 @@ func (region *SRegion) AssiginSecurityGroup(instanceId, secgroupId string) error
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetProjectId() string {
|
||||
return ""
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
@@ -174,5 +174,5 @@ func (self *SSnapshot) GetDiskType() string {
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetProjectId() string {
|
||||
return ""
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user