cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [12/50] [abbrv] git commit: updated refs/heads/feature/systemvm-persistent-config to 4fe7264
Date Wed, 04 Feb 2015 20:28:32 GMT
Java: Fixing the redundant flag for the router control nic and the guest network command;
Python: fix the redundant setup in the CsRedundant class


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

Branch: refs/heads/feature/systemvm-persistent-config
Commit: b53c1e7991f73ca0ea646fe674585f2454f9511e
Parents: 2ab3023
Author: wilderrodrigues <wrodrigues@schubergphilis.com>
Authored: Thu Dec 18 13:38:49 2014 +0100
Committer: wilderrodrigues <wrodrigues@schubergphilis.com>
Committed: Wed Feb 4 18:41:11 2015 +0100

----------------------------------------------------------------------
 .../VirtualNetworkApplianceManagerImpl.java     |  44 +++--
 .../VpcVirtualNetworkApplianceManagerImpl.java  | 186 +++++++++----------
 .../config/opt/cloud/bin/cs/CsRedundant.py      |   3 +-
 .../config/opt/cloud/bin/set_redundant.py       |   4 +-
 4 files changed, 127 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b53c1e79/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 37abd71..63f32b7 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -1309,7 +1309,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine>
{
         }
     }
 
-    protected int getUpdatedPriority(final Network guestNetwork, final List<DomainRouterVO>
routers, final DomainRouterVO exclude)
+    protected int getUpdatedPriority(final Network network, final List<DomainRouterVO>
routers, final DomainRouterVO exclude)
             throws InsufficientVirtualNetworkCapacityException {
         int priority;
         if (routers.size() == 0) {
@@ -1331,11 +1331,11 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine>
{
             }
             if (maxPriority < 20) {
                 s_logger.error("Current maximum priority is too low!");
-                throw new InsufficientVirtualNetworkCapacityException("Current maximum priority
is too low as " + maxPriority + "!", guestNetwork.getId());
+                throw new InsufficientVirtualNetworkCapacityException("Current maximum priority
is too low as " + maxPriority + "!", network.getId());
             } else if (maxPriority > 200) {
                 s_logger.error("Too many times fail-over happened! Current maximum priority
is too high as " + maxPriority + "!");
                 throw new InsufficientVirtualNetworkCapacityException("Too many times fail-over
happened! Current maximum priority is too high as " + maxPriority + "!",
-                        guestNetwork.getId());
+                        network.getId());
             }
             priority = maxPriority - DEFAULT_DELTA + 1;
         }
@@ -1402,6 +1402,8 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine>
{
                 buf.append(" localgw=").append(dest.getPod().getGateway());
             } else if (nic.getTrafficType() == TrafficType.Control) {
                 controlNic = nic;
+                buf.append(createRedundantRouterArgs(controlNic, router));
+
                 // DOMR control command is sent over management server in VMware
                 if (dest.getHost().getHypervisorType() == HypervisorType.VMware || dest.getHost().getHypervisorType()
== HypervisorType.Hyperv) {
                     s_logger.info("Check if we need to add management server explicit route
to DomR. pod cidr: " + dest.getPod().getCidrAddress() + "/"
@@ -1529,7 +1531,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine>
{
         return true;
     }
 
-    protected StringBuilder createGuestBootLoadArgs(final NicProfile guestNic, final String
defaultDns1, final String defaultDns2, DomainRouterVO router) {
+    protected StringBuilder createGuestBootLoadArgs(final NicProfile guestNic, final String
defaultDns1, final String defaultDns2, final DomainRouterVO router) {
         final long guestNetworkId = guestNic.getNetworkId();
         final NetworkVO guestNetwork = _networkDao.findById(guestNetworkId);
         String dhcpRange = null;
@@ -1539,16 +1541,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine>
{
 
         final boolean isRedundant = router.getIsRedundantRouter();
         if (isRedundant) {
-            buf.append(" redundant_router=1");
-            final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(guestNetwork.getId(),
Role.VIRTUAL_ROUTER);
-            try {
-                final int priority = getUpdatedPriority(guestNetwork, routers, router);
-                router.setPriority(priority);
-                router = _routerDao.persist(router);
-            } catch (final InsufficientVirtualNetworkCapacityException e) {
-                s_logger.error("Failed to get update priority!", e);
-                throw new CloudRuntimeException("Failed to get update priority!");
-            }
+            buf.append(createRedundantRouterArgs(guestNic, router));
             final Network net = _networkModel.getNetwork(guestNic.getNetworkId());
             buf.append(" guestgw=").append(net.getGateway());
             final String brd = NetUtils.long2Ip(NetUtils.ip2Long(guestNic.getIp4Address())
| ~NetUtils.ip2Long(guestNic.getNetmask()));
@@ -1594,6 +1587,29 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine>
{
         return buf;
     }
 
+    protected StringBuilder createRedundantRouterArgs(final NicProfile nic, DomainRouterVO
router) {
+        final StringBuilder buf = new StringBuilder();
+
+        final long networkId = nic.getNetworkId();
+        final NetworkVO network = _networkDao.findById(networkId);
+
+        final boolean isRedundant = router.getIsRedundantRouter();
+        if (isRedundant) {
+            buf.append(" redundant_router=1");
+            final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(nic.getNetworkId(),
Role.VIRTUAL_ROUTER);
+            try {
+                final int priority = getUpdatedPriority(network, routers, router);
+                router.setPriority(priority);
+                router = _routerDao.persist(router);
+            } catch (final InsufficientVirtualNetworkCapacityException e) {
+                s_logger.error("Failed to get update priority!", e);
+                throw new CloudRuntimeException("Failed to get update priority!");
+            }
+        }
+
+        return buf;
+    }
+
     @Override
     public boolean finalizeDeployment(final Commands cmds, final VirtualMachineProfile profile,
final DeployDestination dest, final ReservationContext context)
             throws ResourceUnavailableException {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b53c1e79/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index 688453e..feb5d47 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -141,7 +141,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             // 1) add nic to the router
             _routerDao.addRouterToGuestNetwork(router, network);
 
-            NicProfile guestNic = _itMgr.addVmToNetwork(router, network, null);
+            final NicProfile guestNic = _itMgr.addVmToNetwork(router, network, null);
             // 2) setup guest network
             if (guestNic != null) {
                 result = setupVpcGuestNetwork(network, router, true, guestNic);
@@ -153,7 +153,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             if (result && params.get(Param.ReProgramGuestNetworks) != null &&
(Boolean) params.get(Param.ReProgramGuestNetworks) == true) {
                 sendNetworkRulesToRouter(router.getId(), network.getId());
             }
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             s_logger.warn("Failed to add router " + router + " to network " + network + "
due to ", ex);
             result = false;
         } finally {
@@ -174,7 +174,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
 
     @Override
     public boolean removeVpcRouterFromGuestNetwork(final VirtualRouter router, final Network
network, final boolean isRedundant) throws ConcurrentOperationException,
-            ResourceUnavailableException {
+    ResourceUnavailableException {
         if (network.getTrafficType() != TrafficType.Guest) {
             s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest);
             return false;
@@ -205,18 +205,18 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     }
 
     protected boolean setupVpcGuestNetwork(final Network network, final VirtualRouter router,
final boolean add, final NicProfile guestNic) throws ConcurrentOperationException,
-            ResourceUnavailableException {
+    ResourceUnavailableException {
 
         boolean result = true;
         if (router.getState() == State.Running) {
-            SetupGuestNetworkCommand setupCmd = _commandSetupHelper.createSetupGuestNetworkCommand(router,
add, guestNic);
+            final SetupGuestNetworkCommand setupCmd = _commandSetupHelper.createSetupGuestNetworkCommand(router,
add, guestNic);
 
-            Commands cmds = new Commands(Command.OnError.Stop);
+            final Commands cmds = new Commands(Command.OnError.Stop);
             cmds.addCommand("setupguestnetwork", setupCmd);
             _nwHelper.sendCommandsToRouter(router, cmds);
 
-            Answer setupAnswer = cmds.getAnswer("setupguestnetwork");
-            String setup = add ? "set" : "destroy";
+            final Answer setupAnswer = cmds.getAnswer("setupguestnetwork");
+            final String setup = add ? "set" : "destroy";
             if (!(setupAnswer != null && setupAnswer.getResult())) {
                 s_logger.warn("Unable to " + setup + " guest network on router " + router);
                 result = false;
@@ -234,15 +234,15 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
 
     @Override
     public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile, final
DeployDestination dest, final ReservationContext context) {
-        DomainRouterVO vr = _routerDao.findById(profile.getId());
+        final DomainRouterVO vr = _routerDao.findById(profile.getId());
 
         if (vr.getVpcId() != null) {
             String defaultDns1 = null;
             String defaultDns2 = null;
             // remove public and guest nics as we will plug them later
-            Iterator<NicProfile> it = profile.getNics().iterator();
+            final Iterator<NicProfile> it = profile.getNics().iterator();
             while (it.hasNext()) {
-                NicProfile nic = it.next();
+                final NicProfile nic = it.next();
                 if (nic.getTrafficType() == TrafficType.Public || nic.getTrafficType() ==
TrafficType.Guest) {
                     // save dns information
                     if (nic.getTrafficType() == TrafficType.Public) {
@@ -255,8 +255,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             }
 
             // add vpc cidr/dns/networkdomain to the boot load args
-            StringBuilder buf = profile.getBootArgsBuilder();
-            Vpc vpc = _entityMgr.findById(Vpc.class, vr.getVpcId());
+            final StringBuilder buf = profile.getBootArgsBuilder();
+            final Vpc vpc = _entityMgr.findById(Vpc.class, vr.getVpcId());
             buf.append(" vpccidr=" + vpc.getCidr() + " domain=" + vpc.getNetworkDomain());
 
             buf.append(" dns1=").append(defaultDns1);
@@ -270,15 +270,15 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
 
     @Override
     public boolean finalizeCommandsOnStart(final Commands cmds, final VirtualMachineProfile
profile) {
-        DomainRouterVO router = _routerDao.findById(profile.getId());
+        final DomainRouterVO router = _routerDao.findById(profile.getId());
 
-        boolean isVpc = router.getVpcId() != null;
+        final boolean isVpc = router.getVpcId() != null;
         if (!isVpc) {
             return super.finalizeCommandsOnStart(cmds, profile);
         }
 
         // 1) FORM SSH CHECK COMMAND
-        NicProfile controlNic = getControlNic(profile);
+        final NicProfile controlNic = getControlNic(profile);
         if (controlNic == null) {
             s_logger.error("Control network doesn't exist for the router " + router);
             return false;
@@ -287,52 +287,52 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         finalizeSshAndVersionAndNetworkUsageOnStart(cmds, profile, router, controlNic);
 
         // 2) FORM PLUG NIC COMMANDS
-        List<Pair<Nic, Network>> guestNics = new ArrayList<Pair<Nic, Network>>();
-        List<Pair<Nic, Network>> publicNics = new ArrayList<Pair<Nic, Network>>();
-        Map<String, String> vlanMacAddress = new HashMap<String, String>();
+        final List<Pair<Nic, Network>> guestNics = new ArrayList<Pair<Nic,
Network>>();
+        final List<Pair<Nic, Network>> publicNics = new ArrayList<Pair<Nic,
Network>>();
+        final Map<String, String> vlanMacAddress = new HashMap<String, String>();
 
-        List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
-        for (Nic routerNic : routerNics) {
-            Network network = _networkModel.getNetwork(routerNic.getNetworkId());
+        final List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
+        for (final Nic routerNic : routerNics) {
+            final Network network = _networkModel.getNetwork(routerNic.getNetworkId());
             if (network.getTrafficType() == TrafficType.Guest) {
-                Pair<Nic, Network> guestNic = new Pair<Nic, Network>(routerNic,
network);
+                final Pair<Nic, Network> guestNic = new Pair<Nic, Network>(routerNic,
network);
                 guestNics.add(guestNic);
             } else if (network.getTrafficType() == TrafficType.Public) {
-                Pair<Nic, Network> publicNic = new Pair<Nic, Network>(routerNic,
network);
+                final Pair<Nic, Network> publicNic = new Pair<Nic, Network>(routerNic,
network);
                 publicNics.add(publicNic);
-                String vlanTag = BroadcastDomainType.getValue(routerNic.getBroadcastUri());
+                final String vlanTag = BroadcastDomainType.getValue(routerNic.getBroadcastUri());
                 vlanMacAddress.put(vlanTag, routerNic.getMacAddress());
             }
         }
 
-        List<Command> usageCmds = new ArrayList<Command>();
+        final List<Command> usageCmds = new ArrayList<Command>();
 
         // 3) PREPARE PLUG NIC COMMANDS
         try {
             // add VPC router to public networks
-            List<PublicIp> sourceNat = new ArrayList<PublicIp>(1);
-            for (Pair<Nic, Network> nicNtwk : publicNics) {
-                Nic publicNic = nicNtwk.first();
-                Network publicNtwk = nicNtwk.second();
-                IPAddressVO userIp = _ipAddressDao.findByIpAndSourceNetworkId(publicNtwk.getId(),
publicNic.getIp4Address());
+            final List<PublicIp> sourceNat = new ArrayList<PublicIp>(1);
+            for (final Pair<Nic, Network> nicNtwk : publicNics) {
+                final Nic publicNic = nicNtwk.first();
+                final Network publicNtwk = nicNtwk.second();
+                final IPAddressVO userIp = _ipAddressDao.findByIpAndSourceNetworkId(publicNtwk.getId(),
publicNic.getIp4Address());
 
                 if (userIp.isSourceNat()) {
-                    PublicIp publicIp = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId()));
+                    final PublicIp publicIp = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId()));
                     sourceNat.add(publicIp);
 
                     if (router.getPublicIpAddress() == null) {
-                        DomainRouterVO routerVO = _routerDao.findById(router.getId());
+                        final DomainRouterVO routerVO = _routerDao.findById(router.getId());
                         routerVO.setPublicIpAddress(publicNic.getIp4Address());
                         routerVO.setPublicNetmask(publicNic.getNetmask());
                         routerVO.setPublicMacAddress(publicNic.getMacAddress());
                         _routerDao.update(routerVO.getId(), routerVO);
                     }
                 }
-                PlugNicCommand plugNicCmd = new PlugNicCommand(_nwHelper.getNicTO(router,
publicNic.getNetworkId(), publicNic.getBroadcastUri().toString()),
+                final PlugNicCommand plugNicCmd = new PlugNicCommand(_nwHelper.getNicTO(router,
publicNic.getNetworkId(), publicNic.getBroadcastUri().toString()),
                         router.getInstanceName(), router.getType());
                 cmds.addCommand(plugNicCmd);
-                VpcVO vpc = _vpcDao.findById(router.getVpcId());
-                NetworkUsageCommand netUsageCmd = new NetworkUsageCommand(router.getPrivateIpAddress(),
router.getInstanceName(), true, publicNic.getIp4Address(), vpc.getCidr());
+                final VpcVO vpc = _vpcDao.findById(router.getVpcId());
+                final NetworkUsageCommand netUsageCmd = new NetworkUsageCommand(router.getPrivateIpAddress(),
router.getInstanceName(), true, publicNic.getIp4Address(), vpc.getCidr());
                 usageCmds.add(netUsageCmd);
                 UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(),
publicNtwk.getId(), publicNic.getIp4Address(), router.getId(),
                         router.getType().toString());
@@ -349,35 +349,35 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             }
 
             // add VPC router to guest networks
-            for (Pair<Nic, Network> nicNtwk : guestNics) {
-                Nic guestNic = nicNtwk.first();
+            for (final Pair<Nic, Network> nicNtwk : guestNics) {
+                final Nic guestNic = nicNtwk.first();
                 // plug guest nic
-                PlugNicCommand plugNicCmd = new PlugNicCommand(_nwHelper.getNicTO(router,
guestNic.getNetworkId(), null), router.getInstanceName(), router.getType());
+                final PlugNicCommand plugNicCmd = new PlugNicCommand(_nwHelper.getNicTO(router,
guestNic.getNetworkId(), null), router.getInstanceName(), router.getType());
                 cmds.addCommand(plugNicCmd);
                 if (!_networkModel.isPrivateGateway(guestNic.getNetworkId())) {
                     // set guest network
-                    VirtualMachine vm = _vmDao.findById(router.getId());
-                    NicProfile nicProfile = _networkModel.getNicProfile(vm, guestNic.getNetworkId(),
null);
-                    SetupGuestNetworkCommand setupCmd = _commandSetupHelper.createSetupGuestNetworkCommand(router,
true, nicProfile);
+                    final VirtualMachine vm = _vmDao.findById(router.getId());
+                    final NicProfile nicProfile = _networkModel.getNicProfile(vm, guestNic.getNetworkId(),
null);
+                    final SetupGuestNetworkCommand setupCmd = _commandSetupHelper.createSetupGuestNetworkCommand(router,
true, nicProfile);
                     cmds.addCommand(setupCmd);
                 } else {
 
                     // set private network
-                    PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(guestNic.getNetworkId(),
guestNic.getIp4Address());
-                    Network network = _networkDao.findById(guestNic.getNetworkId());
+                    final PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(guestNic.getNetworkId(),
guestNic.getIp4Address());
+                    final Network network = _networkDao.findById(guestNic.getNetworkId());
                     BroadcastDomainType.getValue(network.getBroadcastUri());
-                    String netmask = NetUtils.getCidrNetmask(network.getCidr());
-                    PrivateIpAddress ip = new PrivateIpAddress(ipVO, network.getBroadcastUri().toString(),
network.getGateway(), netmask, guestNic.getMacAddress());
+                    final String netmask = NetUtils.getCidrNetmask(network.getCidr());
+                    final PrivateIpAddress ip = new PrivateIpAddress(ipVO, network.getBroadcastUri().toString(),
network.getGateway(), netmask, guestNic.getMacAddress());
 
-                    List<PrivateIpAddress> privateIps = new ArrayList<PrivateIpAddress>(1);
+                    final List<PrivateIpAddress> privateIps = new ArrayList<PrivateIpAddress>(1);
                     privateIps.add(ip);
                     _commandSetupHelper.createVpcAssociatePrivateIPCommands(router, privateIps,
cmds, true);
 
-                    Long privateGwAclId = _vpcGatewayDao.getNetworkAclIdForPrivateIp(ipVO.getVpcId(),
ipVO.getNetworkId(), ipVO.getIpAddress());
+                    final Long privateGwAclId = _vpcGatewayDao.getNetworkAclIdForPrivateIp(ipVO.getVpcId(),
ipVO.getNetworkId(), ipVO.getIpAddress());
 
                     if (privateGwAclId != null) {
                         // set network acl on private gateway
-                        List<NetworkACLItemVO> networkACLs = _networkACLItemDao.listByACL(privateGwAclId);
+                        final List<NetworkACLItemVO> networkACLs = _networkACLItemDao.listByACL(privateGwAclId);
                         s_logger.debug("Found " + networkACLs.size() + " network ACLs to
apply as a part of VPC VR " + router + " start for private gateway ip = "
                                 + ipVO.getIpAddress());
 
@@ -385,16 +385,16 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                     }
                 }
             }
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             s_logger.warn("Failed to add router " + router + " to network due to exception
", ex);
             return false;
         }
 
         // 4) RE-APPLY ALL STATIC ROUTE RULES
-        List<? extends StaticRoute> routes = _staticRouteDao.listByVpcId(router.getVpcId());
-        List<StaticRouteProfile> staticRouteProfiles = new ArrayList<StaticRouteProfile>(routes.size());
-        Map<Long, VpcGateway> gatewayMap = new HashMap<Long, VpcGateway>();
-        for (StaticRoute route : routes) {
+        final List<? extends StaticRoute> routes = _staticRouteDao.listByVpcId(router.getVpcId());
+        final List<StaticRouteProfile> staticRouteProfiles = new ArrayList<StaticRouteProfile>(routes.size());
+        final Map<Long, VpcGateway> gatewayMap = new HashMap<Long, VpcGateway>();
+        for (final StaticRoute route : routes) {
             VpcGateway gateway = gatewayMap.get(route.getVpcGatewayId());
             if (gateway == null) {
                 gateway = _entityMgr.findById(VpcGateway.class, route.getVpcGatewayId());
@@ -409,7 +409,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         }
 
         // 5) RE-APPLY ALL REMOTE ACCESS VPNs
-        RemoteAccessVpnVO vpn = _vpnDao.findByAccountAndVpc(router.getAccountId(), router.getVpcId());
+        final RemoteAccessVpnVO vpn = _vpnDao.findByAccountAndVpc(router.getAccountId(),
router.getVpcId());
         if (vpn != null) {
             _commandSetupHelper.createApplyVpnCommands(true, vpn, router, cmds);
         }
@@ -420,18 +420,18 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             reprogramGuestNtwks = false;
         }
 
-        VirtualRouterProvider vrProvider = _vrProviderDao.findById(router.getElementId());
+        final VirtualRouterProvider vrProvider = _vrProviderDao.findById(router.getElementId());
         if (vrProvider == null) {
             throw new CloudRuntimeException("Cannot find related virtual router provider
of router: " + router.getHostName());
         }
-        Provider provider = Network.Provider.getProvider(vrProvider.getType().toString());
+        final Provider provider = Network.Provider.getProvider(vrProvider.getType().toString());
         if (provider == null) {
             throw new CloudRuntimeException("Cannot find related provider of virtual router
provider: " + vrProvider.getType().toString());
         }
 
-        for (Pair<Nic, Network> nicNtwk : guestNics) {
-            Nic guestNic = nicNtwk.first();
-            AggregationControlCommand startCmd = new AggregationControlCommand(Action.Start,
router.getInstanceName(), controlNic.getIp4Address(), getRouterIpInNetwork(
+        for (final Pair<Nic, Network> nicNtwk : guestNics) {
+            final Nic guestNic = nicNtwk.first();
+            final AggregationControlCommand startCmd = new AggregationControlCommand(Action.Start,
router.getInstanceName(), controlNic.getIp4Address(), getRouterIpInNetwork(
                     guestNic.getNetworkId(), router.getId()));
             cmds.addCommand(startCmd);
             if (reprogramGuestNtwks) {
@@ -440,7 +440,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             }
 
             finalizeUserDataAndDhcpOnStart(cmds, router, provider, guestNic.getNetworkId());
-            AggregationControlCommand finishCmd = new AggregationControlCommand(Action.Finish,
router.getInstanceName(), controlNic.getIp4Address(), getRouterIpInNetwork(
+            final AggregationControlCommand finishCmd = new AggregationControlCommand(Action.Finish,
router.getInstanceName(), controlNic.getIp4Address(), getRouterIpInNetwork(
                     guestNic.getNetworkId(), router.getId()));
             cmds.addCommand(finishCmd);
         }
@@ -458,7 +458,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
 
         if (router.getVpcId() != null) {
             if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.NetworkACL,
Provider.VPCVirtualRouter)) {
-                List<NetworkACLItemVO> networkACLs = _networkACLMgr.listNetworkACLItems(guestNetworkId);
+                final List<NetworkACLItemVO> networkACLs = _networkACLMgr.listNetworkACLItems(guestNetworkId);
                 if (networkACLs != null && !networkACLs.isEmpty()) {
                     s_logger.debug("Found " + networkACLs.size() + " network ACLs to apply
as a part of VPC VR " + router + " start for guest network id=" + guestNetworkId);
                     _commandSetupHelper.createNetworkACLsCommands(networkACLs, router, cmds,
guestNetworkId, false);
@@ -468,14 +468,14 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     }
 
     protected boolean sendNetworkRulesToRouter(final long routerId, final long networkId)
throws ResourceUnavailableException {
-        DomainRouterVO router = _routerDao.findById(routerId);
-        Commands cmds = new Commands(OnError.Continue);
+        final DomainRouterVO router = _routerDao.findById(routerId);
+        final Commands cmds = new Commands(OnError.Continue);
 
-        VirtualRouterProvider vrProvider = _vrProviderDao.findById(router.getElementId());
+        final VirtualRouterProvider vrProvider = _vrProviderDao.findById(router.getElementId());
         if (vrProvider == null) {
             throw new CloudRuntimeException("Cannot find related virtual router provider
of router: " + router.getHostName());
         }
-        Provider provider = Network.Provider.getProvider(vrProvider.getType().toString());
+        final Provider provider = Network.Provider.getProvider(vrProvider.getType().toString());
         if (provider == null) {
             throw new CloudRuntimeException("Cannot find related provider of virtual router
provider: " + vrProvider.getType().toString());
         }
@@ -494,14 +494,14 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     protected boolean setupVpcPrivateNetwork(final VirtualRouter router, final boolean add,
final NicProfile privateNic) throws ResourceUnavailableException {
 
         if (router.getState() == State.Running) {
-            PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(privateNic.getNetworkId(),
privateNic.getIp4Address());
-            Network network = _networkDao.findById(privateNic.getNetworkId());
-            String netmask = NetUtils.getCidrNetmask(network.getCidr());
-            PrivateIpAddress ip = new PrivateIpAddress(ipVO, network.getBroadcastUri().toString(),
network.getGateway(), netmask, privateNic.getMacAddress());
+            final PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(privateNic.getNetworkId(),
privateNic.getIp4Address());
+            final Network network = _networkDao.findById(privateNic.getNetworkId());
+            final String netmask = NetUtils.getCidrNetmask(network.getCidr());
+            final PrivateIpAddress ip = new PrivateIpAddress(ipVO, network.getBroadcastUri().toString(),
network.getGateway(), netmask, privateNic.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,
add);
 
             try {
@@ -512,7 +512,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                     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  " + (add ? "add " : "delete ") + " private
network " + network + " commands to rotuer ");
                 return false;
             }
@@ -535,7 +535,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             return true;
         }
 
-        Network privateNetwork = _networkModel.getNetwork(gateway.getNetworkId());
+        final Network privateNetwork = _networkModel.getNetwork(gateway.getNetworkId());
 
         s_logger.debug("Releasing private ip for gateway " + gateway + " from " + router);
         boolean result = setupVpcPrivateNetwork(router, false, _networkModel.getNicProfile(router,
privateNetwork.getId(), null));
@@ -565,7 +565,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             return;
         }
 
-        ArrayList<? extends PublicIpAddress> publicIps = getPublicIpsToApply(router,
provider, guestNetworkId, IpAddress.State.Releasing);
+        final ArrayList<? extends PublicIpAddress> publicIps = getPublicIpsToApply(router,
provider, guestNetworkId, IpAddress.State.Releasing);
 
         if (publicIps != null && !publicIps.isEmpty()) {
             s_logger.debug("Found " + publicIps.size() + " ip(s) to apply as a part of domR
" + router + " start.");
@@ -597,7 +597,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     }
 
     protected boolean applySite2SiteVpn(final boolean isCreate, final VirtualRouter router,
final Site2SiteVpnConnection conn) throws ResourceUnavailableException {
-        Commands cmds = new Commands(Command.OnError.Continue);
+        final Commands cmds = new Commands(Command.OnError.Continue);
         _commandSetupHelper.createSite2SiteVpnCfgCommands(conn, isCreate, router, cmds);
         return _nwHelper.sendCommandsToRouter(router, cmds);
     }
@@ -605,12 +605,12 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     protected Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>>
getNicsToChangeOnRouter(final List<? extends PublicIpAddress> publicIps, final VirtualRouter
router) {
         // 1) check which nics need to be plugged/unplugged and plug/unplug them
 
-        Map<String, PublicIpAddress> nicsToPlug = new HashMap<String, PublicIpAddress>();
-        Map<String, PublicIpAddress> nicsToUnplug = new HashMap<String, PublicIpAddress>();
+        final Map<String, PublicIpAddress> nicsToPlug = new HashMap<String, PublicIpAddress>();
+        final Map<String, PublicIpAddress> nicsToUnplug = new HashMap<String, PublicIpAddress>();
 
         // find out nics to unplug
-        for (PublicIpAddress ip : publicIps) {
-            long publicNtwkId = ip.getNetworkId();
+        for (final PublicIpAddress ip : publicIps) {
+            final long publicNtwkId = ip.getNetworkId();
 
             // if ip is not associated to any network, and there are no firewall
             // rules, release it on the backend
@@ -619,7 +619,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             }
 
             if (ip.getState() == IpAddress.State.Releasing) {
-                Nic nic = _nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId,
router.getId(), ip.getAddress().addr());
+                final Nic nic = _nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId,
router.getId(), ip.getAddress().addr());
                 if (nic != null) {
                     nicsToUnplug.put(ip.getVlanTag(), ip);
                     s_logger.debug("Need to unplug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag()
+ " in public network id =" + publicNtwkId);
@@ -628,9 +628,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         }
 
         // find out nics to plug
-        for (PublicIpAddress ip : publicIps) {
-            URI broadcastUri = BroadcastDomainType.Vlan.toUri(ip.getVlanTag());
-            long publicNtwkId = ip.getNetworkId();
+        for (final PublicIpAddress ip : publicIps) {
+            final URI broadcastUri = BroadcastDomainType.Vlan.toUri(ip.getVlanTag());
+            final long publicNtwkId = ip.getNetworkId();
 
             // if ip is not associated to any network, and there are no firewall
             // rules, release it on the backend
@@ -641,15 +641,15 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             if (ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating)
{
                 // nic has to be plugged only when there are no nics for this
                 // vlan tag exist on VR
-                Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(publicNtwkId,
router.getId(), broadcastUri.toString());
+                final Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(publicNtwkId,
router.getId(), broadcastUri.toString());
 
                 if (nic == null && nicsToPlug.get(ip.getVlanTag()) == null) {
                     nicsToPlug.put(ip.getVlanTag(), ip);
                     s_logger.debug("Need to plug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag()
+ " in public network id =" + publicNtwkId);
                 } else {
-                    PublicIpAddress nicToUnplug = nicsToUnplug.get(ip.getVlanTag());
+                    final PublicIpAddress nicToUnplug = nicsToUnplug.get(ip.getVlanTag());
                     if (nicToUnplug != null) {
-                        NicVO nicVO = _nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId,
router.getId(), nicToUnplug.getAddress().addr());
+                        final NicVO nicVO = _nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId,
router.getId(), nicToUnplug.getAddress().addr());
                         nicVO.setIp4Address(ip.getAddress().addr());
                         _nicDao.update(nicVO.getId(), nicVO);
                         s_logger.debug("Updated the nic " + nicVO + " with the new ip address
" + ip.getAddress().addr());
@@ -659,7 +659,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             }
         }
 
-        Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>>
nicsToChange = new Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>>(nicsToPlug,
+        final Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>>
nicsToChange = new Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>>(nicsToPlug,
                 nicsToUnplug);
         return nicsToChange;
     }
@@ -668,8 +668,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     public void finalizeStop(final VirtualMachineProfile profile, final Answer answer) {
         super.finalizeStop(profile, answer);
         // Mark VPN connections as Disconnected
-        DomainRouterVO router = _routerDao.findById(profile.getId());
-        Long vpcId = router.getVpcId();
+        final DomainRouterVO router = _routerDao.findById(profile.getId());
+        final Long vpcId = router.getVpcId();
         if (vpcId != null) {
             _s2sVpnMgr.markDisconnectVpnConnByVpc(vpcId);
         }
@@ -698,12 +698,12 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                     router.getDataCenterId());
         }
 
-        Commands cmds = new Commands(Command.OnError.Stop);
+        final Commands cmds = new Commands(Command.OnError.Stop);
         _commandSetupHelper.createApplyVpnCommands(true, vpn, router, cmds);
 
         try {
             _agentMgr.send(router.getHostId(), cmds);
-        } catch (OperationTimedoutException e) {
+        } catch (final OperationTimedoutException e) {
             s_logger.debug("Failed to start remote access VPN: ", e);
             throw new AgentUnavailableException("Unable to send commands to virtual router
", router.getHostId(), e);
         }
@@ -730,7 +730,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         boolean result = true;
 
         if (router.getState() == State.Running) {
-            Commands cmds = new Commands(Command.OnError.Continue);
+            final Commands cmds = new Commands(Command.OnError.Continue);
             _commandSetupHelper.createApplyVpnCommands(false, vpn, router, cmds);
             result = result && _nwHelper.sendCommandsToRouter(router, cmds);
         } else if (router.getState() == State.Stopped) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b53c1e79/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 4a61409..0144ea0 100644
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -59,7 +59,8 @@ class CsRedundant(object):
 
     def set(self):
         logging.debug("Router redundancy status is %s", self.cl.is_redundant())
-        if self.cl.is_redundant():
+        guest = self.address.get_guest_if()
+        if self.cl.is_redundant() and guest:
             self._redundant_on()
         else:
             self._redundant_off()

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b53c1e79/systemvm/patches/debian/config/opt/cloud/bin/set_redundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/set_redundant.py b/systemvm/patches/debian/config/opt/cloud/bin/set_redundant.py
index 328eedd..7a8dad0 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/set_redundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/set_redundant.py
@@ -40,8 +40,8 @@ logging.basicConfig(filename=config.get_logger(),
 config.set_cl()
 
 if options.enable:
-    config.get_cmdline().dbag['config']['redundant_router'] = "true"
+    config.get_cmdline().set_redundant("true")
 if options.disable:
-    config.get_cmdline().dbag['config']['redundant_router'] = "false"
+    config.get_cmdline().set_redundant("false")
 
 config.get_cmdline().save()


Mime
View raw message