diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 6dda5c707af..2a3520be9b2 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -268,6 +268,7 @@
+
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDetailVO.java b/engine/schema/src/com/cloud/network/dao/NetworkDetailVO.java
new file mode 100644
index 00000000000..62923974c8e
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/NetworkDetailVO.java
@@ -0,0 +1,90 @@
+// 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 com.cloud.network.dao;
+
+import org.apache.cloudstack.api.InternalIdentity;
+import org.apache.cloudstack.api.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;
+
+@Entity
+@Table(name="network_details")
+public class NetworkDetailVO implements InternalIdentity, ResourceDetail {
+ @Id
+ @GeneratedValue(strategy= GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="network_id")
+ private long networkId;
+
+ @Column(name="name")
+ private String name;
+
+ @Column(name="value", length=1024)
+ private String value;
+
+ public NetworkDetailVO() {}
+
+ public NetworkDetailVO(long networkId, String name, String value) {
+ this.networkId = networkId;
+ this.name = name;
+ this.value = value;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getNetworkId() {
+ return networkId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public void setNetworkId(long networkId) {
+ this.networkId = networkId;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public long getResourceDetail() {
+ return networkId;
+ }
+}
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDetailsDao.java b/engine/schema/src/com/cloud/network/dao/NetworkDetailsDao.java
new file mode 100644
index 00000000000..f788534a0e1
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/NetworkDetailsDao.java
@@ -0,0 +1,35 @@
+// 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
+// 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 com.cloud.network.dao;
+
+import com.cloud.utils.db.GenericDao;
+
+import java.util.List;
+import java.util.Map;
+
+public interface NetworkDetailsDao extends GenericDao {
+ List findDetails(long networkId);
+
+ void persist(long networkId, Map details);
+
+ NetworkDetailVO findDetail(long networkId, String name);
+
+ void deleteDetails(long networkId);
+
+ public void removeDetails(Long networkId, String key);
+
+}
\ No newline at end of file
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java
new file mode 100644
index 00000000000..453a95a11ec
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java
@@ -0,0 +1,93 @@
+// 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
+// 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 com.cloud.network.dao;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.network.dao.NetworkDetailVO;
+import com.cloud.vm.dao.UserVmDetailsDao;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import java.util.List;
+import java.util.Map;
+
+@Component
+@Local(value=NetworkDetailsDao.class)
+public class NetworkDetailsDaoImpl extends GenericDaoBase implements NetworkDetailsDao {
+
+ protected final SearchBuilder NetworkSearch;
+ protected final SearchBuilder DetailSearch;
+
+ public NetworkDetailsDaoImpl() {
+ NetworkSearch = createSearchBuilder();
+ NetworkSearch.and("networkId", NetworkSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
+ NetworkSearch.done();
+
+ DetailSearch = createSearchBuilder();
+ DetailSearch.and("networkId", DetailSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
+ DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
+ DetailSearch.done();
+ }
+
+
+ @Override
+ public List findDetails(long networkId) {
+ SearchCriteria sc = NetworkSearch.create();
+ sc.setParameters("networkId", networkId);
+
+ List results = search(sc, null);
+ return results;
+ }
+
+ @Override
+ public void persist(long networkId, Map details) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public NetworkDetailVO findDetail(long networkId, String name) {
+ SearchCriteria sc = DetailSearch.create();
+ sc.setParameters("networkId", networkId);
+ sc.setParameters("name", name);
+
+ return findOneBy(sc); }
+
+ @Override
+ public void deleteDetails(long networkId) {
+ SearchCriteria sc = NetworkSearch.create();
+ sc.setParameters("networkId", networkId);
+
+ List results = search(sc, null);
+ for (NetworkDetailVO result : results) {
+ remove(result.getId());
+ }
+ }
+
+ @Override
+ public void removeDetails(Long networkId, String key) {
+ if(key != null){
+ NetworkDetailVO detail = findDetail(networkId, key);
+ if(detail != null){
+ remove(detail.getId());
+ }
+ }else {
+ deleteDetails(networkId);
+ }
+ }
+}
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 3b247fae949..e65a8b8a286 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -26,6 +26,7 @@ import java.util.Set;
import javax.ejb.Local;
import javax.inject.Inject;
+import com.cloud.network.dao.NetworkDetailsDao;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
@@ -332,6 +333,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
@Inject
AffinityGroupDomainMapDao _affinityGroupDomainMapDao;
+ @Inject
+ NetworkDetailsDao _networkDetailsDao;
+
/*
* (non-Javadoc)
*
@@ -3250,7 +3254,13 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
} else {
requestedDetail = _dcDetailsDao.findDetail(id, key);
}
- } else {
+ } else if (resourceType == TaggedResourceType.Network){
+ if (key == null) {
+ detailList = _networkDetailsDao.findDetails(id);
+ } else {
+ requestedDetail = _networkDetailsDao.findDetail(id, key);
+ }
+ }else {
throw new UnsupportedServiceException("Resource type " + resourceType + " is not supported by the cloudStack");
}
diff --git a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
index 836786349c3..5481ebb8c44 100644
--- a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
+++ b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
@@ -26,6 +26,8 @@ import javax.naming.ConfigurationException;
import com.cloud.dc.DcDetailVO;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.DcDetailsDao;
+import com.cloud.network.dao.NetworkDetailVO;
+import com.cloud.network.dao.NetworkDetailsDao;
import com.cloud.server.ResourceMetaDataService;
import com.cloud.storage.VolumeDetailVO;
import com.cloud.storage.dao.VolumeDetailsDao;
@@ -130,6 +132,8 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
@Inject
DcDetailsDao _dcDetailsDao;
@Inject
+ NetworkDetailsDao _networkDetailsDao;
+ @Inject
TaggedResourceService _taggedResourceMgr;
@Inject
UserVmDetailsDao _userVmDetail;
@@ -219,6 +223,9 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
} else if (resourceType == TaggedResourceType.Zone){
DcDetailVO dataCenterDetail = new DcDetailVO(id, key, value);
_dcDetailsDao.persist(dataCenterDetail);
+ } else if (resourceType == TaggedResourceType.Network){
+ NetworkDetailVO networkDetail = new NetworkDetailVO(id, key, value);
+ _networkDetailsDao.persist(networkDetail);
} else {
throw new InvalidParameterValueException("The resource type " + resourceType + " is not supported by the API yet");
}
@@ -246,8 +253,9 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements Resource
_userVmDetailDao.removeDetails(id, key);
} else if (resourceType == TaggedResourceType.Zone){
_dcDetailsDao.removeDetails(id, key);
- }
- else{
+ } else if (resourceType == TaggedResourceType.Network){
+ _networkDetailsDao.removeDetails(id, key);
+ } else{
throw new InvalidParameterValueException("The resource type " + resourceType + " is not supported by the API yet");
}