mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): sync apsara project info
This commit is contained in:
@@ -17,8 +17,6 @@ package apsara
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -27,7 +25,6 @@ import (
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
|
||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/http/httpproxy"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
@@ -115,15 +112,6 @@ func NewApsaraClient(cfg *ApsaraClientConfig) (*SApsaraClient, error) {
|
||||
client := SApsaraClient{
|
||||
ApsaraClientConfig: cfg,
|
||||
}
|
||||
pcfg := &httpproxy.Config{
|
||||
HTTPProxy: "http://192.168.199.117:8888",
|
||||
HTTPSProxy: "",
|
||||
NoProxy: "",
|
||||
}
|
||||
proxyFunc := pcfg.ProxyFunc()
|
||||
client.cpcfg.ProxyFunc = func(req *http.Request) (*url.URL, error) {
|
||||
return proxyFunc(req.URL)
|
||||
}
|
||||
|
||||
err := client.fetchRegions()
|
||||
if err != nil {
|
||||
@@ -253,8 +241,6 @@ func _jsonRequest(client *sdk.Client, domain string, version string, apiName str
|
||||
req.GetHeaders()["x-acs-instanceId"] = id
|
||||
}
|
||||
|
||||
log.Errorf("header: %s", req.GetHeaders())
|
||||
|
||||
resp, err := processCommonRequest(client, req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "processCommonRequest(%s, %s)", apiName, params)
|
||||
|
||||
@@ -40,10 +40,8 @@ type SBucket struct {
|
||||
Location string
|
||||
CreationDate time.Time
|
||||
StorageClass string
|
||||
}
|
||||
|
||||
func (b *SBucket) GetProjectId() string {
|
||||
return ""
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (b *SBucket) GetGlobalId() string {
|
||||
|
||||
@@ -92,7 +92,6 @@ type SDBInstance struct {
|
||||
PayType TChargeType
|
||||
ReadOnlyDBInstanceIds SReadOnlyDBInstanceIds
|
||||
RegionId string
|
||||
ResourceGroupId string
|
||||
VSwitchId string
|
||||
VpcCloudInstanceId string
|
||||
VpcId string
|
||||
@@ -104,6 +103,7 @@ type SDBInstance struct {
|
||||
SupportUpgradeAccountType string
|
||||
TempUpgradeTimeEnd time.Time
|
||||
TempUpgradeTimeStart time.Time
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetName() string {
|
||||
@@ -753,10 +753,6 @@ func (region *SRegion) RecoveryDBInstanceFromBackup(srcId, destId string, backup
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetProjectId() string {
|
||||
return rds.ResourceGroupId
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) CreateDatabase(conf *cloudprovider.SDBInstanceDatabaseCreateConfig) error {
|
||||
return rds.region.CreateDBInstanceDatabae(rds.DBInstanceId, conf.CharacterSet, conf.Name, conf.Description)
|
||||
}
|
||||
|
||||
@@ -67,13 +67,13 @@ type SDisk struct {
|
||||
Portable bool
|
||||
ProductCode string
|
||||
RegionId string
|
||||
ResourceGroupId string
|
||||
Size int
|
||||
SourceSnapshotId string
|
||||
Status string
|
||||
Tags STags
|
||||
Type string
|
||||
ZoneId string
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (self *SRegion) GetDisks(instanceId string, zoneId string, category string, diskIds []string, offset int, limit int) ([]SDisk, int, error) {
|
||||
@@ -437,7 +437,3 @@ func (self *SRegion) rebuildDisk(diskId string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SDisk) GetProjectId() string {
|
||||
return self.ResourceGroupId
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ type SEipAddress struct {
|
||||
|
||||
OperationLocks string
|
||||
|
||||
ChargeType TChargeType
|
||||
ExpiredTime time.Time
|
||||
ResourceGroupId string
|
||||
ChargeType TChargeType
|
||||
ExpiredTime time.Time
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetId() string {
|
||||
@@ -377,7 +377,3 @@ func (region *SRegion) UpdateEipBandwidth(eipId string, bw int) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetProjectId() string {
|
||||
return self.ResourceGroupId
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ type SElasticcache struct {
|
||||
NodeType string `json:"NodeType"`
|
||||
CapacityMB int `json:"Capacity"`
|
||||
Connections int64 `json:"Connections"`
|
||||
ResourceGroupId string `json:"ResourceGroupId"`
|
||||
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
type SElasticcacheAttribute struct {
|
||||
@@ -864,10 +865,6 @@ func (self *SElasticcache) UpdateAuthMode(noPwdAccess bool, password string) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetProjectId() string {
|
||||
return self.ResourceGroupId
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetAuthMode() string {
|
||||
attribute, err := self.GetAttribute()
|
||||
if err != nil {
|
||||
|
||||
@@ -118,7 +118,6 @@ type SInstance struct {
|
||||
PublicIpAddress SIpAddress
|
||||
Recyclable bool
|
||||
RegionId string
|
||||
ResourceGroupId string
|
||||
SaleCycle string
|
||||
SecurityGroupIds SSecurityGroupIds
|
||||
SerialNumber string
|
||||
@@ -130,6 +129,7 @@ type SInstance struct {
|
||||
VlanId string
|
||||
VpcAttributes SVpcAttributes
|
||||
ZoneId string
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
// {"AutoReleaseTime":"","ClusterId":"","Cpu":1,"CreationTime":"2018-05-23T07:58Z","DedicatedHostAttribute":{"DedicatedHostId":"","DedicatedHostName":""},"Description":"","DeviceAvailable":true,"EipAddress":{"AllocationId":"","InternetChargeType":"","IpAddress":""},"ExpiredTime":"2018-05-30T16:00Z","GPUAmount":0,"GPUSpec":"","HostName":"iZ2ze57isp1ali72tzkjowZ","ImageId":"centos_7_04_64_20G_alibase_201701015.vhd","InnerIpAddress":{"IpAddress":[]},"InstanceChargeType":"PrePaid","InstanceId":"i-2ze57isp1ali72tzkjow","InstanceName":"gaoxianqi-test-7days","InstanceNetworkType":"vpc","InstanceType":"ecs.t5-lc2m1.nano","InstanceTypeFamily":"ecs.t5","InternetChargeType":"PayByBandwidth","InternetMaxBandwidthIn":-1,"InternetMaxBandwidthOut":0,"IoOptimized":true,"Memory":512,"NetworkInterfaces":{"NetworkInterface":[{"MacAddress":"00:16:3e:10:f0:c9","NetworkInterfaceId":"eni-2zecqsagtpztl6x5hu2r","PrimaryIpAddress":"192.168.220.214"}]},"OSName":"CentOS 7.4 64位","OSType":"linux","OperationLocks":{"LockReason":[]},"PublicIpAddress":{"IpAddress":[]},"Recyclable":false,"RegionId":"cn-beijing","ResourceGroupId":"","SaleCycle":"Week","SecurityGroupIds":{"SecurityGroupId":["sg-2zecqsagtpztl6x9zynl"]},"SerialNumber":"df05d9b4-df3d-4400-88d1-5f843f0dd088","SpotPriceLimit":0.000000,"SpotStrategy":"NoSpot","StartTime":"2018-05-23T07:58Z","Status":"Running","StoppedMode":"Not-applicable","VlanId":"","VpcAttributes":{"NatIpAddress":"","PrivateIpAddress":{"IpAddress":["192.168.220.214"]},"VSwitchId":"vsw-2ze9cqwza4upoyujq1thd","VpcId":"vpc-2zer4jy8ix3i8f0coc5uw"},"ZoneId":"cn-beijing-f"}
|
||||
@@ -932,10 +932,6 @@ func (region *SRegion) RenewInstance(instanceId string, bc billing.SBillingCycle
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetProjectId() string {
|
||||
return self.ResourceGroupId
|
||||
}
|
||||
|
||||
func (self *SInstance) GetError() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ type SLoadbalancer struct {
|
||||
SlaveZoneId string //实例的备可用区ID。
|
||||
InternetChargeType TInternetChargeType //公网实例的计费方式。取值:paybybandwidth:按带宽计费 paybytraffic:按流量计费(默认值) 说明 当 PayType参数的值为PrePay时,只支持按带宽计费。
|
||||
PayType string //实例的计费类型,取值:PayOnDemand:按量付费 PrePay:预付费
|
||||
ResourceGroupId string //企业资源组ID。
|
||||
LoadBalancerSpec string //负载均衡实例的的性能规格
|
||||
Bandwidth int //按带宽计费的公网型实例的带宽峰值
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetName() string {
|
||||
@@ -405,10 +405,6 @@ func (lb *SLoadbalancer) GetILoadBalancerListeners() ([]cloudprovider.ICloudLoad
|
||||
return listeners, nil
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetProjectId() string {
|
||||
return lb.ResourceGroupId
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) SetTags(tags map[string]string, replace bool) error {
|
||||
return lb.region.SetResourceTags("slb", "instance", []string{lb.LoadBalancerId}, tags, replace)
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ type SLoadbalancerAcl struct {
|
||||
AclName string
|
||||
|
||||
AclEntrys AclEntrys
|
||||
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (acl *SLoadbalancerAcl) GetAclListenerID() string {
|
||||
@@ -156,7 +158,3 @@ func (acl *SLoadbalancerAcl) Sync(_acl *cloudprovider.SLoadbalancerAccessControl
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (acl *SLoadbalancerAcl) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ type SLoadbalancerBackend struct {
|
||||
ServerId string
|
||||
Port int
|
||||
Weight int
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerBackend) GetName() string {
|
||||
@@ -104,10 +105,6 @@ func (region *SRegion) GetLoadbalancerBackends(backendgroupId string) ([]SLoadba
|
||||
return backends, body.Unmarshal(&backends, "BackendServers", "BackendServer")
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerBackend) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerBackend) SyncConf(ctx context.Context, port, weight int) error {
|
||||
err := backend.lbbg.lb.region.RemoveBackendVServer(backend.lbbg.lb.LoadBalancerId, backend.lbbg.VServerGroupId, backend.ServerId, backend.Port)
|
||||
if err != nil {
|
||||
|
||||
@@ -58,6 +58,7 @@ type SLoadbalancerBackendGroup struct {
|
||||
VServerGroupId string
|
||||
VServerGroupName string
|
||||
AssociatedObjects AssociatedObjects
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerBackendGroup) GetILoadbalancer() cloudprovider.ICloudLoadbalancer {
|
||||
@@ -271,7 +272,3 @@ func (backendgroup *SLoadbalancerBackendGroup) AddBackendServer(serverId string,
|
||||
func (backendgroup *SLoadbalancerBackendGroup) RemoveBackendServer(serverId string, weight, port int) error {
|
||||
return backendgroup.lb.region.RemoveBackendVServer(backendgroup.lb.LoadBalancerId, backendgroup.VServerGroupId, serverId, port)
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerBackendGroup) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ type SLoadbalancerDefaultBackend struct {
|
||||
|
||||
ServerId string
|
||||
Weight int
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerDefaultBackend) GetName() string {
|
||||
@@ -81,10 +82,6 @@ func (backend *SLoadbalancerDefaultBackend) GetIpAddress() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerDefaultBackend) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerDefaultBackend) SyncConf(ctx context.Context, port, weight int) error {
|
||||
params := map[string]string{}
|
||||
params["RegionId"] = backend.lbbg.lb.region.RegionId
|
||||
|
||||
@@ -29,6 +29,7 @@ type SLoadbalancerDefaultBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.ApsaraTags
|
||||
lb *SLoadbalancer
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerDefaultBackendGroup) GetILoadbalancer() cloudprovider.ICloudLoadbalancer {
|
||||
@@ -153,7 +154,3 @@ func (region *SRegion) RemoveBackendServer(loadbalancerId, serverId string) erro
|
||||
func (backendgroup *SLoadbalancerDefaultBackendGroup) RemoveBackendServer(serverId string, weight, port int) error {
|
||||
return backendgroup.lb.region.RemoveBackendServer(backendgroup.lb.LoadBalancerId, serverId)
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerDefaultBackendGroup) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ type SLoadbalancerHTTPListener struct {
|
||||
ForwardPort int // HTTP至HTTPS的监听转发端口。暂时只支持将HTTP 80访问重定向转发至HTTPS 443。 说明 如果 ListenerForward的值为 off,该参数不显示。
|
||||
ListenerForward string // 表示是否开启HTTP至HTTPS的监听转发。on:表示开启 off:表示未开启
|
||||
VServerGroupId string // 绑定的服务器组ID
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (listener *SLoadbalancerHTTPListener) GetName() string {
|
||||
@@ -366,10 +367,6 @@ func (listerner *SLoadbalancerHTTPListener) Sync(ctx context.Context, lblis *clo
|
||||
return listerner.lb.region.SyncLoadbalancerHTTPListener(listerner.lb, lblis)
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPListener) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPListener) GetClientIdleTimeout() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ type SLoadbalancerHTTPSListener struct {
|
||||
EnableHttp2 string // 是否开启HTTP/2特性。取值:on(默认值)|off
|
||||
|
||||
TLSCipherPolicy string //
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (listener *SLoadbalancerHTTPSListener) GetName() string {
|
||||
@@ -396,10 +397,6 @@ func (listerner *SLoadbalancerHTTPSListener) Sync(ctx context.Context, lblis *cl
|
||||
return listerner.lb.region.SyncLoadbalancerHTTPSListener(listerner.lb, lblis)
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPSListener) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerHTTPSListener) GetClientIdleTimeout() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ type SLoadbalancerListenerRule struct {
|
||||
RuleName string `json:"RuleName"`
|
||||
Url string `json:"Url"`
|
||||
VServerGroupId string `json:"VServerGroupId"`
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (lbr *SLoadbalancerListenerRule) GetName() string {
|
||||
@@ -97,10 +98,6 @@ func (lbr *SLoadbalancerListenerRule) GetPath() string {
|
||||
return lbr.Url
|
||||
}
|
||||
|
||||
func (lbr *SLoadbalancerListenerRule) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (lbr *SLoadbalancerListenerRule) GetBackendGroupId() string {
|
||||
return lbr.VServerGroupId
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ type SLoadbalancerMasterSlaveBackend struct {
|
||||
Weight int
|
||||
Port int
|
||||
ServerType string
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerMasterSlaveBackend) GetName() string {
|
||||
@@ -83,10 +84,6 @@ func (backend *SLoadbalancerMasterSlaveBackend) GetIpAddress() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerMasterSlaveBackend) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (backend *SLoadbalancerMasterSlaveBackend) SyncConf(ctx context.Context, port, weight int) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ type SLoadbalancerMasterSlaveBackendGroup struct {
|
||||
|
||||
MasterSlaveServerGroupId string
|
||||
MasterSlaveServerGroupName string
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerMasterSlaveBackendGroup) GetLoadbalancerId() string {
|
||||
@@ -208,7 +209,3 @@ func (backendgroup *SLoadbalancerMasterSlaveBackendGroup) AddBackendServer(serve
|
||||
func (backendgroup *SLoadbalancerMasterSlaveBackendGroup) RemoveBackendServer(serverId string, weight, port int) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (backendgroup *SLoadbalancerMasterSlaveBackendGroup) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ type SLoadbalancerServerCertificate struct {
|
||||
ExpireTimeStamp uint64 // 过期时间戳。
|
||||
CommonName string // 域名,对应证书的CommonName字段。
|
||||
SubjectAlternativeNames SubjectAlternativeNames // 数组格式,返回证书的备用域名列表,对应证书的Subject Alternative Name字段,详情请参见SubjectAlternativeNames。
|
||||
ResourceGroupId string // 实例的企业资源组ID
|
||||
RegionId string // 负载均衡实例的地域。
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (certificate *SLoadbalancerServerCertificate) GetPublickKey() string {
|
||||
@@ -133,7 +133,3 @@ func (region *SRegion) GetLoadbalancerServerCertificates() ([]SLoadbalancerServe
|
||||
certificates := []SLoadbalancerServerCertificate{}
|
||||
return certificates, body.Unmarshal(&certificates, "ServerCertificates", "ServerCertificate")
|
||||
}
|
||||
|
||||
func (certificate *SLoadbalancerServerCertificate) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ type SLoadbalancerTCPListener struct {
|
||||
HealthCheckConnectTimeout int // 每次健康检查响应的最大超时间,单位为秒。
|
||||
HealthCheckInterval int // 健康检查的时间间隔,单位为秒。
|
||||
HealthCheckConnectPort int // 健康检查的端口。
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (listener *SLoadbalancerTCPListener) GetName() string {
|
||||
@@ -355,10 +356,6 @@ func (listerner *SLoadbalancerTCPListener) Sync(ctx context.Context, lblis *clou
|
||||
return listerner.lb.region.SyncLoadbalancerTCPListener(listerner.lb, lblis)
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerTCPListener) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerTCPListener) GetClientIdleTimeout() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ type SLoadbalancerUDPListener struct {
|
||||
|
||||
HealthCheckExp string // UDP监听健康检查的响应串
|
||||
HealthCheckReq string // UDP监听健康检查的请求串
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (listener *SLoadbalancerUDPListener) GetName() string {
|
||||
@@ -281,10 +282,6 @@ func (listerner *SLoadbalancerUDPListener) Sync(ctx context.Context, lblis *clou
|
||||
return listerner.lb.region.SyncLoadbalancerUDPListener(listerner.lb, lblis)
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerUDPListener) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (listerner *SLoadbalancerUDPListener) GetClientIdleTimeout() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ type SNetworkInterface struct {
|
||||
MacAddress string
|
||||
NetworkInterfaceName string
|
||||
PrivateIpSets SPrivateIpSets
|
||||
ResourceGroupId string
|
||||
SecurityGroupIds SSecurityGroupIds
|
||||
Status string
|
||||
Type string
|
||||
@@ -71,6 +70,7 @@ type SNetworkInterface struct {
|
||||
NetworkInterfaceId string
|
||||
PrimaryIpAddress string
|
||||
PrivateIpAddress string
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (nic *SNetworkInterface) GetName() string {
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
@@ -26,17 +25,28 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
)
|
||||
|
||||
type DepartmentInfo struct {
|
||||
Department string
|
||||
DepartmentName string
|
||||
ResourceGroupId string
|
||||
}
|
||||
|
||||
func (self DepartmentInfo) GetProjectId() string {
|
||||
return self.Department
|
||||
}
|
||||
|
||||
type SResourceGroup struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.ApsaraTags
|
||||
client *SApsaraClient
|
||||
|
||||
Status string
|
||||
AccountId string
|
||||
DisplayName string
|
||||
Id string
|
||||
CreateDate time.Time
|
||||
Name string
|
||||
Creator string
|
||||
GmtCreated string
|
||||
Id string
|
||||
OrganizationId string
|
||||
OrganizationName string
|
||||
ResourceGroupName string
|
||||
RsId string
|
||||
}
|
||||
|
||||
func (self *SResourceGroup) GetGlobalId() string {
|
||||
@@ -48,31 +58,15 @@ func (self *SResourceGroup) GetId() string {
|
||||
}
|
||||
|
||||
func (self *SResourceGroup) GetName() string {
|
||||
if len(self.DisplayName) > 0 {
|
||||
return self.DisplayName
|
||||
}
|
||||
return self.Name
|
||||
return self.ResourceGroupName
|
||||
}
|
||||
|
||||
func (self *SResourceGroup) Refresh() error {
|
||||
group, err := self.client.GetResourceGroup(self.Id)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "GetResourceGroup")
|
||||
}
|
||||
return jsonutils.Update(self, group)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SResourceGroup) GetStatus() string {
|
||||
switch self.Status {
|
||||
case "Creating":
|
||||
return api.EXTERNAL_PROJECT_STATUS_CREATING
|
||||
case "OK":
|
||||
return api.EXTERNAL_PROJECT_STATUS_AVAILABLE
|
||||
case "Deleted", "Deleting", "PendingDelete":
|
||||
return api.EXTERNAL_PROJECT_STATUS_DELETING
|
||||
default:
|
||||
return api.EXTERNAL_PROJECT_STATUS_UNKNOWN
|
||||
}
|
||||
return api.EXTERNAL_PROJECT_STATUS_AVAILABLE
|
||||
}
|
||||
|
||||
func (self *SApsaraClient) GetResourceGroups(pageNumber int, pageSize int) ([]SResourceGroup, int, error) {
|
||||
@@ -91,11 +85,11 @@ func (self *SApsaraClient) GetResourceGroups(pageNumber int, pageSize int) ([]SR
|
||||
return nil, 0, errors.Wrap(err, "rmRequest.ListResourceGroup")
|
||||
}
|
||||
groups := []SResourceGroup{}
|
||||
err = resp.Unmarshal(&groups, "ResourceGroups", "ResourceGroup")
|
||||
err = resp.Unmarshal(&groups, "data")
|
||||
if err != nil {
|
||||
return nil, 0, errors.Wrap(err, "resp.Unmarshal")
|
||||
}
|
||||
total, _ := resp.Int("TotalCount")
|
||||
total, _ := resp.Int("pageInfo", "total")
|
||||
return groups, int(total), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,8 @@ type SSecurityGroup struct {
|
||||
Permissions SPermissions
|
||||
RegionId string
|
||||
Tags Tags
|
||||
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetVpcId() string {
|
||||
@@ -489,10 +491,6 @@ func (self *SSecurityGroup) Delete() error {
|
||||
return self.vpc.region.DeleteSecurityGroup(self.SecurityGroupId)
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) SyncRules(common, inAdds, outAdds, inDels, outDels []cloudprovider.SecurityRule) error {
|
||||
for _, rule := range append(inDels, outDels...) {
|
||||
err := self.vpc.region.DelSecurityGroupRule(self.SecurityGroupId, rule.SecurityRule)
|
||||
|
||||
@@ -43,15 +43,15 @@ type SSnapshot struct {
|
||||
multicloud.ApsaraTags
|
||||
region *SRegion
|
||||
|
||||
Progress string
|
||||
SnapshotId string
|
||||
SnapshotName string
|
||||
SourceDiskId string
|
||||
SourceDiskSize int32
|
||||
SourceDiskType string
|
||||
Status SnapshotStatusType
|
||||
Usage string
|
||||
ResourceGroupId string
|
||||
Progress string
|
||||
SnapshotId string
|
||||
SnapshotName string
|
||||
SourceDiskId string
|
||||
SourceDiskSize int32
|
||||
SourceDiskType string
|
||||
Status SnapshotStatusType
|
||||
Usage string
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetId() string {
|
||||
@@ -199,10 +199,6 @@ func (self *SRegion) DeleteSnapshot(snapshotId string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetProjectId() string {
|
||||
return self.ResourceGroupId
|
||||
}
|
||||
|
||||
// If snapshot linked images can't be delete
|
||||
// delete images first -- Apsara
|
||||
func (self *SRegion) SnapshotPreDelete(snapshotId string) error {
|
||||
|
||||
@@ -45,6 +45,7 @@ type SSnapshotPolicy struct {
|
||||
TimePoints string
|
||||
RetentionDays int
|
||||
Status SSnapshotPolicyType
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (self *SSnapshotPolicy) GetId() string {
|
||||
@@ -85,10 +86,6 @@ func (self *SSnapshotPolicy) GetGlobalId() string {
|
||||
return self.AutoSnapshotPolicyId
|
||||
}
|
||||
|
||||
func (self *SSnapshotPolicy) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SSnapshotPolicy) GetRetentionDays() int {
|
||||
return self.RetentionDays
|
||||
}
|
||||
|
||||
@@ -59,9 +59,9 @@ type SVSwitch struct {
|
||||
VpcId string
|
||||
ZoneId string
|
||||
|
||||
CloudResources SCloudResources
|
||||
ResourceGroupId string
|
||||
RouteTable SRouteTable
|
||||
CloudResources SCloudResources
|
||||
RouteTable SRouteTable
|
||||
DepartmentInfo
|
||||
}
|
||||
|
||||
func (self *SVSwitch) GetId() string {
|
||||
@@ -270,7 +270,3 @@ func (vsw *SVSwitch) dissociateWithSNAT() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SVSwitch) GetProjectId() string {
|
||||
return self.ResourceGroupId
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user