You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -3957,35 +3944,16 @@ public DiskOffering updateDiskOffering(final UpdateDiskOfferingCmd cmd) {
3957
3944
Collections.sort(filteredZoneIds);
3958
3945
3959
3946
if (account.getType() == Account.Type.DOMAIN_ADMIN) {
3960
-
if (!filteredZoneIds.equals(existingZoneIds)) { // Domain-admins cannot update zone(s) for offerings
3961
-
thrownewInvalidParameterValueException(String.format("Unable to update zone(s) for disk offering: %s by admin: %s as it is domain-admin", diskOfferingHandle.getUuid(), user.getUuid()));
3962
-
}
3963
-
if (existingDomainIds.isEmpty()) {
3964
-
thrownewInvalidParameterValueException(String.format("Unable to update public disk offering: %s by user: %s because it is domain-admin", diskOfferingHandle.getUuid(), user.getUuid()));
3965
-
} else {
3966
-
if (filteredDomainIds.isEmpty()) {
3967
-
thrownewInvalidParameterValueException(String.format("Unable to update disk offering: %s to a public offering by user: %s because it is domain-admin", diskOfferingHandle.getUuid(), user.getUuid()));
if (StringUtils.isNotBlank(tags) && !ALLOW_DOMAIN_ADMINS_TO_CREATE_TAGGED_OFFERINGS.valueIn(account.getAccountId())) {
3971
3950
thrownewInvalidParameterValueException(String.format("User [%s] is unable to update disk offering tags.", user.getUuid()));
3972
3951
}
3973
3952
3974
-
List<Long> nonChildDomains = newArrayList<>();
3975
-
for (LongdomainId : existingDomainIds) {
3976
-
if (!_domainDao.isChildDomain(account.getDomainId(), domainId)) {
3977
-
if (name != null || displayText != null || sortKey != null) { // Domain-admins cannot update name, display text, sort key for offerings with domain which are not child domains for domain-admin
3978
-
thrownewInvalidParameterValueException(String.format("Unable to update disk offering: %s as it has linked domain(s) which are not child domain for domain-admin: %s", diskOfferingHandle.getUuid(), user.getUuid()));
3979
-
}
3980
-
nonChildDomains.add(domainId);
3981
-
}
3982
-
}
3983
-
for (LongdomainId : filteredDomainIds) {
3984
-
if (!_domainDao.isChildDomain(account.getDomainId(), domainId)) {
thrownewInvalidParameterValueException(String.format("Unable to update disk offering: %s by domain-admin: %s with domain: %3$s which is not a child domain", diskOfferingHandle.getUuid(), user.getUuid(), domain.getUuid()));
filteredDomainIds.addAll(nonChildDomains); // Final list must include domains which were not child domain for domain-admin but specified for this offering prior to update
thrownewInvalidParameterValueException(String.format("Unable to update disk offering: %s by id user: %s because it is not root-admin or domain-admin", diskOfferingHandle.getUuid(), user.getUuid()));
@@ -4001,22 +3969,7 @@ public DiskOffering updateDiskOffering(final UpdateDiskOfferingCmd cmd) {
thrownewInvalidParameterValueException(String.format("Unable to update zone(s) for disk offering [%s] by admin [%s] as it is domain-admin.", diskOffering.getUuid(), user.getUuid()));
4089
+
}
4090
+
if (existingDomainIds.isEmpty()) {
4091
+
thrownewInvalidParameterValueException(String.format("Unable to update public disk offering [%s] by user [%s] because it is domain-admin.", diskOffering.getUuid(), user.getUuid()));
4092
+
}
4093
+
if (filteredDomainIds.isEmpty()) {
4094
+
thrownewInvalidParameterValueException(String.format("Unable to update disk offering [%s] to a public offering by user [%s] because it is domain-admin.", diskOffering.getUuid(), user.getUuid()));
if (_domainDao.isChildDomain(account.getDomainId(), domainId)) {
4106
+
continue;
4107
+
}
4108
+
4109
+
if (ObjectUtils.anyNotNull(name, displayText, sortKey)) {
4110
+
thrownewInvalidParameterValueException(String.format("Unable to update disk offering [%s] as it has linked domain(s) which are not child domain for domain-admin [%s].", diskOffering.getUuid(), user.getUuid()));
thrownewInvalidParameterValueException(String.format("Unable to update disk offering [%s] by domain-admin [%s] with domain [%3$s] which is not a child domain.", diskOffering.getUuid(), user.getUuid(), domain.getUuid()));
4125
+
}
4126
+
}
4127
+
4072
4128
/**
4073
4129
* Check the tags parameters to the disk/service offering
0 commit comments