You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2013/11/21 22:50:50 UTC

git commit: updated refs/heads/4.3 to cb14dad

Updated Branches:
  refs/heads/4.3 98ed8b7e5 -> cb14dad75


Resource metadata - support for VPC

Conflicts:
	api/src/com/cloud/server/ResourceTag.java
	server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java


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

Branch: refs/heads/4.3
Commit: cb14dad75b8af0b389da3dd477f23b6a7a67a2df
Parents: 98ed8b7
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Thu Nov 21 10:15:30 2013 -0800
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Thu Nov 21 12:59:49 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/server/ResourceTag.java       | 47 ++++++------
 .../spring-engine-schema-core-daos-context.xml  |  2 +-
 .../cloudstack/resourcedetail/VpcDetailVO.java  | 81 ++++++++++++++++++++
 .../resourcedetail/dao/VpcDetailsDao.java       | 26 +++++++
 .../resourcedetail/dao/VpcDetailsDaoImpl.java   | 33 ++++++++
 .../metadata/ResourceMetaDataManagerImpl.java   | 11 ++-
 setup/db/db/schema-421to430.sql                 | 11 +++
 7 files changed, 183 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb14dad7/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 ba1aeb8..7d17dab 100644
--- a/api/src/com/cloud/server/ResourceTag.java
+++ b/api/src/com/cloud/server/ResourceTag.java
@@ -22,30 +22,31 @@ import org.apache.cloudstack.api.InternalIdentity;
 
 public interface ResourceTag extends ControlledEntity, Identity, InternalIdentity {
 
-    //FIXME - extract enum to another interface as its used both by resourceTags and resourceMetaData code
-    public enum  ResourceObjectType {
-        UserVm (true, true),
-        Template (true, true),
-        ISO (true, false),
-        Volume (true, true),
-        Snapshot (true, false),
-        Network (true, true),
-        Nic (false, true),
-        LoadBalancer (true, true),
-        PortForwardingRule (true, true),
-        FirewallRule (true, true),
-        SecurityGroup (true, false),
-        PublicIpAddress (true, true),
-        Project (true, false),
-        Vpc (true, false),
-        NetworkACL (true, false),
-        StaticRoute (true, false),
-        VMSnapshot (true, false),
-        RemoteAccessVpn (true, true),
-        Zone (false, true),
-        ServiceOffering (false, true),
+
+    // FIXME - extract enum to another interface as its used both by resourceTags and resourceMetaData code
+    public enum ResourceObjectType {
+        UserVm(true, true),
+        Template(true, true),
+        ISO(true, false),
+        Volume(true, true),
+        Snapshot(true, false),
+        Network(true, true),
+        Nic(false, true),
+        LoadBalancer(true, true),
+        PortForwardingRule(true, true),
+        FirewallRule(true, true),
+        SecurityGroup(true, false),
+        PublicIpAddress(true, true),
+        Project(true, false),
+        Vpc(true, true),
+        NetworkACL(true, false),
+        StaticRoute(true, false),
+        VMSnapshot(true, false),
+        RemoteAccessVpn(true, true),
+        Zone(false, true),
+        ServiceOffering(false, true),
         Storage(false, true);
-        
+
         ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport) {
             this.resourceTagsSupport = resourceTagsSupport;
             this.metadataSupport = resourceMetadataSupport;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb14dad7/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
----------------------------------------------------------------------
diff --git a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
index a8a1bff..23db19d 100644
--- a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
+++ b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
@@ -323,7 +323,7 @@
   <bean id="FirewallRuleDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.FirewallRuleDetailsDaoImpl" />
   <bean id="UserIpAddressDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDaoImpl" />
   <bean id="RemoteAccessVpnDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDaoImpl" />
-  
+  <bean id="VpcDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.VpcDetailsDaoImpl" />
   <bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
 
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb14dad7/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcDetailVO.java
new file mode 100644
index 0000000..beb38b5
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcDetailVO.java
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.resourcedetail;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.ResourceDetail;
+
+@Entity
+@Table(name = "vpc_details")
+public class VpcDetailVO implements ResourceDetail {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "vpc_id")
+    private long resourceId;
+
+    @Column(name = "name")
+    private String name;
+
+    @Column(name = "value", length = 1024)
+    private String value;
+
+    @Column(name = "display")
+    private boolean display;
+
+    public VpcDetailVO() {
+    }
+
+    public VpcDetailVO(long id, String name, String value) {
+        this.resourceId = id;
+        this.name = name;
+        this.value = value;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getValue() {
+        return value;
+    }
+
+    @Override
+    public long getResourceId() {
+        return resourceId;
+    }
+
+    @Override
+    public boolean isDisplay() {
+        return display;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb14dad7/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDao.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDao.java
new file mode 100644
index 0000000..8ebd500
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDao.java
@@ -0,0 +1,26 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.resourcedetail.dao;
+
+import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
+import org.apache.cloudstack.resourcedetail.VpcDetailVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface VpcDetailsDao extends GenericDao<VpcDetailVO, Long>, ResourceDetailsDao<VpcDetailVO> {
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb14dad7/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDaoImpl.java
new file mode 100644
index 0000000..6459723
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDaoImpl.java
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+// 
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.resourcedetail.dao;
+
+import javax.ejb.Local;
+
+import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
+import org.apache.cloudstack.resourcedetail.VpcDetailVO;
+import org.springframework.stereotype.Component;
+
+@Component
+@Local(value = { VpcDetailsDao.class })
+public class VpcDetailsDaoImpl extends ResourceDetailsDaoBase<VpcDetailVO> implements VpcDetailsDao {
+
+    @Override
+    public void addDetail(long resourceId, String key, String value) {
+        super.addDetail(new VpcDetailVO(resourceId, key, value));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb14dad7/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 cf1254b..4f8907e 100644
--- a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
+++ b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
@@ -29,6 +29,7 @@ import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
 import org.apache.cloudstack.resourcedetail.dao.FirewallRuleDetailsDao;
 import org.apache.cloudstack.resourcedetail.dao.RemoteAccessVpnDetailsDao;
 import org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDao;
+import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -81,10 +82,11 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
     UserIpAddressDetailsDao _userIpAddressDetailsDao;
     @Inject
     RemoteAccessVpnDetailsDao _vpnDetailsDao;
-    
-    private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> _daoMap= 
+    @Inject
+    VpcDetailsDao _vpcDetailsDao;
+
+    private static Map<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>> _daoMap =
             new HashMap<ResourceObjectType, ResourceDetailsDao<? extends ResourceDetail>>();
-    
 
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
@@ -101,6 +103,7 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
         _daoMap.put(ResourceObjectType.PortForwardingRule, _firewallRuleDetailsDao);
         _daoMap.put(ResourceObjectType.LoadBalancer, _firewallRuleDetailsDao);
         _daoMap.put(ResourceObjectType.RemoteAccessVpn, _vpnDetailsDao);
+        _daoMap.put(ResourceObjectType.Vpc, _vpcDetailsDao);
 
         return true;
     }
@@ -165,7 +168,7 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
             if (dao == null) {
                 throw new UnsupportedOperationException("ResourceType " + resourceType + " doesn't support metadata");
             }
-            this.dao = (ResourceDetailsDao)_daoMap.get(resourceType);
+            this.dao = (ResourceDetailsDao) _daoMap.get(resourceType);
         }
         
         private void removeDetail(long resourceId, String key) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb14dad7/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index 8495ccf..77e3641 100644
--- a/setup/db/db/schema-421to430.sql
+++ b/setup/db/db/schema-421to430.sql
@@ -742,6 +742,17 @@ CREATE VIEW `cloud`.`domain_router_view` AS
         `cloud`.`async_job` ON async_job.instance_id = vm_instance.id
             and async_job.instance_type = 'DomainRouter'
             and async_job.job_status = 0;
+
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Advanced", 'DEFAULT', 'management-server', "vmware.vcenter.session.timeout", "1200", "VMware client timeout in seconds", "1200", NULL,NULL,0);
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Advanced", 'DEFAULT', 'management-server', "mgt.server.vendor", "ACS", "the vendor of management server", "ACS", NULL,NULL,0);
 
+
+CREATE TABLE `cloud`.`vpc_details` (
+  `id` bigint unsigned NOT NULL auto_increment,
+  `vpc_id` bigint unsigned NOT NULL COMMENT 'VPC id',
+  `name` varchar(255) NOT NULL,
+  `value` varchar(1024) NOT NULL,
+  `display` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'True if the detail can be displayed to the end user',
+  PRIMARY KEY (`id`),
+  CONSTRAINT `fk_vpc_details__vpc_id` FOREIGN KEY `fk_vpc_details__vpc_id`(`vpc_id`) REFERENCES `vpc`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;