cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [20/50] [abbrv] git commit: updated refs/heads/kvm-vnc-listen to 3890860
Date Wed, 03 Apr 2013 10:33:28 GMT
Mulitiple ip address per nic support for advacned shared networks

Description:
Changes added for supporting multiple ip address per nic for shared networks

Testing Done:
Tested adding and removing the ip for nic using the APIs


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

Branch: refs/heads/kvm-vnc-listen
Commit: 8dd0b7747b2da1aa71110e871b0bd4ffdbcdfcb4
Parents: 355589c
Author: Jayapal Reddy <jayapalreddy.uradi@citrix.com>
Authored: Mon Apr 1 16:22:12 2013 +0530
Committer: Murali Reddy <murali.reddy@citrix.com>
Committed: Mon Apr 1 16:24:48 2013 +0530

----------------------------------------------------------------------
 .../src/com/cloud/network/NetworkServiceImpl.java  |   24 ++++++++-------
 1 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8dd0b774/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index d503459..4eb620c 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -490,6 +490,9 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
         accountId = network.getAccountId();
         domainId = network.getDomainId();
 
+        // Validate network offering
+        NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(network.getNetworkOfferingId());
+
         // verify permissions
         _accountMgr.checkAccess(ipOwner, null, true, network);
 
@@ -518,7 +521,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
             } catch (InsufficientAddressCapacityException e) {
                 throw new InvalidParameterValueException("Allocating guest ip for nic failed");
             }
-        } else if (dc.getNetworkType() == NetworkType.Basic) {
+        } else if (dc.getNetworkType() == NetworkType.Basic || ntwkOff.getGuestType()  ==
Network.GuestType.Shared) {
             Account caller = UserContext.current().getCaller();
             long callerUserId = UserContext.current().getCallerUserId();
             _accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network);
@@ -546,14 +549,6 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
                 s_logger.error("Allocating ip to guest nic " + nicId + " failed");
                 return null;
             }
-        } else if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) &&
zone.getNetworkType() == NetworkType.Advanced) {
-            // if shared network in the advanced zone, then check the caller against the
network for 'AccessType.UseNetwork'
-            Account caller = UserContext.current().getCaller();
-            long callerUserId = UserContext.current().getCallerUserId();
-            _accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network);
-            if (s_logger.isDebugEnabled()) {
-                s_logger.debug("Associate IP address called by the user " + callerUserId
+ " account " + ipOwner.getId());
-            }
         } else {
             s_logger.error("AddIpToVMNic is not supported in this network...");
             return null;
@@ -594,6 +589,13 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
 
         Network network = _networksDao.findById(secIpVO.getNetworkId());
 
+        if (network == null) {
+            throw new InvalidParameterValueException("Invalid network id is given");
+        }
+
+        // Validate network offering
+        NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(network.getNetworkOfferingId());
+
         // verify permissions
         _accountMgr.checkAccess(caller, null, true, network);
 
@@ -627,7 +629,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
                 s_logger.debug("VM nic IP " + secondaryIp + " is associated with the static
NAT rule public IP address id " + publicIpVO.getId());
                 throw new InvalidParameterValueException("Can' remove the ip " + secondaryIp
+ "is associate with static NAT rule public IP address id " + publicIpVO.getId());
             }
-        } else if (dc.getNetworkType() == NetworkType.Basic) {
+        } else if (dc.getNetworkType() == NetworkType.Basic || ntwkOff.getGuestType()  ==
Network.GuestType.Shared) {
             IPAddressVO ip = _ipAddressDao.findByIpAndNetworkId(secIpVO.getNetworkId(), secIpVO.getIp4Address());
             if (ip != null) {
                 Transaction txn = Transaction.currentTxn();
@@ -636,7 +638,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
                 _ipAddressDao.unassignIpAddress(ip.getId());
                 txn.commit();
             }
-        } else if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) &&
dc.getNetworkType() == NetworkType.Advanced) {
+        } else {
             throw new InvalidParameterValueException("Not supported for this network now");
         }
 


Mime
View raw message