cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [27/50] [abbrv] git commit: updated refs/heads/object_store to 18aeef3
Date Wed, 12 Jun 2013 18:22:36 GMT
CLOUDSTACK-1771: Fix ipv6 address for router

Now it won't change(as ipv4 address) after router is destroyed.


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

Branch: refs/heads/object_store
Commit: 4a14ea8a4d0d8a729928b05f137ea6721acf02ea
Parents: 5541785
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Thu Jun 6 18:03:20 2013 -0700
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Thu Jun 6 18:04:35 2013 -0700

----------------------------------------------------------------------
 .../ExternalFirewallDeviceManagerImpl.java      |  2 +-
 .../ExternalLoadBalancerDeviceManagerImpl.java  |  4 +-
 .../src/com/cloud/network/NetworkManager.java   |  2 +-
 .../com/cloud/network/NetworkManagerImpl.java   |  3 +-
 .../src/com/cloud/network/NetworkModelImpl.java | 17 +++++---
 .../cloud/network/guru/DirectNetworkGuru.java   |  5 +--
 .../network/guru/DirectPodBasedNetworkGuru.java |  2 +-
 .../VirtualNetworkApplianceManagerImpl.java     | 46 +++++++++++---------
 .../cloud/network/MockNetworkManagerImpl.java   |  9 +---
 .../com/cloud/vpc/MockNetworkManagerImpl.java   |  2 +-
 10 files changed, 48 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a14ea8a/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java
index 9d24e47..9b190aa 100644
--- a/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java
+++ b/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java
@@ -485,7 +485,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase
impl
 
         if (add && (!reservedIpAddressesForGuestNetwork.contains(network.getGateway())))
{
             // Insert a new NIC for this guest network to reserve the gateway address
-            _networkMgr.savePlaceholderNic(network,  network.getGateway(), null);
+            _networkMgr.savePlaceholderNic(network,  network.getGateway(), null, null);
         }
         
         // Delete any mappings used for inline external load balancers in this network

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a14ea8a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
index 4b110e9..829ad3f 100644
--- a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
+++ b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
@@ -774,7 +774,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
                 // If a NIC doesn't exist for the load balancing IP address, create one
                 loadBalancingIpNic = _nicDao.findByIp4AddressAndNetworkId(loadBalancingIpAddress,
network.getId());
                 if (loadBalancingIpNic == null) {
-                    loadBalancingIpNic = _networkMgr.savePlaceholderNic(network, loadBalancingIpAddress,
null);
+                    loadBalancingIpNic = _networkMgr.savePlaceholderNic(network, loadBalancingIpAddress,
null, null);
                 }
 
                 // Save a mapping between the source IP address and the load balancing IP
address NIC
@@ -1019,7 +1019,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends
AdapterBase
 
         if (add) {
             // Insert a new NIC for this guest network to reserve the self IP
-            _networkMgr.savePlaceholderNic(guestConfig, selfIp, null);
+            _networkMgr.savePlaceholderNic(guestConfig, selfIp, null, null);
         } else {
             // release the self-ip obtained from guest network
             Nic selfipNic = getPlaceholderNic(guestConfig);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a14ea8a/server/src/com/cloud/network/NetworkManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java
index 8627251..bc43daa 100755
--- a/server/src/com/cloud/network/NetworkManager.java
+++ b/server/src/com/cloud/network/NetworkManager.java
@@ -381,7 +381,7 @@ public interface NetworkManager  {
     
     String allocatePublicIpForGuestNic(Long networkId, DataCenter dc, Pod pod, Account caller,
String requestedIp) throws InsufficientAddressCapacityException;
 
-    NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType);
+    NicVO savePlaceholderNic(Network network, String ip4Address, String ip6Address, Type
vmType);
 
     DhcpServiceProvider getDhcpServiceProvider(Network network);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a14ea8a/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 cae4e8a..d6a6450 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -4325,9 +4325,10 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
 
 
     @Override
-    public NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType) {
+    public NicVO savePlaceholderNic(Network network, String ip4Address, String ip6Address,
Type vmType) {
         NicVO nic = new NicVO(null, null, network.getId(), null); 
         nic.setIp4Address(ip4Address);
+        nic.setIp6Address(ip6Address);
         nic.setReservationStrategy(ReservationStrategy.PlaceHolder);
         nic.setState(Nic.State.Reserved);
         nic.setVmType(vmType);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a14ea8a/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index 6b63ead..21917f7 100755
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -2065,17 +2065,24 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
     public NicVO getPlaceholderNicForRouter(Network network, Long podId) {
         List<NicVO> nics = _nicDao.listPlaceholderNicsByNetworkIdAndVmType(network.getId(),
VirtualMachine.Type.DomainRouter);
         for (NicVO nic : nics) {
-            if (nic.getReserver() == null && nic.getIp4Address() != null) {
+            if (nic.getReserver() == null && (nic.getIp4Address() != null || nic.getIp6Address()
!= null)) {
                 if (podId == null) {
                     return nic;
                 } else {
                     //return nic only when its ip address belong to the pod range (for the
Basic zone case)
                     List<? extends Vlan> vlans = _vlanDao.listVlansForPod(podId);
                     for (Vlan vlan : vlans) {
-                        IpAddress ip = _ipAddressDao.findByIpAndNetworkId(network.getId(),
nic.getIp4Address());
-                        if (ip != null && ip.getVlanId() == vlan.getId()) {
-                            return nic;
-                        }
+                    	if (nic.getIp4Address() != null) {
+                    		IpAddress ip = _ipAddressDao.findByIpAndNetworkId(network.getId(),
nic.getIp4Address());
+                    		if (ip != null && ip.getVlanId() == vlan.getId()) {
+                    			return nic;
+                    		}
+                    	} else {
+                    		UserIpv6AddressVO ipv6 = _ipv6Dao.findByNetworkIdAndIp(network.getId(),
nic.getIp6Address());
+                    		if (ipv6 != null && ipv6.getVlanId() == vlan.getId()) {
+                    			return nic;
+                    		}
+                    	}
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a14ea8a/server/src/com/cloud/network/guru/DirectNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
index 84008c0..b4577ac 100755
--- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
@@ -221,7 +221,6 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru
{
             throws InsufficientVirtualNetworkCapcityException,
             InsufficientAddressCapacityException {
         
-        //FIXME - save ipv6 informaiton in the placeholder nic
         Transaction txn = Transaction.currentTxn();
         txn.start();
         _networkMgr.allocateDirectIp(nic, dc, vm, network, requestedIp4Addr, requestedIp6Addr);
@@ -229,8 +228,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru
{
         if (vm.getType() == VirtualMachine.Type.DomainRouter) {
             Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, null);
             if (placeholderNic == null) {
-                s_logger.debug("Saving placeholder nic with ip4 address " + nic.getIp4Address()
+ " and ipv6 address " + requestedIp6Addr + " for the network " + network);
-                _networkMgr.savePlaceholderNic(network, nic.getIp4Address(), VirtualMachine.Type.DomainRouter);
+                s_logger.debug("Saving placeholder nic with ip4 address " + nic.getIp4Address()
+ " and ipv6 address " + nic.getIp6Address() + " for the network " + network);
+                _networkMgr.savePlaceholderNic(network, nic.getIp4Address(), nic.getIp6Address(),
VirtualMachine.Type.DomainRouter);
             }
         }
         txn.commit();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a14ea8a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
index cf27986..f21e352 100755
--- a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
@@ -203,7 +203,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
                 Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, pod.getId());
                 if (placeholderNic == null) {
                     s_logger.debug("Saving placeholder nic with ip4 address " + nic.getIp4Address()
+ " for the network " + network);
-                    _networkMgr.savePlaceholderNic(network, nic.getIp4Address(), VirtualMachine.Type.DomainRouter);
+                    _networkMgr.savePlaceholderNic(network, nic.getIp4Address(), null, VirtualMachine.Type.DomainRouter);
                 }
             }
             txn.commit();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a14ea8a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index e0ff157..db4786a 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -1740,30 +1740,34 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
             s_logger.debug("Adding nic for Virtual Router in Guest network " + guestNetwork);
             String defaultNetworkStartIp = null, defaultNetworkStartIpv6 = null;
             if (!setupPublicNetwork) {
+            	Nic placeholder = _networkModel.getPlaceholderNicForRouter(guestNetwork, plan.getPodId());
             	if (guestNetwork.getCidr() != null) {
-            	    Nic placeholder = _networkModel.getPlaceholderNicForRouter(guestNetwork,
plan.getPodId());
-            	    if (placeholder != null) {
-            	        s_logger.debug("Requesting ip address " + placeholder.getIp4Address()
+ " stored in placeholder nic for the network " + guestNetwork);
-            	        defaultNetworkStartIp = placeholder.getIp4Address();
-            	    } else {
-            	        String startIp = _networkModel.getStartIpAddress(guestNetwork.getId());
-                        if (startIp != null && _ipAddressDao.findByIpAndSourceNetworkId(guestNetwork.getId(),
startIp).getAllocatedTime() == null) {
-                            defaultNetworkStartIp = startIp;
-                        } else if (s_logger.isDebugEnabled()){
-                            s_logger.debug("First ip " + startIp + " in network id=" + guestNetwork.getId()
+ 
-                                    " is already allocated, can't use it for domain router;
will get random ip address from the range");
-                        }
-            	    }
+            		if (placeholder != null && placeholder.getIp4Address() != null) {
+            			s_logger.debug("Requesting ipv4 address " + placeholder.getIp4Address() +
" stored in placeholder nic for the network " + guestNetwork);
+            			defaultNetworkStartIp = placeholder.getIp4Address(); 
+            		} else {
+            			String startIp = _networkModel.getStartIpAddress(guestNetwork.getId());
+            			if (startIp != null && _ipAddressDao.findByIpAndSourceNetworkId(guestNetwork.getId(),
startIp).getAllocatedTime() == null) {
+            				defaultNetworkStartIp = startIp;
+            			} else if (s_logger.isDebugEnabled()){
+            				s_logger.debug("First ipv4 " + startIp + " in network id=" + guestNetwork.getId()
+ 
+            						" is already allocated, can't use it for domain router; will get random
ip address from the range");
+            			}
+            		}
             	}
-            	
-            	//FIXME - get ipv6 stored in the placeholder
+
             	if (guestNetwork.getIp6Cidr() != null) {
-            		String startIpv6 = _networkModel.getStartIpv6Address(guestNetwork.getId());
-            		if (startIpv6 != null && _ipv6Dao.findByNetworkIdAndIp(guestNetwork.getId(),
startIpv6) == null) {
-            			defaultNetworkStartIpv6 = startIpv6;
-            		} else if (s_logger.isDebugEnabled()){
-            			s_logger.debug("First ipv6 " + startIpv6 + " in network id=" + guestNetwork.getId()
+ 
-            					" is already allocated, can't use it for domain router; will get random
ipv6 address from the range");
+            		if (placeholder != null && placeholder.getIp6Address() != null) {
+            			s_logger.debug("Requesting ipv6 address " + placeholder.getIp6Address() +
" stored in placeholder nic for the network " + guestNetwork);
+            			defaultNetworkStartIpv6 = placeholder.getIp6Address(); 
+            		} else {
+            			String startIpv6 = _networkModel.getStartIpv6Address(guestNetwork.getId());
+            			if (startIpv6 != null && _ipv6Dao.findByNetworkIdAndIp(guestNetwork.getId(),
startIpv6) == null) {
+            				defaultNetworkStartIpv6 = startIpv6;
+            			} else if (s_logger.isDebugEnabled()){
+            				s_logger.debug("First ipv6 " + startIpv6 + " in network id=" + guestNetwork.getId()
+ 
+            						" is already allocated, can't use it for domain router; will get random
ipv6 address from the range");
+            			}
             		}
             	}
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a14ea8a/server/test/com/cloud/network/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java
index 7ab322b..077395f 100755
--- a/server/test/com/cloud/network/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java
@@ -66,15 +66,8 @@ import com.cloud.user.Account;
 import com.cloud.user.User;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.ManagerBase;
-import com.cloud.vm.Nic;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.NicVO;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VMInstanceVO;
-import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.*;
 import com.cloud.vm.VirtualMachine.Type;
-import com.cloud.vm.VirtualMachineProfile;
 import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
 import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
 import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
@@ -924,7 +917,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
 
 
     @Override
-    public NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType) {
+    public NicVO savePlaceholderNic(Network network, String ip4Address, String ip6Address,
Type vmType) {
         // TODO Auto-generated method stub
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a14ea8a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
index d46be7c..b609022 100644
--- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
@@ -1393,7 +1393,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
 
 
     @Override
-    public NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType) {
+    public NicVO savePlaceholderNic(Network network, String ip4Address, String ip6Address,
Type vmType) {
         // TODO Auto-generated method stub
         return null;
     }


Mime
View raw message