cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [5/6] git commit: updated refs/heads/ui-restyle to 019e075
Date Tue, 08 Oct 2013 00:13:07 GMT
CLOUDSTACK-4824:
Add support for adding zone details
Signed off by : nitin mehta<nitin.mehta@citrix.com>


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

Branch: refs/heads/ui-restyle
Commit: 6e80bb001c3a4b721c071bc120d662ad8cf3f422
Parents: 4f932d0
Author: Nitin Mehta <nitin.mehta@citrix.com>
Authored: Mon Oct 7 15:48:43 2013 -0700
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Mon Oct 7 15:48:43 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/server/ResourceTag.java       |  3 +-
 .../src/com/cloud/dc/dao/DcDetailsDao.java      |  5 +++
 .../src/com/cloud/dc/dao/DcDetailsDaoImpl.java  | 25 ++++++++++++-
 .../com/cloud/api/query/QueryManagerImpl.java   | 37 +++++++++++++++++---
 .../metadata/ResourceMetaDataManagerImpl.java   | 16 ++++++++-
 .../cloud/tags/TaggedResourceManagerImpl.java   |  4 +++
 6 files changed, 83 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e80bb00/api/src/com/cloud/server/ResourceTag.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ResourceTag.java b/api/src/com/cloud/server/ResourceTag.java
index f1d31e4..1c16f25 100644
--- a/api/src/com/cloud/server/ResourceTag.java
+++ b/api/src/com/cloud/server/ResourceTag.java
@@ -40,7 +40,8 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
         NetworkACL,
         StaticRoute,
         VMSnapshot,
-        RemoteAccessVpn
+        RemoteAccessVpn,
+        Zone
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e80bb00/engine/schema/src/com/cloud/dc/dao/DcDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/DcDetailsDao.java b/engine/schema/src/com/cloud/dc/dao/DcDetailsDao.java
index a3b72a8..814c7af 100644
--- a/engine/schema/src/com/cloud/dc/dao/DcDetailsDao.java
+++ b/engine/schema/src/com/cloud/dc/dao/DcDetailsDao.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.dc.dao;
 
+import java.util.List;
 import java.util.Map;
 
 import com.cloud.dc.DcDetailVO;
@@ -29,4 +30,8 @@ public interface DcDetailsDao extends GenericDao<DcDetailVO, Long>
{
     DcDetailVO findDetail(long dcId, String name);
 
 	void deleteDetails(long dcId);
+
+    void removeDetails(Long id, String key);
+
+    List<DcDetailVO> findDetailsList(long dcId);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e80bb00/engine/schema/src/com/cloud/dc/dao/DcDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/DcDetailsDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/DcDetailsDaoImpl.java
index 7f5723f..88c326b 100644
--- a/engine/schema/src/com/cloud/dc/dao/DcDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/DcDetailsDaoImpl.java
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import javax.ejb.Local;
 
+import com.cloud.vm.UserVmDetailVO;
 import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.config.ConfigKey.Scope;
 import org.apache.cloudstack.framework.config.ScopedConfigStorage;
@@ -69,7 +70,17 @@ public class DcDetailsDaoImpl extends GenericDaoBase<DcDetailVO, Long>
implement
         }
         return details;
     }
-    
+
+    @Override
+    public List<DcDetailVO> findDetailsList(long dcId) {
+        SearchCriteria<DcDetailVO> sc = DcSearch.create();
+        sc.setParameters("dcId", dcId);
+
+        List<DcDetailVO> results = search(sc, null);
+        return results;
+    }
+
+
     @Override
     public void deleteDetails(long dcId) {
         SearchCriteria<DcDetailVO> sc = DcSearch.create();
@@ -82,6 +93,18 @@ public class DcDetailsDaoImpl extends GenericDaoBase<DcDetailVO, Long>
implement
     }
 
     @Override
+    public void removeDetails(Long id, String key) {
+        if(key != null){
+            DcDetailVO detail = findDetail(id, key);
+            if(detail != null){
+                remove(detail.getId());
+            }
+        }else {
+            deleteDetails(id);
+        }
+    }
+
+    @Override
     public void persist(long dcId, Map<String, String> details) {
         Transaction txn = Transaction.currentTxn();
         txn.start();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e80bb00/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 bd4f158..9ff37a6 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -27,6 +27,8 @@ import java.util.Set;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import com.cloud.dc.DcDetailVO;
+import com.cloud.dc.dao.DcDetailsDao;
 import com.cloud.vm.UserVmDetailVO;
 import com.cloud.vm.dao.UserVmDetailsDao;
 import org.apache.log4j.Logger;
@@ -327,6 +329,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
     private DedicatedResourceDao _dedicatedDao;
 
     @Inject
+    DcDetailsDao _dcDetailsDao;
+
+    @Inject
     DomainManager _domainMgr;
 
     @Inject
@@ -3271,7 +3276,31 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
 
             return nicDetailResponseList;
 
-        } else {
+        } else if (resourceType == ResourceTag.TaggedResourceType.Zone){
+
+            List<DcDetailVO> dcDetailList;
+            if (key == null) {
+                dcDetailList = _dcDetailsDao.findDetailsList(id);
+            } else {
+                DcDetailVO nicDetail = _dcDetailsDao.findDetail(id, key);
+                dcDetailList = new LinkedList<DcDetailVO>();
+                dcDetailList.add(nicDetail);
+            }
+
+            List<ResourceDetailResponse> dcDetailResponseList = new ArrayList<ResourceDetailResponse>();
+            for (DcDetailVO dcDetail : dcDetailList) {
+                ResourceDetailResponse dcDetailResponse = new ResourceDetailResponse();
+                // String uuid = ApiDBUtils.findN
+                dcDetailResponse.setName(dcDetail.getName());
+                dcDetailResponse.setValue(dcDetail.getValue());
+                dcDetailResponse.setResourceType(ResourceTag.TaggedResourceType.Nic.toString());
+                dcDetailResponse.setObjectName("zonedetail");
+                dcDetailResponseList.add(dcDetailResponse);
+            }
+
+            return dcDetailResponseList;
+
+        }else {
 
             List<UserVmDetailVO> userVmDetailList;
             if (key == null) {
@@ -3282,17 +3311,17 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
                 userVmDetailList.add(nicDetail);
             }
 
-            List<ResourceDetailResponse> nicDetailResponseList = new ArrayList<ResourceDetailResponse>();
+            List<ResourceDetailResponse> userVmDetailResponseList = new ArrayList<ResourceDetailResponse>();
             for (UserVmDetailVO nicDetail : userVmDetailList) {
                 ResourceDetailResponse userVmDetailResponse = new ResourceDetailResponse();
                 userVmDetailResponse.setName(nicDetail.getName());
                 userVmDetailResponse.setValue(nicDetail.getValue());
                 userVmDetailResponse.setResourceType(ResourceTag.TaggedResourceType.Nic.toString());
                 userVmDetailResponse.setObjectName("uservmdetail");
-                nicDetailResponseList.add(userVmDetailResponse);
+                userVmDetailResponseList.add(userVmDetailResponse);
             }
 
-            return nicDetailResponseList;
+            return userVmDetailResponseList;
         }
 
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e80bb00/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
index 80d5055..8367863 100644
--- a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
+++ b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
@@ -23,6 +23,9 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import com.cloud.dc.DcDetailVO;
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.dc.dao.DcDetailsDao;
 import com.cloud.server.ResourceMetaDataService;
 import com.cloud.storage.VolumeDetailVO;
 import com.cloud.storage.dao.VolumeDetailsDao;
@@ -95,6 +98,8 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
     @Inject
     NetworkDao _networkDao;
     @Inject
+    DataCenterDao _dataCenterDao;
+    @Inject
     LoadBalancerDao _lbDao;
     @Inject
     PortForwardingRulesDao _pfDao;
@@ -123,6 +128,8 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
     @Inject
     NicDao _nicDao;
     @Inject
+    DcDetailsDao _dcDetailsDao;
+    @Inject
     TaggedResourceService _taggedResourceMgr;
     @Inject
     UserVmDetailsDao _userVmDetail;
@@ -148,6 +155,7 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
         _daoMap.put(TaggedResourceType.StaticRoute, _staticRouteDao);
         _daoMap.put(TaggedResourceType.VMSnapshot, _vmSnapshotDao);
         _daoMap.put(TaggedResourceType.RemoteAccessVpn, _vpnDao);
+        _daoMap.put(TaggedResourceType.Zone, _dataCenterDao);
         return true;
     }
 
@@ -208,6 +216,9 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
                 }else if (resourceType == TaggedResourceType.UserVm){
                     UserVmDetailVO userVmDetail = new UserVmDetailVO(id, key, value);
                     _userVmDetailDao.persist(userVmDetail);
+                } else if (resourceType == TaggedResourceType.Zone){
+                     DcDetailVO dataCenterDetail = new DcDetailVO(id, key, value);
+                     _dcDetailsDao.persist(dataCenterDetail);
                 } else {
                     throw new InvalidParameterValueException("The resource type " + resourceType
+ " is not supported by the API yet");
                 }
@@ -233,7 +244,10 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
             _nicDetailDao.removeDetails(id, key);
         } else if(resourceType == TaggedResourceType.UserVm){
             _userVmDetailDao.removeDetails(id, key);
-        } else {
+        } else if (resourceType == TaggedResourceType.Zone){
+            _dcDetailsDao.removeDetails(id, key);
+        }
+        else{
             throw new InvalidParameterValueException("The resource type " + resourceType
+ " is not supported by the API yet");
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e80bb00/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
index e90481c..795a970 100644
--- a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
+++ b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
@@ -25,6 +25,7 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.vm.dao.NicDao;
 import com.cloud.network.vpc.NetworkACLItemDao;
 
@@ -125,6 +126,8 @@ public class TaggedResourceManagerImpl extends ManagerBase implements
TaggedReso
     NicDao _nicDao;
     @Inject
     NetworkACLItemDao _networkACLItemDao;
+    @Inject
+    DataCenterDao _dataCenterDao;
 
 
     @Override
@@ -147,6 +150,7 @@ public class TaggedResourceManagerImpl extends ManagerBase implements
TaggedReso
         _daoMap.put(TaggedResourceType.StaticRoute, _staticRouteDao);
         _daoMap.put(TaggedResourceType.VMSnapshot, _vmSnapshotDao);
         _daoMap.put(TaggedResourceType.RemoteAccessVpn, _vpnDao);
+        _daoMap.put(TaggedResourceType.Zone, _dataCenterDao);
 
         return true;
     }


Mime
View raw message