mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
用户id和subscriptionID放一起
This commit is contained in:
@@ -394,6 +394,10 @@ func fetchContextObjectId(manager IModelManager, ctx context.Context, userCred m
|
||||
}
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func listItems(manager IModelManager, ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, ctxId string) (*modules.ListResult, error) {
|
||||
var maxLimit int64 = 2048
|
||||
limit, _ := query.Int("limit")
|
||||
@@ -419,7 +423,13 @@ func listItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok
|
||||
return nil, err
|
||||
}
|
||||
totalCnt := int64(q.Count())
|
||||
log.Debugf("total count %d", totalCnt)
|
||||
data := Data{}
|
||||
q.First(&data)
|
||||
log.Debugf("total count %d result: %v", totalCnt, data)
|
||||
{
|
||||
retList, _ := query2List(manager, ctx, userCred, q, queryDict)
|
||||
log.Errorf("result: %s", retList)
|
||||
}
|
||||
if totalCnt == 0 {
|
||||
emptyList := modules.ListResult{Data: []jsonutils.JSONObject{}}
|
||||
return &emptyList, nil
|
||||
@@ -458,6 +468,7 @@ func listItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok
|
||||
q = q.Offset(int(offset))
|
||||
}
|
||||
retList, err := query2List(manager, ctx, userCred, q, queryDict)
|
||||
log.Errorf("result: %s", retList)
|
||||
if err != nil {
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ func (manager *SCloudregionManager) ListItemFilter(ctx context.Context, q *sqlch
|
||||
wires := WireManager.Query().SubQuery()
|
||||
vpcs := VpcManager.Query().SubQuery()
|
||||
|
||||
sq := vpcs.Query(sqlchemy.DISTINCT("cloudregion_id", vpcs.Field("cloudregion_id")))
|
||||
sq := vpcs.Query(vpcs.Field("cloudregion_id"))
|
||||
sq = sq.Join(wires, sqlchemy.Equals(vpcs.Field("id"), wires.Field("vpc_id")))
|
||||
sq = sq.Join(networks, sqlchemy.Equals(wires.Field("id"), networks.Field("wire_id")))
|
||||
sq = sq.Filter(sqlchemy.Equals(networks.Field("status"), NETWORK_STATUS_AVAILABLE))
|
||||
|
||||
@@ -54,9 +54,10 @@ func NewAzureClient(providerId string, providerName string, accessKey string, se
|
||||
if _, ok := authAddr[url]; !ok {
|
||||
return nil, httperrors.NewUnauthorizedError("Access url choices: %v", reflect.ValueOf(authAddr).MapKeys())
|
||||
}
|
||||
if clientInfo := strings.Split(secret, "/"); len(clientInfo) == 3 {
|
||||
client := SAzureClient{providerId: providerId, providerName: providerName, tenantId: accessKey, secret: secret, baseUrl: url}
|
||||
client.clientId, client.clientScret, client.subscriptionId = clientInfo[0], clientInfo[1], clientInfo[2]
|
||||
if clientInfo, accountInfo := strings.Split(secret, "/"), strings.Split(accessKey, "/"); len(clientInfo) == 2 && len(accountInfo) == 2 {
|
||||
client := SAzureClient{providerId: providerId, providerName: providerName, secret: secret, baseUrl: url}
|
||||
client.clientId, client.clientScret = clientInfo[0], clientInfo[1]
|
||||
client.tenantId, client.subscriptionId = accountInfo[0], accountInfo[1]
|
||||
if err := client.fetchAzureInof(); err != nil {
|
||||
return nil, err
|
||||
} else if err := client.fetchRegions(); err != nil {
|
||||
|
||||
@@ -26,7 +26,8 @@ func (self *SNetwork) GetMetadata() *jsonutils.JSONDict {
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetId() string {
|
||||
return fmt.Sprintf("%s/%s/%s", self.wire.zone.region.GetGlobalId(), self.wire.zone.region.SubscriptionID, self.Name)
|
||||
vpcName := self.wire.vpc.GetName()
|
||||
return fmt.Sprintf("%s/%s/%s/%s", self.wire.zone.region.GetGlobalId(), self.wire.zone.region.SubscriptionID, vpcName, self.Name)
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetName() string {
|
||||
@@ -43,7 +44,7 @@ func (self *SNetwork) IsEmulated() bool {
|
||||
|
||||
func (self *SNetwork) GetStatus() string {
|
||||
if strings.ToLower(self.Properties.ProvisioningState) == "succeeded" {
|
||||
return "avaliable"
|
||||
return "available"
|
||||
}
|
||||
return "disabled"
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ func (self *SVpc) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, err
|
||||
}
|
||||
|
||||
func (self *SVpc) fetchWires() error {
|
||||
self.iwires = make([]cloudprovider.ICloudWire, 0)
|
||||
networks := make([]cloudprovider.ICloudNetwork, len(self.Properties.Subnets))
|
||||
wire := SWire{zone: self.region.izones[0].(*SZone), vpc: self, inetworks: networks}
|
||||
for i, _network := range self.Properties.Subnets {
|
||||
@@ -125,7 +124,7 @@ func (self *SVpc) fetchWires() error {
|
||||
}
|
||||
networks[i] = &network
|
||||
}
|
||||
self.iwires = append(self.iwires, &wire)
|
||||
self.iwires = []cloudprovider.ICloudWire{&wire}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -21,15 +21,15 @@ func (self *SWire) GetMetadata() *jsonutils.JSONDict {
|
||||
}
|
||||
|
||||
func (self *SWire) GetId() string {
|
||||
return fmt.Sprintf("%s-%s", self.zone.region.client.providerId, self.zone.region.GetId())
|
||||
return fmt.Sprintf("%s/%s/%s", self.zone.region.GetGlobalId(), self.zone.region.client.subscriptionId, self.vpc.GetName())
|
||||
}
|
||||
|
||||
func (self *SWire) GetGlobalId() string {
|
||||
return fmt.Sprintf("%s/%s", self.zone.region.GetGlobalId(), self.zone.region.client.subscriptionId)
|
||||
return self.GetId()
|
||||
}
|
||||
|
||||
func (self *SWire) GetName() string {
|
||||
return fmt.Sprintf("%s-%s", self.zone.region.client.providerName, self.zone.region.Name)
|
||||
return fmt.Sprintf("%s-%s", self.zone.region.client.providerName, self.vpc.GetName())
|
||||
}
|
||||
|
||||
func (self *SWire) IsEmulated() bool {
|
||||
@@ -81,7 +81,7 @@ func (self *SWire) GetINetworks() ([]cloudprovider.ICloudNetwork, error) {
|
||||
if self.inetworks == nil {
|
||||
self.inetworks = make([]cloudprovider.ICloudNetwork, len(self.vpc.Properties.Subnets))
|
||||
for i, _netwrok := range self.vpc.Properties.Subnets {
|
||||
network := SNetwork{wire: self}
|
||||
network := SNetwork{wire: self, Name: _netwrok.Name, ID: _netwrok.ID}
|
||||
if err := jsonutils.Update(&network, _netwrok); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user