cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject git commit: updated refs/heads/4.2 to 3ad0008
Date Tue, 13 Aug 2013 00:45:59 GMT
Updated Branches:
  refs/heads/4.2 ed9f7691c -> 3ad0008c8


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


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3ad0008c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3ad0008c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3ad0008c

Branch: refs/heads/4.2
Commit: 3ad0008c899014870b7e94f75c167695644efa4b
Parents: ed9f769
Author: Prachi Damle <prachi@cloud.com>
Authored: Mon Aug 12 17:33:18 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Mon Aug 12 17:34:38 2013 -0700

----------------------------------------------------------------------
 .../dedicated/DedicatedResourceManagerImpl.java | 21 ++++++++++
 .../com/cloud/api/query/QueryManagerImpl.java   | 12 +++---
 .../configuration/ConfigurationManagerImpl.java | 42 ++++++++++++++++----
 3 files changed, 62 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ad0008c/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java
b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java
index 9092a1a..cedb33b 100755
--- a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java
+++ b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java
@@ -236,6 +236,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.");
@@ -904,6 +912,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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ad0008c/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index dab3c2a..359543d 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -2496,12 +2496,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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ad0008c/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 570edca..f5e417e 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -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);
+                }
             }
         }
 
@@ -1864,12 +1872,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();
 
@@ -1921,6 +1923,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.");
@@ -1963,7 +1988,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);
@@ -1976,7 +2002,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());


Mime
View raw message