cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [19/50] [abbrv] git commit: updated refs/heads/feature/systemvm-persistent-config to 4fe7264
Date Wed, 04 Feb 2015 20:28:39 GMT
Fix: allow multiple VIFs per Mac Address
Fix: RTNETLINK errors
     - Management Server health check trying to create already existing interface
     - Changes on update_config.py, cs_guestnetwork.py, merger.py
Fix: replace RRouTER_LOG in the CsRedundant.py per log file location
Fix: Guest Net address association during Router restart
     - Changes on NicProfileHelper, NicProfileHelperImpl
Fix: aggregationExecution() method on VirtualNetworkApplianceManagerImpl
     - Do not send an AggregationControlCommand to a non-configured router

Some classes have been formatted.


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

Branch: refs/heads/feature/systemvm-persistent-config
Commit: f97a552264c90658275c053684e61678d3d5d86a
Parents: 294a42a
Author: wilderrodrigues <wrodrigues@schubergphilis.com>
Authored: Thu Jan 15 06:29:20 2015 +0100
Committer: wilderrodrigues <wrodrigues@schubergphilis.com>
Committed: Wed Feb 4 18:47:06 2015 +0100

----------------------------------------------------------------------
 .../api/routing/NetworkElementCommand.java      |  10 +-
 .../virtualnetwork/model/GuestNetwork.java      |  25 ++-
 .../xenserver/resource/CitrixResourceBase.java  |   7 +-
 .../network/router/CommandSetupHelper.java      | 212 ++++++++++---------
 .../cloud/network/router/NicProfileHelper.java  |   4 +-
 .../network/router/NicProfileHelperImpl.java    |  46 ++--
 .../VirtualNetworkApplianceManagerImpl.java     |  14 +-
 .../network/router/VpcNetworkHelperImpl.java    |   2 +-
 .../topology/AdvancedNetworkVisitor.java        |  34 +--
 .../config/opt/cloud/bin/cs/CsRedundant.py      |   6 +
 .../debian/config/opt/cloud/bin/merge.py        |   6 +-
 .../config/opt/cloud/bin/serve_password.sh      |   2 +-
 .../config/opt/cloud/bin/update_config.py       |  94 ++++++--
 .../config/opt/cloud/bin/vpc_passwd_server      |   2 +-
 14 files changed, 293 insertions(+), 171 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
index e4105c1..6e62e81 100644
--- a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
+++ b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
@@ -19,10 +19,10 @@
 
 package com.cloud.agent.api.routing;
 
-import com.cloud.agent.api.Command;
-
 import java.util.HashMap;
 
+import com.cloud.agent.api.Command;
+
 public abstract class NetworkElementCommand extends Command {
     HashMap<String, String> accessDetails = new HashMap<String, String>(0);
 
@@ -45,11 +45,11 @@ public abstract class NetworkElementCommand extends Command {
         super();
     }
 
-    public void setAccessDetail(String name, String value) {
+    public void setAccessDetail(final String name, final String value) {
         accessDetails.put(name, value);
     }
 
-    public String getAccessDetail(String name) {
+    public String getAccessDetail(final String name) {
         return accessDetails.get(name);
     }
 
@@ -62,7 +62,7 @@ public abstract class NetworkElementCommand extends Command {
         return routerAccessIp;
     }
 
-    public void setRouterAccessIp(String routerAccessIp) {
+    public void setRouterAccessIp(final String routerAccessIp) {
         this.routerAccessIp = routerAccessIp;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/core/src/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java b/core/src/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java
index 68440c6..076073e 100644
--- a/core/src/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/model/GuestNetwork.java
@@ -34,8 +34,8 @@ public class GuestNetwork extends ConfigBase {
         super(ConfigBase.GUEST_NETWORK);
     }
 
-    public GuestNetwork(boolean add, String macAddress, String device, String routerGuestIp,
String routerGuestNetmask, String routerGuestGateway, String cidr, String dns,
-            String domainName) {
+    public GuestNetwork(final boolean add, final String macAddress, final String device,
final String routerGuestIp, final String routerGuestNetmask, final String routerGuestGateway,
+            final String cidr, final String dns, final String domainName) {
         super(ConfigBase.GUEST_NETWORK);
         this.add = add;
         this.macAddress = macAddress;
@@ -52,7 +52,7 @@ public class GuestNetwork extends ConfigBase {
         return add;
     }
 
-    public void setAdd(boolean add) {
+    public void setAdd(final boolean add) {
         this.add = add;
     }
 
@@ -60,7 +60,7 @@ public class GuestNetwork extends ConfigBase {
         return macAddress;
     }
 
-    public void setMacAddress(String macAddress) {
+    public void setMacAddress(final String macAddress) {
         this.macAddress = macAddress;
     }
 
@@ -68,7 +68,7 @@ public class GuestNetwork extends ConfigBase {
         return device;
     }
 
-    public void setDevice(String device) {
+    public void setDevice(final String device) {
         this.device = device;
     }
 
@@ -76,7 +76,7 @@ public class GuestNetwork extends ConfigBase {
         return routerGuestIp;
     }
 
-    public void setRouterGuestIp(String routerGuestIp) {
+    public void setRouterGuestIp(final String routerGuestIp) {
         this.routerGuestIp = routerGuestIp;
     }
 
@@ -84,7 +84,7 @@ public class GuestNetwork extends ConfigBase {
         return routerGuestNetmask;
     }
 
-    public void setRouterGuestNetmask(String routerGuestNetmask) {
+    public void setRouterGuestNetmask(final String routerGuestNetmask) {
         this.routerGuestNetmask = routerGuestNetmask;
     }
 
@@ -92,7 +92,7 @@ public class GuestNetwork extends ConfigBase {
         return routerGuestGateway;
     }
 
-    public void setRouterGuestGateway(String routerGuestGateway) {
+    public void setRouterGuestGateway(final String routerGuestGateway) {
         this.routerGuestGateway = routerGuestGateway;
     }
 
@@ -100,7 +100,7 @@ public class GuestNetwork extends ConfigBase {
         return cidr;
     }
 
-    public void setCidr(String cidr) {
+    public void setCidr(final String cidr) {
         this.cidr = cidr;
     }
 
@@ -108,7 +108,7 @@ public class GuestNetwork extends ConfigBase {
         return dns;
     }
 
-    public void setDns(String dns) {
+    public void setDns(final String dns) {
         this.dns = dns;
     }
 
@@ -116,8 +116,7 @@ public class GuestNetwork extends ConfigBase {
         return domainName;
     }
 
-    public void setDomainName(String domainName) {
+    public void setDomainName(final String domainName) {
         this.domainName = domainName;
     }
-
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
index 4d663b2..eeddeb0 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
@@ -1612,7 +1612,7 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             if (result != null) {
                 return new CheckSshAnswer(cmd, "Can not ping System vm " + vmName + "due
to:" + result);
             }
-            destroyPatchVbd(conn, vmName);
+            //destroyPatchVbd(conn, vmName);
         } catch (final Exception e) {
             return new CheckSshAnswer(cmd, e);
         }
@@ -7147,9 +7147,9 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             }
 
             // Wilder Rodrigues - replaced this code with the code above.
-            //            VIF vif = getVifByMac(conn, vm, nic.getMac());
+            //            final VIF vif = getVifByMac(conn, vm, nic.getMac());
             //            if (vif != null) {
-            //                String msg = " Plug Nic failed due to a VIF with the same mac
" + nic.getMac() + " exists";
+            //                final String msg = " Plug Nic failed due to a VIF with the
same mac " + nic.getMac() + " exists";
             //                s_logger.warn(msg);
             //                return new PlugNicAnswer(cmd, false, msg);
             //            }
@@ -7157,6 +7157,7 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             final String deviceId = getLowestAvailableVIFDeviceNum(conn, vm);
             nic.setDeviceId(Integer.parseInt(deviceId));
             final VIF vif = createVif(conn, vmName, vm, null, nic);
+            //            vif = createVif(conn, vmName, vm, null, nic);
             vif.plug(conn);
             return new PlugNicAnswer(cmd, true, "success");
         } catch (final Exception e) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/server/src/com/cloud/network/router/CommandSetupHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/CommandSetupHelper.java b/server/src/com/cloud/network/router/CommandSetupHelper.java
index 7002136..939cf9f 100644
--- a/server/src/com/cloud/network/router/CommandSetupHelper.java
+++ b/server/src/com/cloud/network/router/CommandSetupHelper.java
@@ -482,100 +482,8 @@ public class CommandSetupHelper {
     }
 
     public void createAssociateIPCommands(final VirtualRouter router, final List<? extends
PublicIpAddress> ips, final Commands cmds, final long vmId) {
-
-        // Ensure that in multiple vlans case we first send all ip addresses of
-        // vlan1, then all ip addresses of vlan2, etc..
-        final Map<String, ArrayList<PublicIpAddress>> vlanIpMap = new HashMap<String,
ArrayList<PublicIpAddress>>();
-        for (final PublicIpAddress ipAddress : ips) {
-            final String vlanTag = ipAddress.getVlanTag();
-            ArrayList<PublicIpAddress> ipList = vlanIpMap.get(vlanTag);
-            if (ipList == null) {
-                ipList = new ArrayList<PublicIpAddress>();
-            }
-            // domR doesn't support release for sourceNat IP address; so reset
-            // the state
-            if (ipAddress.isSourceNat() && ipAddress.getState() == IpAddress.State.Releasing)
{
-                ipAddress.setState(IpAddress.State.Allocated);
-            }
-            ipList.add(ipAddress);
-            vlanIpMap.put(vlanTag, ipList);
-        }
-
-        final List<NicVO> nics = _nicDao.listByVmId(router.getId());
-        String baseMac = null;
-        for (final NicVO nic : nics) {
-            final NetworkVO nw = _networkDao.findById(nic.getNetworkId());
-            if (nw.getTrafficType() == TrafficType.Public) {
-                baseMac = nic.getMacAddress();
-                break;
-            }
-        }
-
-        for (final Map.Entry<String, ArrayList<PublicIpAddress>> vlanAndIp :
vlanIpMap.entrySet()) {
-            final List<PublicIpAddress> ipAddrList = vlanAndIp.getValue();
-            // Source nat ip address should always be sent first
-            Collections.sort(ipAddrList, new Comparator<PublicIpAddress>() {
-                @Override
-                public int compare(final PublicIpAddress o1, final PublicIpAddress o2) {
-                    final boolean s1 = o1.isSourceNat();
-                    final boolean s2 = o2.isSourceNat();
-                    return s1 ^ s2 ? s1 ^ true ? 1 : -1 : 0;
-                }
-            });
-
-            // Get network rate - required for IpAssoc
-            final Integer networkRate = _networkModel.getNetworkRate(ipAddrList.get(0).getNetworkId(),
router.getId());
-            final Network network = _networkModel.getNetwork(ipAddrList.get(0).getNetworkId());
-
-            final IpAddressTO[] ipsToSend = new IpAddressTO[ipAddrList.size()];
-            int i = 0;
-            boolean firstIP = true;
-
-            for (final PublicIpAddress ipAddr : ipAddrList) {
-
-                final boolean add = ipAddr.getState() == IpAddress.State.Releasing ? false
: true;
-                boolean sourceNat = ipAddr.isSourceNat();
-                /* enable sourceNAT for the first ip of the public interface */
-                if (firstIP) {
-                    sourceNat = true;
-                }
-                final String vlanId = ipAddr.getVlanTag();
-                final String vlanGateway = ipAddr.getGateway();
-                final String vlanNetmask = ipAddr.getNetmask();
-                String vifMacAddress = null;
-                // For non-source nat IP, set the mac to be something based on
-                // first public nic's MAC
-                // We cannot depends on first ip because we need to deal with
-                // first ip of other nics
-                if (!ipAddr.isSourceNat() && ipAddr.getVlanId() != 0) {
-                    vifMacAddress = NetUtils.generateMacOnIncrease(baseMac, ipAddr.getVlanId());
-                } else {
-                    vifMacAddress = ipAddr.getMacAddress();
-                }
-
-                final IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(),
add, firstIP, sourceNat, vlanId, vlanGateway, vlanNetmask,
-                        vifMacAddress, networkRate, ipAddr.isOneToOneNat());
-
-                ip.setTrafficType(network.getTrafficType());
-                ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(),
network));
-                ipsToSend[i++] = ip;
-                /*
-                 * send the firstIP = true for the first Add, this is to create
-                 * primary on interface
-                 */
-                if (!firstIP || add) {
-                    firstIP = false;
-                }
-            }
-            final IpAssocCommand cmd = new IpAssocCommand(ipsToSend);
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(ipAddrList.get(0).getAssociatedWithNetworkId(),
router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-            final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
-            cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-
-            cmds.addCommand("IPAssocCommand", cmd);
-        }
+        final String ipAssocCommand = "IPAssocCommand";
+        createRedundantAssociateIPCommands(router, ips, cmds, ipAssocCommand, vmId);
     }
 
     public void createNetworkACLsCommands(final List<? extends NetworkACLItem> rules,
final VirtualRouter router, final Commands cmds, final long guestNetworkId,
@@ -741,6 +649,12 @@ public class CommandSetupHelper {
     public void createVpcAssociatePublicIPCommands(final VirtualRouter router, final List<?
extends PublicIpAddress> ips, final Commands cmds,
             final Map<String, String> vlanMacAddress) {
 
+        final String ipAssocCommand = "IPAssocVpcCommand";
+        if (router.getIsRedundantRouter()) {
+            createRedundantAssociateIPCommands(router, ips, cmds, ipAssocCommand, 0);
+            return;
+        }
+
         Pair<IpAddressTO, Long> sourceNatIpAdd = null;
         Boolean addSourceNat = null;
         // Ensure that in multiple vlans case we first send all ip addresses of
@@ -794,7 +708,7 @@ public class CommandSetupHelper {
             final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
             cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
 
-            cmds.addCommand("IPAssocVpcCommand", cmd);
+            cmds.addCommand(ipAssocCommand, cmd);
         }
 
         // set source nat ip
@@ -809,6 +723,114 @@ public class CommandSetupHelper {
         }
     }
 
+    public void createRedundantAssociateIPCommands(final VirtualRouter router, final List<?
extends PublicIpAddress> ips, final Commands cmds, final String ipAssocCommand, final long
vmId) {
+
+        // Ensure that in multiple vlans case we first send all ip addresses of
+        // vlan1, then all ip addresses of vlan2, etc..
+        final Map<String, ArrayList<PublicIpAddress>> vlanIpMap = new HashMap<String,
ArrayList<PublicIpAddress>>();
+        for (final PublicIpAddress ipAddress : ips) {
+            final String vlanTag = ipAddress.getVlanTag();
+            ArrayList<PublicIpAddress> ipList = vlanIpMap.get(vlanTag);
+            if (ipList == null) {
+                ipList = new ArrayList<PublicIpAddress>();
+            }
+            // domR doesn't support release for sourceNat IP address; so reset
+            // the state
+            if (ipAddress.isSourceNat() && ipAddress.getState() == IpAddress.State.Releasing)
{
+                ipAddress.setState(IpAddress.State.Allocated);
+            }
+            ipList.add(ipAddress);
+            vlanIpMap.put(vlanTag, ipList);
+        }
+
+        final List<NicVO> nics = _nicDao.listByVmId(router.getId());
+        String baseMac = null;
+        for (final NicVO nic : nics) {
+            final NetworkVO nw = _networkDao.findById(nic.getNetworkId());
+            if (nw.getTrafficType() == TrafficType.Public) {
+                baseMac = nic.getMacAddress();
+                break;
+            }
+        }
+
+        for (final Map.Entry<String, ArrayList<PublicIpAddress>> vlanAndIp :
vlanIpMap.entrySet()) {
+            final List<PublicIpAddress> ipAddrList = vlanAndIp.getValue();
+            // Source nat ip address should always be sent first
+            Collections.sort(ipAddrList, new Comparator<PublicIpAddress>() {
+                @Override
+                public int compare(final PublicIpAddress o1, final PublicIpAddress o2) {
+                    final boolean s1 = o1.isSourceNat();
+                    final boolean s2 = o2.isSourceNat();
+                    return s1 ^ s2 ? s1 ^ true ? 1 : -1 : 0;
+                }
+            });
+
+            // Get network rate - required for IpAssoc
+            final Integer networkRate = _networkModel.getNetworkRate(ipAddrList.get(0).getNetworkId(),
router.getId());
+            final Network network = _networkModel.getNetwork(ipAddrList.get(0).getNetworkId());
+
+            final IpAddressTO[] ipsToSend = new IpAddressTO[ipAddrList.size()];
+            int i = 0;
+            boolean firstIP = true;
+
+            for (final PublicIpAddress ipAddr : ipAddrList) {
+
+                final boolean add = ipAddr.getState() == IpAddress.State.Releasing ? false
: true;
+                boolean sourceNat = ipAddr.isSourceNat();
+                /* enable sourceNAT for the first ip of the public interface */
+                if (firstIP) {
+                    sourceNat = true;
+                }
+                final String vlanId = ipAddr.getVlanTag();
+                final String vlanGateway = ipAddr.getGateway();
+                final String vlanNetmask = ipAddr.getNetmask();
+                String vifMacAddress = null;
+                // For non-source nat IP, set the mac to be something based on
+                // first public nic's MAC
+                // We cannot depend on first ip because we need to deal with
+                // first ip of other nics
+                if (router.getVpcId() != null) {
+                    //vifMacAddress = NetUtils.generateMacOnIncrease(baseMac, ipAddr.getVlanId());
+                    vifMacAddress = ipAddr.getMacAddress();
+                } else {
+                    if (!sourceNat && ipAddr.getVlanId() != 0) {
+                        vifMacAddress = NetUtils.generateMacOnIncrease(baseMac, ipAddr.getVlanId());
+                    } else {
+                        vifMacAddress = ipAddr.getMacAddress();
+                    }
+                }
+
+                final IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(),
add, firstIP, sourceNat, vlanId, vlanGateway, vlanNetmask,
+                        vifMacAddress, networkRate, ipAddr.isOneToOneNat());
+
+                ip.setTrafficType(network.getTrafficType());
+                ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(),
network));
+                ipsToSend[i++] = ip;
+                /*
+                 * send the firstIP = true for the first Add, this is to create
+                 * primary on interface
+                 */
+                if (!firstIP || add) {
+                    firstIP = false;
+                }
+            }
+
+            Long associatedWithNetworkId = ipAddrList.get(0).getAssociatedWithNetworkId();
+            if (associatedWithNetworkId == null || associatedWithNetworkId == 0) {
+                associatedWithNetworkId = ipAddrList.get(0).getNetworkId();
+            }
+
+            final IpAssocCommand cmd = new IpAssocCommand(ipsToSend);
+            cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
+            cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(associatedWithNetworkId,
router.getId()));
+            cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
+            final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
+            cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
+
+            cmds.addCommand(ipAssocCommand, cmd);
+        }
+    }
+
     public void createStaticRouteCommands(final List<StaticRouteProfile> staticRoutes,
final DomainRouterVO router, final Commands cmds) {
         final SetStaticRouteCommand cmd = new SetStaticRouteCommand(staticRoutes);
         cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/server/src/com/cloud/network/router/NicProfileHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NicProfileHelper.java b/server/src/com/cloud/network/router/NicProfileHelper.java
index 12f3038..db42abf 100644
--- a/server/src/com/cloud/network/router/NicProfileHelper.java
+++ b/server/src/com/cloud/network/router/NicProfileHelper.java
@@ -16,6 +16,8 @@
 // under the License.
 package com.cloud.network.router;
 
+import org.cloud.network.router.deployment.RouterDeploymentDefinition;
+
 import com.cloud.network.Network;
 import com.cloud.network.vpc.VpcGateway;
 import com.cloud.vm.NicProfile;
@@ -25,7 +27,7 @@ public interface NicProfileHelper {
     public abstract NicProfile createPrivateNicProfileForGateway(
             VpcGateway privateGateway);
 
-    public abstract NicProfile createGuestNicProfileForVpcRouter(
+    public abstract NicProfile createGuestNicProfileForVpcRouter(final RouterDeploymentDefinition
vpcRouterDeploymentDefinition,
             Network guestNetwork);
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/server/src/com/cloud/network/router/NicProfileHelperImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/NicProfileHelperImpl.java b/server/src/com/cloud/network/router/NicProfileHelperImpl.java
index a06dbff..aaa1f27 100644
--- a/server/src/com/cloud/network/router/NicProfileHelperImpl.java
+++ b/server/src/com/cloud/network/router/NicProfileHelperImpl.java
@@ -22,6 +22,9 @@ import java.net.URI;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import org.cloud.network.router.deployment.RouterDeploymentDefinition;
+
+import com.cloud.network.IpAddressManager;
 import com.cloud.network.Network;
 import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.AddressFormat;
@@ -53,30 +56,31 @@ public class NicProfileHelperImpl implements NicProfileHelper {
     protected VpcManager _vpcMgr;
     @Inject
     protected NicDao _nicDao;
-
+    @Inject
+    protected IpAddressManager _ipAddrMgr;
 
     @Override
     @DB
-    public NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway) {
-        Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
-        PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(),
privateNetwork.getId(), privateGateway.getIp4Address());
-        Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(), privateNetwork.getId());
+    public NicProfile createPrivateNicProfileForGateway(final VpcGateway privateGateway)
{
+        final Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
+        final PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(),
privateNetwork.getId(), privateGateway.getIp4Address());
+        final Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(),
privateNetwork.getId());
 
         NicProfile privateNicProfile = new NicProfile();
 
         if (privateNic != null) {
-            VirtualMachine vm = _vmDao.findById(privateNic.getInstanceId());
+            final VirtualMachine vm = _vmDao.findById(privateNic.getInstanceId());
             privateNicProfile =
-                new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(),
privateNic.getIsolationUri(), _networkModel.getNetworkRate(
-                    privateNetwork.getId(), vm.getId()), _networkModel.isSecurityGroupSupportedInNetwork(privateNetwork),
_networkModel.getNetworkTag(
-                    vm.getHypervisorType(), privateNetwork));
+                    new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(),
privateNic.getIsolationUri(), _networkModel.getNetworkRate(
+                            privateNetwork.getId(), vm.getId()), _networkModel.isSecurityGroupSupportedInNetwork(privateNetwork),
_networkModel.getNetworkTag(
+                                    vm.getHypervisorType(), privateNetwork));
         } else {
-            String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());
-            PrivateIpAddress ip =
-                new PrivateIpAddress(ipVO, privateNetwork.getBroadcastUri().toString(), privateNetwork.getGateway(),
netmask,
-                    NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress())));
+            final String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());
+            final PrivateIpAddress ip =
+                    new PrivateIpAddress(ipVO, privateNetwork.getBroadcastUri().toString(),
privateNetwork.getGateway(), netmask,
+                            NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress())));
 
-            URI netUri = BroadcastDomainType.fromString(ip.getBroadcastUri());
+            final URI netUri = BroadcastDomainType.fromString(ip.getBroadcastUri());
             privateNicProfile.setIp4Address(ip.getIpAddress());
             privateNicProfile.setGateway(ip.getGateway());
             privateNicProfile.setNetmask(ip.getNetmask());
@@ -94,14 +98,20 @@ public class NicProfileHelperImpl implements NicProfileHelper {
     }
 
     @Override
-    public NicProfile createGuestNicProfileForVpcRouter(final Network guestNetwork) {
-        NicProfile guestNic = new NicProfile();
-        guestNic.setIp4Address(guestNetwork.getGateway());
+    public NicProfile createGuestNicProfileForVpcRouter(final RouterDeploymentDefinition
vpcRouterDeploymentDefinition, final Network guestNetwork) {
+        final NicProfile guestNic = new NicProfile();
+
+        if (vpcRouterDeploymentDefinition.isRedundant()) {
+            guestNic.setIp4Address(_ipAddrMgr.acquireGuestIpAddress(guestNetwork, null));
+        } else {
+            guestNic.setIp4Address(guestNetwork.getGateway());
+        }
+
         guestNic.setBroadcastUri(guestNetwork.getBroadcastUri());
         guestNic.setBroadcastType(guestNetwork.getBroadcastDomainType());
         guestNic.setIsolationUri(guestNetwork.getBroadcastUri());
         guestNic.setMode(guestNetwork.getMode());
-        String gatewayCidr = guestNetwork.getCidr();
+        final String gatewayCidr = guestNetwork.getCidr();
         guestNic.setNetmask(NetUtils.getCidrNetmask(gatewayCidr));
 
         return guestNic;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/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 6b928d7..a3f56c6 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -2631,15 +2631,19 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine>
{
 
     protected boolean aggregationExecution(final AggregationControlCommand.Action action,
final Network network, final List<DomainRouterVO> routers)
             throws AgentUnavailableException, ResourceUnavailableException {
+
+        int errors = 0;
+
         for (final DomainRouterVO router : routers) {
 
             final String routerControlIp = _routerControlHelper.getRouterControlIp(router.getId());
             final String routerIpInNetwork = _routerControlHelper.getRouterIpInNetwork(network.getId(),
router.getId());
 
             if (routerIpInNetwork == null) {
-                //Guest Nics are getting removed during the procedure and added back again.
-                //Returniung false here and waiting for the retry.
-                return false;
+                // Nic hasn't been created in this router yet. Try to configure the next
one.
+                s_logger.warn("The Network is not configured in the router " + router.getHostName()
+ " yet. Try the next router!");
+                errors++;
+                continue;
             }
 
             final AggregationControlCommand cmd = new AggregationControlCommand(action, router.getInstanceName(),
routerControlIp, routerIpInNetwork);
@@ -2648,6 +2652,10 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine>
{
                 return false;
             }
         }
+        if (errors == routers.size()) {
+            s_logger.error("aggregationExecution() on " + getClass().getName() + " failed!
Network is not configured in any router.");
+            return false;
+        }
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
index 069937d..3d7ed5f 100644
--- a/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
+++ b/server/src/com/cloud/network/router/VpcNetworkHelperImpl.java
@@ -105,7 +105,7 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl {
                 continue;
             }
             if (guestNetwork.getState() == Network.State.Implemented || guestNetwork.getState()
== Network.State.Setup) {
-                final NicProfile guestNic = nicProfileHelper.createGuestNicProfileForVpcRouter(guestNetwork);
+                final NicProfile guestNic = nicProfileHelper.createGuestNicProfileForVpcRouter(vpcRouterDeploymentDefinition,
guestNetwork);
                 networks.put(guestNetwork, new ArrayList<NicProfile>(Arrays.asList(guestNic)));
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
index 8ee3010..b5283da 100644
--- a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
+++ b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
@@ -103,8 +103,8 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
         final VirtualRouter router = acls.getRouter();
         final Network network = acls.getNetwork();
 
-        Commands commands = new Commands(Command.OnError.Continue);
-        List<? extends NetworkACLItem> rules = acls.getRules();
+        final Commands commands = new Commands(Command.OnError.Continue);
+        final List<? extends NetworkACLItem> rules = acls.getRules();
         _commandSetupHelper.createNetworkACLsCommands(rules, router, commands, network.getId(),
acls.isPrivateGateway());
 
         return _networkGeneralHelper.sendCommandsToRouter(router, commands);
@@ -114,9 +114,9 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
     public boolean visit(final VpcIpAssociationRules vpcip) throws ResourceUnavailableException
{
         final VirtualRouter router = vpcip.getRouter();
 
-        Commands cmds = new Commands(Command.OnError.Continue);
-        Map<String, String> vlanMacAddress = vpcip.getVlanMacAddress();
-        List<PublicIpAddress> ipsToSend = vpcip.getIpsToSend();
+        final Commands cmds = new Commands(Command.OnError.Continue);
+        final Map<String, String> vlanMacAddress = vpcip.getVlanMacAddress();
+        final List<PublicIpAddress> ipsToSend = vpcip.getIpsToSend();
 
         if (!ipsToSend.isEmpty()) {
             _commandSetupHelper.createVpcAssociatePublicIPCommands(router, ipsToSend, cmds,
vlanMacAddress);
@@ -135,16 +135,16 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
 
         if (router.getState() == State.Running) {
 
-            PrivateIpVO ipVO = privateGW.retrivePrivateIP(this);
-            Network network = privateGW.retrievePrivateNetwork(this);
+            final PrivateIpVO ipVO = privateGW.retrivePrivateIP(this);
+            final Network network = privateGW.retrievePrivateNetwork(this);
 
-            String netmask = NetUtils.getCidrNetmask(network.getCidr());
-            PrivateIpAddress ip = new PrivateIpAddress(ipVO, network.getBroadcastUri().toString(),
network.getGateway(), netmask, nicProfile.getMacAddress());
+            final String netmask = NetUtils.getCidrNetmask(network.getCidr());
+            final PrivateIpAddress ip = new PrivateIpAddress(ipVO, network.getBroadcastUri().toString(),
network.getGateway(), netmask, nicProfile.getMacAddress());
 
-            List<PrivateIpAddress> privateIps = new ArrayList<PrivateIpAddress>(1);
+            final List<PrivateIpAddress> privateIps = new ArrayList<PrivateIpAddress>(1);
             privateIps.add(ip);
 
-            Commands cmds = new Commands(Command.OnError.Stop);
+            final Commands cmds = new Commands(Command.OnError.Stop);
             _commandSetupHelper.createVpcAssociatePrivateIPCommands(router, privateIps, cmds,
isAddOperation);
 
             try {
@@ -155,7 +155,7 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
                     s_logger.warn("Failed to associate ip address " + ip + " in vpc network
" + network);
                     return false;
                 }
-            } catch (Exception ex) {
+            } catch (final Exception ex) {
                 s_logger.warn("Failed to send  " + (isAddOperation ? "add " : "delete ")
+ " private network " + network + " commands to rotuer ");
                 return false;
             }
@@ -177,7 +177,7 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
 
         // In fact we send command to the host of router, we're not programming
         // router but the host
-        Commands cmds = new Commands(Command.OnError.Stop);
+        final Commands cmds = new Commands(Command.OnError.Stop);
         cmds.addCommand(setupCommand);
 
         try {
@@ -191,9 +191,9 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
     @Override
     public boolean visit(final StaticRoutesRules staticRoutesRules) throws ResourceUnavailableException
{
         final VirtualRouter router = staticRoutesRules.getRouter();
-        List<StaticRouteProfile> staticRoutes = staticRoutesRules.getStaticRoutes();
+        final List<StaticRouteProfile> staticRoutes = staticRoutesRules.getStaticRoutes();
 
-        Commands cmds = new Commands(Command.OnError.Continue);
+        final Commands cmds = new Commands(Command.OnError.Continue);
         _commandSetupHelper.createStaticRouteCommands(staticRoutes, router, cmds);
 
         return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
@@ -202,9 +202,9 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
     @Override
     public boolean visit(final AdvancedVpnRules vpnRules) throws ResourceUnavailableException
{
         final VirtualRouter router = vpnRules.getRouter();
-        List<? extends VpnUser> users = vpnRules.getUsers();
+        final List<? extends VpnUser> users = vpnRules.getUsers();
 
-        Commands cmds = new Commands(Command.OnError.Continue);
+        final Commands cmds = new Commands(Command.OnError.Continue);
         _commandSetupHelper.createApplyVpnUsersCommand(users, router, cmds);
 
         // Currently we receive just one answer from the agent. In the future we

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index 0144ea0..1a3e12a 100644
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -52,6 +52,7 @@ class CsRedundant(object):
     CONNTRACKD_BIN = "/usr/sbin/conntrackd"
     CONNTRACKD_LOCK = "/var/lock/conntrack.lock"
     CONNTRACKD_CONFIG = "/etc/conntrackd/conntrackd.conf"
+    RROUTER_LOG = "/var/log/cloud.log"
 
     def __init__(self, config):
         self.cl = config.cmdline()
@@ -86,6 +87,11 @@ class CsRedundant(object):
         CsHelper.copy_if_needed("%s/%s" % (self.CS_TEMPLATES_DIR, "conntrackd.conf.templ"),
"/etc/conntrackd/conntrackd.conf")
         CsHelper.copy_if_needed("%s/%s" % (self.CS_TEMPLATES_DIR, "checkrouter.sh.templ"),
"/opt/cloud/bin/checkrouter.sh")
 
+        # checkrouter.sh configuration
+        file = CsFile("/opt/cloud/bin/checkrouter.sh")
+        file.greplace("[RROUTER_LOG]", self.RROUTER_LOG)
+        file.commit()
+
         # keepalived configuration
         file = CsFile("/etc/keepalived/keepalived.conf")
         file.search(" router_id ", "    router_id %s" % self.cl.get_name())

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/systemvm/patches/debian/config/opt/cloud/bin/merge.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/merge.py b/systemvm/patches/debian/config/opt/cloud/bin/merge.py
index e3d54ac..6028415 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/merge.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/merge.py
@@ -126,6 +126,10 @@ class updateDataBag:
 
     def processGuestNetwork(self, dbag):
         d = self.qFile.data
+        
+        if not set(['device']).issubset(d):
+            return dbag
+        
         dp = {}
         dp['public_ip'] = d['router_guest_ip']
         dp['netmask'] = d['router_guest_netmask']
@@ -139,7 +143,7 @@ class updateDataBag:
         qf.load({'ip_address': [dp], 'type': 'ips'})
         if 'domain_name' not in d.keys() or d['domain_name'] == '':
             d['domain_name'] = "cloudnine.internal"
-        return cs_guestnetwork.merge(dbag, self.qFile.data)
+        return cs_guestnetwork.merge(dbag, d)
 
     def process_dhcp_entry(self, dbag):
         return cs_dhcp.merge(dbag, self.qFile.data)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/systemvm/patches/debian/config/opt/cloud/bin/serve_password.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/serve_password.sh b/systemvm/patches/debian/config/opt/cloud/bin/serve_password.sh
index 294eab0..7bf1f0a 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/serve_password.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/serve_password.sh
@@ -68,7 +68,7 @@ do
 	then
 		break
 	fi
-done
+done &
 
 echo -ne "HTTP/1.0 200 OK\r\nDocumentType: text/plain\r\n\r\n"
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/systemvm/patches/debian/config/opt/cloud/bin/update_config.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/update_config.py b/systemvm/patches/debian/config/opt/cloud/bin/update_config.py
index 4c017ab..75e0c85 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/update_config.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/update_config.py
@@ -24,6 +24,7 @@ from subprocess import PIPE, STDOUT
 import os
 import os.path
 import configure
+import json
 
 logging.basicConfig(filename='/var/log/cloud.log', level=logging.DEBUG, format='%(asctime)s
%(message)s')
 
@@ -33,23 +34,92 @@ if (len(sys.argv) != 2):
     sys.exit(1)
 
 # FIXME we should get this location from a configuration class
-filePath = "/var/cache/cloud/%s" % sys.argv[1]
-if not (os.path.isfile(filePath) and os.access(filePath, os.R_OK)):
-    print "[ERROR]: You are telling me to process %s, but i can't access it" % filePath
+jsonPath = "/var/cache/cloud/%s"
+jsonCmdConfigPath = jsonPath % sys.argv[1]
+currentGuestNetConfig = "/etc/cloudstack/guestnetwork.json"
+
+def finish_config():
+    # Converge
+    returncode = configure.main([])
+    sys.exit(returncode)
+
+def process_file():
+    print "[INFO] Processing JSON file %s" % sys.argv[1]
+    qf = QueueFile()
+    qf.setFile(sys.argv[1])
+    qf.load(None)
+    # Converge
+    finish_config()
+
+def is_guestnet_configured(guestnet_dict, key):
+    
+    existing_key = None
+    new_eth_key = None
+    
+    for k1, v in guestnet_dict.iteritems():
+        for k2 in key:
+            if k1 == k2 and len(guestnet_dict[k1]) > 0:
+                existing_key = k1
+        if existing_key:
+            break
+    
+    if not existing_key:
+        return False
+    
+    file = open(jsonCmdConfigPath)
+    new_guestnet_dict = json.load(file)
+    
+    for k1, v in new_guestnet_dict.iteritems():
+        for k2 in key:
+            if k1 == k2 and len(new_guestnet_dict[k1]) > 0:
+                new_eth_key = k1
+        if new_eth_key:
+            break
+    
+    if not new_eth_key:
+        '''
+        Why is the new guest net dictionary empty?
+          1. It might be setting up a single VPC, no  need to continue.
+          2. Did we get any RTNETLINK error? If so, it might be trying to unplug the Guest
Net NIC. Let's not allow it for now.
+          3. Might be a bug on the Java side.
+        Return True so we won't process an empty file. However, we have to investigate it!
+        '''
+        return True
+
+    old_eth = guestnet_dict[existing_key][0]
+    new_eth = new_guestnet_dict[new_eth_key][0]
+    
+    new_mac = new_eth["mac_address"].encode('utf-8')
+    old_mac = old_eth["mac_address"].encode('utf-8')
+    new_ip = new_eth["router_guest_ip"].encode('utf-8')
+    old_ip = old_eth["router_guest_ip"].encode('utf-8')
+    
+    if (new_mac == old_mac) and (new_ip == old_ip):
+        print "[WARN] Guest Network already configured. Will skip the file to avoid RTNETLINK
errors."
+        return True
+    
+    return False
+
+if not (os.path.isfile(jsonCmdConfigPath) and os.access(jsonCmdConfigPath, os.R_OK)):
+    print "[ERROR]: You are telling me to process %s, but i can't access it" % jsonCmdConfigPath
     sys.exit(1)
 
 # If the command line json file is unprocessed process it
 # This is important or, the control interfaces will get deleted!
-if os.path.isfile("filePath/%s" % "cmd_line.json"):
+if os.path.isfile(jsonPath % "cmd_line.json"):
     qf = QueueFile()
     qf.setFile("cmd_line.json")
     qf.load(None)
 
-qf = QueueFile()
-qf.setFile(sys.argv[1])
-qf.load(None)
-
-# Converge
-returncode = configure.main([])
-
-sys.exit(returncode)
+# If the guest network is already configured and have the same IP, do not try to configure
it again otherwise it will break
+if sys.argv[1] == "guest_network.json":
+    if os.path.isfile(currentGuestNetConfig):
+        file = open(currentGuestNetConfig)
+        guestnet_dict = json.load(file)
+    
+        if not is_guestnet_configured(guestnet_dict, ['eth1', 'eth2', 'eth3']):
+            process_file()
+        else:
+            finish_config() 
+else:
+    process_file()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f97a5522/systemvm/patches/debian/config/opt/cloud/bin/vpc_passwd_server
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/vpc_passwd_server b/systemvm/patches/debian/config/opt/cloud/bin/vpc_passwd_server
index 6488bec..44de1c2 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/vpc_passwd_server
+++ b/systemvm/patches/debian/config/opt/cloud/bin/vpc_passwd_server
@@ -29,4 +29,4 @@ do
         sleep 3
     fi
     result=`ip addr show | grep $ip`
-done
+done &
\ No newline at end of file


Mime
View raw message