mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4276 Dedicated Resources: Private Zone functionality issues
Changes: createZone API: - This API takes in domainid, set it to the zone record in the data_center table updateZone API: - This API uses 'isPublic' flag to set a private zone to public - if this flag is set and the zone is dedicated, release the dedication and remove the domainid from the data_center table listZone API: - This API already has 'domainid' parameter. We should allow list zones by domain for Root admin. DedicateZone API: - set domainid in the data_center table ReleaseDedicatedZone API: - remove zoneid from the data_center table
This commit is contained in:
parent
96ca70e2da
commit
012afceed2
|
|
@ -237,6 +237,14 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
dedicatedResource.setAccountId(accountId);
|
||||
}
|
||||
dedicatedResource = _dedicatedDao.persist(dedicatedResource);
|
||||
|
||||
// save the domainId in the zone
|
||||
dc.setDomainId(domainId);
|
||||
if (!_zoneDao.update(zoneId, dc)) {
|
||||
throw new CloudRuntimeException(
|
||||
"Failed to dedicate zone, could not set domainId. Please contact Cloud Support.");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Unable to dedicate zone due to " + e.getMessage(), e);
|
||||
throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support.");
|
||||
|
|
@ -905,6 +913,19 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
if (!_dedicatedDao.remove(resourceId)) {
|
||||
throw new CloudRuntimeException("Failed to delete Resource " + resourceId);
|
||||
}
|
||||
if (zoneId != null) {
|
||||
// remove the domainId set in zone
|
||||
DataCenterVO dc = _zoneDao.findById(zoneId);
|
||||
if (dc != null) {
|
||||
dc.setDomainId(null);
|
||||
dc.setDomain(null);
|
||||
if (!_zoneDao.update(zoneId, dc)) {
|
||||
throw new CloudRuntimeException(
|
||||
"Failed to release dedicated zone, could not clear domainId. Please contact Cloud Support.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
|
||||
// find the group associated and check if there are any more
|
||||
|
|
|
|||
|
|
@ -2497,12 +2497,14 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
|||
|
||||
/*
|
||||
* List all resources due to Explicit Dedication except the
|
||||
* dedicated resources of other account if (domainId != null) { //
|
||||
* for domainId != null // right now, we made the decision to only
|
||||
* list zones associated // with this domain, private zone
|
||||
* sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId); } else
|
||||
* dedicated resources of other account
|
||||
*/
|
||||
if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) {
|
||||
if (domainId != null && account.getType() == Account.ACCOUNT_TYPE_ADMIN) { //
|
||||
// for domainId != null // right now, we made the decision to
|
||||
// only
|
||||
// / list zones associated // with this domain, private zone
|
||||
sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
|
||||
} else if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) {
|
||||
// it was decided to return all zones for the user's domain, and
|
||||
// everything above till root
|
||||
// list all zones belonging to this domain, and all of its
|
||||
|
|
|
|||
|
|
@ -1543,6 +1543,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
DedicatedResourceVO dr = _dedicatedDao.findByZoneId(zoneId);
|
||||
if (dr != null) {
|
||||
_dedicatedDao.remove(dr.getId());
|
||||
// find the group associated and check if there are any more
|
||||
// resources under that group
|
||||
List<DedicatedResourceVO> resourcesInGroup = _dedicatedDao.listByAffinityGroupId(dr
|
||||
.getAffinityGroupId());
|
||||
if (resourcesInGroup.isEmpty()) {
|
||||
// delete the group
|
||||
_affinityGroupService.deleteAffinityGroup(dr.getAffinityGroupId(), null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1695,12 +1703,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
}
|
||||
|
||||
// update a private zone to public; not vice versa
|
||||
if (isPublic != null && isPublic) {
|
||||
zone.setDomainId(null);
|
||||
zone.setDomain(null);
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
|
|
@ -1752,6 +1754,29 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if (dhcpProvider != null) {
|
||||
zone.setDhcpProvider(dhcpProvider);
|
||||
}
|
||||
|
||||
// update a private zone to public; not vice versa
|
||||
if (isPublic != null && isPublic) {
|
||||
zone.setDomainId(null);
|
||||
zone.setDomain(null);
|
||||
|
||||
// release the dedication for this zone
|
||||
DedicatedResourceVO resource = _dedicatedDao.findByZoneId(zoneId);
|
||||
Long resourceId = null;
|
||||
if (resource != null) {
|
||||
resourceId = resource.getId();
|
||||
if (!_dedicatedDao.remove(resourceId)) {
|
||||
throw new CloudRuntimeException("Failed to delete dedicated Zone Resource " + resourceId);
|
||||
}
|
||||
// find the group associated and check if there are any more
|
||||
// resources under that group
|
||||
List<DedicatedResourceVO> resourcesInGroup = _dedicatedDao.listByAffinityGroupId(resource.getAffinityGroupId());
|
||||
if (resourcesInGroup.isEmpty()) {
|
||||
// delete the group
|
||||
_affinityGroupService.deleteAffinityGroup(resource.getAffinityGroupId(), null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!_zoneDao.update(zoneId, zone)) {
|
||||
throw new CloudRuntimeException("Failed to edit zone. Please contact Cloud Support.");
|
||||
|
|
@ -1794,7 +1819,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
txn.start();
|
||||
// Create the new zone in the database
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, guestCidr,
|
||||
null, null, zoneType, zoneToken, networkDomain, isSecurityGroupEnabled, isLocalStorageEnabled,
|
||||
domain, domainId, zoneType, zoneToken, networkDomain, isSecurityGroupEnabled,
|
||||
isLocalStorageEnabled,
|
||||
ip6Dns1, ip6Dns2);
|
||||
if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
|
||||
Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
|
||||
|
|
@ -1807,7 +1833,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
zone = _zoneDao.persist(zone);
|
||||
if (domainId != null) {
|
||||
// zone is explicitly dedicated to this domain
|
||||
// create affinity group associated.
|
||||
// create affinity group associated and dedicate the zone.
|
||||
AffinityGroup group = createDedicatedAffinityGroup(null, domainId, null);
|
||||
DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(zone.getId(), null, null, null,
|
||||
domainId, null, group.getId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue