You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/05/09 02:20:22 UTC
[11/91] [abbrv] [partial] Moved most of the VOs and DAOs from server
package into engine-schema as well
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java b/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java
deleted file mode 100644
index 45a8068..0000000
--- a/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java
+++ /dev/null
@@ -1,352 +0,0 @@
-// 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 java.util.List;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.network.rules.FirewallRule;
-import com.cloud.network.rules.FirewallRule.FirewallRuleType;
-import com.cloud.network.rules.FirewallRule.Purpose;
-import com.cloud.network.rules.FirewallRule.State;
-import com.cloud.network.rules.FirewallRule.TrafficType;
-import com.cloud.network.rules.FirewallRuleVO;
-import com.cloud.server.ResourceTag.TaggedResourceType;
-import com.cloud.tags.dao.ResourceTagDao;
-import com.cloud.tags.dao.ResourceTagsDaoImpl;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.JoinBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
-
-@Component
-@Local(value = FirewallRulesDao.class)
-@DB(txn = false)
-public class FirewallRulesDaoImpl extends GenericDaoBase<FirewallRuleVO, Long> implements FirewallRulesDao {
-
- protected final SearchBuilder<FirewallRuleVO> AllFieldsSearch;
- protected final SearchBuilder<FirewallRuleVO> NotRevokedSearch;
- protected final SearchBuilder<FirewallRuleVO> ReleaseSearch;
- protected SearchBuilder<FirewallRuleVO> VmSearch;
- protected final SearchBuilder<FirewallRuleVO> SystemRuleSearch;
- protected final GenericSearchBuilder<FirewallRuleVO, Long> RulesByIpCount;
-
- @Inject protected FirewallRulesCidrsDao _firewallRulesCidrsDao;
- @Inject ResourceTagDao _tagsDao;
- @Inject IPAddressDao _ipDao;
-
- protected FirewallRulesDaoImpl() {
- super();
-
- AllFieldsSearch = createSearchBuilder();
- AllFieldsSearch.and("ipId", AllFieldsSearch.entity().getSourceIpAddressId(), Op.EQ);
- AllFieldsSearch.and("protocol", AllFieldsSearch.entity().getProtocol(), Op.EQ);
- AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
- AllFieldsSearch.and("purpose", AllFieldsSearch.entity().getPurpose(), Op.EQ);
- AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ);
- AllFieldsSearch.and("domain", AllFieldsSearch.entity().getDomainId(), Op.EQ);
- AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
- AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
- AllFieldsSearch.and("related", AllFieldsSearch.entity().getRelated(), Op.EQ);
- AllFieldsSearch.and("trafficType", AllFieldsSearch.entity().getTrafficType(), Op.EQ);
- AllFieldsSearch.done();
-
- NotRevokedSearch = createSearchBuilder();
- NotRevokedSearch.and("ipId", NotRevokedSearch.entity().getSourceIpAddressId(), Op.EQ);
- NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), Op.NEQ);
- NotRevokedSearch.and("purpose", NotRevokedSearch.entity().getPurpose(), Op.EQ);
- NotRevokedSearch.and("protocol", NotRevokedSearch.entity().getProtocol(), Op.EQ);
- NotRevokedSearch.and("sourcePortStart", NotRevokedSearch.entity().getSourcePortStart(), Op.EQ);
- NotRevokedSearch.and("sourcePortEnd", NotRevokedSearch.entity().getSourcePortEnd(), Op.EQ);
- NotRevokedSearch.and("networkId", NotRevokedSearch.entity().getNetworkId(), Op.EQ);
- NotRevokedSearch.and("trafficType", NotRevokedSearch.entity().getTrafficType(), Op.EQ);
- NotRevokedSearch.done();
-
- ReleaseSearch = createSearchBuilder();
- ReleaseSearch.and("protocol", ReleaseSearch.entity().getProtocol(), Op.EQ);
- ReleaseSearch.and("ipId", ReleaseSearch.entity().getSourceIpAddressId(), Op.EQ);
- ReleaseSearch.and("purpose", ReleaseSearch.entity().getPurpose(), Op.EQ);
- ReleaseSearch.and("ports", ReleaseSearch.entity().getSourcePortStart(), Op.IN);
- ReleaseSearch.done();
-
- SystemRuleSearch = createSearchBuilder();
- SystemRuleSearch.and("type", SystemRuleSearch.entity().getType(), Op.EQ);
- SystemRuleSearch.and("ipId", SystemRuleSearch.entity().getSourceIpAddressId(), Op.NULL);
- SystemRuleSearch.done();
-
- RulesByIpCount = createSearchBuilder(Long.class);
- RulesByIpCount.select(null, Func.COUNT, RulesByIpCount.entity().getId());
- RulesByIpCount.and("ipAddressId", RulesByIpCount.entity().getSourceIpAddressId(), Op.EQ);
- RulesByIpCount.done();
- }
-
- @Override
- public List<FirewallRuleVO> listSystemRules() {
- SearchCriteria<FirewallRuleVO> sc = SystemRuleSearch.create();
- sc.setParameters("type", FirewallRuleType.System.toString());
- return listBy(sc);
- }
-
- @Override
- public boolean releasePorts(long ipId, String protocol, FirewallRule.Purpose purpose, int[] ports) {
- SearchCriteria<FirewallRuleVO> sc = ReleaseSearch.create();
- sc.setParameters("protocol", protocol);
- sc.setParameters("ipId", ipId);
- sc.setParameters("purpose", purpose);
- sc.setParameters("ports", ports);
-
- int results = remove(sc);
- return results == ports.length;
- }
-
- @Override
- public List<FirewallRuleVO> listByIpAndPurpose(long ipId, FirewallRule.Purpose purpose) {
- SearchCriteria<FirewallRuleVO> sc = AllFieldsSearch.create();
- sc.setParameters("ipId", ipId);
- sc.setParameters("purpose", purpose);
-
- return listBy(sc);
- }
-
- @Override
- public List<FirewallRuleVO> listByIpAndPurposeAndNotRevoked(long ipId, FirewallRule.Purpose purpose) {
- SearchCriteria<FirewallRuleVO> sc = NotRevokedSearch.create();
- sc.setParameters("ipId", ipId);
- sc.setParameters("state", State.Revoke);
-
- if (purpose != null) {
- sc.setParameters("purpose", purpose);
- }
-
- return listBy(sc);
- }
-
- @Override
- public List<FirewallRuleVO> listByNetworkAndPurposeAndNotRevoked(long networkId, FirewallRule.Purpose purpose) {
- SearchCriteria<FirewallRuleVO> sc = NotRevokedSearch.create();
- sc.setParameters("networkId", networkId);
- sc.setParameters("state", State.Revoke);
-
- if (purpose != null) {
- sc.setParameters("purpose", purpose);
- }
-
- return listBy(sc);
- }
-
- @Override
- public List<FirewallRuleVO> listByNetworkAndPurpose(long networkId, FirewallRule.Purpose purpose) {
- SearchCriteria<FirewallRuleVO> sc = AllFieldsSearch.create();
- sc.setParameters("purpose", purpose);
- sc.setParameters("networkId", networkId);
-
- return listBy(sc);
- }
-
- @Override
- public List<FirewallRuleVO> listByNetworkPurposeTrafficTypeAndNotRevoked(long networkId, FirewallRule.Purpose purpose, TrafficType trafficType) {
- SearchCriteria<FirewallRuleVO> sc = NotRevokedSearch.create();
- sc.setParameters("networkId", networkId);
- sc.setParameters("state", State.Revoke);
- if (purpose != null) {
- sc.setParameters("purpose", purpose);
- }
- sc.setParameters("trafficType", trafficType);
-
- return listBy(sc);
- }
-
-
- @Override
- public boolean setStateToAdd(FirewallRuleVO rule) {
- SearchCriteria<FirewallRuleVO> sc = AllFieldsSearch.create();
- sc.setParameters("id", rule.getId());
- sc.setParameters("state", State.Staged);
-
- rule.setState(State.Add);
-
- return update(rule, sc) > 0;
- }
-
- @Override
- public boolean revoke(FirewallRuleVO rule) {
- rule.setState(State.Revoke);
- return update(rule.getId(), rule);
- }
-
- @Override
- public List<FirewallRuleVO> listStaticNatByVmId(long vmId) {
- if (VmSearch == null) {
- SearchBuilder<IPAddressVO> IpSearch = _ipDao.createSearchBuilder();
- IpSearch.and("associatedWithVmId", IpSearch.entity().getAssociatedWithVmId(), SearchCriteria.Op.EQ);
- IpSearch.and("oneToOneNat", IpSearch.entity().isOneToOneNat(), SearchCriteria.Op.NNULL);
-
- VmSearch = createSearchBuilder();
- VmSearch.and("purpose", VmSearch.entity().getPurpose(), Op.EQ);
- VmSearch.join("ipSearch", IpSearch, VmSearch.entity().getSourceIpAddressId(), IpSearch.entity().getId(), JoinBuilder.JoinType.INNER);
- VmSearch.done();
- }
-
- SearchCriteria<FirewallRuleVO> sc = VmSearch.create();
- sc.setParameters("purpose", Purpose.StaticNat);
- sc.setJoinParameters("ipSearch", "associatedWithVmId", vmId);
-
- return listBy(sc);
- }
-
- @Override
- @DB
- public FirewallRuleVO persist(FirewallRuleVO firewallRule) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
-
- FirewallRuleVO dbfirewallRule = super.persist(firewallRule);
- saveSourceCidrs(firewallRule, firewallRule.getSourceCidrList());
- loadSourceCidrs(dbfirewallRule);
-
- txn.commit();
- return dbfirewallRule;
- }
-
- public void saveSourceCidrs(FirewallRuleVO firewallRule, List<String> cidrList) {
- if (cidrList == null) {
- return;
- }
- _firewallRulesCidrsDao.persist(firewallRule.getId(), cidrList);
- }
-
- @Override
- public List<FirewallRuleVO> listByIpPurposeAndProtocolAndNotRevoked(long ipAddressId, Integer startPort, Integer endPort, String protocol, FirewallRule.Purpose purpose) {
- SearchCriteria<FirewallRuleVO> sc = NotRevokedSearch.create();
- sc.setParameters("ipId", ipAddressId);
- sc.setParameters("state", State.Revoke);
-
- if (purpose != null) {
- sc.setParameters("purpose", purpose);
- }
-
- if (protocol != null) {
- sc.setParameters("protocol", protocol);
- }
-
- sc.setParameters("sourcePortStart", startPort);
-
- sc.setParameters("sourcePortEnd", endPort);
-
- return listBy(sc);
- }
-
- @Override
- public FirewallRuleVO findByRelatedId(long ruleId) {
- SearchCriteria<FirewallRuleVO> sc = AllFieldsSearch.create();
- sc.setParameters("related", ruleId);
- sc.setParameters("purpose", Purpose.Firewall);
-
- return findOneBy(sc);
- }
-
- @Override
- public List<FirewallRuleVO> listByIp(long ipId) {
- SearchCriteria<FirewallRuleVO> sc = AllFieldsSearch.create();
- sc.setParameters("ipId", ipId);
-
- return listBy(sc);
- }
-
- @Override
- public List<FirewallRuleVO> listByIpAndNotRevoked(long ipId) {
- SearchCriteria<FirewallRuleVO> sc = NotRevokedSearch.create();
- sc.setParameters("ipId", ipId);
- sc.setParameters("state", State.Revoke);
-
- return listBy(sc);
- }
-
- @Override
- public long countRulesByIpId(long sourceIpId) {
- SearchCriteria<Long> sc = RulesByIpCount.create();
- sc.setParameters("ipAddressId", sourceIpId);
- return customSearch(sc, null).get(0);
- }
-
- @Override
- public List<FirewallRuleVO> listByNetworkPurposeTrafficType(long networkId, Purpose purpose, TrafficType trafficType) {
- SearchCriteria<FirewallRuleVO> sc = AllFieldsSearch.create();
- sc.setParameters("networkId", networkId);
-
- if (purpose != null) {
- sc.setParameters("purpose", purpose);
- }
-
- sc.setParameters("trafficType", trafficType);
-
- return listBy(sc);
- }
-
- @Override
- @DB
- public boolean remove(Long id) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
- FirewallRuleVO entry = findById(id);
- if (entry != null) {
- if (entry.getPurpose() == Purpose.LoadBalancing) {
- _tagsDao.removeByIdAndType(id, TaggedResourceType.LoadBalancer);
- } else if (entry.getPurpose() == Purpose.PortForwarding) {
- _tagsDao.removeByIdAndType(id, TaggedResourceType.PortForwardingRule);
- } else if (entry.getPurpose() == Purpose.Firewall) {
- _tagsDao.removeByIdAndType(id, TaggedResourceType.FirewallRule);
- } else if (entry.getPurpose() == Purpose.NetworkACL) {
- _tagsDao.removeByIdAndType(id, TaggedResourceType.NetworkACL);
- }
- }
- boolean result = super.remove(id);
- txn.commit();
- return result;
- }
-
- @Override
- public List<FirewallRuleVO> listByIpAndPurposeWithState(Long ipId, Purpose purpose, State state) {
- SearchCriteria<FirewallRuleVO> sc = AllFieldsSearch.create();
- sc.setParameters("ipId", ipId);
-
- if (state != null) {
- sc.setParameters("state", state);
- }
-
- if (purpose != null) {
- sc.setParameters("purpose", purpose);
- }
-
- return listBy(sc);
- }
-
- @Override
- public void loadSourceCidrs(FirewallRuleVO rule) {
- List<String> sourceCidrs = _firewallRulesCidrsDao.getSourceCidrs(rule.getId());
- rule.setSourceCidrList(sourceCidrs);
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/IPAddressDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/IPAddressDao.java b/server/src/com/cloud/network/dao/IPAddressDao.java
deleted file mode 100755
index 3d588fa..0000000
--- a/server/src/com/cloud/network/dao/IPAddressDao.java
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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 java.util.List;
-
-import com.cloud.dc.Vlan.VlanType;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.net.Ip;
-
-public interface IPAddressDao extends GenericDao<IPAddressVO, Long> {
-
- IPAddressVO markAsUnavailable(long ipAddressId);
-
- void unassignIpAddress(long ipAddressId);
-
- List<IPAddressVO> listByAccount(long accountId);
-
- List<IPAddressVO> listByVlanId(long vlanId);
-
- List<IPAddressVO> listByDcIdIpAddress(long dcId, String ipAddress);
-
- List<IPAddressVO> listByDcId(long dcId);
-
- List<IPAddressVO> listByAssociatedNetwork(long networkId, Boolean isSourceNat);
-
- List<IPAddressVO> listStaticNatPublicIps(long networkId);
-
- int countIPs(long dcId, long vlanDbId, boolean onlyCountAllocated);
-
- int countIPs(long dcId, Long accountId, String vlanId, String vlanGateway, String vlanNetmask);
-
- long countAllocatedIPsForAccount(long accountId);
-
- boolean mark(long dcId, Ip ip);
-
- int countIPsForNetwork(long dcId, boolean onlyCountAllocated, VlanType vlanType);
-
- IPAddressVO findByAssociatedVmId(long vmId);
-
- IPAddressVO findByIpAndSourceNetworkId(long networkId, String ipAddress);
-
- public IPAddressVO findByIpAndDcId(long dcId, String ipAddress);
-
- List<IPAddressVO> listByPhysicalNetworkId(long physicalNetworkId);
-
- List<IPAddressVO> listByAssociatedVpc(long vpcId, Boolean isSourceNat);
-
- long countFreePublicIPs();
-
- long countFreeIPsInNetwork(long networkId);
- IPAddressVO findByVmIp(String vmIp);
-
- IPAddressVO findByAssociatedVmIdAndVmIp(long vmId, String vmIp);
-
- IPAddressVO findByIpAndNetworkId(long networkId, String ipAddress);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/IPAddressDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/IPAddressDaoImpl.java b/server/src/com/cloud/network/dao/IPAddressDaoImpl.java
deleted file mode 100755
index 73f310f..0000000
--- a/server/src/com/cloud/network/dao/IPAddressDaoImpl.java
+++ /dev/null
@@ -1,376 +0,0 @@
-// 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 java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.Date;
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.dc.Vlan.VlanType;
-import com.cloud.dc.VlanVO;
-import com.cloud.dc.dao.VlanDao;
-import com.cloud.dc.dao.VlanDaoImpl;
-import com.cloud.network.IpAddress.State;
-import com.cloud.server.ResourceTag.TaggedResourceType;
-import com.cloud.tags.dao.ResourceTagDao;
-import com.cloud.tags.dao.ResourceTagsDaoImpl;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.JoinBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.net.Ip;
-
-@Component
-@Local(value = { IPAddressDao.class })
-@DB
-public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implements IPAddressDao {
- private static final Logger s_logger = Logger.getLogger(IPAddressDaoImpl.class);
-
- protected SearchBuilder<IPAddressVO> AllFieldsSearch;
- protected SearchBuilder<IPAddressVO> VlanDbIdSearchUnallocated;
- protected GenericSearchBuilder<IPAddressVO, Integer> AllIpCount;
- protected GenericSearchBuilder<IPAddressVO, Integer> AllocatedIpCount;
- protected GenericSearchBuilder<IPAddressVO, Integer> AllIpCountForDashboard;
- protected GenericSearchBuilder<IPAddressVO, Long> AllocatedIpCountForAccount;
- @Inject protected VlanDao _vlanDao;
- protected GenericSearchBuilder<IPAddressVO, Long> CountFreePublicIps;
- @Inject ResourceTagDao _tagsDao;
-
- // make it public for JUnit test
- public IPAddressDaoImpl() {
- }
-
- @PostConstruct
- public void init() {
- AllFieldsSearch = createSearchBuilder();
- AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
- AllFieldsSearch.and("dataCenterId", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
- AllFieldsSearch.and("ipAddress", AllFieldsSearch.entity().getAddress(), Op.EQ);
- AllFieldsSearch.and("vlan", AllFieldsSearch.entity().getVlanId(), Op.EQ);
- AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAllocatedToAccountId(), Op.EQ);
- AllFieldsSearch.and("sourceNat", AllFieldsSearch.entity().isSourceNat(), Op.EQ);
- AllFieldsSearch.and("network", AllFieldsSearch.entity().getAssociatedWithNetworkId(), Op.EQ);
- AllFieldsSearch.and("associatedWithVmId", AllFieldsSearch.entity().getAssociatedWithVmId(), Op.EQ);
- AllFieldsSearch.and("oneToOneNat", AllFieldsSearch.entity().isOneToOneNat(), Op.EQ);
- AllFieldsSearch.and("sourcenetwork", AllFieldsSearch.entity().getSourceNetworkId(), Op.EQ);
- AllFieldsSearch.and("physicalNetworkId", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
- AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ);
- AllFieldsSearch.and("associatedVmIp", AllFieldsSearch.entity().getVmIp(), Op.EQ);
- AllFieldsSearch.done();
-
- VlanDbIdSearchUnallocated = createSearchBuilder();
- VlanDbIdSearchUnallocated.and("allocated", VlanDbIdSearchUnallocated.entity().getAllocatedTime(), Op.NULL);
- VlanDbIdSearchUnallocated.and("vlanDbId", VlanDbIdSearchUnallocated.entity().getVlanId(), Op.EQ);
- VlanDbIdSearchUnallocated.done();
-
- AllIpCount = createSearchBuilder(Integer.class);
- AllIpCount.select(null, Func.COUNT, AllIpCount.entity().getAddress());
- AllIpCount.and("dc", AllIpCount.entity().getDataCenterId(), Op.EQ);
- AllIpCount.and("vlan", AllIpCount.entity().getVlanId(), Op.EQ);
- AllIpCount.done();
-
- AllocatedIpCount = createSearchBuilder(Integer.class);
- AllocatedIpCount.select(null, Func.COUNT, AllocatedIpCount.entity().getAddress());
- AllocatedIpCount.and("dc", AllocatedIpCount.entity().getDataCenterId(), Op.EQ);
- AllocatedIpCount.and("vlan", AllocatedIpCount.entity().getVlanId(), Op.EQ);
- AllocatedIpCount.and("allocated", AllocatedIpCount.entity().getAllocatedTime(), Op.NNULL);
- AllocatedIpCount.done();
-
- AllIpCountForDashboard = createSearchBuilder(Integer.class);
- AllIpCountForDashboard.select(null, Func.COUNT, AllIpCountForDashboard.entity().getAddress());
- AllIpCountForDashboard.and("dc", AllIpCountForDashboard.entity().getDataCenterId(), Op.EQ);
- AllIpCountForDashboard.and("state", AllIpCountForDashboard.entity().getState(), SearchCriteria.Op.NEQ);
-
- SearchBuilder<VlanVO> virtaulNetworkVlan = _vlanDao.createSearchBuilder();
- virtaulNetworkVlan.and("vlanType", virtaulNetworkVlan.entity().getVlanType(), SearchCriteria.Op.EQ);
-
- AllIpCountForDashboard.join("vlan", virtaulNetworkVlan, virtaulNetworkVlan.entity().getId(),
- AllIpCountForDashboard.entity().getVlanId(), JoinBuilder.JoinType.INNER);
- virtaulNetworkVlan.done();
- AllIpCountForDashboard.done();
-
- AllocatedIpCountForAccount = createSearchBuilder(Long.class);
- AllocatedIpCountForAccount.select(null, Func.COUNT, AllocatedIpCountForAccount.entity().getAddress());
- AllocatedIpCountForAccount.and("account", AllocatedIpCountForAccount.entity().getAllocatedToAccountId(), Op.EQ);
- AllocatedIpCountForAccount.and("allocated", AllocatedIpCountForAccount.entity().getAllocatedTime(), Op.NNULL);
- AllocatedIpCountForAccount.and("network", AllocatedIpCountForAccount.entity().getAssociatedWithNetworkId(), Op.NNULL);
- AllocatedIpCountForAccount.done();
-
- CountFreePublicIps = createSearchBuilder(Long.class);
- CountFreePublicIps.select(null, Func.COUNT, null);
- CountFreePublicIps.and("state", CountFreePublicIps.entity().getState(), SearchCriteria.Op.EQ);
- CountFreePublicIps.and("networkId", CountFreePublicIps.entity().getSourceNetworkId(), SearchCriteria.Op.EQ);
- SearchBuilder<VlanVO> join = _vlanDao.createSearchBuilder();
- join.and("vlanType", join.entity().getVlanType(), Op.EQ);
- CountFreePublicIps.join("vlans", join, CountFreePublicIps.entity().getVlanId(), join.entity().getId(), JoinBuilder.JoinType.INNER);
- CountFreePublicIps.done();
- }
-
- @Override
- public boolean mark(long dcId, Ip ip) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("dataCenterId", dcId);
- sc.setParameters("ipAddress", ip);
-
- IPAddressVO vo = createForUpdate();
- vo.setAllocatedTime(new Date());
- vo.setState(State.Allocated);
-
- return update(vo, sc) >= 1;
- }
-
- @Override
- public void unassignIpAddress(long ipAddressId) {
- IPAddressVO address = createForUpdate();
- address.setAllocatedToAccountId(null);
- address.setAllocatedInDomainId(null);
- address.setAllocatedTime(null);
- address.setSourceNat(false);
- address.setOneToOneNat(false);
- address.setAssociatedWithVmId(null);
- address.setState(State.Free);
- address.setAssociatedWithNetworkId(null);
- address.setVpcId(null);
- address.setSystem(false);
- update(ipAddressId, address);
- }
-
- @Override
- public List<IPAddressVO> listByAccount(long accountId) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("accountId", accountId);
- return listBy(sc);
- }
-
- @Override
- public List<IPAddressVO> listByVlanId(long vlanId) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("vlan", vlanId);
- return listBy(sc);
- }
-
- @Override
- public IPAddressVO findByIpAndSourceNetworkId(long networkId, String ipAddress) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("sourcenetwork", networkId);
- sc.setParameters("ipAddress", ipAddress);
- return findOneBy(sc);
- }
-
- @Override
- public IPAddressVO findByIpAndNetworkId(long networkId, String ipAddress) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("network", networkId);
- sc.setParameters("ipAddress", ipAddress);
- return findOneBy(sc);
- }
-
- @Override
- public IPAddressVO findByIpAndDcId(long dcId, String ipAddress) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("dataCenterId", dcId);
- sc.setParameters("ipAddress", ipAddress);
- return findOneBy(sc);
- }
-
- @Override
- public List<IPAddressVO> listByDcId(long dcId) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("dataCenterId", dcId);
- return listBy(sc);
- }
-
- @Override
- public List<IPAddressVO> listByDcIdIpAddress(long dcId, String ipAddress) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("dataCenterId", dcId);
- sc.setParameters("ipAddress", ipAddress);
- return listBy(sc);
- }
-
- @Override
- public List<IPAddressVO> listByAssociatedNetwork(long networkId, Boolean isSourceNat) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("network", networkId);
-
- if (isSourceNat != null) {
- sc.setParameters("sourceNat", isSourceNat);
- }
-
- return listBy(sc);
- }
-
- @Override
- public List<IPAddressVO> listStaticNatPublicIps(long networkId) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("network", networkId);
- sc.setParameters("oneToOneNat", true);
- return listBy(sc);
- }
-
- @Override
- public IPAddressVO findByAssociatedVmId(long vmId) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("associatedWithVmId", vmId);
-
- return findOneBy(sc);
- }
-
- @Override
- public IPAddressVO findByVmIp(String vmIp) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("associatedVmIp", vmIp);
- return findOneBy(sc);
- }
- @Override
- public int countIPs(long dcId, long vlanId, boolean onlyCountAllocated) {
- SearchCriteria<Integer> sc = onlyCountAllocated ? AllocatedIpCount.create() : AllIpCount.create();
- sc.setParameters("dc", dcId);
- sc.setParameters("vlan", vlanId);
-
- return customSearch(sc, null).get(0);
- }
-
- @Override
- public int countIPsForNetwork(long dcId, boolean onlyCountAllocated, VlanType vlanType) {
- SearchCriteria<Integer> sc = AllIpCountForDashboard.create();
- sc.setParameters("dc", dcId);
- if (onlyCountAllocated){
- sc.setParameters("state", State.Free);
- }
- sc.setJoinParameters("vlan", "vlanType", vlanType.toString());
- return customSearch(sc, null).get(0);
- }
-
-
- @Override
- @DB
- public int countIPs(long dcId, Long accountId, String vlanId, String vlanGateway, String vlanNetmask) {
- Transaction txn = Transaction.currentTxn();
- int ipCount = 0;
- try {
- String sql = "SELECT count(*) FROM user_ip_address u INNER JOIN vlan v on (u.vlan_db_id = v.id AND v.data_center_id = ? AND v.vlan_id = ? AND v.vlan_gateway = ? AND v.vlan_netmask = ? AND u.account_id = ?)";
-
- PreparedStatement pstmt = txn.prepareAutoCloseStatement(sql);
- pstmt.setLong(1, dcId);
- pstmt.setString(2, vlanId);
- pstmt.setString(3, vlanGateway);
- pstmt.setString(4, vlanNetmask);
- pstmt.setLong(5, accountId);
- ResultSet rs = pstmt.executeQuery();
-
- if (rs.next()) {
- ipCount = rs.getInt(1);
- }
- } catch (Exception e) {
- s_logger.warn("Exception counting IP addresses", e);
- }
-
- return ipCount;
- }
-
- @Override @DB
- public IPAddressVO markAsUnavailable(long ipAddressId) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("id", ipAddressId);
-
- IPAddressVO ip = createForUpdate();
- ip.setState(State.Releasing);
- if (update(ip, sc) != 1) {
- return null;
- }
-
- return findOneBy(sc);
- }
-
- @Override
- public long countAllocatedIPsForAccount(long accountId) {
- SearchCriteria<Long> sc = AllocatedIpCountForAccount.create();
- sc.setParameters("account", accountId);
- return customSearch(sc, null).get(0);
- }
-
- @Override
- public List<IPAddressVO> listByPhysicalNetworkId(long physicalNetworkId) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("physicalNetworkId", physicalNetworkId);
- return listBy(sc);
- }
-
- @Override
- public long countFreePublicIPs() {
- SearchCriteria<Long> sc = CountFreePublicIps.create();
- sc.setParameters("state", State.Free);
- sc.setJoinParameters("vlans", "vlanType", VlanType.VirtualNetwork);
- return customSearch(sc, null).get(0);
- }
-
- @Override
- public List<IPAddressVO> listByAssociatedVpc(long vpcId, Boolean isSourceNat) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("vpcId", vpcId);
-
- if (isSourceNat != null) {
- sc.setParameters("sourceNat", isSourceNat);
- }
-
- return listBy(sc);
- }
-
- @Override
- public long countFreeIPsInNetwork(long networkId) {
- SearchCriteria<Long> sc = CountFreePublicIps.create();
- sc.setParameters("state", State.Free);
- sc.setParameters("networkId", networkId);
- return customSearch(sc, null).get(0);
- }
-
- @Override
- @DB
- public boolean remove(Long id) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
- IPAddressVO entry = findById(id);
- if (entry != null) {
- _tagsDao.removeByIdAndType(id, TaggedResourceType.SecurityGroup);
- }
- boolean result = super.remove(id);
- txn.commit();
- return result;
- }
-
- @Override
- public IPAddressVO findByAssociatedVmIdAndVmIp(long vmId, String vmIp) {
- SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
- sc.setParameters("associatedWithVmId", vmId);
- sc.setParameters("associatedVmIp", vmIp);
- return findOneBy(sc);
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/IPAddressVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/IPAddressVO.java b/server/src/com/cloud/network/dao/IPAddressVO.java
deleted file mode 100644
index c5c78e5..0000000
--- a/server/src/com/cloud/network/dao/IPAddressVO.java
+++ /dev/null
@@ -1,307 +0,0 @@
-// 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 java.util.Date;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-
-import org.apache.cloudstack.api.Identity;
-
-import com.cloud.network.IpAddress;
-import com.cloud.network.IpAddress.State;
-import com.cloud.utils.net.Ip;
-import org.apache.cloudstack.api.InternalIdentity;
-
-/**
- * A bean representing a public IP Address
- *
- */
-@Entity
-@Table(name=("user_ip_address"))
-public class IPAddressVO implements IpAddress {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- long id;
-
- @Column(name="account_id")
- private Long allocatedToAccountId = null;
-
- @Column(name="domain_id")
- private Long allocatedInDomainId = null;
-
- @Id
- @Column(name="public_ip_address")
- @Enumerated(value=EnumType.STRING)
- private Ip address = null;
-
- @Column(name="data_center_id", updatable=false)
- private long dataCenterId;
-
- @Column(name="source_nat")
- private boolean sourceNat;
-
- @Column(name="allocated")
- @Temporal(value=TemporalType.TIMESTAMP)
- private Date allocatedTime;
-
- @Column(name="vlan_db_id")
- private long vlanId;
-
- @Column(name="one_to_one_nat")
- private boolean oneToOneNat;
-
- @Column(name="vm_id")
- private Long associatedWithVmId;
-
- @Column(name="state")
- private State state;
-
- @Column(name="mac_address")
- private long macAddress;
-
- @Column(name="source_network_id")
- private Long sourceNetworkId;
-
- @Column(name="network_id")
- private Long associatedWithNetworkId;
-
- @Column(name="uuid")
- private String uuid;
-
- @Column(name="physical_network_id")
- private Long physicalNetworkId;
-
- @Column(name="is_system")
- private boolean system;
-
- @Column(name="account_id")
- @Transient
- private Long accountId = null;
-
- @Transient
- @Column(name="domain_id")
- private Long domainId = null;
-
- @Column(name="vpc_id")
- private Long vpcId;
-
- @Column(name="dnat_vmip")
- private String vmIp;
-
-
- protected IPAddressVO() {
- this.uuid = UUID.randomUUID().toString();
- }
-
- @Override
- public boolean readyToUse() {
- return state == State.Allocated;
- }
-
- public IPAddressVO(Ip address, long dataCenterId, long macAddress, long vlanDbId, boolean sourceNat) {
- this.address = address;
- this.dataCenterId = dataCenterId;
- this.vlanId = vlanDbId;
- this.sourceNat = sourceNat;
- this.allocatedInDomainId = null;
- this.allocatedToAccountId = null;
- this.allocatedTime = null;
- this.state = State.Free;
- this.macAddress = macAddress;
- this.uuid = UUID.randomUUID().toString();
- }
-
- public long getMacAddress() {
- return macAddress;
- }
-
- @Override
- public long getDataCenterId() {
- return dataCenterId;
- }
-
- @Override
- public Ip getAddress() {
- return address;
- }
-
- @Override
- public Long getAllocatedToAccountId() {
- return allocatedToAccountId;
- }
-
- @Override
- public Long getAllocatedInDomainId() {
- return allocatedInDomainId;
- }
-
- @Override
- public Long getAssociatedWithNetworkId() {
- return associatedWithNetworkId;
- }
-
- public void setAssociatedWithNetworkId(Long networkId) {
- this.associatedWithNetworkId = networkId;
- }
-
- @Override
- public Long getAssociatedWithVmId() {
- return associatedWithVmId;
- }
-
- public void setAssociatedWithVmId(Long associatedWithVmId) {
- this.associatedWithVmId = associatedWithVmId;
- }
-
- @Override
- public Date getAllocatedTime() {
- return allocatedTime;
- }
-
- public void setAllocatedToAccountId(Long accountId) {
- this.allocatedToAccountId = accountId;
- }
-
- public void setAllocatedInDomainId(Long domainId) {
- this.allocatedInDomainId = domainId;
- }
-
- public void setSourceNat(boolean sourceNat) {
- this.sourceNat = sourceNat;
- }
-
- @Override
- public boolean isSourceNat() {
- return sourceNat;
- }
-
- public void setAllocatedTime(Date allocated) {
- this.allocatedTime = allocated;
- }
-
- @Override
- public long getVlanId() {
- return this.vlanId;
- }
-
- public void setVlanId(long vlanDbId) {
- this.vlanId = vlanDbId;
- }
-
- @Override
- public boolean isOneToOneNat() {
- return oneToOneNat;
- }
-
- public void setOneToOneNat(boolean oneToOneNat) {
- this.oneToOneNat = oneToOneNat;
- }
-
- @Override
- public long getDomainId() {
- return allocatedInDomainId == null ? -1 : allocatedInDomainId;
- }
-
- @Override
- public long getAccountId() {
- return allocatedToAccountId == null ? -1 : allocatedToAccountId;
- }
-
- @Override
- public State getState() {
- return state;
- }
-
- public void setState(State state) {
- this.state = state;
- }
-
- @Override
- public String toString() {
- return new StringBuilder("Ip[").append(address).append("-").append(dataCenterId).append("]").toString();
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- public Long getSourceNetworkId() {
- return sourceNetworkId;
- }
-
- public void setSourceNetworkId(Long sourceNetworkId) {
- this.sourceNetworkId = sourceNetworkId;
- }
-
- @Override
- public String getUuid() {
- return this.uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public Long getPhysicalNetworkId() {
- return physicalNetworkId;
- }
-
- public void setPhysicalNetworkId(Long physicalNetworkId) {
- this.physicalNetworkId = physicalNetworkId;
- }
-
- @Override
- public boolean getSystem() {
- return system;
- }
-
- public void setSystem(boolean isSystem) {
- this.system = isSystem;
- }
-
- @Override
- public Long getVpcId() {
- return vpcId;
- }
-
- public void setVpcId(Long vpcId) {
- this.vpcId = vpcId;
- }
-
- @Override
- public String getVmIp() {
- return vmIp;
- }
-
- public void setVmIp(String vmIp) {
- this.vmIp = vmIp;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapDao.java b/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapDao.java
deleted file mode 100644
index 36a8eef..0000000
--- a/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapDao.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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 com.cloud.utils.db.GenericDao;
-
-public interface InlineLoadBalancerNicMapDao extends GenericDao<InlineLoadBalancerNicMapVO, Long> {
- InlineLoadBalancerNicMapVO findByPublicIpAddress(String publicIpAddress);
- InlineLoadBalancerNicMapVO findByNicId(long nicId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapDaoImpl.java b/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapDaoImpl.java
deleted file mode 100644
index f3f04ed..0000000
--- a/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapDaoImpl.java
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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 javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchCriteria;
-
-@Component
-@Local(value={InlineLoadBalancerNicMapDao.class})
-public class InlineLoadBalancerNicMapDaoImpl extends GenericDaoBase<InlineLoadBalancerNicMapVO, Long> implements InlineLoadBalancerNicMapDao {
-
- @Override
- public InlineLoadBalancerNicMapVO findByPublicIpAddress(String publicIpAddress) {
- SearchCriteria<InlineLoadBalancerNicMapVO> sc = createSearchCriteria();
- sc.addAnd("publicIpAddress", SearchCriteria.Op.EQ, publicIpAddress);
-
- return findOneBy(sc);
- }
-
- @Override
- public InlineLoadBalancerNicMapVO findByNicId(long nicId) {
- SearchCriteria<InlineLoadBalancerNicMapVO> sc = createSearchCriteria();
- sc.addAnd("nicId", SearchCriteria.Op.EQ, nicId);
-
- return findOneBy(sc);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapVO.java b/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapVO.java
deleted file mode 100644
index 35aeefa..0000000
--- a/server/src/com/cloud/network/dao/InlineLoadBalancerNicMapVO.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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 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=("inline_load_balancer_nic_map"))
-public class InlineLoadBalancerNicMapVO implements InternalIdentity {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="public_ip_address")
- private String publicIpAddress;
-
- @Column(name="nic_id")
- private long nicId;
-
- public InlineLoadBalancerNicMapVO() { }
-
- public InlineLoadBalancerNicMapVO(String publicIpAddress, long nicId) {
- this.publicIpAddress = publicIpAddress;
- this.nicId = nicId;
- }
-
- public long getId() {
- return id;
- }
-
- public String getPublicIpAddress() {
- return publicIpAddress;
- }
-
- public long getNicId() {
- return nicId;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LBHealthCheckPolicyDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LBHealthCheckPolicyDao.java b/server/src/com/cloud/network/dao/LBHealthCheckPolicyDao.java
deleted file mode 100644
index 42a9e42..0000000
--- a/server/src/com/cloud/network/dao/LBHealthCheckPolicyDao.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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 java.util.List;
-
-import com.cloud.network.LBHealthCheckPolicyVO;
-import com.cloud.utils.db.GenericDao;
-
-
-public interface LBHealthCheckPolicyDao extends
- GenericDao<LBHealthCheckPolicyVO, Long> {
- void remove(long loadBalancerId);
-
- void remove(long loadBalancerId, Boolean pending);
-
- List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId);
-
- List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId,
- boolean revoke);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LBHealthCheckPolicyDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LBHealthCheckPolicyDaoImpl.java b/server/src/com/cloud/network/dao/LBHealthCheckPolicyDaoImpl.java
deleted file mode 100644
index 65e0689..0000000
--- a/server/src/com/cloud/network/dao/LBHealthCheckPolicyDaoImpl.java
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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 java.util.List;
-
-import javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.network.LBHealthCheckPolicyVO;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchCriteria;
-
-
-@Component
-@Local(value = { LBHealthCheckPolicyDao.class })
-public class LBHealthCheckPolicyDaoImpl extends
- GenericDaoBase<LBHealthCheckPolicyVO, Long> implements
- LBHealthCheckPolicyDao {
-
- @Override
- public void remove(long loadBalancerId) {
- SearchCriteria<LBHealthCheckPolicyVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
-
- expunge(sc);
- }
-
- @Override
- public void remove(long loadBalancerId, Boolean revoke) {
- SearchCriteria<LBHealthCheckPolicyVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
- sc.addAnd("revoke", SearchCriteria.Op.EQ, revoke);
-
- expunge(sc);
- }
-
- @Override
- public List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId) {
- SearchCriteria<LBHealthCheckPolicyVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
-
- return listBy(sc);
- }
-
- @Override
- public List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId,
- boolean pending) {
- SearchCriteria<LBHealthCheckPolicyVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
- sc.addAnd("revoke", SearchCriteria.Op.EQ, pending);
-
- return listBy(sc);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LBStickinessPolicyDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LBStickinessPolicyDao.java b/server/src/com/cloud/network/dao/LBStickinessPolicyDao.java
deleted file mode 100644
index 9a25c1a..0000000
--- a/server/src/com/cloud/network/dao/LBStickinessPolicyDao.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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 java.util.List;
-
-import com.cloud.utils.db.GenericDao;
-
-
-public interface LBStickinessPolicyDao extends
- GenericDao<LBStickinessPolicyVO, Long> {
- void remove(long loadBalancerId);
-
- void remove(long loadBalancerId, Boolean pending);
-
- List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId);
-
- List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId,
- boolean revoke);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LBStickinessPolicyDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LBStickinessPolicyDaoImpl.java b/server/src/com/cloud/network/dao/LBStickinessPolicyDaoImpl.java
deleted file mode 100644
index 43b4669..0000000
--- a/server/src/com/cloud/network/dao/LBStickinessPolicyDaoImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-// 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 java.util.List;
-
-import javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchCriteria;
-
-@Component
-@Local(value = { LBStickinessPolicyDao.class })
-public class LBStickinessPolicyDaoImpl extends
- GenericDaoBase<LBStickinessPolicyVO, Long> implements
- LBStickinessPolicyDao {
-
- @Override
- public void remove(long loadBalancerId) {
- SearchCriteria<LBStickinessPolicyVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
-
- expunge(sc);
- }
-
- @Override
- public void remove(long loadBalancerId, Boolean revoke) {
- SearchCriteria<LBStickinessPolicyVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
- sc.addAnd("revoke", SearchCriteria.Op.EQ, revoke);
-
- expunge(sc);
- }
-
- @Override
- public List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId) {
- SearchCriteria<LBStickinessPolicyVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
-
- return listBy(sc);
- }
-
- @Override
- public List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId,
- boolean pending) {
- SearchCriteria<LBStickinessPolicyVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
- sc.addAnd("revoke", SearchCriteria.Op.EQ, pending);
-
- return listBy(sc);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LBStickinessPolicyVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LBStickinessPolicyVO.java b/server/src/com/cloud/network/dao/LBStickinessPolicyVO.java
deleted file mode 100644
index 3fbba68..0000000
--- a/server/src/com/cloud/network/dao/LBStickinessPolicyVO.java
+++ /dev/null
@@ -1,145 +0,0 @@
-// 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 java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.PrimaryKeyJoinColumn;
-import javax.persistence.Table;
-import com.cloud.network.rules.StickinessPolicy;
-import com.cloud.utils.Pair;
-import org.apache.cloudstack.api.InternalIdentity;
-
-@Entity
-@Table(name = ("load_balancer_stickiness_policies"))
-@PrimaryKeyJoinColumn(name = "load_balancer_id", referencedColumnName = "id")
-public class LBStickinessPolicyVO implements StickinessPolicy {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- private long id;
-
- @Column(name = "load_balancer_id")
- private long loadBalancerId;
-
- @Column(name = "name")
- private String name;
-
- @Column(name = "description")
- private String description;
-
- @Column(name = "method_name")
- private String methodName;
-
- @Column(name = "params")
- private String paramsInDB;
-
- @Column(name = "uuid")
- private String uuid;
-
- @Column(name = "revoke")
- private boolean revoke = false;
- protected LBStickinessPolicyVO() {
- this.uuid = UUID.randomUUID().toString();
- }
-
-/* get the params in Map format and converts in to string format and stores in DB
- * paramsInDB represent the string stored in database :
- * Format : param1=value1¶m2=value2¶m3=value3&
- * Example for App cookie method: "name=cookapp&length=12&holdtime=3h" . Here 3 parameters name,length and holdtime with corresponding values.
- * getParams function is used to get in List<Pair<string,String>> Format.
- * - API response use Map format
- * - In database plain String with DB_PARM_DELIMITER
- * - rest of the code uses List<Pair<string,String>>
- */
- public LBStickinessPolicyVO(long loadBalancerId, String name, String methodName, Map paramList, String description) {
- this.loadBalancerId = loadBalancerId;
- this.name = name;
- this.methodName = methodName;
- StringBuilder sb = new StringBuilder("");
-
- if (paramList != null) {
- Iterator<HashMap<String, String>> iter = paramList.values().iterator();
- while (iter.hasNext()) {
- HashMap<String, String> paramKVpair = iter.next();
- String paramName = paramKVpair.get("name");
- String paramValue = paramKVpair.get("value");
- sb.append(paramName + "=" + paramValue + "&");
- }
- }
- paramsInDB = sb.toString();
- this.description = description;
- this.uuid = UUID.randomUUID().toString();
- }
-
- public List<Pair<String, String>> getParams() {
- List<Pair<String, String>> paramsList = new ArrayList<Pair<String, String>>();
- String[] params = paramsInDB.split("[=&]");
-
- for (int i = 0; i < (params.length - 1); i = i + 2) {
- paramsList.add(new Pair<String, String>(params[i], params[i + 1]));
- }
- return paramsList;
- }
-
- public long getId() {
- return id;
- }
-
- public long getLoadBalancerId() {
- return loadBalancerId;
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public boolean isRevoke() {
- return revoke;
- }
-
- public void setRevoke(boolean revoke) {
- this.revoke = revoke;
- }
-
- @Override
- public String getUuid() {
- return this.uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LoadBalancerDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LoadBalancerDao.java b/server/src/com/cloud/network/dao/LoadBalancerDao.java
deleted file mode 100644
index 611282e..0000000
--- a/server/src/com/cloud/network/dao/LoadBalancerDao.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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 java.util.List;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface LoadBalancerDao extends GenericDao<LoadBalancerVO, Long> {
- List<Long> listInstancesByLoadBalancer(long loadBalancerId);
-
- List<LoadBalancerVO> listByIpAddress(long ipAddressId);
-
- LoadBalancerVO findByIpAddressAndPublicPort(long ipAddressId, String publicPort);
-
- LoadBalancerVO findByAccountAndName(Long accountId, String name);
-
- List<LoadBalancerVO> listByNetworkId(long networkId);
-
- List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java b/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
deleted file mode 100644
index f211a7f..0000000
--- a/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
+++ /dev/null
@@ -1,137 +0,0 @@
-// 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 java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.network.rules.FirewallRule.State;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
-
-@Component
-@Local(value = { LoadBalancerDao.class })
-public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> implements LoadBalancerDao {
- private static final Logger s_logger = Logger.getLogger(LoadBalancerDaoImpl.class);
- private static final String LIST_INSTANCES_BY_LOAD_BALANCER = "SELECT vm.id " +
- " FROM vm_instance vm, load_balancer lb, ip_forwarding fwd, user_ip_address ip " +
- " WHERE lb.id = ? AND " +
- " fwd.group_id = lb.id AND " +
- " fwd.forwarding = 0 AND " +
- " fwd.private_ip_address = vm.private_ip_address AND " +
- " lb.ip_address = ip.public_ip_address AND " +
- " ip.data_center_id = vm.data_center_id ";
- private final SearchBuilder<LoadBalancerVO> ListByIp;
- private final SearchBuilder<LoadBalancerVO> IpAndPublicPortSearch;
- private final SearchBuilder<LoadBalancerVO> AccountAndNameSearch;
- protected final SearchBuilder<LoadBalancerVO> TransitionStateSearch;
-
- @Inject protected FirewallRulesCidrsDao _portForwardingRulesCidrsDao;
-
- protected LoadBalancerDaoImpl() {
- ListByIp = createSearchBuilder();
- ListByIp.and("ipAddressId", ListByIp.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
- ListByIp.and("networkId", ListByIp.entity().getNetworkId(), SearchCriteria.Op.EQ);
- ListByIp.done();
-
- IpAndPublicPortSearch = createSearchBuilder();
- IpAndPublicPortSearch.and("ipAddressId", IpAndPublicPortSearch.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
- IpAndPublicPortSearch.and("publicPort", IpAndPublicPortSearch.entity().getSourcePortStart(), SearchCriteria.Op.EQ);
- IpAndPublicPortSearch.done();
-
- AccountAndNameSearch = createSearchBuilder();
- AccountAndNameSearch.and("accountId", AccountAndNameSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
- AccountAndNameSearch.and("name", AccountAndNameSearch.entity().getName(), SearchCriteria.Op.EQ);
- AccountAndNameSearch.done();
-
- TransitionStateSearch = createSearchBuilder();
- TransitionStateSearch.and("networkId", TransitionStateSearch.entity().getNetworkId(), Op.EQ);
- TransitionStateSearch.and("state", TransitionStateSearch.entity().getState(), Op.IN);
- TransitionStateSearch.done();
- }
-
- @Override
- public List<Long> listInstancesByLoadBalancer(long loadBalancerId) {
- Transaction txn = Transaction.currentTxn();
- String sql = LIST_INSTANCES_BY_LOAD_BALANCER;
- PreparedStatement pstmt = null;
- List<Long> instanceList = new ArrayList<Long>();
- try {
- pstmt = txn.prepareAutoCloseStatement(sql);
- pstmt.setLong(1, loadBalancerId);
-
- ResultSet rs = pstmt.executeQuery();
- while (rs.next()) {
- Long vmId = rs.getLong(1);
- instanceList.add(vmId);
- }
- } catch (Exception ex) {
- s_logger.error("error getting recent usage network stats", ex);
- }
- return instanceList;
- }
-
- @Override
- public List<LoadBalancerVO> listByIpAddress(long ipAddressId) {
- SearchCriteria<LoadBalancerVO> sc = ListByIp.create();
- sc.setParameters("ipAddressId", ipAddressId);
- return listBy(sc);
- }
-
- @Override
- public List<LoadBalancerVO> listByNetworkId(long networkId) {
- SearchCriteria<LoadBalancerVO> sc = ListByIp.create();
- sc.setParameters("networkId", networkId);
- return listBy(sc);
- }
-
- @Override
- public LoadBalancerVO findByIpAddressAndPublicPort(long ipAddressId, String publicPort) {
- SearchCriteria<LoadBalancerVO> sc = IpAndPublicPortSearch.create();
- sc.setParameters("ipAddressId", ipAddressId);
- sc.setParameters("publicPort", publicPort);
- return findOneBy(sc);
- }
-
- @Override
- public LoadBalancerVO findByAccountAndName(Long accountId, String name) {
- SearchCriteria<LoadBalancerVO> sc = AccountAndNameSearch.create();
- sc.setParameters("accountId", accountId);
- sc.setParameters("name", name);
- return findOneBy(sc);
- }
-
- @Override
- public List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId) {
- SearchCriteria<LoadBalancerVO> sc = TransitionStateSearch.create();
- sc.setParameters("networkId", networkId);
- sc.setParameters("state", State.Add.toString(), State.Revoke.toString());
- return listBy(sc);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LoadBalancerVMMapDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LoadBalancerVMMapDao.java b/server/src/com/cloud/network/dao/LoadBalancerVMMapDao.java
deleted file mode 100644
index e122d0a..0000000
--- a/server/src/com/cloud/network/dao/LoadBalancerVMMapDao.java
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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 java.util.List;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface LoadBalancerVMMapDao extends GenericDao<LoadBalancerVMMapVO, Long> {
- void remove(long loadBalancerId);
- void remove(long loadBalancerId, List<Long> instanceIds, Boolean pending);
- List<LoadBalancerVMMapVO> listByInstanceId(long instanceId);
- List<LoadBalancerVMMapVO> listByLoadBalancerId(long loadBalancerId);
- List<LoadBalancerVMMapVO> listByLoadBalancerId(long loadBalancerId, boolean revoke);
- LoadBalancerVMMapVO findByLoadBalancerIdAndVmId(long loadBalancerId, long instanceId);
- boolean isVmAttachedToLoadBalancer(long loadBalancerId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java b/server/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java
deleted file mode 100644
index 8f979cd..0000000
--- a/server/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-// 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 java.util.List;
-
-import javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-
-@Component
-@Local(value={LoadBalancerVMMapDao.class})
-public class LoadBalancerVMMapDaoImpl extends GenericDaoBase<LoadBalancerVMMapVO, Long> implements LoadBalancerVMMapDao {
-
- @Override
- public void remove(long loadBalancerId) {
- SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
-
- expunge(sc);
- }
-
- @Override
- public void remove(long loadBalancerId, List<Long> instanceIds, Boolean revoke) {
- SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
- sc.addAnd("instanceId", SearchCriteria.Op.IN, instanceIds.toArray());
- if (revoke != null) {
- sc.addAnd("revoke", SearchCriteria.Op.EQ, revoke);
- }
-
- expunge(sc);
- }
-
- @Override
- public List<LoadBalancerVMMapVO> listByInstanceId(long instanceId) {
- SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
- sc.addAnd("instanceId", SearchCriteria.Op.EQ, instanceId);
-
- return listBy(sc);
- }
-
- @Override
- public List<LoadBalancerVMMapVO> listByLoadBalancerId(long loadBalancerId) {
- SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
-
- return listBy(sc);
- }
-
- @Override
- public List<LoadBalancerVMMapVO> listByLoadBalancerId(long loadBalancerId, boolean pending) {
- SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
- sc.addAnd("revoke", SearchCriteria.Op.EQ, pending);
-
- return listBy(sc);
- }
-
- @Override
- public LoadBalancerVMMapVO findByLoadBalancerIdAndVmId(long loadBalancerId, long instanceId) {
- SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
- sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
- sc.addAnd("instanceId", SearchCriteria.Op.EQ, instanceId);
- return findOneBy(sc);
- }
-
- @Override
- public boolean isVmAttachedToLoadBalancer(long loadBalancerId) {
- GenericSearchBuilder<LoadBalancerVMMapVO, Long> CountByAccount = createSearchBuilder(Long.class);
- CountByAccount.select(null, Func.COUNT, null);
- CountByAccount.and("loadBalancerId", CountByAccount.entity().getLoadBalancerId(), SearchCriteria.Op.EQ);
-
- SearchCriteria<Long> sc = CountByAccount.create();
- sc.setParameters("loadBalancerId", loadBalancerId);
- return customSearch(sc, null).get(0) > 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LoadBalancerVMMapVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LoadBalancerVMMapVO.java b/server/src/com/cloud/network/dao/LoadBalancerVMMapVO.java
deleted file mode 100644
index 852302e..0000000
--- a/server/src/com/cloud/network/dao/LoadBalancerVMMapVO.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// 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 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=("load_balancer_vm_map"))
-public class LoadBalancerVMMapVO implements InternalIdentity {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name="load_balancer_id")
- private long loadBalancerId;
-
- @Column(name="instance_id")
- private long instanceId;
-
- @Column(name = "revoke")
- private boolean revoke = false;
-
- @Column(name = "state")
- private String state;
-
- public LoadBalancerVMMapVO() {
- }
-
- public LoadBalancerVMMapVO(long loadBalancerId, long instanceId) {
- this.loadBalancerId = loadBalancerId;
- this.instanceId = instanceId;
- }
-
- public LoadBalancerVMMapVO(long loadBalancerId, long instanceId, boolean revoke) {
- this.loadBalancerId = loadBalancerId;
- this.instanceId = instanceId;
- this.revoke = revoke;
- }
-
- public long getId() {
- return id;
- }
-
- public long getLoadBalancerId() {
- return loadBalancerId;
- }
-
- public long getInstanceId() {
- return instanceId;
- }
-
- public boolean isRevoke() {
- return revoke;
- }
-
- public void setRevoke(boolean revoke) {
- this.revoke = revoke;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/LoadBalancerVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LoadBalancerVO.java b/server/src/com/cloud/network/dao/LoadBalancerVO.java
deleted file mode 100644
index 5422f41..0000000
--- a/server/src/com/cloud/network/dao/LoadBalancerVO.java
+++ /dev/null
@@ -1,98 +0,0 @@
-// 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 javax.persistence.Column;
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
-import javax.persistence.PrimaryKeyJoinColumn;
-import javax.persistence.Table;
-
-import com.cloud.network.rules.FirewallRuleVO;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.utils.net.NetUtils;
-
-@Entity
-@Table(name=("load_balancing_rules"))
-@DiscriminatorValue(value="LoadBalancing")
-@PrimaryKeyJoinColumn(name="id")
-public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
-
- @Column(name="name")
- private String name;
-
- @Column(name="description", length=4096)
- private String description;
-
- @Column(name="algorithm")
- private String algorithm;
-
- @Column(name="default_port_start")
- private int defaultPortStart;
-
- @Column(name="default_port_end")
- private int defaultPortEnd;
-
- public LoadBalancerVO() {
- }
-
- public LoadBalancerVO(String xId, String name, String description, long srcIpId, int srcPort, int dstPort, String algorithm, long networkId, long accountId, long domainId) {
- super(xId, srcIpId, srcPort, NetUtils.TCP_PROTO, networkId, accountId, domainId, Purpose.LoadBalancing, null, null, null, null);
- this.name = name;
- this.description = description;
- this.algorithm = algorithm;
- this.defaultPortStart = dstPort;
- this.defaultPortEnd = dstPort;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- @Override
- public String getAlgorithm() {
- return algorithm;
- }
-
- @Override
- public int getDefaultPortStart() {
- return defaultPortStart;
- }
-
- @Override
- public int getDefaultPortEnd() {
- return defaultPortEnd;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setAlgorithm(String algorithm) {
- this.algorithm = algorithm;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/NetworkAccountDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/NetworkAccountDao.java b/server/src/com/cloud/network/dao/NetworkAccountDao.java
deleted file mode 100644
index c4435c8..0000000
--- a/server/src/com/cloud/network/dao/NetworkAccountDao.java
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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 com.cloud.utils.db.GenericDao;
-
-public interface NetworkAccountDao extends GenericDao<NetworkAccountVO, Long> {
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java b/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
deleted file mode 100644
index 0947905..0000000
--- a/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// 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.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.db.GenericDaoBase;
-
-@Component
-public class NetworkAccountDaoImpl extends GenericDaoBase<NetworkAccountVO, Long> implements NetworkAccountDao {
- public NetworkAccountDaoImpl() {
- super();
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/dao/NetworkAccountVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/NetworkAccountVO.java b/server/src/com/cloud/network/dao/NetworkAccountVO.java
deleted file mode 100644
index afce805..0000000
--- a/server/src/com/cloud/network/dao/NetworkAccountVO.java
+++ /dev/null
@@ -1,72 +0,0 @@
-// 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 javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import com.cloud.user.OwnedBy;
-import org.apache.cloudstack.api.InternalIdentity;
-
-@Entity
-@Table(name="account_network_ref")
-public class NetworkAccountVO implements OwnedBy, InternalIdentity {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- long id;
-
- @Column(name="account_id")
- long accountId;
-
- @Column(name="network_id")
- long networkId;
-
- @Column(name="is_owner")
- boolean owner;
-
- protected NetworkAccountVO() {
- }
-
- public NetworkAccountVO(long networkId, long accountId, boolean owner) {
- this.networkId = networkId;
- this.accountId = accountId;
- this.owner = owner;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public long getAccountId() {
- return accountId;
- }
-
- public long getNetworkId() {
- return networkId;
- }
-
- public boolean isOwner() {
- return owner;
- }
-
-}