You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/05/08 13:59:36 UTC
[07/90] [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/security/dao/SecurityGroupDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupDao.java b/server/src/com/cloud/network/security/dao/SecurityGroupDao.java
deleted file mode 100644
index 482e13c..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupDao.java
+++ /dev/null
@@ -1,30 +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.security.dao;
-
-import java.util.List;
-
-import com.cloud.network.security.SecurityGroupVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface SecurityGroupDao extends GenericDao<SecurityGroupVO, Long> {
- List<SecurityGroupVO> listByAccountId(long accountId);
- boolean isNameInUse(Long accountId, Long domainId, String name);
- SecurityGroupVO findByAccountAndName(Long accountId, String name);
- List<SecurityGroupVO> findByAccountAndNames(Long accountId, String... names);
- int removeByAccountId(long accountId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java b/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java
deleted file mode 100644
index d82cc4a..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java
+++ /dev/null
@@ -1,136 +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.security.dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.network.security.SecurityGroupVO;
-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.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.Transaction;
-
-@Component
-@Local(value={SecurityGroupDao.class})
-public class SecurityGroupDaoImpl extends GenericDaoBase<SecurityGroupVO, Long> implements SecurityGroupDao {
- private SearchBuilder<SecurityGroupVO> AccountIdSearch;
- private SearchBuilder<SecurityGroupVO> AccountIdNameSearch;
- private SearchBuilder<SecurityGroupVO> AccountIdNamesSearch;
- @Inject ResourceTagDao _tagsDao;
-
-
- protected SecurityGroupDaoImpl() {
- AccountIdSearch = createSearchBuilder();
- AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
- AccountIdSearch.done();
-
- AccountIdNameSearch = createSearchBuilder();
- AccountIdNameSearch.and("accountId", AccountIdNameSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
- AccountIdNameSearch.and("name", AccountIdNameSearch.entity().getName(), SearchCriteria.Op.EQ);
-
- AccountIdNamesSearch = createSearchBuilder();
- AccountIdNamesSearch.and("accountId", AccountIdNamesSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
- AccountIdNamesSearch.and("groupNames", AccountIdNamesSearch.entity().getName(), SearchCriteria.Op.IN);
- AccountIdNameSearch.done();
- }
-
- @Override
- public List<SecurityGroupVO> listByAccountId(long accountId) {
- SearchCriteria<SecurityGroupVO> sc = AccountIdSearch.create();
- sc.setParameters("accountId", accountId);
- return listBy(sc);
- }
-
- @Override
- public boolean isNameInUse(Long accountId, Long domainId, String name) {
- SearchCriteria<SecurityGroupVO> sc = createSearchCriteria();
- sc.addAnd("name", SearchCriteria.Op.EQ, name);
- if (accountId != null) {
- sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
- } else {
- sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
- sc.addAnd("accountId", SearchCriteria.Op.NULL);
- }
-
- List<SecurityGroupVO> securityGroups = listBy(sc);
- return ((securityGroups != null) && !securityGroups.isEmpty());
- }
-
- @Override
- public SecurityGroupVO findByAccountAndName(Long accountId, String name) {
- SearchCriteria<SecurityGroupVO> sc = AccountIdNameSearch.create();
- sc.setParameters("accountId", accountId);
- sc.setParameters("name", name);
-
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- public List<SecurityGroupVO> findByAccountAndNames(Long accountId, String... names) {
- SearchCriteria<SecurityGroupVO> sc = AccountIdNamesSearch.create();
- sc.setParameters("accountId", accountId);
-
- sc.setParameters("groupNames", (Object [])names);
-
- return listBy(sc);
- }
- @Override
- public int removeByAccountId(long accountId) {
- SearchCriteria<SecurityGroupVO> sc = AccountIdSearch.create();
- sc.setParameters("accountId", accountId);
- return expunge(sc);
- }
-
-
- @Override
- @DB
- public boolean remove(Long id) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
- SecurityGroupVO entry = findById(id);
- if (entry != null) {
- _tagsDao.removeByIdAndType(id, TaggedResourceType.SecurityGroup);
- }
- boolean result = super.remove(id);
- txn.commit();
- return result;
- }
-
- @Override
- @DB
- public boolean expunge(Long id) {
- Transaction txn = Transaction.currentTxn();
- txn.start();
- SecurityGroupVO entry = findById(id);
- if (entry != null) {
- _tagsDao.removeByIdAndType(id, TaggedResourceType.SecurityGroup);
- }
- boolean result = super.expunge(id);
- txn.commit();
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/SecurityGroupRuleDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupRuleDao.java b/server/src/com/cloud/network/security/dao/SecurityGroupRuleDao.java
deleted file mode 100644
index 4668aa4..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupRuleDao.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.security.dao;
-
-import java.util.List;
-
-import com.cloud.network.security.SecurityGroupRuleVO;
-import com.cloud.network.security.SecurityRule.SecurityRuleType;
-import com.cloud.utils.db.GenericDao;
-
-public interface SecurityGroupRuleDao extends GenericDao<SecurityGroupRuleVO, Long> {
- List<SecurityGroupRuleVO> listBySecurityGroupId(long securityGroupId, SecurityRuleType type);
- List<SecurityGroupRuleVO> listByAllowedSecurityGroupId(long networkGroupId);
- SecurityGroupRuleVO findByProtoPortsAndCidr(long networkGroupId, String proto, int startPort, int endPort, String cidr);
- SecurityGroupRuleVO findByProtoPortsAndGroup(String proto, int startPort, int endPort, String networkGroup);
- SecurityGroupRuleVO findByProtoPortsAndAllowedGroupId(long networkGroupId, String proto, int startPort, int endPort, Long allowedGroupId);
- int deleteBySecurityGroup(long securityGroupId);
- int deleteByPortProtoAndGroup(long securityGroupId, String protocol, int startPort,int endPort, Long id);
- int deleteByPortProtoAndCidr(long securityGroupId, String protocol, int startPort,int endPort, String cidr);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/SecurityGroupRuleDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupRuleDaoImpl.java b/server/src/com/cloud/network/security/dao/SecurityGroupRuleDaoImpl.java
deleted file mode 100644
index 346ed26..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupRuleDaoImpl.java
+++ /dev/null
@@ -1,176 +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.security.dao;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.network.security.SecurityGroupRuleVO;
-import com.cloud.network.security.SecurityGroupVO;
-import com.cloud.network.security.SecurityRule.SecurityRuleType;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.JoinBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-@Component
-@Local(value={SecurityGroupRuleDao.class})
-public class SecurityGroupRuleDaoImpl extends GenericDaoBase<SecurityGroupRuleVO, Long> implements SecurityGroupRuleDao {
-
- @Inject SecurityGroupDao _securityGroupDao;
-
- protected SearchBuilder<SecurityGroupRuleVO> securityGroupIdSearch;
- protected SearchBuilder<SecurityGroupRuleVO> securityGroupIdAndTypeSearch;
- protected SearchBuilder<SecurityGroupRuleVO> allowedSecurityGroupIdSearch;
- protected SearchBuilder<SecurityGroupRuleVO> protoPortsAndCidrSearch;
- protected SearchBuilder<SecurityGroupRuleVO> protoPortsAndSecurityGroupNameSearch;
- protected SearchBuilder<SecurityGroupRuleVO> protoPortsAndSecurityGroupIdSearch;
-
-
-
- protected SecurityGroupRuleDaoImpl() {
- securityGroupIdSearch = createSearchBuilder();
- securityGroupIdSearch.and("securityGroupId", securityGroupIdSearch.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
- securityGroupIdSearch.done();
-
- securityGroupIdAndTypeSearch = createSearchBuilder();
- securityGroupIdAndTypeSearch.and("securityGroupId", securityGroupIdAndTypeSearch.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
- securityGroupIdAndTypeSearch.and("type", securityGroupIdAndTypeSearch.entity().getType(), SearchCriteria.Op.EQ);
- securityGroupIdAndTypeSearch.done();
-
- allowedSecurityGroupIdSearch = createSearchBuilder();
- allowedSecurityGroupIdSearch.and("allowedNetworkId", allowedSecurityGroupIdSearch.entity().getAllowedNetworkId(), SearchCriteria.Op.EQ);
- allowedSecurityGroupIdSearch.done();
-
- protoPortsAndCidrSearch = createSearchBuilder();
- protoPortsAndCidrSearch.and("securityGroupId", protoPortsAndCidrSearch.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
- protoPortsAndCidrSearch.and("proto", protoPortsAndCidrSearch.entity().getProtocol(), SearchCriteria.Op.EQ);
- protoPortsAndCidrSearch.and("startPort", protoPortsAndCidrSearch.entity().getStartPort(), SearchCriteria.Op.EQ);
- protoPortsAndCidrSearch.and("endPort", protoPortsAndCidrSearch.entity().getEndPort(), SearchCriteria.Op.EQ);
- protoPortsAndCidrSearch.and("cidr", protoPortsAndCidrSearch.entity().getAllowedSourceIpCidr(), SearchCriteria.Op.EQ);
- protoPortsAndCidrSearch.done();
-
- protoPortsAndSecurityGroupIdSearch = createSearchBuilder();
- protoPortsAndSecurityGroupIdSearch.and("securityGroupId", protoPortsAndSecurityGroupIdSearch.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
- protoPortsAndSecurityGroupIdSearch.and("proto", protoPortsAndSecurityGroupIdSearch.entity().getProtocol(), SearchCriteria.Op.EQ);
- protoPortsAndSecurityGroupIdSearch.and("startPort", protoPortsAndSecurityGroupIdSearch.entity().getStartPort(), SearchCriteria.Op.EQ);
- protoPortsAndSecurityGroupIdSearch.and("endPort", protoPortsAndSecurityGroupIdSearch.entity().getEndPort(), SearchCriteria.Op.EQ);
- protoPortsAndSecurityGroupIdSearch.and("allowedNetworkId", protoPortsAndSecurityGroupIdSearch.entity().getAllowedNetworkId(), SearchCriteria.Op.EQ);
-
- }
-
- public List<SecurityGroupRuleVO> listBySecurityGroupId(long securityGroupId, SecurityRuleType type) {
- SearchCriteria<SecurityGroupRuleVO> sc = securityGroupIdAndTypeSearch.create();
- sc.setParameters("securityGroupId", securityGroupId);
- String dbType;
- if (type == SecurityRuleType.EgressRule) {
- dbType = SecurityRuleType.EgressRule.getType();
- }else {
- dbType = SecurityRuleType.IngressRule.getType();
- }
-
- sc.setParameters("type", dbType);
- return listBy(sc);
- }
-
- public int deleteBySecurityGroup(long securityGroupId) {
- SearchCriteria<SecurityGroupRuleVO> sc = securityGroupIdSearch.create();
- sc.setParameters("securityGroupId", securityGroupId);
- return expunge(sc);
- }
-
- @Override
- public List<SecurityGroupRuleVO> listByAllowedSecurityGroupId(long securityGroupId) {
- SearchCriteria<SecurityGroupRuleVO> sc = allowedSecurityGroupIdSearch.create();
- sc.setParameters("allowedNetworkId", securityGroupId);
- return listBy(sc);
- }
-
- @Override
- public SecurityGroupRuleVO findByProtoPortsAndCidr(long securityGroupId,
- String proto, int startPort, int endPort, String cidr) {
- SearchCriteria<SecurityGroupRuleVO> sc = protoPortsAndCidrSearch.create();
- sc.setParameters("securityGroupId", securityGroupId);
- sc.setParameters("proto", proto);
- sc.setParameters("startPort", startPort);
- sc.setParameters("endPort", endPort);
- sc.setParameters("cidr", cidr);
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- public SecurityGroupRuleVO findByProtoPortsAndGroup(String proto, int startPort, int endPort, String securityGroup) {
- SearchCriteria<SecurityGroupRuleVO> sc = protoPortsAndSecurityGroupNameSearch.create();
- sc.setParameters("proto", proto);
- sc.setParameters("startPort", startPort);
- sc.setParameters("endPort", endPort);
- sc.setJoinParameters("groupName", "groupName", securityGroup);
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
- protoPortsAndSecurityGroupNameSearch = createSearchBuilder();
- protoPortsAndSecurityGroupNameSearch.and("proto", protoPortsAndSecurityGroupNameSearch.entity().getProtocol(), SearchCriteria.Op.EQ);
- protoPortsAndSecurityGroupNameSearch.and("startPort", protoPortsAndSecurityGroupNameSearch.entity().getStartPort(), SearchCriteria.Op.EQ);
- protoPortsAndSecurityGroupNameSearch.and("endPort", protoPortsAndSecurityGroupNameSearch.entity().getEndPort(), SearchCriteria.Op.EQ);
- SearchBuilder<SecurityGroupVO> ngSb = _securityGroupDao.createSearchBuilder();
- ngSb.and("groupName", ngSb.entity().getName(), SearchCriteria.Op.EQ);
- protoPortsAndSecurityGroupNameSearch.join("groupName", ngSb, protoPortsAndSecurityGroupNameSearch.entity().getAllowedNetworkId(), ngSb.entity().getId(), JoinBuilder.JoinType.INNER);
- protoPortsAndSecurityGroupNameSearch.done();
- return super.configure(name, params);
- }
-
- @Override
- public int deleteByPortProtoAndGroup(long securityGroupId, String protocol, int startPort, int endPort, Long allowedGroupId) {
- SearchCriteria<SecurityGroupRuleVO> sc = protoPortsAndSecurityGroupIdSearch.create();
- sc.setParameters("securityGroupId", securityGroupId);
- sc.setParameters("proto", protocol);
- sc.setParameters("startPort", startPort);
- sc.setParameters("endPort", endPort);
- sc.setParameters("allowedNetworkId", allowedGroupId);
- return expunge(sc);
- }
-
- @Override
- public int deleteByPortProtoAndCidr(long securityGroupId, String protocol, int startPort, int endPort, String cidr) {
- SearchCriteria<SecurityGroupRuleVO> sc = protoPortsAndCidrSearch.create();
- sc.setParameters("securityGroupId", securityGroupId);
- sc.setParameters("proto", protocol);
- sc.setParameters("startPort", startPort);
- sc.setParameters("endPort", endPort);
- sc.setParameters("cidr", cidr);
- return expunge(sc);
- }
-
- @Override
- public SecurityGroupRuleVO findByProtoPortsAndAllowedGroupId(long securityGroupId, String proto, int startPort, int endPort, Long allowedGroupId) {
- SearchCriteria<SecurityGroupRuleVO> sc = protoPortsAndSecurityGroupIdSearch.create();
- sc.addAnd("securityGroupId", SearchCriteria.Op.EQ, securityGroupId);
- sc.setParameters("proto", proto);
- sc.setParameters("startPort", startPort);
- sc.setParameters("endPort", endPort);
- sc.setParameters("allowedNetworkId", allowedGroupId);
- return findOneIncludingRemovedBy(sc);
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/SecurityGroupRulesDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupRulesDao.java b/server/src/com/cloud/network/security/dao/SecurityGroupRulesDao.java
deleted file mode 100644
index b97662c..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupRulesDao.java
+++ /dev/null
@@ -1,48 +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.security.dao;
-
-import java.util.List;
-
-import com.cloud.network.security.SecurityGroupRulesVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface SecurityGroupRulesDao extends GenericDao<SecurityGroupRulesVO, Long> {
- /**
- * List a security group and associated ingress rules
- * @return the list of ingress rules associated with the security group (and security group info)
- */
- List<SecurityGroupRulesVO> listSecurityGroupRules(long accountId, String groupName);
-
- /**
- * List security groups and associated ingress rules
- * @return the list of security groups with associated ingress rules
- */
- List<SecurityGroupRulesVO> listSecurityGroupRules(long accountId);
-
- /**
- * List all security groups and associated ingress rules
- * @return the list of security groups with associated ingress rules
- */
- List<SecurityGroupRulesVO> listSecurityGroupRules();
-
- /**
- * List all security rules belonging to the specific group
- * @return the security group with associated ingress rules
- */
- List<SecurityGroupRulesVO> listSecurityRulesByGroupId(long groupId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/SecurityGroupRulesDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupRulesDaoImpl.java b/server/src/com/cloud/network/security/dao/SecurityGroupRulesDaoImpl.java
deleted file mode 100644
index 18ef57f..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupRulesDaoImpl.java
+++ /dev/null
@@ -1,96 +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.security.dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.network.security.SecurityGroupRulesVO;
-import com.cloud.utils.db.Filter;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-@Component
-@Local(value={SecurityGroupRulesDao.class})
-public class SecurityGroupRulesDaoImpl extends GenericDaoBase<SecurityGroupRulesVO, Long> implements SecurityGroupRulesDao {
- private SearchBuilder<SecurityGroupRulesVO> AccountGroupNameSearch;
- private SearchBuilder<SecurityGroupRulesVO> AccountSearch;
- private SearchBuilder<SecurityGroupRulesVO> GroupSearch;
-
-
- protected SecurityGroupRulesDaoImpl() {
- AccountGroupNameSearch = createSearchBuilder();
- AccountGroupNameSearch.and("accountId", AccountGroupNameSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
- AccountGroupNameSearch.and("name", AccountGroupNameSearch.entity().getName(), SearchCriteria.Op.EQ);
- AccountGroupNameSearch.done();
-
- AccountSearch = createSearchBuilder();
- AccountSearch.and("accountId", AccountSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
- AccountSearch.done();
-
- GroupSearch = createSearchBuilder();
- GroupSearch.and("groupId", GroupSearch.entity().getId(), SearchCriteria.Op.EQ);
- GroupSearch.done();
-
- }
-
- @Override
- public List<SecurityGroupRulesVO> listSecurityGroupRules() {
- Filter searchFilter = new Filter(SecurityGroupRulesVO.class, "id", true, null, null);
- return listAll(searchFilter);
- }
-
- @Override
- public List<SecurityGroupRulesVO> listSecurityGroupRules(long accountId, String groupName) {
- Filter searchFilter = new Filter(SecurityGroupRulesVO.class, "id", true, null, null);
-
- SearchCriteria<SecurityGroupRulesVO> sc = AccountGroupNameSearch.create();
- sc.setParameters("accountId", accountId);
- sc.setParameters("name", groupName);
-
- return listBy(sc, searchFilter);
- }
-
- @Override
- public List<SecurityGroupRulesVO> listSecurityGroupRules(long accountId) {
- Filter searchFilter = new Filter(SecurityGroupRulesVO.class, "id", true, null, null);
- SearchCriteria<SecurityGroupRulesVO> sc = AccountSearch.create();
- sc.setParameters("accountId", accountId);
- return listBy(sc, searchFilter);
- }
-
- @Override
- public List<SecurityGroupRulesVO> listSecurityRulesByGroupId(long groupId) {
- Filter searchFilter = new Filter(SecurityGroupRulesVO.class, "id", true, null, null);
- SearchCriteria<SecurityGroupRulesVO> sc = GroupSearch.create();
- sc.setParameters("groupId", groupId);
- return listBy(sc, searchFilter);
- }
-
- @Override
- public SecurityGroupRulesVO findByUuidIncludingRemoved(final String uuid) {
- SearchCriteria<SecurityGroupRulesVO> sc = createSearchCriteria();
- sc.addAnd("ruleUuid", SearchCriteria.Op.EQ, uuid);
- SecurityGroupRulesVO rule = findOneIncludingRemovedBy(sc);
- SecurityGroupRulesVO newRule = new SecurityGroupRulesVO(rule.getRuleId());
- return newRule;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/SecurityGroupVMMapDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupVMMapDao.java b/server/src/com/cloud/network/security/dao/SecurityGroupVMMapDao.java
deleted file mode 100644
index cbeae4f..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupVMMapDao.java
+++ /dev/null
@@ -1,38 +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.security.dao;
-
-import java.util.List;
-
-import com.cloud.network.security.SecurityGroupVMMapVO;
-import com.cloud.utils.Pair;
-import com.cloud.utils.db.Filter;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.vm.VirtualMachine.State;
-
-public interface SecurityGroupVMMapDao extends GenericDao<SecurityGroupVMMapVO, Long> {
- List<SecurityGroupVMMapVO> listByIpAndInstanceId(String ipAddress, long instanceId);
- List<SecurityGroupVMMapVO> listByInstanceId(long instanceId);
- Pair<List<SecurityGroupVMMapVO>, Integer> listByInstanceId(long instanceId, Filter filter);
- List<SecurityGroupVMMapVO> listByIp(String ipAddress);
- List<SecurityGroupVMMapVO> listBySecurityGroup(long securityGroupId);
- List<SecurityGroupVMMapVO> listBySecurityGroup(long securityGroupId, State ... vmStates);
- int deleteVM(long instanceid);
- List<Long> listVmIdsBySecurityGroup(long securityGroupId);
- SecurityGroupVMMapVO findByVmIdGroupId(long instanceId, long securityGroupId);
- long countSGForVm(long instanceId);
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/SecurityGroupVMMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupVMMapDaoImpl.java b/server/src/com/cloud/network/security/dao/SecurityGroupVMMapDaoImpl.java
deleted file mode 100644
index 46135d1..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupVMMapDaoImpl.java
+++ /dev/null
@@ -1,166 +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.security.dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.dc.VlanVO;
-import com.cloud.dc.Vlan.VlanType;
-import com.cloud.network.dao.IPAddressVO;
-import com.cloud.network.security.SecurityGroupVMMapVO;
-import com.cloud.utils.Pair;
-import com.cloud.utils.db.Filter;
-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.vm.VirtualMachine.State;
-
-@Component
-@Local(value={SecurityGroupVMMapDao.class})
-public class SecurityGroupVMMapDaoImpl extends GenericDaoBase<SecurityGroupVMMapVO, Long> implements SecurityGroupVMMapDao {
- private SearchBuilder<SecurityGroupVMMapVO> ListByIpAndVmId;
- private SearchBuilder<SecurityGroupVMMapVO> ListByVmId;
- private SearchBuilder<SecurityGroupVMMapVO> ListByVmIdGroupId;
- protected GenericSearchBuilder<SecurityGroupVMMapVO, Long> CountSGForVm;
-
- private GenericSearchBuilder<SecurityGroupVMMapVO, Long> ListVmIdBySecurityGroup;
-
- private SearchBuilder<SecurityGroupVMMapVO> ListByIp;
- private SearchBuilder<SecurityGroupVMMapVO> ListBySecurityGroup;
- private SearchBuilder<SecurityGroupVMMapVO> ListBySecurityGroupAndStates;
-
- protected SecurityGroupVMMapDaoImpl() {
- ListByIpAndVmId = createSearchBuilder();
- ListByIpAndVmId.and("ipAddress", ListByIpAndVmId.entity().getGuestIpAddress(), SearchCriteria.Op.EQ);
- ListByIpAndVmId.and("instanceId", ListByIpAndVmId.entity().getInstanceId(), SearchCriteria.Op.EQ);
- ListByIpAndVmId.done();
-
- ListVmIdBySecurityGroup = createSearchBuilder(Long.class);
- ListVmIdBySecurityGroup.and("securityGroupId", ListVmIdBySecurityGroup.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
- ListVmIdBySecurityGroup.selectField(ListVmIdBySecurityGroup.entity().getInstanceId());
- ListVmIdBySecurityGroup.done();
-
- ListBySecurityGroup = createSearchBuilder();
- ListBySecurityGroup.and("securityGroupId", ListBySecurityGroup.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
- ListBySecurityGroup.done();
-
- ListByIp = createSearchBuilder();
- ListByIp.and("ipAddress", ListByIp.entity().getGuestIpAddress(), SearchCriteria.Op.EQ);
- ListByIp.done();
-
- ListByVmId = createSearchBuilder();
- ListByVmId.and("instanceId", ListByVmId.entity().getInstanceId(), SearchCriteria.Op.EQ);
- ListByVmId.done();
-
- ListBySecurityGroupAndStates = createSearchBuilder();
- ListBySecurityGroupAndStates.and("securityGroupId", ListBySecurityGroupAndStates.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
- ListBySecurityGroupAndStates.and("states", ListBySecurityGroupAndStates.entity().getVmState(), SearchCriteria.Op.IN);
- ListBySecurityGroupAndStates.done();
-
- ListByVmIdGroupId = createSearchBuilder();
- ListByVmIdGroupId.and("instanceId", ListByVmIdGroupId.entity().getInstanceId(), SearchCriteria.Op.EQ);
- ListByVmIdGroupId.and("securityGroupId", ListByVmIdGroupId.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
- ListByVmIdGroupId.done();
-
- CountSGForVm = createSearchBuilder(Long.class);
- CountSGForVm.select(null, Func.COUNT, null);
- CountSGForVm.and("vmId", CountSGForVm.entity().getInstanceId(), SearchCriteria.Op.EQ);
- CountSGForVm.done();
- }
-
- @Override
- public List<SecurityGroupVMMapVO> listByIpAndInstanceId(String ipAddress, long vmId) {
- SearchCriteria<SecurityGroupVMMapVO> sc = ListByIpAndVmId.create();
- sc.setParameters("ipAddress", ipAddress);
- sc.setParameters("instanceId", vmId);
- return listBy(sc);
- }
-
- @Override
- public List<SecurityGroupVMMapVO> listBySecurityGroup(long securityGroupId) {
- SearchCriteria<SecurityGroupVMMapVO> sc = ListBySecurityGroup.create();
- sc.setParameters("securityGroupId", securityGroupId);
- return listBy(sc);
- }
-
- @Override
- public List<SecurityGroupVMMapVO> listByIp(String ipAddress) {
- SearchCriteria<SecurityGroupVMMapVO> sc = ListByIp.create();
- sc.setParameters("ipAddress", ipAddress);
- return listBy(sc);
- }
-
- @Override
- public List<SecurityGroupVMMapVO> listByInstanceId(long vmId) {
- SearchCriteria<SecurityGroupVMMapVO> sc = ListByVmId.create();
- sc.setParameters("instanceId", vmId);
- return listBy(sc);
- }
-
- @Override
- public Pair<List<SecurityGroupVMMapVO>, Integer> listByInstanceId(long instanceId, Filter filter) {
- SearchCriteria<SecurityGroupVMMapVO> sc = ListByVmId.create();
- sc.setParameters("instanceId", instanceId);
- return this.searchAndCount(sc, filter);
- }
-
- @Override
- public int deleteVM(long instanceId) {
- SearchCriteria<SecurityGroupVMMapVO> sc = ListByVmId.create();
- sc.setParameters("instanceId", instanceId);
- return super.expunge(sc);
- }
-
- @Override
- public List<SecurityGroupVMMapVO> listBySecurityGroup(long securityGroupId, State... vmStates) {
- SearchCriteria<SecurityGroupVMMapVO> sc = ListBySecurityGroupAndStates.create();
- sc.setParameters("securityGroupId", securityGroupId);
- sc.setParameters("states", (Object[])vmStates);
- return listBy(sc, null, true);
- }
-
- @Override
- public List<Long> listVmIdsBySecurityGroup(long securityGroupId) {
- SearchCriteria<Long> sc = ListVmIdBySecurityGroup.create();
- sc.setParameters("securityGroupId", securityGroupId);
- return customSearchIncludingRemoved(sc, null);
- }
-
- @Override
- public SecurityGroupVMMapVO findByVmIdGroupId(long instanceId, long securityGroupId) {
- SearchCriteria<SecurityGroupVMMapVO> sc = ListByVmIdGroupId.create();
- sc.setParameters("securityGroupId", securityGroupId);
- sc.setParameters("instanceId", instanceId);
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- public long countSGForVm(long instanceId) {
- SearchCriteria<Long> sc = CountSGForVm.create();
- sc.setParameters("vmId", instanceId);
- return customSearch(sc, null).get(0);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/SecurityGroupWorkDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupWorkDao.java b/server/src/com/cloud/network/security/dao/SecurityGroupWorkDao.java
deleted file mode 100644
index e6b4b88..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupWorkDao.java
+++ /dev/null
@@ -1,49 +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.security.dao;
-
-import java.util.Date;
-import java.util.List;
-
-import com.cloud.network.security.SecurityGroupWork;
-import com.cloud.network.security.SecurityGroupWorkVO;
-import com.cloud.network.security.SecurityGroupWork.Step;
-import com.cloud.utils.db.GenericDao;
-
-public interface SecurityGroupWorkDao extends GenericDao<SecurityGroupWorkVO, Long> {
- SecurityGroupWork findByVmId(long vmId, boolean taken);
-
- SecurityGroupWorkVO findByVmIdStep(long vmId, Step step);
-
-
- SecurityGroupWorkVO take(long serverId);
-
- void updateStep(Long vmId, Long logSequenceNumber, Step done);
-
- void updateStep(Long workId, Step done);
-
- int deleteFinishedWork(Date timeBefore);
-
- List<SecurityGroupWorkVO> findUnfinishedWork(Date timeBefore);
-
- List<SecurityGroupWorkVO> findAndCleanupUnfinishedWork(Date timeBefore);
-
-
- List<SecurityGroupWorkVO> findScheduledWork();
-
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/SecurityGroupWorkDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupWorkDaoImpl.java b/server/src/com/cloud/network/security/dao/SecurityGroupWorkDaoImpl.java
deleted file mode 100644
index dcd1238..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupWorkDaoImpl.java
+++ /dev/null
@@ -1,242 +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.security.dao;
-
-import java.util.Date;
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.ha.HaWorkVO;
-import com.cloud.network.security.SecurityGroupWork;
-import com.cloud.network.security.SecurityGroupWorkVO;
-import com.cloud.network.security.SecurityGroupWork.Step;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Filter;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Component
-@Local(value={SecurityGroupWorkDao.class})
-public class SecurityGroupWorkDaoImpl extends GenericDaoBase<SecurityGroupWorkVO, Long> implements SecurityGroupWorkDao {
- private static final Logger s_logger = Logger.getLogger(SecurityGroupWorkDaoImpl.class);
-
- private SearchBuilder<SecurityGroupWorkVO> VmIdTakenSearch;
- private SearchBuilder<SecurityGroupWorkVO> VmIdSeqNumSearch;
- private SearchBuilder<SecurityGroupWorkVO> VmIdUnTakenSearch;
- private SearchBuilder<SecurityGroupWorkVO> UntakenWorkSearch;
- private SearchBuilder<SecurityGroupWorkVO> VmIdStepSearch;
- private SearchBuilder<SecurityGroupWorkVO> CleanupSearch;
-
-
- protected SecurityGroupWorkDaoImpl() {
- VmIdTakenSearch = createSearchBuilder();
- VmIdTakenSearch.and("vmId", VmIdTakenSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
- VmIdTakenSearch.and("taken", VmIdTakenSearch.entity().getDateTaken(), SearchCriteria.Op.NNULL);
-
- VmIdTakenSearch.done();
-
- VmIdUnTakenSearch = createSearchBuilder();
- VmIdUnTakenSearch.and("vmId", VmIdUnTakenSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
- VmIdUnTakenSearch.and("taken", VmIdUnTakenSearch.entity().getDateTaken(), SearchCriteria.Op.NULL);
-
- VmIdUnTakenSearch.done();
-
- UntakenWorkSearch = createSearchBuilder();
- UntakenWorkSearch.and("server", UntakenWorkSearch.entity().getServerId(), SearchCriteria.Op.NULL);
- UntakenWorkSearch.and("taken", UntakenWorkSearch.entity().getDateTaken(), SearchCriteria.Op.NULL);
- UntakenWorkSearch.and("step", UntakenWorkSearch.entity().getStep(), SearchCriteria.Op.EQ);
-
- UntakenWorkSearch.done();
-
- VmIdSeqNumSearch = createSearchBuilder();
- VmIdSeqNumSearch.and("vmId", VmIdSeqNumSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
- VmIdSeqNumSearch.and("seqno", VmIdSeqNumSearch.entity().getLogsequenceNumber(), SearchCriteria.Op.EQ);
-
- VmIdSeqNumSearch.done();
-
- VmIdStepSearch = createSearchBuilder();
- VmIdStepSearch.and("vmId", VmIdStepSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
- VmIdStepSearch.and("step", VmIdStepSearch.entity().getStep(), SearchCriteria.Op.EQ);
-
- VmIdStepSearch.done();
-
- CleanupSearch = createSearchBuilder();
- CleanupSearch.and("taken", CleanupSearch.entity().getDateTaken(), Op.LTEQ);
- CleanupSearch.and("step", CleanupSearch.entity().getStep(), SearchCriteria.Op.IN);
-
- CleanupSearch.done();
-
-
- }
-
- @Override
- public SecurityGroupWork findByVmId(long vmId, boolean taken) {
- SearchCriteria<SecurityGroupWorkVO> sc = taken?VmIdTakenSearch.create():VmIdUnTakenSearch.create();
- sc.setParameters("vmId", vmId);
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- @DB
- public SecurityGroupWorkVO take(long serverId) {
- final Transaction txn = Transaction.currentTxn();
- try {
- final SearchCriteria<SecurityGroupWorkVO> sc = UntakenWorkSearch.create();
- sc.setParameters("step", Step.Scheduled);
-
- final Filter filter = new Filter(SecurityGroupWorkVO.class, null, true, 0l, 1l);//FIXME: order desc by update time?
-
- txn.start();
- final List<SecurityGroupWorkVO> vos = lockRows(sc, filter, true);
- if (vos.size() == 0) {
- txn.commit();
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("Security Group take: no work found");
- }
- return null;
- }
- SecurityGroupWorkVO work = vos.get(0);
- boolean processing = false;
- if ( findByVmIdStep(work.getInstanceId(), Step.Processing) != null) {
- //ensure that there is no job in Processing state for the same VM
- processing = true;
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("Security Group work take: found a job in Scheduled and Processing vmid=" + work.getInstanceId());
- }
- }
- work.setServerId(serverId);
- work.setDateTaken(new Date());
- if (processing) {
- //the caller to take() should check the step and schedule another work item to come back
- //and take a look.
- work.setStep(SecurityGroupWork.Step.Done);
- } else {
- work.setStep(SecurityGroupWork.Step.Processing);
- }
-
- update(work.getId(), work);
-
- txn.commit();
-
- return work;
-
- } catch (final Throwable e) {
- throw new CloudRuntimeException("Unable to execute take", e);
- }
- }
-
- @Override
- @DB
- public void updateStep(Long vmId, Long logSequenceNumber, Step step) {
- final Transaction txn = Transaction.currentTxn();
- txn.start();
- SearchCriteria<SecurityGroupWorkVO> sc = VmIdSeqNumSearch.create();
- sc.setParameters("vmId", vmId);
- sc.setParameters("seqno", logSequenceNumber);
-
- final Filter filter = new Filter(HaWorkVO.class, null, true, 0l, 1l);
-
- final List<SecurityGroupWorkVO> vos = lockRows(sc, filter, true);
- if (vos.size() == 0) {
- txn.commit();
- return;
- }
- SecurityGroupWorkVO work = vos.get(0);
- work.setStep(step);
- update(work.getId(), work);
-
- txn.commit();
- }
-
- @Override
- public SecurityGroupWorkVO findByVmIdStep(long vmId, Step step) {
- SearchCriteria<SecurityGroupWorkVO> sc = VmIdStepSearch.create();
- sc.setParameters("vmId", vmId);
- sc.setParameters("step", step);
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- @DB
- public void updateStep(Long workId, Step step) {
- final Transaction txn = Transaction.currentTxn();
- txn.start();
-
- SecurityGroupWorkVO work = lockRow(workId, true);
- if (work == null) {
- txn.commit();
- return;
- }
- work.setStep(step);
- update(work.getId(), work);
-
- txn.commit();
-
- }
-
- @Override
- public int deleteFinishedWork(Date timeBefore) {
- final SearchCriteria<SecurityGroupWorkVO> sc = CleanupSearch.create();
- sc.setParameters("taken", timeBefore);
- sc.setParameters("step", Step.Done);
-
- return expunge(sc);
- }
-
- @Override
- public List<SecurityGroupWorkVO> findUnfinishedWork(Date timeBefore) {
- final SearchCriteria<SecurityGroupWorkVO> sc = CleanupSearch.create();
- sc.setParameters("taken", timeBefore);
- sc.setParameters("step", Step.Processing);
-
- List<SecurityGroupWorkVO> result = listIncludingRemovedBy(sc);
-
- return result;
- }
-
- @Override
- public List<SecurityGroupWorkVO> findAndCleanupUnfinishedWork(Date timeBefore) {
- final SearchCriteria<SecurityGroupWorkVO> sc = CleanupSearch.create();
- sc.setParameters("taken", timeBefore);
- sc.setParameters("step", Step.Processing);
-
- List<SecurityGroupWorkVO> result = listIncludingRemovedBy(sc);
-
- SecurityGroupWorkVO work = createForUpdate();
- work.setStep(Step.Error);
- update(work, sc);
-
- return result;
- }
-
- @Override
- public List<SecurityGroupWorkVO> findScheduledWork() {
- final SearchCriteria<SecurityGroupWorkVO> sc = UntakenWorkSearch.create();
- sc.setParameters("step", Step.Scheduled);
- return listIncludingRemovedBy(sc);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/VmRulesetLogDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/VmRulesetLogDao.java b/server/src/com/cloud/network/security/dao/VmRulesetLogDao.java
deleted file mode 100644
index d5ed4a0..0000000
--- a/server/src/com/cloud/network/security/dao/VmRulesetLogDao.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.security.dao;
-
-import java.util.Set;
-
-import com.cloud.network.security.VmRulesetLogVO;
-import com.cloud.utils.db.GenericDao;
-
-public interface VmRulesetLogDao extends GenericDao<VmRulesetLogVO, Long> {
- VmRulesetLogVO findByVmId(long vmId);
-
- int createOrUpdate(Set<Long> workItems);
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java b/server/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java
deleted file mode 100644
index 746b66f..0000000
--- a/server/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java
+++ /dev/null
@@ -1,200 +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.security.dao;
-
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.SQLTransactionRollbackException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.network.security.VmRulesetLogVO;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.Transaction;
-
-@Component
-@Local(value={VmRulesetLogDao.class})
-public class VmRulesetLogDaoImpl extends GenericDaoBase<VmRulesetLogVO, Long> implements VmRulesetLogDao {
- protected static Logger s_logger = Logger.getLogger(VmRulesetLogDaoImpl.class);
- private SearchBuilder<VmRulesetLogVO> VmIdSearch;
- private String INSERT_OR_UPDATE = "INSERT INTO op_vm_ruleset_log (instance_id, created, logsequence) " +
- " VALUES(?, now(), 1) ON DUPLICATE KEY UPDATE logsequence=logsequence+1";
- private static HashMap<Integer, String> cachedPrepStmtStrings = new HashMap<Integer, String>();
- final static private int cacheStringSizes [] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
-
- static {
- //prepare the cache.
- for (int size: cacheStringSizes) {
- cachedPrepStmtStrings.put(size, createPrepStatementString(size));
- }
- }
-
-
- private static String createPrepStatementString(int numItems) {
- StringBuilder builder = new StringBuilder("INSERT INTO op_vm_ruleset_log (instance_id, created, logsequence) VALUES ");
- for (int i=0; i < numItems-1; i++) {
- builder.append("(?, now(), 1), ");
- }
- builder.append("(?, now(), 1) ");
- builder.append(" ON DUPLICATE KEY UPDATE logsequence=logsequence+1");
- return builder.toString();
- }
-
- protected VmRulesetLogDaoImpl() {
- VmIdSearch = createSearchBuilder();
- VmIdSearch.and("vmId", VmIdSearch.entity().getInstanceId(), SearchCriteria.Op.EQ);
-
- VmIdSearch.done();
-
- }
-
- @Override
- public VmRulesetLogVO findByVmId(long vmId) {
- SearchCriteria<VmRulesetLogVO> sc = VmIdSearch.create();
- sc.setParameters("vmId", vmId);
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- public int createOrUpdate(Set<Long> workItems) {
- //return createOrUpdateUsingBatch(workItems);
- return createOrUpdateUsingMultiInsert(workItems);
- }
-
- private int executeWithRetryOnDeadlock(Transaction txn, String pstmt, List<Long> vmIds) throws SQLException {
-
- int numUpdated = 0;
- final int maxTries = 3;
- for (int i=0; i < maxTries; i++) {
- try {
- PreparedStatement stmtInsert = txn.prepareAutoCloseStatement(pstmt);
- int argIndex = 1;
- for (Long vmId: vmIds) {
- stmtInsert.setLong(argIndex++, vmId);
- }
- numUpdated = stmtInsert.executeUpdate();
- i = maxTries;
- } catch (SQLTransactionRollbackException e1) {
- if (i < maxTries-1) {
- int delayMs = (i+1)*1000;
- s_logger.debug("Caught a deadlock exception while inserting security group rule log, retrying in " + delayMs);
- try {
- Thread.sleep(delayMs);
- } catch(InterruptedException ie) {
-
- }
- }
- else
- s_logger.warn("Caught another deadlock exception while retrying inserting security group rule log, giving up");
-
- }
- }
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("Inserted or updated " + numUpdated + " rows");
- }
- return numUpdated;
- }
-
- protected int createOrUpdateUsingMultiInsert(Set<Long> workItems) {
- Transaction txn = Transaction.currentTxn();
-
- int size = workItems.size();
- int count = 0;
- Iterator<Long> workIter = workItems.iterator();
- int remaining = size;
- try {
- for (int stmtSize : cacheStringSizes) {
- int numStmts = remaining / stmtSize;
- if (numStmts > 0) {
- String pstmt = cachedPrepStmtStrings.get(stmtSize);
- for (int i=0; i < numStmts; i++) {
- List<Long> vmIds = new ArrayList<Long>();
- for (int argIndex=1; argIndex <= stmtSize; argIndex++) {
- Long vmId = workIter.next();
- vmIds.add(vmId);
- }
- int numUpdated = executeWithRetryOnDeadlock(txn, pstmt, vmIds);
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("Inserted or updated " + numUpdated + " rows");
- }
- if (numUpdated > 0)
- count += stmtSize;
- }
- remaining = remaining - numStmts * stmtSize;
- }
-
- }
- } catch (SQLException sqe) {
- s_logger.warn("Failed to execute multi insert ", sqe);
- }
-
- return count;
- }
-
- protected int createOrUpdateUsingBatch(Set<Long> workItems) {
- Transaction txn = Transaction.currentTxn();
- PreparedStatement stmtInsert = null;
- int [] queryResult = null;
- int count=0;
- boolean success = true;
- try {
- stmtInsert = txn.prepareAutoCloseStatement(INSERT_OR_UPDATE);
-
- txn.start();
- for (Long vmId: workItems) {
- stmtInsert.setLong(1, vmId);
- stmtInsert.addBatch();
- count++;
- if (count % 16 ==0) {
- queryResult = stmtInsert.executeBatch();
- stmtInsert.clearBatch();
- }
- }
- queryResult = stmtInsert.executeBatch();
-
- txn.commit();
- if (s_logger.isTraceEnabled())
- s_logger.trace("Updated or inserted " + workItems.size() + " log items");
- } catch (SQLException e) {
- s_logger.warn("Failed to execute batch update statement for ruleset log: ", e);
- txn.rollback();
- success = false;
- }
- if (!success && queryResult != null) {
- Long [] arrayItems = new Long[workItems.size()];
- workItems.toArray(arrayItems);
- for (int i=0; i < queryResult.length; i++) {
- if (queryResult[i] < 0 ) {
- s_logger.debug("Batch query update failed for vm " + arrayItems[i]);
- }
- }
- }
- return count;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/vpc/PrivateIpVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/PrivateIpVO.java b/server/src/com/cloud/network/vpc/PrivateIpVO.java
deleted file mode 100644
index 952a0c2..0000000
--- a/server/src/com/cloud/network/vpc/PrivateIpVO.java
+++ /dev/null
@@ -1,103 +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.vpc;
-
-import org.apache.cloudstack.api.InternalIdentity;
-
-import java.util.Date;
-
-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 javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-
-@Entity
-@Table(name="private_ip_address")
-public class PrivateIpVO implements InternalIdentity {
-
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- long id;
-
- @Column(name="ip_address", updatable=false, nullable=false)
- String ipAddress;
-
- @Column(name="mac_address")
- private long macAddress;
-
- @Column(name="taken")
- @Temporal(value=TemporalType.TIMESTAMP)
- private Date takenAt;
-
- @Column(name="network_id", updatable=false, nullable=false)
- private long networkId;
-
- @Column(name="vpc_id")
- private Long vpcId;
-
- @Column(name="source_nat")
- private boolean sourceNat;
-
- public PrivateIpVO() {
- }
-
- public PrivateIpVO(String ipAddress, long networkId, long macAddress, long vpcId, boolean sourceNat) {
- this.ipAddress = ipAddress;
- this.networkId = networkId;
- this.macAddress = macAddress;
- this.vpcId = vpcId;
- this.sourceNat = sourceNat;
- }
-
- public void setTakenAt(Date takenDate) {
- this.takenAt = takenDate;
- }
-
- public String getIpAddress() {
- return ipAddress;
- }
-
- public long getNetworkId() {
- return networkId;
- }
-
- public Date getTakenAt() {
- return takenAt;
- }
-
- public long getId() {
- return id;
- }
-
- public long getMacAddress() {
- return macAddress;
- }
-
- public Long getVpcId() {
- return vpcId;
- }
- public boolean getSourceNat() {
- return sourceNat;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/vpc/StaticRouteVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/StaticRouteVO.java b/server/src/com/cloud/network/vpc/StaticRouteVO.java
deleted file mode 100644
index eb4c61b..0000000
--- a/server/src/com/cloud/network/vpc/StaticRouteVO.java
+++ /dev/null
@@ -1,141 +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.vpc;
-
-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 org.apache.cloudstack.api.Identity;
-import com.cloud.utils.db.GenericDao;
-import org.apache.cloudstack.api.InternalIdentity;
-
-
-@Entity
-@Table(name="static_routes")
-public class StaticRouteVO implements StaticRoute {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- long id;
-
- @Column(name="uuid")
- String uuid;
-
- @Column(name="vpc_gateway_id", updatable=false)
- long vpcGatewayId;
-
- @Column(name="cidr")
- private String cidr;
-
- @Enumerated(value=EnumType.STRING)
- @Column(name="state")
- State state;
-
- @Column(name="vpc_id")
- private Long vpcId;
-
- @Column(name = "account_id")
- long accountId;
-
- @Column(name = "domain_id")
- long domainId;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- Date created;
-
- protected StaticRouteVO(){
- this.uuid = UUID.randomUUID().toString();
- }
-
- /**
- * @param vpcGatewayId
- * @param cidr
- * @param vpcId
- * @param accountId TODO
- * @param domainId TODO
- */
- public StaticRouteVO(long vpcGatewayId, String cidr, Long vpcId, long accountId, long domainId) {
- super();
- this.vpcGatewayId = vpcGatewayId;
- this.cidr = cidr;
- this.state = State.Staged;
- this.vpcId = vpcId;
- this.accountId = accountId;
- this.domainId = domainId;
- this.uuid = UUID.randomUUID().toString();
- }
-
- @Override
- public long getVpcGatewayId() {
- return vpcGatewayId;
- }
-
- @Override
- public String getCidr() {
- return cidr;
- }
-
- @Override
- public State getState() {
- return state;
- }
-
- @Override
- public Long getVpcId() {
- return vpcId;
- }
-
- @Override
- public String getUuid() {
- return this.uuid;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public long getAccountId() {
- return accountId;
- }
-
- @Override
- public long getDomainId() {
- return domainId;
- }
-
- public void setState(State state) {
- this.state = state;
- }
-
- @Override
- public String toString() {
- StringBuilder buf = new StringBuilder("StaticRoute[");
- buf.append(uuid).append("|").append(cidr).append("|").append(vpcGatewayId).append("]");
- return buf.toString();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/vpc/VpcGatewayVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcGatewayVO.java b/server/src/com/cloud/network/vpc/VpcGatewayVO.java
deleted file mode 100644
index e8dcb46..0000000
--- a/server/src/com/cloud/network/vpc/VpcGatewayVO.java
+++ /dev/null
@@ -1,206 +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.vpc;
-
-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 com.cloud.utils.db.GenericDao;
-
-
-@Entity
-@Table(name="vpc_gateways")
-public class VpcGatewayVO implements VpcGateway {
-
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private long id;
-
- @Column(name = "ip4_address")
- String ip4Address;
-
- @Column(name="gateway")
- String gateway;
-
- @Column(name="netmask")
- String netmask;
-
- @Column(name="vlan_tag")
- String vlanTag;
-
- @Column(name = "type")
- @Enumerated(value = EnumType.STRING)
- VpcGateway.Type type;
-
- @Column(name="vpc_id")
- Long vpcId;
-
- @Column(name="zone_id")
- long zoneId;
-
- @Column(name="network_id")
- Long networkId;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- Date created;
-
- @Column(name=GenericDao.REMOVED_COLUMN)
- Date removed;
-
- @Column(name="uuid")
- private String uuid;
-
- @Column(name = "account_id")
- long accountId;
-
- @Column(name = "domain_id")
- long domainId;
-
- @Column(name="state")
- @Enumerated(value=EnumType.STRING)
- State state;
-
- @Column(name="source_nat")
- boolean sourceNat;
-
- protected VpcGatewayVO(){
- this.uuid = UUID.randomUUID().toString();
- }
-
- /**
- * @param ip4Address
- * @param type
- * @param vpcId
- * @param zoneId
- * @param networkId
- * @param vlanTag TODO
- * @param gateway TODO
- * @param netmask TODO
- * @param accountId TODO
- * @param domainId TODO
- * @param account_id
- * @param sourceNat
- */
- public VpcGatewayVO(String ip4Address, Type type, Long vpcId, long zoneId, Long networkId, String vlanTag,
- String gateway, String netmask, long accountId, long domainId, boolean sourceNat) {
- this.ip4Address = ip4Address;
- this.type = type;
- this.vpcId = vpcId;
- this.zoneId = zoneId;
- this.networkId = networkId;
- this.vlanTag = vlanTag;
- this.gateway = gateway;
- this.netmask = netmask;
- this.uuid = UUID.randomUUID().toString();
- this.accountId = accountId;
- this.domainId = domainId;
- this.state = State.Creating;
- this.sourceNat = sourceNat;
- }
-
- @Override
- public String getUuid() {
- return this.uuid;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public String getIp4Address() {
- return ip4Address;
- }
-
- @Override
- public VpcGateway.Type getType() {
- return type;
- }
-
- @Override
- public Long getVpcId() {
- return vpcId;
- }
-
- @Override
- public long getZoneId() {
- return zoneId;
- }
-
- @Override
- public Long getNetworkId() {
- return networkId;
- }
-
- @Override
- public String toString() {
- StringBuilder buf = new StringBuilder("VpcGateway[");
- buf.append(id).append("|").append(ip4Address.toString()).append("|").append(vpcId).append("]");
- return buf.toString();
- }
-
- @Override
- public String getGateway() {
- return gateway;
- }
-
- @Override
- public String getNetmask() {
- return netmask;
- }
-
- @Override
- public String getVlanTag() {
- return vlanTag;
- }
-
- @Override
- public long getAccountId() {
- return accountId;
- }
-
- @Override
- public long getDomainId() {
- return domainId;
- }
-
- @Override
- public State getState() {
- return state;
- }
-
- public void setState(State state) {
- this.state = state;
- }
-
- @Override
- public boolean getSourceNat() {
- return this.sourceNat;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/vpc/VpcOfferingServiceMapVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcOfferingServiceMapVO.java b/server/src/com/cloud/network/vpc/VpcOfferingServiceMapVO.java
deleted file mode 100644
index 9dbb32f..0000000
--- a/server/src/com/cloud/network/vpc/VpcOfferingServiceMapVO.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.vpc;
-
-import java.util.Date;
-
-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.network.Network.Provider;
-import com.cloud.network.Network.Service;
-import com.cloud.utils.db.GenericDao;
-import org.apache.cloudstack.api.InternalIdentity;
-
-
-@Entity
-@Table(name="vpc_offering_service_map")
-public class VpcOfferingServiceMapVO implements InternalIdentity {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- long id;
-
- @Column(name="vpc_offering_id")
- long vpcOfferingId;
-
- @Column(name="service")
- String service;
-
- @Column(name="provider")
- String provider;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- Date created;
-
- public long getId() {
- return id;
- }
-
- public long getVpcOfferingId() {
- return vpcOfferingId;
- }
-
- public String getService() {
- return service;
- }
-
- public String getProvider() {
- return provider;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public VpcOfferingServiceMapVO() {
- }
-
- public VpcOfferingServiceMapVO(long vpcOfferingId, Service service, Provider provider) {
- this.vpcOfferingId = vpcOfferingId;
- this.service = service.getName();
- if (provider != null) {
- this.provider = provider.getName();
- }
- }
-
- public String toString() {
- StringBuilder buf = new StringBuilder("[VPC Offering Service[");
- return buf.append(vpcOfferingId).append("-").append(service).append("-").append(provider).append("]").toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/vpc/VpcOfferingVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcOfferingVO.java b/server/src/com/cloud/network/vpc/VpcOfferingVO.java
deleted file mode 100644
index 9d5becf..0000000
--- a/server/src/com/cloud/network/vpc/VpcOfferingVO.java
+++ /dev/null
@@ -1,151 +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.vpc;
-
-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 com.cloud.utils.db.GenericDao;
-import org.apache.cloudstack.api.InternalIdentity;
-
-
-@Entity
-@Table(name="vpc_offerings")
-public class VpcOfferingVO implements VpcOffering {
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- long id;
-
- @Column(name="uuid")
- private String uuid;
-
- @Column(name = "name")
- String name;
-
- @Column(name = "unique_name")
- String uniqueName;
-
- @Column(name = "display_text")
- String displayText;
-
- @Column(name = "state")
- @Enumerated(value = EnumType.STRING)
- State state = State.Disabled;
-
- @Column(name = "default")
- boolean isDefault = false;
-
- @Column(name = GenericDao.REMOVED_COLUMN)
- Date removed;
-
- @Column(name = GenericDao.CREATED_COLUMN)
- Date created;
-
- @Column(name = "service_offering_id")
- Long serviceOfferingId;
-
- public VpcOfferingVO() {
- this.uuid = UUID.randomUUID().toString();
- }
-
- public VpcOfferingVO(String name, String displayText, Long serviceOfferingId) {
- this.name = name;
- this.displayText = displayText;
- this.uniqueName = name;
- this.serviceOfferingId = serviceOfferingId;
- this.uuid = UUID.randomUUID().toString();
- this.state = State.Disabled;
- }
-
- public VpcOfferingVO(String name, String displayText, boolean isDefault, Long serviceOfferingId) {
- this(name, displayText, serviceOfferingId);
- this.isDefault = isDefault;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public String getUuid() {
- return uuid;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- public String getUniqueName() {
- return uniqueName;
- }
-
- @Override
- public String getDisplayText() {
- return displayText;
- }
-
- @Override
- public State getState() {
- return state;
- }
-
- @Override
- public boolean isDefault() {
- return isDefault;
- }
-
- public void setUniqueName(String uniqueName) {
- this.uniqueName = uniqueName;
- }
-
- @Override
- public String toString() {
- StringBuilder buf = new StringBuilder("[VPC Offering [");
- return buf.append(id).append("-").append(name).append("]").toString();
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-
- public void setDisplayText(String displayText) {
- this.displayText = displayText;
- }
-
- public void setState(State state) {
- this.state = state;
- }
-
- @Override
- public Long getServiceOfferingId() {
- return serviceOfferingId;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/vpc/VpcServiceMapVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcServiceMapVO.java b/server/src/com/cloud/network/vpc/VpcServiceMapVO.java
deleted file mode 100644
index 6f22909..0000000
--- a/server/src/com/cloud/network/vpc/VpcServiceMapVO.java
+++ /dev/null
@@ -1,90 +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.vpc;
-
-import java.util.Date;
-
-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.network.Network.Provider;
-import com.cloud.network.Network.Service;
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name="vpc_service_map")
-public class VpcServiceMapVO {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- long id;
-
- @Column(name="vpc_id")
- long vpcId;
-
- @Column(name="service")
- String service;
-
- @Column(name="provider")
- String provider;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- Date created;
-
- public long getId() {
- return id;
- }
-
- public long getVpcId() {
- return vpcId;
- }
-
- public String getService() {
- return service;
- }
-
- public String getProvider() {
- return provider;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public VpcServiceMapVO() {
- }
-
- public VpcServiceMapVO(long vpcId, Service service, Provider provider) {
- this.vpcId = vpcId;
- this.service = service.getName();
- this.provider = provider.getName();
- }
-
- public String toString() {
- StringBuilder buf = new StringBuilder("[VPC Service[");
- return buf.append(vpcId).append("-").append(service).append("-").append(provider).append("]").toString();
- }
-}
-
-
-
-
-
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/server/src/com/cloud/network/vpc/VpcVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcVO.java b/server/src/com/cloud/network/vpc/VpcVO.java
deleted file mode 100644
index 7b784eb..0000000
--- a/server/src/com/cloud/network/vpc/VpcVO.java
+++ /dev/null
@@ -1,181 +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.vpc;
-
-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.Id;
-import javax.persistence.Table;
-
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name="vpc")
-public class VpcVO implements Vpc {
- @Id
- @Column(name="id")
- long id;
-
- @Column(name="uuid")
- private String uuid;
-
- @Column(name="name")
- private String name;
-
- @Column(name = "display_text")
- String displayText;
-
- @Column(name="zone_id")
- long zoneId;
-
- @Column(name="cidr")
- private String cidr = null;
-
- @Column(name="domain_id")
- Long domainId = null;
-
- @Column(name="account_id")
- Long accountId = null;
-
- @Column(name="state")
- @Enumerated(value=EnumType.STRING)
- State state;
-
- @Column(name="vpc_offering_id")
- long vpcOfferingId;
-
- @Column(name=GenericDao.REMOVED_COLUMN)
- Date removed;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- Date created;
-
- @Column(name="network_domain")
- String networkDomain;
-
- @Column(name="restart_required")
- boolean restartRequired = false;
-
- public VpcVO() {
- this.uuid = UUID.randomUUID().toString();
- }
-
- public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr,
- String networkDomain) {
- this.zoneId = zoneId;
- this.name = name;
- this.displayText = displayText;
- this.accountId = accountId;
- this.domainId = domainId;
- this.cidr = cidr;
- this.uuid = UUID.randomUUID().toString();
- this.state = State.Enabled;
- this.networkDomain = networkDomain;
- this.vpcOfferingId = vpcOffId;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public String getUuid() {
- return uuid;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public long getZoneId() {
- return zoneId;
- }
-
- @Override
- public String getCidr() {
- return cidr;
- }
-
- @Override
- public long getDomainId() {
- return domainId;
- }
-
- @Override
- public long getAccountId() {
- return accountId;
- }
-
- @Override
- public State getState() {
- return state;
- }
-
- public void setState(State state) {
- this.state = state;
- }
-
- @Override
- public long getVpcOfferingId() {
- return vpcOfferingId;
- }
-
- public Date getRemoved() {
- return removed;
- }
-
- @Override
- public String getDisplayText() {
- return displayText;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setDisplayText(String displayText) {
- this.displayText = displayText;
- }
-
- @Override
- public String toString() {
- StringBuilder buf = new StringBuilder("[VPC [");
- return buf.append(id).append("-").append(name).append("]").toString();
- }
-
- @Override
- public String getNetworkDomain() {
- return networkDomain;
- }
-
- public void setRestartRequired(boolean restartRequired) {
- this.restartRequired = restartRequired;
- }
-
- @Override
- public boolean isRestartRequired() {
- return restartRequired;
- }
-}