Updated Branches:
  refs/heads/master-6-17-stable f00ebad1c -> 4f7506264
  refs/heads/network_acl 0396ef9c2 -> 9a5912a3f


CLOUDSTACK-2364: fixed private gateway creation in VPC - the vnet for the 
private gateway network is not stored in data_center_vnet table


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

Branch: refs/heads/network_acl
Commit: 9a5912a3f0dbb045e73391301d78a7ee33a6d630
Parents: 0396ef9
Author: Alena Prokharchyk <alena.prokharc...@citrix.com>
Authored: Tue May 7 13:02:29 2013 -0700
Committer: Jayapal <jayapalreddy.ur...@citrix.com>
Committed: Thu May 9 11:00:56 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/network/NetworkManagerImpl.java   | 39 +++++++++++---------
 1 file changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9a5912a3/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java 
b/server/src/com/cloud/network/NetworkManagerImpl.java
index 7d349fd..73ec160 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -2005,23 +2005,28 @@ public class NetworkManagerImpl extends ManagerBase 
implements NetworkManager, L
                 if (_networksDao.countByZoneAndUri(zoneId, uri) > 0) {
                     throw new InvalidParameterValueException("Network with 
vlan " + vlanId + " already exists in zone " + zoneId);
                 } else {
-                    DataCenterVnetVO dcVnet = 
_datacenterVnetDao.findVnet(zoneId, vlanId.toString()).get(0);
-                    // Fail network creation if specified vlan is dedicated to 
a different account
-                    if (dcVnet.getAccountGuestVlanMapId() != null) {
-                        Long accountGuestVlanMapId = 
dcVnet.getAccountGuestVlanMapId();
-                        AccountGuestVlanMapVO map = 
_accountGuestVlanMapDao.findById(accountGuestVlanMapId);
-                        if (map.getAccountId() != owner.getAccountId()) {
-                            throw new InvalidParameterValueException("Vlan " + 
vlanId + " is dedicated to a different account");
-                        }
-                    // Fail network creation if owner has a dedicated range of 
vlans but the specified vlan belongs to the system pool
-                    } else {
-                        List<AccountGuestVlanMapVO> maps = 
_accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(owner.getAccountId());
-                        if (maps != null && !maps.isEmpty()) {
-                            int vnetsAllocatedToAccount = 
_datacenterVnetDao.countVnetsAllocatedToAccount(zoneId, owner.getAccountId());
-                            int vnetsDedicatedToAccount = 
_datacenterVnetDao.countVnetsDedicatedToAccount(zoneId, owner.getAccountId());
-                            if (vnetsAllocatedToAccount < 
vnetsDedicatedToAccount) {
-                                throw new 
InvalidParameterValueException("Specified vlan " + vlanId + " doesn't belong" +
-                                        " to the vlan range dedicated to the 
owner "+ owner.getAccountName());
+                    List<DataCenterVnetVO> dcVnets = 
_datacenterVnetDao.findVnet(zoneId, vlanId.toString());
+                    //for the network that is created as part of private 
gateway,
+                    //the vnet is not coming from the data center vnet table, 
so the list can be empty
+                    if (!dcVnets.isEmpty()) {
+                        DataCenterVnetVO dcVnet = dcVnets.get(0);
+                        // Fail network creation if specified vlan is 
dedicated to a different account
+                        if (dcVnet.getAccountGuestVlanMapId() != null) {
+                            Long accountGuestVlanMapId = 
dcVnet.getAccountGuestVlanMapId();
+                            AccountGuestVlanMapVO map = 
_accountGuestVlanMapDao.findById(accountGuestVlanMapId);
+                            if (map.getAccountId() != owner.getAccountId()) {
+                                throw new InvalidParameterValueException("Vlan 
" + vlanId + " is dedicated to a different account");
+                            }
+                        // Fail network creation if owner has a dedicated 
range of vlans but the specified vlan belongs to the system pool
+                        } else {
+                            List<AccountGuestVlanMapVO> maps = 
_accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(owner.getAccountId());
+                            if (maps != null && !maps.isEmpty()) {
+                                int vnetsAllocatedToAccount = 
_datacenterVnetDao.countVnetsAllocatedToAccount(zoneId, owner.getAccountId());
+                                int vnetsDedicatedToAccount = 
_datacenterVnetDao.countVnetsDedicatedToAccount(zoneId, owner.getAccountId());
+                                if (vnetsAllocatedToAccount < 
vnetsDedicatedToAccount) {
+                                    throw new 
InvalidParameterValueException("Specified vlan " + vlanId + " doesn't belong" +
+                                            " to the vlan range dedicated to 
the owner "+ owner.getAccountName());
+                                }
                             }
                         }
                     }

Reply via email to