mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-29 03:51:54 +08:00
remove serviceips models
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
type ServiceIpListOptions struct {
|
||||
Limit int64 `help:"Limit, default 0, i.e. no limit" default:"20"`
|
||||
Offset int64 `help:"Offset, default 0, i.e. no offset"`
|
||||
ServiceType string `help:"Filter by type"`
|
||||
ServiceId string `help:"Filter by Service Id"`
|
||||
}
|
||||
R(&ServiceIpListOptions{}, "serviceip-list", "List serviceip", func(s *mcclient.ClientSession, args *ServiceIpListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
serviceips, err := modules.ServiceIp.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(serviceips, modules.ServiceIp.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -406,8 +406,3 @@ paths:
|
||||
$ref: "./dbinstance/dbinstanceaccounts.yaml"
|
||||
/dbinstanceaccounts/{accountId}:
|
||||
$ref: "./dbinstance/dbinstanceaccount.yaml"
|
||||
|
||||
/serviceips:
|
||||
$ref: "./serviceip/serviceips.yaml"
|
||||
/serviceips/{serviceipId}:
|
||||
$ref: "./serviceip/serviceip.yaml"
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
serviceipId:
|
||||
name: serviceipId
|
||||
required: true
|
||||
in: path
|
||||
type: string
|
||||
description: 服务IP名称或ID,建议使用ID
|
||||
|
||||
service_type:
|
||||
name: service_type
|
||||
in: query
|
||||
type: string
|
||||
enum: [dbinstance]
|
||||
description: 根据服务类型过滤资源
|
||||
|
||||
service_id:
|
||||
name: service_id
|
||||
in: query
|
||||
type: string
|
||||
description: 根据服务ID过滤资源
|
||||
@@ -1,48 +0,0 @@
|
||||
ServiceIp:
|
||||
allOf:
|
||||
- $ref: "./common.yaml#/ResourceBaseResponse"
|
||||
- type: object
|
||||
description: 服务IP信息
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
example: 80d8e168-fc51-45f8-8d8d-f072ed27b390
|
||||
description: 资源UUID
|
||||
service_id:
|
||||
type: string
|
||||
example: 53c2dc1e-d799-40fc-8c16-d49ded656930
|
||||
description: 服务ID
|
||||
service_type:
|
||||
type: string
|
||||
example: dbinstance
|
||||
description: 服务类型
|
||||
ip_addr:
|
||||
type: string
|
||||
example: "100.118.3.23"
|
||||
description: 服务IP地址
|
||||
url:
|
||||
type: string
|
||||
example: rr-2zej70lc855hk07rq.mysql.rds.aliyuncs.com
|
||||
description: 服务域名地址
|
||||
|
||||
|
||||
ServiceIpListResponse:
|
||||
type: object
|
||||
properties:
|
||||
limit:
|
||||
type: integer
|
||||
example: 20
|
||||
serviceips:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/ServiceIp'
|
||||
total:
|
||||
type: integer
|
||||
example: 124
|
||||
|
||||
ServiceIpResponse:
|
||||
type: object
|
||||
properties:
|
||||
serviceip:
|
||||
type: object
|
||||
$ref: '#/ServiceIp'
|
||||
@@ -1,11 +0,0 @@
|
||||
get:
|
||||
summary: 获取服务IP详细信息
|
||||
parameters:
|
||||
- $ref: '../parameters/serviceip.yaml#/serviceipId'
|
||||
responses:
|
||||
200:
|
||||
description: 服务IP详细信息
|
||||
schema:
|
||||
$ref: '../schemas/serviceip.yaml#/ServiceIpResponse'
|
||||
tags:
|
||||
- serviceip
|
||||
@@ -1,15 +0,0 @@
|
||||
get:
|
||||
summary: 按指定条件列出服务的IP信息列表
|
||||
parameters:
|
||||
- $ref: '../parameters/common.yaml#/limit'
|
||||
- $ref: '../parameters/common.yaml#/offset'
|
||||
- $ref: '../parameters/serviceip.yaml#/service_type'
|
||||
- $ref: '../parameters/serviceip.yaml#/service_id'
|
||||
|
||||
responses:
|
||||
200:
|
||||
description: 服务IP信息列表
|
||||
schema:
|
||||
$ref: '../schemas/serviceip.yaml#/ServiceIpListResponse'
|
||||
tags:
|
||||
- serviceip
|
||||
@@ -318,7 +318,6 @@ type ICloudEIP interface {
|
||||
|
||||
type ICloudSecurityGroup interface {
|
||||
ICloudResource
|
||||
//IVirtualResource
|
||||
|
||||
GetDescription() string
|
||||
GetRules() ([]secrules.SecurityRule, error)
|
||||
@@ -709,12 +708,12 @@ type ICloudDBInstance interface {
|
||||
|
||||
GetMaintainTime() string
|
||||
|
||||
GetConnectionStr() string
|
||||
GetInternalConnectionStr() string
|
||||
GetIZoneId() string
|
||||
GetIVpcId() string
|
||||
|
||||
GetDBNetwork() (*SDBInstanceNetwork, error)
|
||||
GetExtraIps() ([]SExtraIp, error)
|
||||
|
||||
GetIDBInstanceParameters() ([]ICloudDBInstanceParameter, error)
|
||||
GetIDBInstanceDatabases() ([]ICloudDBInstanceDatabase, error)
|
||||
GetIDBInstanceAccounts() ([]ICloudDBInstanceAccount, error)
|
||||
@@ -748,4 +747,13 @@ type ICloudDBInstanceDatabase interface {
|
||||
|
||||
type ICloudDBInstanceAccount interface {
|
||||
ICloudResource
|
||||
|
||||
GetIDBInstanceAccountPrivileges() ([]ICloudDBInstanceAccountPrivilege, error)
|
||||
}
|
||||
|
||||
type ICloudDBInstanceAccountPrivilege interface {
|
||||
ICloudResource
|
||||
|
||||
GetPrivilege() string
|
||||
GetDBName() string
|
||||
}
|
||||
|
||||
@@ -890,9 +890,7 @@ func syncRegionDBInstances(ctx context.Context, userCred mcclient.TokenCredentia
|
||||
defer lockman.ReleaseObject(ctx, &localInstances[i])
|
||||
|
||||
syncDBInstanceNetwork(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i])
|
||||
syncDBInstanceExtraIps(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i])
|
||||
syncDBInstanceParameters(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i])
|
||||
// syncDBInstanceBackups(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i])
|
||||
syncDBInstanceDatabases(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i])
|
||||
syncDBInstanceAccounts(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i])
|
||||
}()
|
||||
@@ -921,24 +919,6 @@ func syncDBInstanceNetwork(ctx context.Context, userCred mcclient.TokenCredentia
|
||||
}
|
||||
}
|
||||
|
||||
func syncDBInstanceExtraIps(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, localInstance *SDBInstance, remoteInstance cloudprovider.ICloudDBInstance) {
|
||||
ips, err := remoteInstance.GetExtraIps()
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("GetExtraIps for dbinstance %s failed %s", remoteInstance.GetName(), err)
|
||||
log.Errorf(msg)
|
||||
return
|
||||
}
|
||||
|
||||
result := ServiceIpManager.SyncExtraIps(ctx, userCred, localInstance, ips)
|
||||
syncResults.Add(ServiceIpManager, result)
|
||||
|
||||
msg := result.Result()
|
||||
log.Infof("SyncExtraIps for dbinstance %s result: %s", localInstance.Name, msg)
|
||||
if result.IsError() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func syncDBInstanceParameters(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, localInstance *SDBInstance, remoteInstance cloudprovider.ICloudDBInstance) {
|
||||
parameters, err := remoteInstance.GetIDBInstanceParameters()
|
||||
if err != nil {
|
||||
@@ -1002,7 +982,7 @@ func syncDBInstanceAccounts(ctx context.Context, userCred mcclient.TokenCredenti
|
||||
return
|
||||
}
|
||||
|
||||
result := DBInstanceAccountManager.SyncDBInstanceAccounts(ctx, userCred, localInstance, accounts)
|
||||
localAccounts, remoteAccounts, result := DBInstanceAccountManager.SyncDBInstanceAccounts(ctx, userCred, localInstance, accounts)
|
||||
syncResults.Add(DBInstanceDatabaseManager, result)
|
||||
|
||||
msg := result.Result()
|
||||
@@ -1010,6 +990,34 @@ func syncDBInstanceAccounts(ctx context.Context, userCred mcclient.TokenCredenti
|
||||
if result.IsError() {
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i < len(localAccounts); i++ {
|
||||
func() {
|
||||
lockman.LockObject(ctx, &localAccounts[i])
|
||||
defer lockman.ReleaseObject(ctx, &localAccounts[i])
|
||||
|
||||
syncDBInstanceAccountPrivileges(ctx, userCred, syncResults, &localAccounts[i], remoteAccounts[i])
|
||||
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func syncDBInstanceAccountPrivileges(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, localAccount *SDBInstanceAccount, remoteAccount cloudprovider.ICloudDBInstanceAccount) {
|
||||
privileges, err := remoteAccount.GetIDBInstanceAccountPrivileges()
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("GetIDBInstanceAccountPrivileges for dbinstance account %s failed %s", remoteAccount.GetName(), err)
|
||||
log.Errorf(msg)
|
||||
return
|
||||
}
|
||||
|
||||
result := DBInstanceAccountPrivilegeManager.SyncDBInstanceAccountPrivileges(ctx, userCred, localAccount, privileges)
|
||||
syncResults.Add(DBInstanceAccountPrivilegeManager, result)
|
||||
|
||||
msg := result.Result()
|
||||
log.Infof("SyncDBInstanceAccountPrivileges for account %s result: %s", localAccount, msg)
|
||||
if result.IsError() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func syncRegionSnapshots(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, localRegion *SCloudregion, remoteRegion cloudprovider.ICloudRegion, syncRange *SSyncRange) {
|
||||
|
||||
+37
-8
@@ -16,6 +16,7 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
@@ -95,6 +96,27 @@ func (manager *SDBInstanceAccountManager) ValidateCreateData(ctx context.Context
|
||||
return nil, httperrors.NewNotImplementedError("Not Implemented")
|
||||
}
|
||||
|
||||
func (self *SDBInstanceAccount) GetDBInstanceDatabaseByName(dbName string) (*SDBInstanceDatabase, error) {
|
||||
q := DBInstanceDatabaseManager.Query().Equals("dbinstance_id", self.DBInstanceId).Equals("name", dbName)
|
||||
count, err := q.CountWithError()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if count == 1 {
|
||||
database := &SDBInstanceDatabase{}
|
||||
database.SetModelManager(DBInstanceDatabaseManager, database)
|
||||
err = q.First(database)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return database, nil
|
||||
}
|
||||
if count > 1 {
|
||||
return nil, sqlchemy.ErrDuplicateEntry
|
||||
}
|
||||
return nil, sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceAccountManager) getDBInstanceAccountsByInstance(instance *SDBInstance) ([]SDBInstanceAccount, error) {
|
||||
accounts := []SDBInstanceAccount{}
|
||||
q := manager.Query().Equals("dbinstance_id", instance.Id)
|
||||
@@ -105,7 +127,7 @@ func (manager *SDBInstanceAccountManager) getDBInstanceAccountsByInstance(instan
|
||||
return accounts, nil
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceAccountManager) SyncDBInstanceAccounts(ctx context.Context, userCred mcclient.TokenCredential, instance *SDBInstance, cloudAccounts []cloudprovider.ICloudDBInstanceAccount) compare.SyncResult {
|
||||
func (manager *SDBInstanceAccountManager) SyncDBInstanceAccounts(ctx context.Context, userCred mcclient.TokenCredential, instance *SDBInstance, cloudAccounts []cloudprovider.ICloudDBInstanceAccount) ([]SDBInstanceAccount, []cloudprovider.ICloudDBInstanceAccount, compare.SyncResult) {
|
||||
lockman.LockClass(ctx, manager, db.GetLockClassKey(manager, instance.GetOwnerId()))
|
||||
defer lockman.ReleaseClass(ctx, manager, db.GetLockClassKey(manager, instance.GetOwnerId()))
|
||||
|
||||
@@ -113,16 +135,19 @@ func (manager *SDBInstanceAccountManager) SyncDBInstanceAccounts(ctx context.Con
|
||||
dbAccounts, err := manager.getDBInstanceAccountsByInstance(instance)
|
||||
if err != nil {
|
||||
result.Error(err)
|
||||
return result
|
||||
return nil, nil, result
|
||||
}
|
||||
|
||||
localAccounts := []SDBInstanceAccount{}
|
||||
remoteAccounts := []cloudprovider.ICloudDBInstanceAccount{}
|
||||
|
||||
removed := make([]SDBInstanceAccount, 0)
|
||||
commondb := make([]SDBInstanceAccount, 0)
|
||||
commonext := make([]cloudprovider.ICloudDBInstanceAccount, 0)
|
||||
added := make([]cloudprovider.ICloudDBInstanceAccount, 0)
|
||||
if err := compare.CompareSets(dbAccounts, cloudAccounts, &removed, &commondb, &commonext, &added); err != nil {
|
||||
result.Error(err)
|
||||
return result
|
||||
return nil, nil, result
|
||||
}
|
||||
|
||||
for i := 0; i < len(removed); i++ {
|
||||
@@ -140,18 +165,22 @@ func (manager *SDBInstanceAccountManager) SyncDBInstanceAccounts(ctx context.Con
|
||||
result.UpdateError(err)
|
||||
} else {
|
||||
result.Update()
|
||||
localAccounts = append(localAccounts, commondb[i])
|
||||
remoteAccounts = append(remoteAccounts, commonext[i])
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < len(added); i++ {
|
||||
err = manager.newFromCloudDBInstanceAccount(ctx, userCred, instance, added[i])
|
||||
account, err := manager.newFromCloudDBInstanceAccount(ctx, userCred, instance, added[i])
|
||||
if err != nil {
|
||||
result.AddError(err)
|
||||
} else {
|
||||
localAccounts = append(localAccounts, *account)
|
||||
remoteAccounts = append(remoteAccounts, added[i])
|
||||
result.Add()
|
||||
}
|
||||
}
|
||||
return result
|
||||
return localAccounts, remoteAccounts, result
|
||||
}
|
||||
|
||||
func (self *SDBInstanceAccount) SyncWithCloudDBInstanceAccount(ctx context.Context, userCred mcclient.TokenCredential, extAccount cloudprovider.ICloudDBInstanceAccount) error {
|
||||
@@ -165,7 +194,7 @@ func (self *SDBInstanceAccount) SyncWithCloudDBInstanceAccount(ctx context.Conte
|
||||
return nil
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceAccountManager) newFromCloudDBInstanceAccount(ctx context.Context, userCred mcclient.TokenCredential, instance *SDBInstance, extAccount cloudprovider.ICloudDBInstanceAccount) error {
|
||||
func (manager *SDBInstanceAccountManager) newFromCloudDBInstanceAccount(ctx context.Context, userCred mcclient.TokenCredential, instance *SDBInstance, extAccount cloudprovider.ICloudDBInstanceAccount) (*SDBInstanceAccount, error) {
|
||||
lockman.LockClass(ctx, manager, db.GetLockClassKey(manager, userCred))
|
||||
defer lockman.ReleaseClass(ctx, manager, db.GetLockClassKey(manager, userCred))
|
||||
|
||||
@@ -179,7 +208,7 @@ func (manager *SDBInstanceAccountManager) newFromCloudDBInstanceAccount(ctx cont
|
||||
|
||||
err := manager.TableSpec().Insert(&account)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "newFromCloudDBInstanceAccount.Insert")
|
||||
return nil, errors.Wrapf(err, "newFromCloudDBInstanceAccount.Insert")
|
||||
}
|
||||
return nil
|
||||
return &account, nil
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
"yunion.io/x/sqlchemy"
|
||||
)
|
||||
|
||||
type SDBInstanceAccountPrivilegeManager struct {
|
||||
db.SResourceBaseManager
|
||||
}
|
||||
|
||||
var DBInstanceAccountPrivilegeManager *SDBInstanceAccountPrivilegeManager
|
||||
|
||||
func init() {
|
||||
DBInstanceAccountPrivilegeManager = &SDBInstanceAccountPrivilegeManager{
|
||||
SResourceBaseManager: db.NewResourceBaseManager(
|
||||
SDBInstanceAccountPrivilege{},
|
||||
"dbinstanceaccountprivilege_tbl",
|
||||
"dbinstanceaccountprivilege",
|
||||
"dbinstanceaccountprivileges",
|
||||
),
|
||||
}
|
||||
DBInstanceAccountPrivilegeManager.SetVirtualObject(DBInstanceAccountPrivilegeManager)
|
||||
}
|
||||
|
||||
type SDBInstanceAccountPrivilege struct {
|
||||
db.SResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
Privilege string `width:"32" charset:"ascii" nullable:"false" list:"user"`
|
||||
DBInstanceaccountId string `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
DBInstancedatabaseId string `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceAccountPrivilegeManager) GetContextManagers() [][]db.IModelManager {
|
||||
return [][]db.IModelManager{
|
||||
{DBInstanceAccountManager, DBInstanceDatabaseManager},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SDBInstanceAccountPrivilegeManager) AllowListItems(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowList(userCred, self)
|
||||
}
|
||||
|
||||
func (self *SDBInstanceAccountPrivilegeManager) AllowCreateItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowCreate(userCred, self)
|
||||
}
|
||||
|
||||
func (self *SDBInstanceAccountPrivilege) AllowGetDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowGet(userCred, self)
|
||||
}
|
||||
|
||||
func (self *SDBInstanceAccountPrivilege) AllowUpdateItem(ctx context.Context, userCred mcclient.TokenCredential) bool {
|
||||
return db.IsAdminAllowUpdate(userCred, self)
|
||||
}
|
||||
|
||||
func (self *SDBInstanceAccountPrivilege) AllowDeleteItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowDelete(userCred, self)
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceAccountPrivilegeManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (*sqlchemy.SQuery, error) {
|
||||
q, err := manager.SResourceBaseManager.ListItemFilter(ctx, q, userCred, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data := query.(*jsonutils.JSONDict)
|
||||
return validators.ApplyModelFilters(q, data, []*validators.ModelFilterOptions{
|
||||
{Key: "dbinstanceaccount", ModelKeyword: "dbinstanceaccount", OwnerId: userCred},
|
||||
{Key: "dbinstancedatabase", ModelKeyword: "dbinstancedatabase", OwnerId: userCred},
|
||||
})
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceAccountPrivilegeManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
return nil, httperrors.NewNotImplementedError("Not Implemented")
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceAccountPrivilegeManager) getPrivilegesByAccount(account *SDBInstanceAccount) ([]SDBInstanceAccountPrivilege, error) {
|
||||
privileges := []SDBInstanceAccountPrivilege{}
|
||||
q := manager.Query().Equals("dbinstanceaccount_id", account.Id)
|
||||
err := db.FetchModelObjects(manager, q, &privileges)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getPrivilegesByAccount.FetchModelObjects")
|
||||
}
|
||||
return privileges, nil
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceAccountPrivilegeManager) SyncDBInstanceAccountPrivileges(ctx context.Context, userCred mcclient.TokenCredential, account *SDBInstanceAccount, cloudPrivileges []cloudprovider.ICloudDBInstanceAccountPrivilege) compare.SyncResult {
|
||||
lockman.LockClass(ctx, manager, db.GetLockClassKey(manager, account.GetOwnerId()))
|
||||
defer lockman.ReleaseClass(ctx, manager, db.GetLockClassKey(manager, account.GetOwnerId()))
|
||||
|
||||
result := compare.SyncResult{}
|
||||
dbPrivileges, err := manager.getPrivilegesByAccount(account)
|
||||
if err != nil {
|
||||
result.Error(err)
|
||||
return result
|
||||
}
|
||||
|
||||
removed := make([]SDBInstanceAccountPrivilege, 0)
|
||||
commondb := make([]SDBInstanceAccountPrivilege, 0)
|
||||
commonext := make([]cloudprovider.ICloudDBInstanceDatabase, 0)
|
||||
added := make([]cloudprovider.ICloudDBInstanceDatabase, 0)
|
||||
if err := compare.CompareSets(dbPrivileges, cloudPrivileges, &removed, &commondb, &commonext, &added); err != nil {
|
||||
result.Error(err)
|
||||
return result
|
||||
}
|
||||
|
||||
for i := 0; i < len(removed); i++ {
|
||||
err := removed[i].Delete(ctx, userCred)
|
||||
if err != nil {
|
||||
result.DeleteError(err)
|
||||
} else {
|
||||
result.Delete()
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < len(added); i++ {
|
||||
err = manager.newFromCloudPrivileges(ctx, userCred, account, added[i])
|
||||
if err != nil {
|
||||
result.AddError(err)
|
||||
} else {
|
||||
result.Add()
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceAccountPrivilegeManager) newFromCloudPrivileges(ctx context.Context, userCred mcclient.TokenCredential, account *SDBInstanceAccount, ext cloudprovider.ICloudDBInstanceAccountPrivilege) error {
|
||||
lockman.LockClass(ctx, manager, db.GetLockClassKey(manager, userCred))
|
||||
defer lockman.ReleaseClass(ctx, manager, db.GetLockClassKey(manager, userCred))
|
||||
|
||||
privilege := SDBInstanceAccountPrivilege{}
|
||||
privilege.SetModelManager(manager, &privilege)
|
||||
|
||||
privilege.DBInstanceaccountId = account.Id
|
||||
privilege.ExternalId = ext.GetGlobalId()
|
||||
privilege.Privilege = ext.GetPrivilege()
|
||||
|
||||
dbName := ext.GetDBName()
|
||||
|
||||
database, err := account.GetDBInstanceDatabaseByName(dbName)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "account.GetDBInstanceDatabaseByName(%s)", dbName)
|
||||
}
|
||||
|
||||
privilege.DBInstancedatabaseId = database.Id
|
||||
|
||||
err = manager.TableSpec().Insert(&privilege)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "newFromCloudDBInstanceDatabase.Insert")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -54,7 +54,7 @@ type SDBInstanceParameter struct {
|
||||
DBInstanceId string `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
|
||||
Key string `width:"64" charset:"ascii" nullable:"false" list:"user" update:"user" create:"required"`
|
||||
Value string `width:"16" charset:"ascii" nullable:"false" list:"user" update:"user" create:"required"`
|
||||
Value string `width:"256" charset:"ascii" nullable:"false" list:"user" update:"user" create:"required"`
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceParameterManager) GetContextManagers() [][]db.IModelManager {
|
||||
|
||||
@@ -69,7 +69,9 @@ type SDBInstance struct {
|
||||
|
||||
MaintainTime string `width:"64" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
|
||||
VpcId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"optional"`
|
||||
VpcId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"optional"`
|
||||
ConnectionStr string `width:"256" charset:"ascii" nullable:"false" list:"user" create:"optional"`
|
||||
InternalConnectionStr string `width:"256" charset:"ascii" nullable:"false" list:"user" create:"optional"`
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceManager) GetContextManagers() [][]db.IModelManager {
|
||||
@@ -226,16 +228,6 @@ func (self *SDBInstance) GetDBParameters() ([]SDBInstanceParameter, error) {
|
||||
return parameters, nil
|
||||
}
|
||||
|
||||
func (self *SDBInstance) GetServiceIps() ([]SServiceIp, error) {
|
||||
serviceips := []SServiceIp{}
|
||||
q := ServiceIpManager.Query().Equals("service_id", self.Id)
|
||||
err := db.FetchModelObjects(ServiceIpManager, q, &serviceips)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "GetServiceIps.FetchModelObjects")
|
||||
}
|
||||
return serviceips, nil
|
||||
}
|
||||
|
||||
func (self *SDBInstance) GetDBNetwork() (*SDBInstanceNetwork, error) {
|
||||
q := DBInstanceNetworkManager.Query().Equals("dbinstance_id", self.Id)
|
||||
count, err := q.CountWithError()
|
||||
@@ -336,6 +328,9 @@ func (self *SDBInstance) SyncWithCloudDBInstance(ctx context.Context, userCred m
|
||||
self.DiskSizeGB = extInstance.GetDiskSizeGB()
|
||||
self.Status = extInstance.GetStatus()
|
||||
|
||||
self.ConnectionStr = extInstance.GetConnectionStr()
|
||||
self.InternalConnectionStr = extInstance.GetInternalConnectionStr()
|
||||
|
||||
self.MaintainTime = extInstance.GetMaintainTime()
|
||||
|
||||
if zoneId := extInstance.GetIZoneId(); len(zoneId) > 0 {
|
||||
@@ -395,6 +390,8 @@ func (manager *SDBInstanceManager) newFromCloudDBInstance(ctx context.Context, u
|
||||
instance.VcpuCount = extInstance.GetVcpuCount()
|
||||
instance.VmemSizeMb = extInstance.GetVmemSizeMB()
|
||||
instance.DiskSizeGB = extInstance.GetDiskSizeGB()
|
||||
instance.ConnectionStr = extInstance.GetConnectionStr()
|
||||
instance.InternalConnectionStr = extInstance.GetInternalConnectionStr()
|
||||
|
||||
instance.MaintainTime = extInstance.GetMaintainTime()
|
||||
|
||||
|
||||
@@ -1155,32 +1155,6 @@ func (instance *SDBInstance) purgeParameters(ctx context.Context, userCred mccli
|
||||
return nil
|
||||
}
|
||||
|
||||
func (serviceip *SServiceIp) purge(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
lockman.LockObject(ctx, serviceip)
|
||||
defer lockman.ReleaseObject(ctx, serviceip)
|
||||
|
||||
err := serviceip.ValidateDeleteCondition(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return serviceip.Delete(ctx, userCred)
|
||||
}
|
||||
|
||||
func (instance *SDBInstance) purgeServiceips(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
serviceips, err := instance.GetServiceIps()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := range serviceips {
|
||||
err = serviceips[i].purge(ctx, userCred)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (network *SDBInstanceNetwork) purge(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
lockman.LockObject(ctx, network)
|
||||
defer lockman.ReleaseObject(ctx, network)
|
||||
@@ -1224,11 +1198,6 @@ func (instance *SDBInstance) purge(ctx context.Context, userCred mcclient.TokenC
|
||||
return err
|
||||
}
|
||||
|
||||
err = instance.purgeServiceips(ctx, userCred)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = instance.purgeNetwork(ctx, userCred)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/sqlchemy"
|
||||
)
|
||||
|
||||
type SServiceIpManager struct {
|
||||
db.SResourceBaseManager
|
||||
}
|
||||
|
||||
var ServiceIpManager *SServiceIpManager
|
||||
|
||||
func init() {
|
||||
ServiceIpManager = &SServiceIpManager{
|
||||
SResourceBaseManager: db.NewResourceBaseManager(
|
||||
SServiceIp{},
|
||||
"serviceips_tbl",
|
||||
"serviceip",
|
||||
"serviceips",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func (model *SServiceIp) BeforeInsert() {
|
||||
if len(model.Id) == 0 {
|
||||
model.Id = db.DefaultUUIDGenerator()
|
||||
}
|
||||
}
|
||||
|
||||
type SServiceIp struct {
|
||||
db.SResourceBase
|
||||
Id string `width:"128" charset:"ascii" primary:"true" list:"user" get:"user"`
|
||||
ServiceId string `width:"36" charset:"ascii" nullable:"false" list:"user" `
|
||||
IpAddr string `width:"16" charset:"ascii" nullable:"false" list:"user"`
|
||||
URL string `width:"256" charset:"ascii" nullable:"true" list:"user"`
|
||||
ServiceType string `width:"16" charset:"ascii" nullable:"false" list:"user"`
|
||||
}
|
||||
|
||||
func (manager *SServiceIpManager) AllowListItems(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (manager *SServiceIpManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (*sqlchemy.SQuery, error) {
|
||||
return manager.SResourceBaseManager.ListItemFilter(ctx, q, userCred, query)
|
||||
}
|
||||
|
||||
func (manager *SServiceIpManager) GetServiceIps(resource db.IModel) ([]SServiceIp, error) {
|
||||
q := manager.Query().Equals("service_id", resource.GetId()).Equals("service_type", resource.Keyword())
|
||||
ips := []SServiceIp{}
|
||||
err := db.FetchModelObjects(manager, q, &ips)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetServiceIps.FetchModelObjects")
|
||||
}
|
||||
return ips, nil
|
||||
}
|
||||
|
||||
func (manager *SServiceIpManager) SyncExtraIps(ctx context.Context, userCred mcclient.TokenCredential, resource db.IModel, ips []cloudprovider.SExtraIp) compare.SyncResult {
|
||||
result := compare.SyncResult{}
|
||||
dbServiceIps, err := manager.GetServiceIps(resource)
|
||||
if err != nil {
|
||||
result.Error(err)
|
||||
return result
|
||||
}
|
||||
localIps := map[string]*SServiceIp{}
|
||||
for i := 0; i < len(dbServiceIps); i++ {
|
||||
localIps[dbServiceIps[i].IpAddr] = &dbServiceIps[i]
|
||||
}
|
||||
remoteIps := map[string]cloudprovider.SExtraIp{}
|
||||
for i := 0; i < len(ips); i++ {
|
||||
remoteIps[ips[i].IP] = ips[i]
|
||||
}
|
||||
|
||||
for _, ip := range ips {
|
||||
if _, exist := localIps[ip.IP]; !exist {
|
||||
err = manager.newServiceIp(ctx, userCred, resource, ip)
|
||||
if err != nil {
|
||||
result.AddError(err)
|
||||
} else {
|
||||
result.Add()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ip, serviceIp := range localIps {
|
||||
if _, exist := remoteIps[ip]; !exist {
|
||||
err := serviceIp.Delete(ctx, userCred)
|
||||
if err != nil {
|
||||
result.DeleteError(err)
|
||||
} else {
|
||||
result.Delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (manager *SServiceIpManager) newServiceIp(ctx context.Context, userCred mcclient.TokenCredential, resource db.IModel, ip cloudprovider.SExtraIp) error {
|
||||
lockman.LockClass(ctx, manager, db.GetLockClassKey(manager, userCred))
|
||||
defer lockman.ReleaseClass(ctx, manager, db.GetLockClassKey(manager, userCred))
|
||||
|
||||
serviceIp := SServiceIp{}
|
||||
serviceIp.SetModelManager(manager, &serviceIp)
|
||||
|
||||
serviceIp.ServiceId = resource.GetId()
|
||||
serviceIp.ServiceType = resource.Keyword()
|
||||
serviceIp.IpAddr = ip.IP
|
||||
serviceIp.URL = ip.URL
|
||||
|
||||
err := manager.TableSpec().Insert(&serviceIp)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "newServiceIp.Insert")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -118,7 +118,6 @@ func InitHandlers(app *appsrv.Application) {
|
||||
models.DBInstanceParameterManager,
|
||||
models.DBInstanceDatabaseManager,
|
||||
models.DBInstanceAccountManager,
|
||||
models.ServiceIpManager,
|
||||
} {
|
||||
db.RegisterModelManager(manager)
|
||||
handler := db.NewModelHandler(manager)
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package modules
|
||||
|
||||
var (
|
||||
ServiceIp ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
ServiceIp = NewComputeManager("serviceip", "serviceips",
|
||||
[]string{"ID", "Ip_Addr", "URL", "Service_Id", "Service_Type"},
|
||||
[]string{})
|
||||
|
||||
registerCompute(&ServiceIp)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package multicloud
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
type SDBInstanceAccountBase struct {
|
||||
SResourceBase
|
||||
}
|
||||
|
||||
func (account *SDBInstanceAccountBase) GetIDBInstanceAccountPrivileges() ([]cloudprovider.ICloudDBInstanceAccountPrivilege, error) {
|
||||
return []cloudprovider.ICloudDBInstanceAccountPrivilege{}, nil
|
||||
}
|
||||
@@ -10,12 +10,16 @@ type SDBInstanceBase struct {
|
||||
SVirtualResourceBase
|
||||
}
|
||||
|
||||
func (instance *SDBInstanceBase) GetDBNetwork() (*cloudprovider.SDBInstanceNetwork, error) {
|
||||
return nil, fmt.Errorf("Not Implemented GetDBNetwork")
|
||||
func (instance *SDBInstanceBase) GetConnectionStr() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (instance *SDBInstanceBase) GetExtraIps() ([]cloudprovider.SExtraIp, error) {
|
||||
return nil, fmt.Errorf("Not Implemented GetExtraIps")
|
||||
func (instance *SDBInstanceBase) GetInternalConnectionStr() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (instance *SDBInstanceBase) GetDBNetwork() (*cloudprovider.SDBInstanceNetwork, error) {
|
||||
return nil, fmt.Errorf("Not Implemented GetDBNetwork")
|
||||
}
|
||||
|
||||
func (instance *SDBInstanceBase) GetIDBInstanceParameters() ([]cloudprovider.ICloudDBInstanceParameter, error) {
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package multicloud
|
||||
|
||||
type SDBInstanceAccountBase struct {
|
||||
SResourceBase
|
||||
}
|
||||
@@ -29,6 +29,8 @@ type SDBInstanceExtra struct {
|
||||
type SDBInstance struct {
|
||||
multicloud.SDBInstanceBase
|
||||
|
||||
netInfo []SDBInstanceNetwork
|
||||
|
||||
region *SRegion
|
||||
|
||||
AccountMaxQuantity int
|
||||
@@ -233,21 +235,46 @@ func (rds *SDBInstance) GetDBNetwork() (*cloudprovider.SDBInstanceNetwork, error
|
||||
return nil, fmt.Errorf("failed to found network for aliyun rds %s", rds.DBInstanceId)
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetExtraIps() ([]cloudprovider.SExtraIp, error) {
|
||||
func (rds *SDBInstance) fetchNetInfo() error {
|
||||
if len(rds.netInfo) > 0 {
|
||||
return nil
|
||||
}
|
||||
netInfo, err := rds.region.GetDBInstanceNetInfo(rds.DBInstanceId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return errors.Wrap(err, "GetDBInstanceNetInfo")
|
||||
}
|
||||
ips := []cloudprovider.SExtraIp{}
|
||||
for _, net := range netInfo {
|
||||
if net.IPType == "Public" || net.IPType == "Inner" {
|
||||
ips = append(ips, cloudprovider.SExtraIp{
|
||||
IP: net.IPAddress,
|
||||
URL: net.ConnectionString,
|
||||
})
|
||||
rds.netInfo = netInfo
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetInternalConnectionStr() string {
|
||||
err := rds.fetchNetInfo()
|
||||
if err != nil {
|
||||
log.Errorf("failed to fetch netInfo error: %v", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
for _, net := range rds.netInfo {
|
||||
if net.IPType != "Public" {
|
||||
return net.ConnectionString
|
||||
}
|
||||
}
|
||||
return ips, nil
|
||||
return ""
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetConnectionStr() string {
|
||||
err := rds.fetchNetInfo()
|
||||
if err != nil {
|
||||
log.Errorf("failed to fetch netInfo error: %v", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
for _, net := range rds.netInfo {
|
||||
if net.IPType == "Public" {
|
||||
return net.ConnectionString
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (region *SRegion) GetDBInstances(ids []string, offset int, limit int) ([]SDBInstance, int, error) {
|
||||
|
||||
@@ -238,8 +238,15 @@ func (rds *SDBInstance) GetDBNetwork() (*cloudprovider.SDBInstanceNetwork, error
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetExtraIps() ([]cloudprovider.SExtraIp, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
func (rds *SDBInstance) GetInternalConnectionStr() string {
|
||||
return rds.Endpoint.Address
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetConnectionStr() string {
|
||||
if rds.PubliclyAccessible {
|
||||
return rds.Endpoint.Address
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetIDBInstanceParameters() ([]cloudprovider.ICloudDBInstanceParameter, error) {
|
||||
|
||||
@@ -52,10 +52,6 @@ type SIpAddress struct {
|
||||
IpAddress []string
|
||||
}
|
||||
|
||||
// type SNetworkInterfaces struct {
|
||||
// NetworkInterface []SNetworkInterface
|
||||
// }
|
||||
|
||||
type SSecurityGroupIds struct {
|
||||
SecurityGroupId []string
|
||||
}
|
||||
|
||||
+13
-12
@@ -173,14 +173,13 @@ func Unmarshal(r *request.Request) {
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
} else {
|
||||
r.Error = awserr.NewRequestFailure(
|
||||
awserr.New("decoder.Token()", "get token", err),
|
||||
r.HTTPResponse.StatusCode,
|
||||
r.RequestID,
|
||||
)
|
||||
return
|
||||
}
|
||||
r.Error = awserr.NewRequestFailure(
|
||||
awserr.New("decoder.Token()", "get token", err),
|
||||
r.HTTPResponse.StatusCode,
|
||||
r.RequestID,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if tok == nil {
|
||||
@@ -193,11 +192,13 @@ func Unmarshal(r *request.Request) {
|
||||
case xml.StartElement:
|
||||
if typed.Name.Local == r.Operation.Name+"Result" {
|
||||
err = decoder.DecodeElement(r.Data, &typed)
|
||||
r.Error = awserr.NewRequestFailure(
|
||||
awserr.New("DecodeElement", "failed decoding Query response", err),
|
||||
r.HTTPResponse.StatusCode,
|
||||
r.RequestID,
|
||||
)
|
||||
if err != nil {
|
||||
r.Error = awserr.NewRequestFailure(
|
||||
awserr.New("DecodeElement", "failed decoding Query response", err),
|
||||
r.HTTPResponse.StatusCode,
|
||||
r.RequestID,
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
case xml.EndElement:
|
||||
|
||||
Reference in New Issue
Block a user