fix: change owner should check required domain list

This commit is contained in:
Qiu Jian
2020-07-29 13:01:14 +08:00
parent dd42c55d1e
commit 244e83b8ae
11 changed files with 94 additions and 1 deletions
+9
View File
@@ -240,3 +240,12 @@ func (globalVpc *SGlobalVpc) GetRequiredSharedDomainIds() []string {
}
return db.ISharableMergeShareRequireDomainIds(requires...)
}
func (globalVpc *SGlobalVpc) GetChangeOwnerRequiredDomainIds() []string {
requires := stringutils2.SSortedStrings{}
vpcs, _ := globalVpc.GetVpcs()
for i := range vpcs {
requires = stringutils2.Append(requires, vpcs[i].DomainId)
}
return requires
}
+9
View File
@@ -5136,6 +5136,15 @@ func (host *SHost) PerformChangeOwner(ctx context.Context, userCred mcclient.Tok
return ret, nil
}
func (host *SHost) GetChangeOwnerRequiredDomainIds() []string {
requires := stringutils2.SSortedStrings{}
guests := host.GetGuests()
for i := range guests {
requires = stringutils2.Append(requires, guests[i].DomainId)
}
return requires
}
func GetHostQuotaKeysFromCreateInput(input api.HostCreateInput) quotas.SDomainRegionalCloudResourceKeys {
ownerId := &db.SOwnerId{DomainId: input.ProjectDomain}
var zone *SZone
+9
View File
@@ -1483,6 +1483,15 @@ func (storage *SStorage) performChangeOwnerInternal(ctx context.Context, userCre
return storage.SEnabledStatusInfrasResourceBase.PerformChangeOwner(ctx, userCred, query, input)
}
func (storage *SStorage) GetChangeOwnerRequiredDomainIds() []string {
requires := stringutils2.SSortedStrings{}
disks := storage.GetDisks()
for i := range disks {
requires = stringutils2.Append(requires, disks[i].DomainId)
}
return requires
}
func (storage *SStorage) PerformPublic(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformPublicDomainInput) (jsonutils.JSONObject, error) {
// not allow to perform public for locally connected storage
if storage.IsLocal() {
+9
View File
@@ -1097,6 +1097,15 @@ func (vpc *SVpc) GetChangeOwnerCandidateDomainIds() []string {
return db.ISharableMergeChangeOwnerCandidateDomainIds(vpc, candidates...)
}
func (vpc *SVpc) GetChangeOwnerRequiredDomainIds() []string {
requires := stringutils2.SSortedStrings{}
wires := vpc.GetWires()
for i := range wires {
requires = stringutils2.Append(requires, wires[i].DomainId)
}
return requires
}
func (vpc *SVpc) GetRequiredSharedDomainIds() []string {
wires := vpc.GetWires()
if len(wires) == 0 {
+9
View File
@@ -1024,6 +1024,15 @@ func (wire *SWire) GetChangeOwnerCandidateDomainIds() []string {
return db.ISharableMergeChangeOwnerCandidateDomainIds(wire, candidates...)
}
func (wire *SWire) GetChangeOwnerRequiredDomainIds() []string {
requires := stringutils2.SSortedStrings{}
networks, _ := wire.getNetworks(nil, rbacutils.ScopeNone)
for i := range networks {
requires = stringutils2.Append(requires, networks[i].DomainId)
}
return requires
}
func (wire *SWire) GetRequiredSharedDomainIds() []string {
networks, _ := wire.getNetworks(nil, rbacutils.ScopeNone)
if len(networks) == 0 {