mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4854:
Add support for adding network details Signed off by : nitin mehta<nitin.mehta@citrix.com>
This commit is contained in:
parent
90cc0d8f01
commit
fa0c685bcb
|
|
@ -268,6 +268,7 @@
|
|||
<bean id="networkACLItemDaoImpl" class="com.cloud.network.vpc.dao.NetworkACLItemDaoImpl" />
|
||||
<bean id="networkDaoImpl" class="com.cloud.network.dao.NetworkDaoImpl" />
|
||||
<bean id="networkDomainDaoImpl" class="com.cloud.network.dao.NetworkDomainDaoImpl" />
|
||||
<bean id="networkDetailsDaoImpl" class="com.cloud.network.dao.NetworkDetailsDaoImpl" />
|
||||
<bean id="networkExternalFirewallDaoImpl" class="com.cloud.network.dao.NetworkExternalFirewallDaoImpl" />
|
||||
<bean id="networkExternalLoadBalancerDaoImpl" class="com.cloud.network.dao.NetworkExternalLoadBalancerDaoImpl" />
|
||||
<bean id="networkOfferingDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingDaoImpl" />
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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<NetworkDetailVO, Long> {
|
||||
List<NetworkDetailVO> findDetails(long networkId);
|
||||
|
||||
void persist(long networkId, Map<String, String> details);
|
||||
|
||||
NetworkDetailVO findDetail(long networkId, String name);
|
||||
|
||||
void deleteDetails(long networkId);
|
||||
|
||||
public void removeDetails(Long networkId, String key);
|
||||
|
||||
}
|
||||
|
|
@ -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<NetworkDetailVO, Long> implements NetworkDetailsDao {
|
||||
|
||||
protected final SearchBuilder<NetworkDetailVO> NetworkSearch;
|
||||
protected final SearchBuilder<NetworkDetailVO> 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<NetworkDetailVO> findDetails(long networkId) {
|
||||
SearchCriteria<NetworkDetailVO> sc = NetworkSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
|
||||
List<NetworkDetailVO> results = search(sc, null);
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void persist(long networkId, Map<String, String> details) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkDetailVO findDetail(long networkId, String name) {
|
||||
SearchCriteria<NetworkDetailVO> sc = DetailSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
sc.setParameters("name", name);
|
||||
|
||||
return findOneBy(sc); }
|
||||
|
||||
@Override
|
||||
public void deleteDetails(long networkId) {
|
||||
SearchCriteria<NetworkDetailVO> sc = NetworkSearch.create();
|
||||
sc.setParameters("networkId", networkId);
|
||||
|
||||
List<NetworkDetailVO> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue