You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2016/05/02 16:36:22 UTC

[01/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75 [Forced Update!]

Repository: cloudstack
Updated Branches:
  refs/heads/4.9-bountycastle-daan 1b6cd4f9a -> a001d75c8 (forced update)


CLOUDSTACK-9194:  Making the console popup window resizable in IE to make sure the focus is not lost.


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: e985db90573accb2abb391c75223d111cb17a664
Parents: 7e12ebf
Author: Anshul Gangwar <an...@citrix.com>
Authored: Fri May 8 15:59:54 2015 +0530
Committer: Anshul Gangwar <an...@citrix.com>
Committed: Tue Dec 22 11:23:46 2015 +0530

----------------------------------------------------------------------
 ui/scripts/ui/widgets/detailView.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e985db90/ui/scripts/ui/widgets/detailView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js
index ddd7265..2ce72a2 100644
--- a/ui/scripts/ui/widgets/detailView.js
+++ b/ui/scripts/ui/widgets/detailView.js
@@ -301,7 +301,7 @@
                     }),
 
                     // Window options
-                    'menubar=0,resizable=0,' + 'width=' + externalLinkAction.width + ',' + 'height=' + externalLinkAction.height
+                    'menubar=0,resizable=1,' + 'width=' + externalLinkAction.width + ',' + 'height=' + externalLinkAction.height
                 );
             } else {
                 notification.desc = messages.notification(messageArgs);


[05/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
CLOUDSTACK-9322 : Changes to support InternalLbVm with Nuage VSP plugin


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: ae0d6b32d8d30f860a53c9c808ca136012609db7
Parents: c48b6c3
Author: Nick Livens <ni...@nuagenetworks.net>
Authored: Thu Feb 18 11:03:34 2016 +0100
Committer: Nick Livens <ni...@nuagenetworks.net>
Committed: Tue Mar 29 11:24:45 2016 +0200

----------------------------------------------------------------------
 .../com/cloud/api/commands/VspConstants.java    |  1 +
 .../api/response/NuageVspDeviceResponse.java    |  7 ++
 .../cloud/network/element/NuageVspElement.java  | 31 +++++++
 .../network/guru/NuageVspGuestNetworkGuru.java  |  9 ++
 .../network/manager/NuageVspManagerImpl.java    | 91 ++++++++++++++------
 .../network/element/NuageVspElementTest.java    |  6 ++
 .../guru/NuageVspGuestNetworkGuruTest.java      | 25 ++++--
 .../com/cloud/network/vpc/VpcManagerImpl.java   |  9 +-
 .../src/com/cloud/user/DomainManagerImpl.java   |  1 +
 ui/scripts/configuration.js                     |  5 +-
 10 files changed, 153 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0d6b32/plugins/network-elements/nuage-vsp/src/com/cloud/api/commands/VspConstants.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/api/commands/VspConstants.java b/plugins/network-elements/nuage-vsp/src/com/cloud/api/commands/VspConstants.java
index 2372890..7abcdfb 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/api/commands/VspConstants.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/api/commands/VspConstants.java
@@ -32,4 +32,5 @@ public class VspConstants {
     public static final String NUAGE_VSP_API_CHILD_RESOURCE = "childresource";
     public static final String NUAGE_VSP_API_RESOURCE_FILTER = "resourcefilter";
     public static final String NUAGE_VSP_API_RESOURCE_INFO = "resourceinfo";
+    public static final String NUAGE_VSP_CMS_ID = "cmsid";
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0d6b32/plugins/network-elements/nuage-vsp/src/com/cloud/api/response/NuageVspDeviceResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/api/response/NuageVspDeviceResponse.java b/plugins/network-elements/nuage-vsp/src/com/cloud/api/response/NuageVspDeviceResponse.java
index 136a465..346e288 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/api/response/NuageVspDeviceResponse.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/api/response/NuageVspDeviceResponse.java
@@ -65,6 +65,10 @@ public class NuageVspDeviceResponse extends BaseResponse {
     @Param(description = "the time to wait after failure before retrying to communicate to Nuage VSD")
     private long apiRetryInterval;
 
+    @SerializedName(VspConstants.NUAGE_VSP_CMS_ID)
+    @Param(description = "the CMS ID generated by the Nuage VSD")
+    private String cmsId;
+
     public void setId(String vspDetailsId) {
         this.id = vspDetailsId;
     }
@@ -101,4 +105,7 @@ public class NuageVspDeviceResponse extends BaseResponse {
         this.apiRetryInterval = apiRetryInterval;
     }
 
+    public void setCmsId(String cmsId) {
+        this.cmsId = cmsId;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0d6b32/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
index cb0d698..d0d5ad2 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/element/NuageVspElement.java
@@ -59,6 +59,7 @@ import com.cloud.network.dao.NuageVspDao;
 import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.PhysicalNetworkVO;
 import com.cloud.network.manager.NuageVspManager;
+import com.cloud.network.manager.NuageVspManagerImpl;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.FirewallRule.FirewallRuleType;
 import com.cloud.network.rules.FirewallRuleVO;
@@ -69,7 +70,9 @@ import com.cloud.network.vpc.NetworkACLItemVO;
 import com.cloud.network.vpc.PrivateGateway;
 import com.cloud.network.vpc.StaticRouteProfile;
 import com.cloud.network.vpc.Vpc;
+import com.cloud.network.vpc.VpcOfferingServiceMapVO;
 import com.cloud.network.vpc.dao.VpcDao;
+import com.cloud.network.vpc.dao.VpcOfferingServiceMapDao;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
@@ -135,6 +138,8 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
     @Inject
     VpcDao _vpcDao;
     @Inject
+    VpcOfferingServiceMapDao _vpcOfferingSrvcDao;
+    @Inject
     NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
     @Inject
     AgentManager _agentMgr;
@@ -426,6 +431,16 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
             }
         }
 
+        if (network.getVpcId() != null) {
+            NetworkOffering networkOffering = _ntwkOfferingDao.findById(network.getNetworkOfferingId());
+            if (!networkOffering.getIsPersistent()) {
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("NuageVsp can't handle VPC tiers which use a network offering which are not persistent");
+                }
+                return false;
+            }
+        }
+
         return true;
     }
 
@@ -586,6 +601,22 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
 
     @Override
     public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
+        List<VpcOfferingServiceMapVO> vpcOfferingServices = _vpcOfferingSrvcDao.listByVpcOffId(vpc.getVpcOfferingId());
+        Map<Network.Service, Set<Network.Provider>> supportedVpcServices = NuageVspManagerImpl.NUAGE_VSP_VPC_SERVICE_MAP;
+        for (VpcOfferingServiceMapVO vpcOfferingService : vpcOfferingServices) {
+            Network.Service service = Network.Service.getService(vpcOfferingService.getService());
+            if (!supportedVpcServices.containsKey(service)) {
+                s_logger.warn(String.format("NuageVsp doesn't support service %s for VPCs", service.getName()));
+                return false;
+            }
+
+            Network.Provider provider = Network.Provider.getProvider(vpcOfferingService.getProvider());
+            if (!supportedVpcServices.get(service).contains(provider)) {
+                s_logger.warn(String.format("NuageVsp doesn't support provider %s for service %s for VPCs", provider.getName(), service.getName()));
+                return false;
+            }
+        }
+
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0d6b32/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
index 5f69a21..2037d92 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
@@ -25,6 +25,7 @@ import com.cloud.agent.api.guru.DeallocateVmVspCommand;
 import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
 import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
 import com.cloud.agent.api.guru.TrashNetworkVspCommand;
+import com.cloud.configuration.ConfigurationManager;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.VlanVO;
@@ -105,6 +106,8 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
     AgentManager _agentMgr;
     @Inject
     NuageVspManager _nuageVspManager;
+    @Inject
+    ConfigurationManager _configMgr;
 
     public NuageVspGuestNetworkGuru() {
         super();
@@ -347,6 +350,12 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
     protected boolean canHandle(NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) {
         if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && (offering.getGuestType() == Network.GuestType.Isolated || offering.getGuestType() == Network.GuestType.Shared)
                 && isMyIsolationMethod(physicalNetwork)) {
+            if (_configMgr.isOfferingForVpc(offering) && !offering.getIsPersistent()) {
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("NuageVsp can't handle VPC tiers which use a network offering which are not persistent");
+                }
+                return false;
+            }
             return true;
         } else {
             if (s_logger.isTraceEnabled()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0d6b32/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
index ce2a363..16fd11d 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
@@ -105,6 +105,7 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 import net.nuage.vsp.acs.NuageVspPluginClientLoader;
 import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.config.Configurable;
@@ -120,7 +121,6 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -137,8 +137,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
 
     private static final int ONE_MINUTE_MULTIPLIER = 60 * 1000;
 
-    private static final Set<Network.Provider> NUAGE_VSP_PROVIDERS;
-    private static final Map<Network.Service, Set<Network.Provider>> NUAGE_VSP_VPC_SERVICE_MAP;
+    public static final Map<Network.Service, Set<Network.Provider>> NUAGE_VSP_VPC_SERVICE_MAP;
     private static final ConfigKey[] NUAGE_VSP_CONFIG_KEYS = new ConfigKey<?>[] { NuageVspConfigDns, NuageVspDnsExternal, NuageVspConfigGateway,
             NuageVspSharedNetworkDomainTemplateName, NuageVspVpcDomainTemplateName, NuageVspIsolatedNetworkDomainTemplateName };
 
@@ -195,13 +194,18 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
     MessageBus _messageBus;
 
     static {
-        NUAGE_VSP_PROVIDERS = ImmutableSet.of(Network.Provider.NuageVsp);
+        Set<Network.Provider> nuageVspProviders = ImmutableSet.of(Network.Provider.NuageVsp);
+        Set<Network.Provider> userDataProviders = ImmutableSet.of(Network.Provider.VPCVirtualRouter);
+        Set<Network.Provider> lbProviders = ImmutableSet.of(Network.Provider.InternalLbVm);
         NUAGE_VSP_VPC_SERVICE_MAP = ImmutableMap.<Network.Service, Set<Network.Provider>>builder()
-                .put(Network.Service.Connectivity, NUAGE_VSP_PROVIDERS)
-                .put(Network.Service.Dhcp, NUAGE_VSP_PROVIDERS)
-                .put(Network.Service.StaticNat, NUAGE_VSP_PROVIDERS)
-                .put(Network.Service.SourceNat, NUAGE_VSP_PROVIDERS)
-                .put(Network.Service.NetworkACL, NUAGE_VSP_PROVIDERS)
+                .put(Network.Service.Connectivity, nuageVspProviders)
+                .put(Network.Service.Gateway, nuageVspProviders)
+                .put(Network.Service.Dhcp, nuageVspProviders)
+                .put(Network.Service.StaticNat, nuageVspProviders)
+                .put(Network.Service.SourceNat, nuageVspProviders)
+                .put(Network.Service.NetworkACL, nuageVspProviders)
+                .put(Network.Service.UserData, userDataProviders)
+                .put(Network.Service.Lb, lbProviders)
                 .build();
     }
 
@@ -424,6 +428,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
         HostVO nuageVspHost = _hostDao.findById(nuageVspDeviceVO.getHostId());
         _hostDao.loadDetails(nuageVspHost);
 
+        NuageVspResource.Configuration resourceConfiguration = NuageVspResource.Configuration.fromConfiguration(nuageVspHost.getDetails());
         NuageVspDeviceResponse response = new NuageVspDeviceResponse();
         response.setDeviceName(nuageVspDeviceVO.getDeviceName());
         PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(nuageVspDeviceVO.getPhysicalNetworkId());
@@ -432,12 +437,13 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
         }
         response.setId(nuageVspDeviceVO.getUuid());
         response.setProviderName(nuageVspDeviceVO.getProviderName());
-        response.setHostName(nuageVspHost.getDetail("hostname"));
-        response.setPort(Integer.parseInt(nuageVspHost.getDetail("port")));
-        String apiRelativePath = nuageVspHost.getDetail("apirelativepath");
+        response.setHostName(resourceConfiguration.hostName());
+        response.setPort(Integer.parseInt(resourceConfiguration.port()));
+        String apiRelativePath = resourceConfiguration.apiRelativePath();
         response.setApiVersion(apiRelativePath.substring(apiRelativePath.lastIndexOf('/') + 1));
-        response.setApiRetryCount(Integer.parseInt(nuageVspHost.getDetail("retrycount")));
-        response.setApiRetryInterval(Long.parseLong(nuageVspHost.getDetail("retryinterval")));
+        response.setApiRetryCount(Integer.parseInt(resourceConfiguration.retryCount()));
+        response.setApiRetryInterval(Long.parseLong(resourceConfiguration.retryInterval()));
+        response.setCmsId(resourceConfiguration.nuageVspCmsId());
         response.setObjectName("nuagevspdevice");
         return response;
     }
@@ -770,7 +776,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
                     defaultNuageVspSharedSGNetworkOffering.setState(NetworkOffering.State.Enabled);
                     defaultNuageVspSharedSGNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultNuageVspSharedSGNetworkOffering);
 
-                    Map<Network.Service, Network.Provider> defaultNuageVspSharedSGNetworkOfferingProviders = new HashMap<>();
+                    Map<Network.Service, Network.Provider> defaultNuageVspSharedSGNetworkOfferingProviders = new HashMap<Network.Service, Network.Provider>();
                     defaultNuageVspSharedSGNetworkOfferingProviders.put(Network.Service.Dhcp, Network.Provider.NuageVsp);
                     defaultNuageVspSharedSGNetworkOfferingProviders.put(Network.Service.SecurityGroup, Network.Provider.NuageVsp);
                     defaultNuageVspSharedSGNetworkOfferingProviders.put(Network.Service.Connectivity, Network.Provider.NuageVsp);
@@ -794,16 +800,15 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
         Transaction.execute(new TransactionCallbackNoReturn() {
             @Override
             public void doInTransactionWithoutResult(TransactionStatus status) {
-                if (_vpcOffDao.findByUniqueName(nuageVPCOfferingName) == null) {
+                VpcOffering offering = _vpcOffDao.findByUniqueName(nuageVPCOfferingName);
+                if (offering == null) {
                     if (s_logger.isDebugEnabled()) {
                         s_logger.debug("Creating default Nuage VPC offering " + nuageVPCOfferingName);
                     }
 
-                    Map<Network.Service, Set<Network.Provider>> svcProviderMap = Maps.newHashMap(NUAGE_VSP_VPC_SERVICE_MAP);
-                    Set<Network.Provider> userDataProviders = Collections.singleton(Network.Provider.VPCVirtualRouter);
-                    svcProviderMap.put(Network.Service.UserData, userDataProviders);
-
-                    createVpcOffering(nuageVPCOfferingName, nuageVPCOfferingDisplayText, svcProviderMap, true, VpcOffering.State.Enabled, null);
+                    createVpcOffering(nuageVPCOfferingName, nuageVPCOfferingDisplayText, NUAGE_VSP_VPC_SERVICE_MAP, true, VpcOffering.State.Enabled, null);
+                } else {
+                    updateVpcOffering(offering, NUAGE_VSP_VPC_SERVICE_MAP);
                 }
             }
         });
@@ -822,7 +827,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
                     offering.setState(state);
                 }
                 if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Adding vpc offering " + offering);
+                    s_logger.debug(String.format("Adding vpc offering %s", offering));
                 }
                 offering = _vpcOffDao.persist(offering);
                 // populate services and providers
@@ -834,11 +839,49 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
                                 VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider);
                                 _vpcOffSvcMapDao.persist(offService);
                                 if (s_logger.isTraceEnabled()) {
-                                    s_logger.trace("Added service for the vpc offering: " + offService + " with provider " + provider.getName());
+                                    s_logger.trace(String.format("Added service for the vpc offering: %s with provider %s", offService, provider.getName()));
                                 }
                             }
                         } else {
-                            throw new InvalidParameterValueException("Provider is missing for the VPC offering service " + service.getName());
+                            throw new InvalidParameterValueException(String.format("Provider is missing for the VPC offering service %s", service.getName()));
+                        }
+                    }
+                }
+                return offering;
+            }
+        });
+    }
+
+    @DB
+    protected void updateVpcOffering(final VpcOffering offering, final Map<Network.Service, Set<Network.Provider>> svcProviderMap) {
+        Transaction.execute(new TransactionCallback<VpcOffering>() {
+            @Override
+            public VpcOffering doInTransaction(TransactionStatus status) {
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug(String.format("Updating vpc offering %s", offering));
+                }
+
+                List<VpcOfferingServiceMapVO> currentVpcOfferingServices = _vpcOffSvcMapDao.listByVpcOffId(offering.getId());
+                Map<Network.Service, Set<Network.Provider>> currentSvcProviderMap = Maps.newHashMap();
+                for (VpcOfferingServiceMapVO vpcOfferingService : currentVpcOfferingServices) {
+                    Network.Service service = Network.Service.getService(vpcOfferingService.getService());
+                    Network.Provider provider = Network.Provider.getProvider(vpcOfferingService.getProvider());
+
+                    if (!currentSvcProviderMap.containsKey(service)) {
+                        currentSvcProviderMap.put(service, Sets.newHashSet(provider));
+                    } else if (!currentSvcProviderMap.get(service).contains(provider)) {
+                        currentSvcProviderMap.get(service).add(provider);
+                    }
+                }
+
+                for (Network.Service service : svcProviderMap.keySet()) {
+                    for (Network.Provider provider : svcProviderMap.get(service)) {
+                        if (currentSvcProviderMap.get(service) == null || !currentSvcProviderMap.get(service).contains(provider)) {
+                            VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider);
+                            _vpcOffSvcMapDao.persist(offService);
+                            if (s_logger.isDebugEnabled()) {
+                                s_logger.debug(String.format("Added service for the vpc offering: %s", offService));
+                            }
                         }
                     }
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0d6b32/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java b/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
index bbdf764..2f5ce7d 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
@@ -142,6 +142,12 @@ public class NuageVspElementTest {
         final Network net = mock(Network.class);
         when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp);
         when(net.getId()).thenReturn(NETWORK_ID);
+        when(net.getNetworkOfferingId()).thenReturn(NETWORK_ID);
+
+        final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class);
+        when(ntwkoffer.getId()).thenReturn(NETWORK_ID);
+        when(ntwkoffer.getIsPersistent()).thenReturn(true);
+        when(ntwkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffer);
 
         when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NuageVsp)).thenReturn(true);
         // Golden path

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0d6b32/plugins/network-elements/nuage-vsp/test/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java b/plugins/network-elements/nuage-vsp/test/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java
index 18c088f..c8d23ab 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java
@@ -22,6 +22,7 @@ package com.cloud.network.guru;
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
+import com.cloud.configuration.ConfigurationManager;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.DataCenterVO;
@@ -78,6 +79,7 @@ import static com.cloud.network.manager.NuageVspManager.NuageVspIsolatedNetworkD
 import static com.cloud.network.manager.NuageVspManager.NuageVspSharedNetworkDomainTemplateName;
 import static com.cloud.network.manager.NuageVspManager.NuageVspVpcDomainTemplateName;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
@@ -102,6 +104,7 @@ public class NuageVspGuestNetworkGuruTest {
     ConfigurationDao configDao = mock(ConfigurationDao.class);
     IPAddressDao ipAddressDao = mock(IPAddressDao.class);
     NuageVspManager nuageVspManager = mock(NuageVspManager.class);
+    ConfigurationManager configurationManager = mock(ConfigurationManager.class);
 
     NetworkDao netdao = mock(NetworkDao.class);
     NuageVspGuestNetworkGuru guru;
@@ -126,6 +129,7 @@ public class NuageVspGuestNetworkGuruTest {
         guru._configDao = configDao;
         guru._ipAddressDao = ipAddressDao;
         guru._nuageVspManager = nuageVspManager;
+        guru._configMgr = configurationManager;
 
         final DataCenterVO dc = mock(DataCenterVO.class);
         when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
@@ -144,6 +148,8 @@ public class NuageVspGuestNetworkGuruTest {
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+        when(offering.getIsPersistent()).thenReturn(false);
+        when(configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(false);
 
         final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VSP"}));
@@ -151,25 +157,28 @@ public class NuageVspGuestNetworkGuruTest {
 
         when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
 
-        assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+        assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet));
 
         // Not supported TrafficType != Guest
         when(offering.getTrafficType()).thenReturn(TrafficType.Management);
-        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet));
 
         // Supported: GuestType Shared
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Shared);
-        assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+        assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet));
 
         // Not supported: Basic networking
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-        assertFalse(guru.canHandle(offering, NetworkType.Basic, physnet) == true);
+        assertFalse(guru.canHandle(offering, NetworkType.Basic, physnet));
 
         // Not supported: IsolationMethod != STT
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VLAN"}));
-        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet));
 
+        // Not supported: Non-persistent VPC tier
+        when(configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(true);
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet));
     }
 
     @Test
@@ -187,6 +196,8 @@ public class NuageVspGuestNetworkGuruTest {
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+        when(offering.getIsPersistent()).thenReturn(false);
+        when(configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(false);
 
         when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
 
@@ -197,6 +208,10 @@ public class NuageVspGuestNetworkGuruTest {
         final Network designednetwork = guru.design(offering, plan, network, account);
         assertTrue(designednetwork != null);
         assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Vsp);
+
+        // Can't design non-persistent VPC tier
+        when(configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(true);
+        assertNull(guru.design(offering, plan, network, account));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0d6b32/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 18fbfe2..706f4c4 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -46,6 +46,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationSe
 import org.apache.cloudstack.framework.config.ConfigDepot;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.log4j.Logger;
 
 import com.cloud.configuration.Config;
@@ -402,8 +403,6 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
             svcProviderMap.put(Service.NetworkACL, defaultProviders);
         }
 
-        svcProviderMap.put(Service.Gateway, defaultProviders);
-
         if (serviceProviders != null) {
             for (final Entry<String, List<String>> serviceEntry : serviceProviders.entrySet()) {
                 final Network.Service service = Network.Service.getService(serviceEntry.getKey());
@@ -425,6 +424,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
             }
         }
 
+        // add gateway provider (if sourceNat provider is enabled)
+        final Set<Provider> sourceNatServiceProviders = svcProviderMap.get(Service.SourceNat);
+        if (CollectionUtils.isNotEmpty(sourceNatServiceProviders)) {
+            svcProviderMap.put(Service.Gateway, sourceNatServiceProviders);
+        }
+
         validateConnectivtyServiceCapabilities(svcProviderMap.get(Service.Connectivity), serviceCapabilitystList);
 
         final boolean supportsDistributedRouter = isVpcOfferingSupportsDistributedRouter(serviceCapabilitystList);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0d6b32/server/src/com/cloud/user/DomainManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/DomainManagerImpl.java b/server/src/com/cloud/user/DomainManagerImpl.java
index 912aa8b..e056e2d 100644
--- a/server/src/com/cloud/user/DomainManagerImpl.java
+++ b/server/src/com/cloud/user/DomainManagerImpl.java
@@ -308,6 +308,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom
 
             cleanupDomainOfferings(domain.getId());
             CallContext.current().putContextParameter(Domain.class, domain.getUuid());
+            _messageBus.publish(_name, MESSAGE_REMOVE_DOMAIN_EVENT, PublishScope.LOCAL, domain);
             return true;
         } catch (Exception ex) {
             s_logger.error("Exception deleting domain with id " + domain.getId(), ex);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0d6b32/ui/scripts/configuration.js
----------------------------------------------------------------------
diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js
index 14b0e15..4f7947a 100644
--- a/ui/scripts/configuration.js
+++ b/ui/scripts/configuration.js
@@ -3583,7 +3583,10 @@
                                             });
                                             networkServiceObjs.push({
                                                 name: 'Lb',
-                                                provider: [{name: 'VpcVirtualRouter'}]
+                                                provider: [
+                                                       {name: 'VpcVirtualRouter'},
+                                                       {name: 'InternalLbVm'}
+                                                ]
                                             });
                                             networkServiceObjs.push({
                                                 name: 'Gateway',


[37/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge release branch 4.8 to master

* 4.8:
  Removed sleeps and used validateList as requested.
  Added required_hardware="false" attr above test_02_root_volume_attach_detach
  Modified test_volumes.py to include a hypervisor test for root attach/detach testing
  Let hypervisor type KVM and Simulator detach root volumes. Updated test_volumes.py to include a test for detaching and reattaching a root volume from a vm. I also had to update base.py to allow attach_volume to have the parameter deviceid to be passed as needed.


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: a5ee4432e757b6944118c0731b2007737c5caaeb
Parents: 1f53adb d11194a
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 16:04:20 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 16:04:20 2016 -0400

----------------------------------------------------------------------
 .../com/cloud/storage/VolumeApiServiceImpl.java |   4 +-
 test/integration/component/test_volumes.py      | 135 ++++++++++++++++++-
 tools/marvin/marvin/lib/base.py                 |   6 +-
 3 files changed, 141 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5ee4432/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5ee4432/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------


[12/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Added required_hardware="false" attr above test_02_root_volume_attach_detach


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 760ad0e265c99200c5a54c154ec54bd871ef634c
Parents: ec7a86b
Author: David Mabry <dm...@ena.com>
Authored: Wed Apr 20 08:32:42 2016 -0500
Committer: David Mabry <dm...@ena.com>
Committed: Wed Apr 20 08:32:42 2016 -0500

----------------------------------------------------------------------
 test/integration/component/test_volumes.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/760ad0e2/test/integration/component/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py
index 1b1773c..0d18ef3 100644
--- a/test/integration/component/test_volumes.py
+++ b/test/integration/component/test_volumes.py
@@ -606,7 +606,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
             self.fail("Exception occurred: %s" % e)
         return
     
-    @attr(tags=["advanced", "advancedns"])
+    @attr(tags=["advanced", "advancedns"], required_hardware="false")
     def test_02_root_volume_attach_detach(self):
         """Test Root Volume attach/detach to VM
         """


[22/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1271 from anshul1886/CLOUDSTACK-9164

CLOUDSTACK-9164: Prevent firefox's quick search from opening in VM consolehttps://issues.apache.org/jira/browse/CLOUDSTACK-9164

To test:
In Firefox open any VM conosle, and try typing "/".
It should be typed in VM console and quick search of firefox should not open.

* pr/1271:
  CLOUDSTACK-9164: Prevent firefox's quick search from opening in VM console

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 4ab7fb78adc3c489e427d20970fd7b396504e7ed
Parents: a2d4692 7db5f18
Author: Will Stevens <wi...@gmail.com>
Authored: Mon Apr 25 15:53:01 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Mon Apr 25 15:53:01 2016 -0400

----------------------------------------------------------------------
 systemvm/js/ajaxviewer.js | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------



[42/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/956fd5d7/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
index 137aa61..9cbc73a 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
@@ -27,9 +27,11 @@ import java.util.Map;
 
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.ApiConstants;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.log4j.Logger;
-import org.bouncycastle.openssl.PEMWriter;
+import org.bouncycastle.util.io.pem.PemObject;
+import org.bouncycastle.util.io.pem.PemWriter;
 
 import com.citrix.netscaler.nitro.exception.nitro_exception;
 import com.citrix.netscaler.nitro.resource.base.base_response;
@@ -75,11 +77,6 @@ import com.citrix.netscaler.nitro.util.filtervalue;
 import com.citrix.sdx.nitro.resource.config.mps.mps;
 import com.citrix.sdx.nitro.resource.config.ns.ns;
 import com.citrix.sdx.nitro.resource.config.xen.xen_nsvpx_image;
-import com.google.common.collect.Lists;
-import com.google.gson.Gson;
-
-import org.apache.cloudstack.api.ApiConstants;
-
 import com.cloud.agent.IAgentControl;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
@@ -127,6 +124,8 @@ import com.cloud.utils.exception.ExecutionException;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.utils.security.CertificateHelper;
 import com.cloud.utils.ssh.SshHelper;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
 
 class NitroError {
     static final int NS_RESOURCE_EXISTS = 273;
@@ -235,7 +234,7 @@ public class NetscalerResource implements ServerResource {
 
             _inline = Boolean.parseBoolean((String)params.get("inline"));
 
-            if (((String)params.get("cloudmanaged")) != null) {
+            if ((String)params.get("cloudmanaged") != null) {
                 _cloudManaged = Boolean.parseBoolean((String)params.get("cloudmanaged"));
             }
 
@@ -264,7 +263,7 @@ public class NetscalerResource implements ServerResource {
             }
 
             return true;
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new ConfigurationException(e.getMessage());
         }
     }
@@ -280,7 +279,7 @@ public class NetscalerResource implements ServerResource {
                     _netscalerSdxService.logout();
                 }
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             // Ignore logout exceptions
         }
     }
@@ -302,15 +301,15 @@ public class NetscalerResource implements ServerResource {
             } else {
                 _netscalerSdxService = new com.citrix.sdx.nitro.service.nitro_service(_ip, "https");
                 _netscalerSdxService.set_credential(_username, _password);
-                com.citrix.sdx.nitro.resource.base.login login = _netscalerSdxService.login();
+                final com.citrix.sdx.nitro.resource.base.login login = _netscalerSdxService.login();
                 if (login == null) {
                     throw new ExecutionException("Failed to log in to Netscaler SDX device at " + _ip + " due to error " + apiCallResult.errorcode + " and message " +
                             apiCallResult.message);
                 }
             }
-        } catch (nitro_exception e) {
+        } catch (final nitro_exception e) {
             throw new ExecutionException("Failed to log in to Netscaler device at " + _ip + " due to " + e.getMessage());
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new ExecutionException("Failed to log in to Netscaler device at " + _ip + " due to " + e.getMessage());
         }
     }
@@ -320,9 +319,9 @@ public class NetscalerResource implements ServerResource {
             return;
         }
         try {
-            String[] features = _netscalerService.get_enabled_features();
+            final String[] features = _netscalerService.get_enabled_features();
             if (features != null) {
-                for (String feature : features) {
+                for (final String feature : features) {
                     if (feature.equalsIgnoreCase("LB")) {
                         return;
                     }
@@ -330,15 +329,15 @@ public class NetscalerResource implements ServerResource {
             }
 
             // enable load balancing on the device
-            String[] feature = new String[1];
+            final String[] feature = new String[1];
             feature[0] = "LB";
             apiCallResult = _netscalerService.enable_features(feature);
             if (apiCallResult.errorcode != 0) {
                 throw new ExecutionException("Enabling load balancing feature on the device failed.");
             }
-        } catch (nitro_exception e) {
+        } catch (final nitro_exception e) {
             throw new ExecutionException("Enabling load balancing feature on the device failed  due to " + e.getMessage());
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new ExecutionException("Enabling load balancing feature on the device failed due to " + e.getMessage());
         }
     }
@@ -346,21 +345,21 @@ public class NetscalerResource implements ServerResource {
     private void validateInterfaces(String publicInterface, String privateInterface) throws ExecutionException {
         try {
             if (!_isSdx && !_cloudManaged) {
-                Interface publicIf = Interface.get(_netscalerService, publicInterface);
-                Interface privateIf = Interface.get(_netscalerService, privateInterface);
+                final Interface publicIf = Interface.get(_netscalerService, publicInterface);
+                final Interface privateIf = Interface.get(_netscalerService, privateInterface);
                 if (publicIf != null || privateIf != null) {
                     return;
                 } else {
                     throw new ExecutionException("Invalid interface name specified for public/private interfaces.");
                 }
             }
-        } catch (nitro_exception e) {
+        } catch (final nitro_exception e) {
             if (e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS) {
                 throw new ExecutionException("Invalid interface name specified for public and private interfaces.");
             } else {
                 throw new ExecutionException("Failed to verify public interface and private intefaces are valid due to " + e.getMessage());
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new ExecutionException("Failed to verify public interface and private intefaces are valid due to " + e.getMessage());
         }
     }
@@ -368,18 +367,18 @@ public class NetscalerResource implements ServerResource {
     private void validateDeviceType(String deviceType) throws ExecutionException {
         try {
             if (!_isSdx && !_cloudManaged) {
-                nshardware nsHw = com.citrix.netscaler.nitro.resource.config.ns.nshardware.get(_netscalerService);
+                final nshardware nsHw = com.citrix.netscaler.nitro.resource.config.ns.nshardware.get(_netscalerService);
                 if (nsHw == null) {
                     throw new ExecutionException("Failed to get the hardware description of the Netscaler device at " + _ip);
                 } else {
-                    if ((_deviceName.equalsIgnoreCase("NetscalerMPXLoadBalancer") && nsHw.get_hwdescription().contains("MPX")) ||
-                            (_deviceName.equalsIgnoreCase("NetscalerVPXLoadBalancer") && nsHw.get_hwdescription().contains("NetScaler Virtual Appliance"))) {
+                    if (_deviceName.equalsIgnoreCase("NetscalerMPXLoadBalancer") && nsHw.get_hwdescription().contains("MPX") ||
+                            _deviceName.equalsIgnoreCase("NetscalerVPXLoadBalancer") && nsHw.get_hwdescription().contains("NetScaler Virtual Appliance")) {
                         return;
                     }
                     throw new ExecutionException("Netscalar device type specified does not match with the actuall device type.");
                 }
             } else if (_isSdx) {
-                mps serviceVM = mps.get(_netscalerSdxService);
+                final mps serviceVM = mps.get(_netscalerSdxService);
                 if (serviceVM != null) {
                     if (serviceVM.get_platform().contains("SDX") || serviceVM.get_product().contains("SDX")) {
                         return;
@@ -390,14 +389,14 @@ public class NetscalerResource implements ServerResource {
                     throw new ExecutionException("Failed to get the hardware details of the Netscaler device at " + _ip);
                 }
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new ExecutionException("Failed to verify device type specified when matching with actuall device type due to " + e.getMessage());
         }
     }
 
     @Override
     public StartupCommand[] initialize() {
-        StartupExternalLoadBalancerCommand cmd = new StartupExternalLoadBalancerCommand();
+        final StartupExternalLoadBalancerCommand cmd = new StartupExternalLoadBalancerCommand();
         cmd.setName(_name);
         cmd.setDataCenter(_zoneId);
         cmd.setPod("");
@@ -452,14 +451,14 @@ public class NetscalerResource implements ServerResource {
             return Answer.createUnsupportedCommandAnswer(cmd);
         }
 
-        String[] results = new String[cmd.getIpAddresses().length];
+        final String[] results = new String[cmd.getIpAddresses().length];
         int i = 0;
         try {
-            IpAddressTO[] ips = cmd.getIpAddresses();
-            for (IpAddressTO ip : ips) {
-                long guestVlanTag = Long.parseLong(ip.getBroadcastUri());
-                String vlanSelfIp = ip.getVlanGateway();
-                String vlanNetmask = ip.getVlanNetmask();
+            final IpAddressTO[] ips = cmd.getIpAddresses();
+            for (final IpAddressTO ip : ips) {
+                final long guestVlanTag = Long.parseLong(ip.getBroadcastUri());
+                final String vlanSelfIp = ip.getVlanGateway();
+                final String vlanNetmask = ip.getVlanNetmask();
 
                 if (ip.isAdd()) {
                     // Add a new guest VLAN and its subnet and bind it to private interface
@@ -471,12 +470,12 @@ public class NetscalerResource implements ServerResource {
 
                 saveConfiguration();
                 results[i++] = ip.getPublicIp() + " - success";
-                String action = ip.isAdd() ? "associate" : "remove";
+                final String action = ip.isAdd() ? "associate" : "remove";
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug("Netscaler load balancer " + _ip + " successfully executed IPAssocCommand to " + action + " IP " + ip);
                 }
             }
-        } catch (ExecutionException e) {
+        } catch (final ExecutionException e) {
             s_logger.error("Netscaler loadbalancer " + _ip + " failed to execute IPAssocCommand due to " + e.getMessage());
             if (shouldRetry(numRetries)) {
                 return retry(cmd, numRetries);
@@ -490,31 +489,31 @@ public class NetscalerResource implements ServerResource {
 
     private Answer execute(HealthCheckLBConfigCommand cmd, int numRetries) {
 
-        List<LoadBalancerTO> hcLB = new ArrayList<LoadBalancerTO>();
+        final List<LoadBalancerTO> hcLB = new ArrayList<LoadBalancerTO>();
         try {
 
             if (_isSdx) {
                 return Answer.createUnsupportedCommandAnswer(cmd);
             }
 
-            LoadBalancerTO[] loadBalancers = cmd.getLoadBalancers();
+            final LoadBalancerTO[] loadBalancers = cmd.getLoadBalancers();
 
             if (loadBalancers == null) {
                 return new HealthCheckLBConfigAnswer(hcLB);
             }
 
-            for (LoadBalancerTO loadBalancer : loadBalancers) {
-                HealthCheckPolicyTO[] healthCheckPolicies = loadBalancer.getHealthCheckPolicies();
-                if ((healthCheckPolicies != null) && (healthCheckPolicies.length > 0) && (healthCheckPolicies[0] != null)) {
-                    String nsVirtualServerName = generateNSVirtualServerName(loadBalancer.getSrcIp(), loadBalancer.getSrcPort());
+            for (final LoadBalancerTO loadBalancer : loadBalancers) {
+                final HealthCheckPolicyTO[] healthCheckPolicies = loadBalancer.getHealthCheckPolicies();
+                if (healthCheckPolicies != null && healthCheckPolicies.length > 0 && healthCheckPolicies[0] != null) {
+                    final String nsVirtualServerName = generateNSVirtualServerName(loadBalancer.getSrcIp(), loadBalancer.getSrcPort());
 
-                    com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding[] serviceBindings =
+                    final com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding[] serviceBindings =
                             com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.get(_netscalerService, nsVirtualServerName);
 
                     if (serviceBindings != null) {
-                        for (DestinationTO destination : loadBalancer.getDestinations()) {
-                            String nsServiceName = generateNSServiceName(destination.getDestIp(), destination.getDestPort());
-                            for (com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding binding : serviceBindings) {
+                        for (final DestinationTO destination : loadBalancer.getDestinations()) {
+                            final String nsServiceName = generateNSServiceName(destination.getDestIp(), destination.getDestPort());
+                            for (final com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding binding : serviceBindings) {
                                 if (nsServiceName.equalsIgnoreCase(binding.get_servicename())) {
                                     destination.setMonitorState(binding.get_curstate());
                                     break;
@@ -526,14 +525,14 @@ public class NetscalerResource implements ServerResource {
                 }
             }
 
-        } catch (ExecutionException e) {
+        } catch (final ExecutionException e) {
             s_logger.error("Failed to execute HealthCheckLBConfigCommand due to ", e);
             if (shouldRetry(numRetries)) {
                 return retry(cmd, numRetries);
             } else {
                 return new HealthCheckLBConfigAnswer(hcLB);
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.error("Failed to execute HealthCheckLBConfigCommand due to ", e);
             if (shouldRetry(numRetries)) {
                 return retry(cmd, numRetries);
@@ -550,19 +549,19 @@ public class NetscalerResource implements ServerResource {
                 return Answer.createUnsupportedCommandAnswer(cmd);
             }
 
-            LoadBalancerTO[] loadBalancers = cmd.getLoadBalancers();
+            final LoadBalancerTO[] loadBalancers = cmd.getLoadBalancers();
             if (loadBalancers == null) {
                 return new Answer(cmd);
             }
 
-            for (LoadBalancerTO loadBalancer : loadBalancers) {
-                String srcIp = loadBalancer.getSrcIp();
-                int srcPort = loadBalancer.getSrcPort();
-                String lbProtocol = getNetScalerProtocol(loadBalancer);
-                String lbAlgorithm = loadBalancer.getAlgorithm();
-                String nsVirtualServerName = generateNSVirtualServerName(srcIp, srcPort);
-                String nsMonitorName = generateNSMonitorName(srcIp, srcPort);
-                LbSslCert sslCert = loadBalancer.getSslCert();
+            for (final LoadBalancerTO loadBalancer : loadBalancers) {
+                final String srcIp = loadBalancer.getSrcIp();
+                final int srcPort = loadBalancer.getSrcPort();
+                final String lbProtocol = getNetScalerProtocol(loadBalancer);
+                final String lbAlgorithm = loadBalancer.getAlgorithm();
+                final String nsVirtualServerName = generateNSVirtualServerName(srcIp, srcPort);
+                final String nsMonitorName = generateNSMonitorName(srcIp, srcPort);
+                final LbSslCert sslCert = loadBalancer.getSslCert();
 
                 if (loadBalancer.isAutoScaleVmGroupTO()) {
                     applyAutoScaleConfig(loadBalancer);
@@ -573,7 +572,7 @@ public class NetscalerResource implements ServerResource {
                 boolean deleteMonitor = false;
                 boolean destinationsToAdd = false;
                 boolean deleteCert = false;
-                for (DestinationTO destination : loadBalancer.getDestinations()) {
+                for (final DestinationTO destination : loadBalancer.getDestinations()) {
                     if (!destination.isRevoked()) {
                         destinationsToAdd = true;
                         break;
@@ -589,10 +588,10 @@ public class NetscalerResource implements ServerResource {
                     }
 
                     // create a new monitor
-                    HealthCheckPolicyTO[] healthCheckPolicies = loadBalancer.getHealthCheckPolicies();
-                    if ((healthCheckPolicies != null) && (healthCheckPolicies.length > 0) && (healthCheckPolicies[0] != null)) {
+                    final HealthCheckPolicyTO[] healthCheckPolicies = loadBalancer.getHealthCheckPolicies();
+                    if (healthCheckPolicies != null && healthCheckPolicies.length > 0 && healthCheckPolicies[0] != null) {
 
-                        for (HealthCheckPolicyTO healthCheckPolicyTO : healthCheckPolicies) {
+                        for (final HealthCheckPolicyTO healthCheckPolicyTO : healthCheckPolicies) {
                             if (!healthCheckPolicyTO.isRevoked()) {
                                 addLBMonitor(nsMonitorName, lbProtocol, healthCheckPolicyTO);
                                 hasMonitor = true;
@@ -604,27 +603,27 @@ public class NetscalerResource implements ServerResource {
 
                     }
 
-                    for (DestinationTO destination : loadBalancer.getDestinations()) {
+                    for (final DestinationTO destination : loadBalancer.getDestinations()) {
 
-                        String nsServerName = generateNSServerName(destination.getDestIp());
-                        String nsServiceName = generateNSServiceName(destination.getDestIp(), destination.getDestPort());
+                        final String nsServerName = generateNSServerName(destination.getDestIp());
+                        final String nsServiceName = generateNSServiceName(destination.getDestIp(), destination.getDestPort());
                         if (!destination.isRevoked()) {
                             // add a new destination to deployed load balancing rule
 
                             // add a new server
                             if (!nsServerExists(nsServerName)) {
-                                com.citrix.netscaler.nitro.resource.config.basic.server nsServer = new com.citrix.netscaler.nitro.resource.config.basic.server();
+                                final com.citrix.netscaler.nitro.resource.config.basic.server nsServer = new com.citrix.netscaler.nitro.resource.config.basic.server();
                                 nsServer.set_name(nsServerName);
                                 nsServer.set_ipaddress(destination.getDestIp());
                                 apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.add(_netscalerService, nsServer);
-                                if ((apiCallResult.errorcode != 0) && (apiCallResult.errorcode != NitroError.NS_RESOURCE_EXISTS)) {
+                                if (apiCallResult.errorcode != 0 && apiCallResult.errorcode != NitroError.NS_RESOURCE_EXISTS) {
                                     throw new ExecutionException("Failed to add server " + destination.getDestIp() + " due to" + apiCallResult.message);
                                 }
                             }
 
                             // create a new service using the server added
                             if (!nsServiceExists(nsServiceName)) {
-                                com.citrix.netscaler.nitro.resource.config.basic.service newService = new com.citrix.netscaler.nitro.resource.config.basic.service();
+                                final com.citrix.netscaler.nitro.resource.config.basic.service newService = new com.citrix.netscaler.nitro.resource.config.basic.service();
                                 newService.set_name(nsServiceName);
                                 newService.set_port(destination.getDestPort());
                                 newService.set_servername(nsServerName);
@@ -644,7 +643,7 @@ public class NetscalerResource implements ServerResource {
 
                             //bind service to load balancing virtual server
                             if (!nsServiceBindingExists(nsVirtualServerName, nsServiceName)) {
-                                com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding svcBinding =
+                                final com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding svcBinding =
                                         new com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding();
                                 svcBinding.set_name(nsVirtualServerName);
                                 svcBinding.set_servicename(nsServiceName);
@@ -686,19 +685,19 @@ public class NetscalerResource implements ServerResource {
                                     String previousCertKeyName = null;
 
                                     if (sslCert.getChain() != null) {
-                                        List<Certificate> chainList = CertificateHelper.parseChain(sslCert.getChain());
+                                        final List<Certificate> chainList = CertificateHelper.parseChain(sslCert.getChain());
                                         // go from ROOT to intermediate CAs
-                                        for (Certificate intermediateCert : Lists.reverse(chainList)) {
+                                        for (final Certificate intermediateCert : Lists.reverse(chainList)) {
 
-                                            String fingerPrint = CertificateHelper.generateFingerPrint(intermediateCert);
-                                            String intermediateCertKeyName = generateSslCertKeyName(fingerPrint);
-                                            String intermediateCertFileName = intermediateCertKeyName + ".pem";
+                                            final String fingerPrint = CertificateHelper.generateFingerPrint(intermediateCert);
+                                            final String intermediateCertKeyName = generateSslCertKeyName(fingerPrint);
+                                            final String intermediateCertFileName = intermediateCertKeyName + ".pem";
 
                                             if (!SSL.isSslCertKeyPresent(_netscalerService, intermediateCertKeyName)) {
-                                                intermediateCert.getEncoded();
-                                                StringWriter textWriter = new StringWriter();
-                                                PEMWriter pemWriter = new PEMWriter(textWriter);
-                                                pemWriter.writeObject(intermediateCert);
+                                                final PemObject pemObject = new PemObject(intermediateCert.getType(), intermediateCert.getEncoded());
+                                                final StringWriter textWriter = new StringWriter();
+                                                final PemWriter pemWriter = new PemWriter(textWriter);
+                                                pemWriter.writeObject(pemObject);
                                                 pemWriter.flush();
 
                                                 SSL.uploadCert(_ip, _username, _password, intermediateCertFileName, textWriter.toString().getBytes());
@@ -713,11 +712,11 @@ public class NetscalerResource implements ServerResource {
                                         }
                                     }
 
-                                    String certFilename = generateSslCertName(sslCert.getFingerprint()) + ".pem"; //netscaler uses ".pem" format for "bundle" files
-                                    String keyFilename = generateSslKeyName(sslCert.getFingerprint()) + ".pem"; //netscaler uses ".pem" format for "bundle" files
-                                    String certKeyName = generateSslCertKeyName(sslCert.getFingerprint());
+                                    final String certFilename = generateSslCertName(sslCert.getFingerprint()) + ".pem"; //netscaler uses ".pem" format for "bundle" files
+                                    final String keyFilename = generateSslKeyName(sslCert.getFingerprint()) + ".pem"; //netscaler uses ".pem" format for "bundle" files
+                                    final String certKeyName = generateSslCertKeyName(sslCert.getFingerprint());
 
-                                    ByteArrayOutputStream certDataStream = new ByteArrayOutputStream();
+                                    final ByteArrayOutputStream certDataStream = new ByteArrayOutputStream();
                                     certDataStream.write(sslCert.getCert().getBytes());
 
                                     if (!SSL.isSslCertKeyPresent(_netscalerService, certKeyName)) {
@@ -743,10 +742,10 @@ public class NetscalerResource implements ServerResource {
 
                         } else {
                             // remove a destination from the deployed load balancing rule
-                            com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding[] serviceBindings =
+                            final com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding[] serviceBindings =
                                     com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.get(_netscalerService, nsVirtualServerName);
                             if (serviceBindings != null) {
-                                for (com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding binding : serviceBindings) {
+                                for (final com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding binding : serviceBindings) {
                                     if (nsServiceName.equalsIgnoreCase(binding.get_servicename())) {
                                         // delete the binding
                                         apiCallResult = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.delete(_netscalerService, binding);
@@ -765,8 +764,8 @@ public class NetscalerResource implements ServerResource {
                                         }
 
                                         // delete the server if there is no associated services
-                                        server_service_binding[] services = server_service_binding.get(_netscalerService, nsServerName);
-                                        if ((services == null) || (services.length == 0)) {
+                                        final server_service_binding[] services = server_service_binding.get(_netscalerService, nsServerName);
+                                        if (services == null || services.length == 0) {
                                             apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.delete(_netscalerService, nsServerName);
                                             if (apiCallResult.errorcode != 0) {
                                                 throw new ExecutionException("Failed to remove server:" + nsServerName + " due to " + apiCallResult.message);
@@ -779,24 +778,24 @@ public class NetscalerResource implements ServerResource {
                     }
                 } else {
                     // delete the implemented load balancing rule and its destinations
-                    lbvserver lbserver = getVirtualServerIfExisits(nsVirtualServerName);
+                    final lbvserver lbserver = getVirtualServerIfExisits(nsVirtualServerName);
                     if (lbserver != null) {
                         //unbind the all services associated with this virtual server
-                        com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding[] serviceBindings =
+                        final com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding[] serviceBindings =
                                 com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.get(_netscalerService, nsVirtualServerName);
 
                         if (serviceBindings != null) {
-                            for (com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding binding : serviceBindings) {
-                                String serviceName = binding.get_servicename();
+                            for (final com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding binding : serviceBindings) {
+                                final String serviceName = binding.get_servicename();
                                 apiCallResult = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.delete(_netscalerService, binding);
                                 if (apiCallResult.errorcode != 0) {
                                     throw new ExecutionException("Failed to unbind service from the lb virtual server: " + nsVirtualServerName + " due to " +
                                             apiCallResult.message);
                                 }
 
-                                com.citrix.netscaler.nitro.resource.config.basic.service svc =
+                                final com.citrix.netscaler.nitro.resource.config.basic.service svc =
                                         com.citrix.netscaler.nitro.resource.config.basic.service.get(_netscalerService, serviceName);
-                                String nsServerName = svc.get_servername();
+                                final String nsServerName = svc.get_servername();
 
                                 // check if service is bound to any other virtual server
                                 if (!isServiceBoundToVirtualServer(serviceName)) {
@@ -808,8 +807,8 @@ public class NetscalerResource implements ServerResource {
                                 }
 
                                 //delete the server if no more services attached
-                                server_service_binding[] services = server_service_binding.get(_netscalerService, nsServerName);
-                                if ((services == null) || (services.length == 0)) {
+                                final server_service_binding[] services = server_service_binding.get(_netscalerService, nsServerName);
+                                if (services == null || services.length == 0) {
                                     apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.delete(_netscalerService, nsServerName);
                                     if (apiCallResult.errorcode != 0) {
                                         throw new ExecutionException("Failed to remove server:" + nsServerName + " due to " + apiCallResult.message);
@@ -827,9 +826,9 @@ public class NetscalerResource implements ServerResource {
                 }
                 if (sslCert != null && deleteCert) {
 
-                    String certFilename = generateSslCertName(sslCert.getFingerprint()) + ".pem"; //netscaler uses ".pem" format for "bundle" files
-                    String keyFilename = generateSslKeyName(sslCert.getFingerprint()) + ".pem"; //netscaler uses ".pem" format for "bundle" files
-                    String certKeyName = generateSslCertKeyName(sslCert.getFingerprint());
+                    final String certFilename = generateSslCertName(sslCert.getFingerprint()) + ".pem"; //netscaler uses ".pem" format for "bundle" files
+                    final String keyFilename = generateSslKeyName(sslCert.getFingerprint()) + ".pem"; //netscaler uses ".pem" format for "bundle" files
+                    final String certKeyName = generateSslCertKeyName(sslCert.getFingerprint());
 
                     // unbind before deleting
                     if (nsVirtualServerExists(nsVirtualServerName) &&
@@ -852,13 +851,13 @@ public class NetscalerResource implements ServerResource {
                      */
 
                     if (sslCert.getChain() != null) {
-                        List<Certificate> chainList = CertificateHelper.parseChain(sslCert.getChain());
+                        final List<Certificate> chainList = CertificateHelper.parseChain(sslCert.getChain());
                         //go from intermediate CAs to ROOT
-                        for (Certificate intermediateCert : chainList) {
+                        for (final Certificate intermediateCert : chainList) {
 
-                            String fingerPrint = CertificateHelper.generateFingerPrint(intermediateCert);
-                            String intermediateCertKeyName = generateSslCertKeyName(fingerPrint);
-                            String intermediateCertFileName = intermediateCertKeyName + ".pem";
+                            final String fingerPrint = CertificateHelper.generateFingerPrint(intermediateCert);
+                            final String intermediateCertKeyName = generateSslCertKeyName(fingerPrint);
+                            final String intermediateCertFileName = intermediateCertKeyName + ".pem";
 
                             if (SSL.isSslCertKeyPresent(_netscalerService, intermediateCertKeyName) &&
                                     !SSL.isCaforCerts(_netscalerService, intermediateCertKeyName)) {
@@ -880,14 +879,14 @@ public class NetscalerResource implements ServerResource {
 
             saveConfiguration();
             return new Answer(cmd);
-        } catch (ExecutionException e) {
+        } catch (final ExecutionException e) {
             s_logger.error("Failed to execute LoadBalancerConfigCommand due to ", e);
             if (shouldRetry(numRetries)) {
                 return retry(cmd, numRetries);
             } else {
                 return new Answer(cmd, e);
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.error("Failed to execute LoadBalancerConfigCommand due to ", e);
             if (shouldRetry(numRetries)) {
                 return retry(cmd, numRetries);
@@ -904,11 +903,11 @@ public class NetscalerResource implements ServerResource {
         }
 
         try {
-            String vpxName = "Cloud-VPX-" + cmd.getLoadBalancerIP();
-            String username = "admin";
-            String password = "admin";
+            final String vpxName = "Cloud-VPX-" + cmd.getLoadBalancerIP();
+            final String username = "admin";
+            final String password = "admin";
 
-            ns ns_obj = new ns();
+            final ns ns_obj = new ns();
             ns_obj.set_name(vpxName);
             ns_obj.set_ip_address(cmd.getLoadBalancerIP());
             ns_obj.set_netmask(cmd.getNetmask());
@@ -926,12 +925,12 @@ public class NetscalerResource implements ServerResource {
 
             // use the first VPX image of the available VPX images on the SDX to create an instance of VPX
             // TODO: should enable the option to choose the template while adding the SDX device in to CloudStack
-            xen_nsvpx_image[] vpxImages = xen_nsvpx_image.get(_netscalerSdxService);
+            final xen_nsvpx_image[] vpxImages = xen_nsvpx_image.get(_netscalerSdxService);
             if (!(vpxImages != null && vpxImages.length >= 1)) {
                 new Answer(cmd, new ExecutionException("Failed to create VPX instance on the netscaler SDX device " + _ip +
                         " as there are no VPX images on SDX to use for creating VPX."));
             }
-            String imageName = vpxImages[0].get_file_name();
+            final String imageName = vpxImages[0].get_file_name();
             ns_obj.set_image_name(imageName);
 
             String publicIf = _publicInterface;
@@ -949,14 +948,14 @@ public class NetscalerResource implements ServerResource {
 
             // wait for VPX instance to start-up
             long startTick = System.currentTimeMillis();
-            long startWaitMilliSeconds = 600000;
+            final long startWaitMilliSeconds = 600000;
             while (!newVpx.get_instance_state().equalsIgnoreCase("up") && System.currentTimeMillis() - startTick < startWaitMilliSeconds) {
                 try {
                     Thread.sleep(10000);
-                } catch (InterruptedException e) {
+                } catch (final InterruptedException e) {
                     s_logger.debug("[ignored] interupted while waiting for netscaler to be 'up'.");
                 }
-                ns refreshNsObj = new ns();
+                final ns refreshNsObj = new ns();
                 refreshNsObj.set_id(newVpx.get_id());
                 newVpx = ns.get(_netscalerSdxService, refreshNsObj);
             }
@@ -969,19 +968,19 @@ public class NetscalerResource implements ServerResource {
             // wait till NS service in side VPX is actually ready
             startTick = System.currentTimeMillis();
             boolean nsServiceUp = false;
-            long nsServiceWaitMilliSeconds = 60000;
+            final long nsServiceWaitMilliSeconds = 60000;
             while (System.currentTimeMillis() - startTick < nsServiceWaitMilliSeconds) {
                 try {
-                    nitro_service _netscalerService = new nitro_service(cmd.getLoadBalancerIP(), "https");
-                    _netscalerService.set_certvalidation(false);
-                    _netscalerService.set_hostnameverification(false);
-                    _netscalerService.set_credential(username, password);
-                    apiCallResult = _netscalerService.login();
+                    final nitro_service netscalerService = new nitro_service(cmd.getLoadBalancerIP(), "https");
+                    netscalerService.set_certvalidation(false);
+                    netscalerService.set_hostnameverification(false);
+                    netscalerService.set_credential(username, password);
+                    apiCallResult = netscalerService.login();
                     if (apiCallResult.errorcode == 0) {
                         nsServiceUp = true;
                         break;
                     }
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     Thread.sleep(10000);
                     continue;
                 }
@@ -999,8 +998,8 @@ public class NetscalerResource implements ServerResource {
             // However the VPX instances created will have interface range start from 10/1 but will only have as many interfaces enabled while creating the VPX instance
             // So due to this, we need to map public & private interface on SDX to correct public & private interface of VPX
 
-            int publicIfnum = Integer.parseInt(_publicInterface.substring(_publicInterface.lastIndexOf("/") + 1));
-            int privateIfnum = Integer.parseInt(_privateInterface.substring(_privateInterface.lastIndexOf("/") + 1));
+            final int publicIfnum = Integer.parseInt(_publicInterface.substring(_publicInterface.lastIndexOf("/") + 1));
+            final int privateIfnum = Integer.parseInt(_privateInterface.substring(_privateInterface.lastIndexOf("/") + 1));
 
             if (_publicInterface.startsWith("10/") && _privateInterface.startsWith("10/")) {
                 if (publicIfnum == privateIfnum) {
@@ -1034,7 +1033,7 @@ public class NetscalerResource implements ServerResource {
 
             return new CreateLoadBalancerApplianceAnswer(cmd, true, "provisioned VPX instance", "NetscalerVPXLoadBalancer", "Netscaler", new NetscalerResource(),
                     publicIf, privateIf, _username, _password);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             if (shouldRetry(numRetries)) {
                 return retry(cmd, numRetries);
             }
@@ -1045,15 +1044,15 @@ public class NetscalerResource implements ServerResource {
 
     private Answer execute(GlobalLoadBalancerConfigCommand gslbCmd, int numRetries) {
 
-        String lbMethod = gslbCmd.getLoadBalancerMethod();
-        String persistenceType = gslbCmd.getPersistenceType();
-        String serviceType = gslbCmd.getServiceType();
-        boolean forRevoke = gslbCmd.isForRevoke();
-        long gslbId = gslbCmd.getGslbId();
-        List<SiteLoadBalancerConfig> sites = gslbCmd.getSiteDetails();
+        final String lbMethod = gslbCmd.getLoadBalancerMethod();
+        final String persistenceType = gslbCmd.getPersistenceType();
+        final String serviceType = gslbCmd.getServiceType();
+        final boolean forRevoke = gslbCmd.isForRevoke();
+        final long gslbId = gslbCmd.getGslbId();
+        final List<SiteLoadBalancerConfig> sites = gslbCmd.getSiteDetails();
 
-        String domainName = gslbCmd.getDomainName();
-        String vserverName = GSLB.generateVirtualServerName(domainName);
+        final String domainName = gslbCmd.getDomainName();
+        final String vserverName = GSLB.generateVirtualServerName(domainName);
 
         try {
 
@@ -1063,17 +1062,17 @@ public class NetscalerResource implements ServerResource {
                 GSLB.createVirtualServer(_netscalerService, vserverName, lbMethod, persistenceType, gslbId, serviceType);
 
                 if (sites != null) { // check if there are any sites that are participating in global load balancing
-                    for (SiteLoadBalancerConfig site : sites) {
+                    for (final SiteLoadBalancerConfig site : sites) {
 
-                        String sitePrivateIP = site.getGslbProviderPrivateIp();
-                        String sitePublicIP = site.getGslbProviderPublicIp();
-                        String servicePublicIp = site.getServicePublicIp();
-                        String servicePublicPort = site.getServicePort();
-                        String siteName = GSLB.generateUniqueSiteName(sitePrivateIP, sitePublicIP, site.getDataCenterId());
+                        final String sitePrivateIP = site.getGslbProviderPrivateIp();
+                        final String sitePublicIP = site.getGslbProviderPublicIp();
+                        final String servicePublicIp = site.getServicePublicIp();
+                        final String servicePublicPort = site.getServicePort();
+                        final String siteName = GSLB.generateUniqueSiteName(sitePrivateIP, sitePublicIP, site.getDataCenterId());
 
                         // Add/Delete GSLB local and remote sites that are part of GSLB virtual server
                         if (!site.forRevoke()) {
-                            String siteType = (site.isLocal()) ? "LOCAL" : "REMOTE";
+                            final String siteType = site.isLocal() ? "LOCAL" : "REMOTE";
                             if (GSLB.getSiteObject(_netscalerService, siteName) != null) {
                                 GSLB.updateSite(_netscalerService, siteType, siteName, site.getGslbProviderPrivateIp(), site.getGslbProviderPublicIp());
                             } else {
@@ -1082,8 +1081,8 @@ public class NetscalerResource implements ServerResource {
                         }
 
                         // Add/Delete GSLB service corresponding the service running on each site
-                        String serviceName = GSLB.generateUniqueServiceName(siteName, servicePublicIp, servicePublicPort);
-                        String monitorName = GSLB.generateGslbServiceMonitorName(servicePublicIp);
+                        final String serviceName = GSLB.generateUniqueServiceName(siteName, servicePublicIp, servicePublicPort);
+                        final String monitorName = GSLB.generateGslbServiceMonitorName(servicePublicIp);
                         if (!site.forRevoke()) {
                             // create a 'gslbservice' object
                             GSLB.createService(_netscalerService, serviceName, site.getServiceType(), servicePublicIp, servicePublicPort, siteName);
@@ -1127,15 +1126,15 @@ public class NetscalerResource implements ServerResource {
                 GSLB.deleteVserverDomainBinding(_netscalerService, vserverName, domainName);
 
                 if (sites != null) {
-                    for (SiteLoadBalancerConfig site : sites) {
+                    for (final SiteLoadBalancerConfig site : sites) {
 
-                        String sitePrivateIP = site.getGslbProviderPrivateIp();
-                        String sitePublicIP = site.getGslbProviderPublicIp();
-                        String servicePublicIp = site.getServicePublicIp();
-                        String servicePublicPort = site.getServicePort();
-                        String siteName = GSLB.generateUniqueSiteName(sitePrivateIP, sitePublicIP, site.getDataCenterId());
-                        String serviceName = GSLB.generateUniqueServiceName(siteName, servicePublicIp, servicePublicPort);
-                        String monitorName = GSLB.generateGslbServiceMonitorName(servicePublicIp);
+                        final String sitePrivateIP = site.getGslbProviderPrivateIp();
+                        final String sitePublicIP = site.getGslbProviderPublicIp();
+                        final String servicePublicIp = site.getServicePublicIp();
+                        final String servicePublicPort = site.getServicePort();
+                        final String siteName = GSLB.generateUniqueSiteName(sitePrivateIP, sitePublicIP, site.getDataCenterId());
+                        final String serviceName = GSLB.generateUniqueServiceName(siteName, servicePublicIp, servicePublicPort);
+                        final String monitorName = GSLB.generateGslbServiceMonitorName(servicePublicIp);
 
                         // delete GSLB service and GSLB monitor binding
                         GSLB.deleteGslbServiceGslbMonitorBinding(_netscalerService, monitorName, serviceName);
@@ -1160,8 +1159,8 @@ public class NetscalerResource implements ServerResource {
 
             saveConfiguration();
 
-        } catch (Exception e) {
-            String errMsg = "Failed to apply GSLB configuration due to " + e.getMessage();
+        } catch (final Exception e) {
+            final String errMsg = "Failed to apply GSLB configuration due to " + e.getMessage();
             if (shouldRetry(numRetries)) {
                 return retry(gslbCmd, numRetries);
             }
@@ -1194,7 +1193,7 @@ public class NetscalerResource implements ServerResource {
                     isUpdateSite = true;
                 }
 
-                assert ("LOCAL".equalsIgnoreCase(siteType) || "REMOTE".equalsIgnoreCase(siteType));
+                assert "LOCAL".equalsIgnoreCase(siteType) || "REMOTE".equalsIgnoreCase(siteType);
                 site.set_sitetype(siteType);
                 site.set_sitename(siteName);
                 site.set_siteipaddress(siteIP);
@@ -1210,8 +1209,8 @@ public class NetscalerResource implements ServerResource {
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug("Successfully created GSLB site: " + siteName);
                 }
-            } catch (Exception e) {
-                String errMsg = "Failed to create GSLB site: " + siteName + " due to " + e.getMessage();
+            } catch (final Exception e) {
+                final String errMsg = "Failed to create GSLB site: " + siteName + " due to " + e.getMessage();
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
                 }
@@ -1222,9 +1221,9 @@ public class NetscalerResource implements ServerResource {
         // delete 'gslbsite' object representing a site
         private static void deleteSite(nitro_service client, String siteName) throws ExecutionException {
             try {
-                gslbsite site = getSiteObject(client, siteName);
+                final gslbsite site = getSiteObject(client, siteName);
                 if (site != null) {
-                    gslbsite_gslbservice_binding[] serviceBindings = gslbsite_gslbservice_binding.get(client, siteName);
+                    final gslbsite_gslbservice_binding[] serviceBindings = gslbsite_gslbservice_binding.get(client, siteName);
                     if (serviceBindings != null && serviceBindings.length > 0) {
                         if (s_logger.isDebugEnabled()) {
                             s_logger.debug("There are services associated with GSLB site: " + siteName + " so ignoring site deletion");
@@ -1239,8 +1238,8 @@ public class NetscalerResource implements ServerResource {
                         s_logger.warn("Ignoring delete request for non existing  GSLB site: " + siteName);
                     }
                 }
-            } catch (Exception e) {
-                String errMsg = "Failed to delete GSLB site: " + siteName + " due to " + e.getMessage();
+            } catch (final Exception e) {
+                final String errMsg = "Failed to delete GSLB site: " + siteName + " due to " + e.getMessage();
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
                 }
@@ -1259,7 +1258,7 @@ public class NetscalerResource implements ServerResource {
                     }
                     return;
                 }
-                assert ("LOCAL".equalsIgnoreCase(siteType) || "REMOTE".equalsIgnoreCase(siteType));
+                assert "LOCAL".equalsIgnoreCase(siteType) || "REMOTE".equalsIgnoreCase(siteType);
                 site.set_sitetype(siteType);
                 site.set_sitename(siteName);
                 site.set_siteipaddress(siteIP);
@@ -1273,8 +1272,8 @@ public class NetscalerResource implements ServerResource {
                     s_logger.debug("Successfully updated GSLB site: " + siteName);
                 }
 
-            } catch (Exception e) {
-                String errMsg = "Failed to update GSLB site: " + siteName + " due to " + e.getMessage();
+            } catch (final Exception e) {
+                final String errMsg = "Failed to update GSLB site: " + siteName + " due to " + e.getMessage();
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
                 }
@@ -1328,8 +1327,8 @@ public class NetscalerResource implements ServerResource {
                     s_logger.debug("Successfully added GSLB virtual server: " + vserverName);
                 }
 
-            } catch (Exception e) {
-                String errMsg = "Failed to add GSLB virtual server: " + vserverName + " due to " + e.getMessage();
+            } catch (final Exception e) {
+                final String errMsg = "Failed to add GSLB virtual server: " + vserverName + " due to " + e.getMessage();
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
                 }
@@ -1340,7 +1339,7 @@ public class NetscalerResource implements ServerResource {
         // delete 'gslbvserver' object representing a globally load balanced service
         private static void deleteVirtualServer(nitro_service client, String vserverName) throws ExecutionException {
             try {
-                gslbvserver vserver = getVserverObject(client, vserverName);
+                final gslbvserver vserver = getVserverObject(client, vserverName);
                 if (vserver != null) {
                     gslbvserver.delete(client, vserver);
                     if (s_logger.isDebugEnabled()) {
@@ -1351,63 +1350,8 @@ public class NetscalerResource implements ServerResource {
                         s_logger.warn("Ignoring delete request for non existing  GSLB virtual server: " + vserverName);
                     }
                 }
-            } catch (Exception e) {
-                String errMsg = "Failed to delete GSLB virtual server: " + vserverName + " due to " + e.getMessage();
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug(errMsg);
-                }
-                throw new ExecutionException(errMsg);
-            }
-        }
-
-        // enable 'gslbvserver' object representing a globally load balanced service
-        private static void enableVirtualServer(nitro_service client, String vserverName) throws ExecutionException {
-            try {
-                gslbvserver vserver = getVserverObject(client, vserverName);
-                if (vserver != null) {
-                    gslbvserver.enable(client, vserver);
-                }
-            } catch (Exception e) {
-                String errMsg = "Failed to enable GSLB virtual server: " + vserverName + " due to " + e.getMessage();
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug(errMsg);
-                }
-                throw new ExecutionException(errMsg);
-            }
-        }
-
-        // disable 'gslbvserver' object representing a globally load balanced service
-        private static void disableVirtualServer(nitro_service client, String vserverName) throws ExecutionException {
-            try {
-                gslbvserver vserver = getVserverObject(client, vserverName);
-                if (vserver != null) {
-                    gslbvserver.disable(client, vserver);
-                }
-            } catch (Exception e) {
-                String errMsg = "Failed to disable GSLB virtual server: " + vserverName + " due to " + e.getMessage();
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug(errMsg);
-                }
-                throw new ExecutionException(errMsg);
-            }
-        }
-
-        // update 'gslbvserver' object representing a globally load balanced service
-        private static void updateVirtualServer(nitro_service client, String vserverName, String lbMethod, String persistenceType, String serviceType)
-                throws ExecutionException {
-            try {
-                gslbvserver vServer = getVserverObject(client, vserverName);
-                if (vServer != null) {
-                    vServer.set_lbmethod(lbMethod);
-                    vServer.set_persistencetype(persistenceType);
-                    vServer.set_servicetype(serviceType);
-                    gslbvserver.update(client, vServer);
-                    if (s_logger.isDebugEnabled()) {
-                        s_logger.debug("Successfully updated GSLB virtual server: " + vserverName);
-                    }
-                }
-            } catch (Exception e) {
-                String errMsg = "Failed to update GSLB virtual server: " + vserverName + " due to " + e.getMessage();
+            } catch (final Exception e) {
+                final String errMsg = "Failed to delete GSLB virtual server: " + vserverName + " due to " + e.getMessage();
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
                 }
@@ -1421,15 +1365,15 @@ public class NetscalerResource implements ServerResource {
             try {
                 gslbservice service;
                 service = getServiceObject(client, serviceName);
-                String gslbServerName = generateGslbServerName(serviceIp);
+                final String gslbServerName = generateGslbServerName(serviceIp);
 
                 if (!gslbServerExists(client, gslbServerName)) {
                     base_response apiCallResult;
-                    com.citrix.netscaler.nitro.resource.config.basic.server nsServer = new com.citrix.netscaler.nitro.resource.config.basic.server();
+                    final com.citrix.netscaler.nitro.resource.config.basic.server nsServer = new com.citrix.netscaler.nitro.resource.config.basic.server();
                     nsServer.set_name(gslbServerName);
                     nsServer.set_ipaddress(serviceIp);
                     apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.add(client, nsServer);
-                    if ((apiCallResult.errorcode != 0) && (apiCallResult.errorcode != NitroError.NS_RESOURCE_EXISTS)) {
+                    if (apiCallResult.errorcode != 0 && apiCallResult.errorcode != NitroError.NS_RESOURCE_EXISTS) {
                         throw new ExecutionException("Failed to add server " + gslbServerName + " due to" + apiCallResult.message);
                     }
                 }
@@ -1443,7 +1387,7 @@ public class NetscalerResource implements ServerResource {
 
                 service.set_sitename(siteName);
                 service.set_servername(gslbServerName);
-                int port = Integer.parseInt(servicePort);
+                final int port = Integer.parseInt(servicePort);
                 service.set_port(port);
                 service.set_servicename(serviceName);
                 service.set_servicetype(serviceType);
@@ -1457,8 +1401,8 @@ public class NetscalerResource implements ServerResource {
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug("Successfully created service: " + serviceName + " at site: " + siteName);
                 }
-            } catch (Exception e) {
-                String errMsg = "Failed to created service: " + serviceName + " at site: " + siteName + " due to " + e.getMessage();
+            } catch (final Exception e) {
+                final String errMsg = "Failed to created service: " + serviceName + " at site: " + siteName + " due to " + e.getMessage();
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
                 }
@@ -1468,7 +1412,7 @@ public class NetscalerResource implements ServerResource {
 
         private static void deleteService(nitro_service client, String serviceName) throws ExecutionException {
             try {
-                gslbservice service = getServiceObject(client, serviceName);
+                final gslbservice service = getServiceObject(client, serviceName);
                 if (service != null) {
                     gslbservice.delete(client, serviceName);
                     if (s_logger.isDebugEnabled()) {
@@ -1479,34 +1423,8 @@ public class NetscalerResource implements ServerResource {
                         s_logger.warn("Ignoring delete request for non existing  service: " + serviceName);
                     }
                 }
-            } catch (Exception e) {
-                String errMsg = "Failed to delete service: " + serviceName + " due to " + e.getMessage();
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug(errMsg);
-                }
-                throw new ExecutionException(errMsg);
-            }
-        }
-
-        private static void updateService(nitro_service client, String serviceName, String serviceType, String publicIp, String publicPort, String siteName)
-                throws ExecutionException {
-            try {
-                gslbservice service;
-                service = getServiceObject(client, serviceName);
-
-                if (service != null) {
-                    service.set_sitename(siteName);
-                    service.set_publicip(publicIp);
-                    service.set_publicport(Integer.getInteger(publicPort));
-                    service.set_servicename(serviceName);
-                    service.set_servicetype(serviceType);
-                    gslbservice.update(client, service);
-                    if (s_logger.isDebugEnabled()) {
-                        s_logger.debug("Successfully updated service: " + serviceName + " at site: " + siteName);
-                    }
-                }
-            } catch (Exception e) {
-                String errMsg = "Failed to update service: " + serviceName + " at site: " + siteName + "due to " + e.getMessage();
+            } catch (final Exception e) {
+                final String errMsg = "Failed to delete service: " + serviceName + " due to " + e.getMessage();
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
                 }
@@ -1517,8 +1435,8 @@ public class NetscalerResource implements ServerResource {
         private static void createVserverServiceBinding(nitro_service client, String serviceName, String vserverName, long weight) throws ExecutionException {
             String errMsg;
             try {
-                assert (weight >= 1 && weight <= 100);
-                gslbvserver_gslbservice_binding binding = new gslbvserver_gslbservice_binding();
+                assert weight >= 1 && weight <= 100;
+                final gslbvserver_gslbservice_binding binding = new gslbvserver_gslbservice_binding();
                 binding.set_name(vserverName);
                 binding.set_servicename(serviceName);
                 binding.set_weight(weight);
@@ -1526,7 +1444,7 @@ public class NetscalerResource implements ServerResource {
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug("Successfully created service: " + serviceName + " and virtual server: " + vserverName + " binding");
                 }
-            } catch (nitro_exception ne) {
+            } catch (final nitro_exception ne) {
                 if (ne.getErrorCode() == 273) {
                     return;
                 }
@@ -1535,7 +1453,7 @@ public class NetscalerResource implements ServerResource {
                     s_logger.debug(errMsg);
                 }
                 throw new ExecutionException(errMsg);
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 errMsg = "Failed to create service: " + serviceName + " and virtual server: " + vserverName + " binding due to " + e.getMessage();
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
@@ -1546,9 +1464,9 @@ public class NetscalerResource implements ServerResource {
 
         private static void deleteVserverServiceBinding(nitro_service client, String serviceName, String vserverName) throws ExecutionException {
             try {
-                gslbvserver_gslbservice_binding[] bindings = gslbvserver_gslbservice_binding.get(client, vserverName);
+                final gslbvserver_gslbservice_binding[] bindings = gslbvserver_gslbservice_binding.get(client, vserverName);
                 if (bindings != null) {
-                    for (gslbvserver_gslbservice_binding binding : bindings) {
+                    for (final gslbvserver_gslbservice_binding binding : bindings) {
                         if (binding.get_servicename().equalsIgnoreCase(serviceName) && binding.get_name().equals(vserverName)) {
                             gslbvserver_gslbservice_binding.delete(client, binding);
                             if (s_logger.isDebugEnabled()) {
@@ -1558,8 +1476,8 @@ public class NetscalerResource implements ServerResource {
                         }
                     }
                 }
-            } catch (Exception e) {
-                String errMsg = "Failed to create service: " + serviceName + " and virtual server: " + vserverName + " binding due to " + e.getMessage();
+            } catch (final Exception e) {
+                final String errMsg = "Failed to create service: " + serviceName + " and virtual server: " + vserverName + " binding due to " + e.getMessage();
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
                 }
@@ -1571,7 +1489,7 @@ public class NetscalerResource implements ServerResource {
         private static void createVserverDomainBinding(nitro_service client, String vserverName, String domainName) throws ExecutionException {
             String errMsg;
             try {
-                gslbvserver_domain_binding binding = new gslbvserver_domain_binding();
+                final gslbvserver_domain_binding binding = new gslbvserver_domain_binding();
                 binding.set_domainname(domainName);
                 binding.set_name(vserverName);
                 gslbvserver_domain_binding.add(client, binding);
@@ -1579,12 +1497,12 @@ public class NetscalerResource implements ServerResource {
                     s_logger.debug("Successfully added virtual server: " + vserverName + " domain name: " + domainName + " binding");
                 }
                 return;
-            } catch (nitro_exception e) {
+            } catch (final nitro_exception e) {
                 if (e.getErrorCode() == NitroError.NS_GSLB_DOMAIN_ALREADY_BOUND) {
                     return;
                 }
                 errMsg = e.getMessage();
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 errMsg = e.getMessage();
             }
             errMsg = "Failed to create virtual server: " + vserverName + " domain name: " + domainName + " binding" + errMsg;
@@ -1596,9 +1514,9 @@ public class NetscalerResource implements ServerResource {
 
         private static void deleteVserverDomainBinding(nitro_service client, String vserverName, String domainName) throws ExecutionException {
             try {
-                gslbvserver_domain_binding[] bindings = gslbvserver_domain_binding.get(client, vserverName);
+                final gslbvserver_domain_binding[] bindings = gslbvserver_domain_binding.get(client, vserverName);
                 if (bindings != null) {
-                    for (gslbvserver_domain_binding binding : bindings) {
+                    for (final gslbvserver_domain_binding binding : bindings) {
                         if (binding.get_domainname().equalsIgnoreCase(domainName)) {
                             gslbvserver_domain_binding.delete(client, binding);
                             if (s_logger.isDebugEnabled()) {
@@ -1608,8 +1526,8 @@ public class NetscalerResource implements ServerResource {
                         }
                     }
                 }
-            } catch (Exception e) {
-                String errMsg = "Failed to delete virtual server: " + vserverName + " and domain " + domainName + " binding due to " + e.getMessage();
+            } catch (final Exception e) {
+                final String errMsg = "Failed to delete virtual server: " + vserverName + " and domain " + domainName + " binding due to " + e.getMessage();
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
                 }
@@ -1619,19 +1537,19 @@ public class NetscalerResource implements ServerResource {
 
         private static void createGslbServiceMonitor(nitro_service nsService, String servicePublicIp, String serviceName) throws ExecutionException {
             try {
-                lbmonitor newmonitor = new lbmonitor();
-                String monitorName = generateGslbServiceMonitorName(servicePublicIp);
+                final lbmonitor newmonitor = new lbmonitor();
+                final String monitorName = generateGslbServiceMonitorName(servicePublicIp);
                 newmonitor.set_type("TCP");
                 newmonitor.set_servicename(serviceName);
                 newmonitor.set_monitorname(monitorName);
                 newmonitor.set_state("ENABLED");
                 lbmonitor.add(nsService, newmonitor);
-            } catch (nitro_exception ne) {
+            } catch (final nitro_exception ne) {
                 if (ne.getErrorCode() == NitroError.NS_RESOURCE_EXISTS) {
                     return;
                 }
-            } catch (Exception e) {
-                String errMsg = "Failed to create GSLB monitor for service public ip" + servicePublicIp;
+            } catch (final Exception e) {
+                final String errMsg = "Failed to create GSLB monitor for service public ip" + servicePublicIp;
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug(errMsg);
                 }
@@ -1641,18 +1559,18 @@ public class NetscalerResource implements ServerResource {
 
         private static void deleteGslbServiceMonitor(nitro_service nsService, String monitorName) throws ExecutionException {
             try {
-                lbmonitor serviceMonitor = lbmonitor.get(nsService, monitorName);
+                final lbmonitor serviceMonitor = lbmonitor.get(nsService, monitorName);
                 if (serviceMonitor != null) {
                     lbmonitor.delete(nsService, serviceMonitor);
                 }
-            } catch (nitro_exception ne) {
+            } catch (final nitro_exception ne) {
                 if (ne.getErrorCode() != NitroError.NS_RESOURCE_NOT_EXISTS) {
-                    String errMsg = "Failed to delete monitor " + monitorName + " for GSLB service due to " + ne.getMessage();
+                    final String errMsg = "Failed to delete monitor " + monitorName + " for GSLB service due to " + ne.getMessage();
                     s_logger.debug(errMsg);
                     throw new com.cloud.utils.exception.ExecutionException(errMsg);
                 }
-            } catch (Exception e) {
-                String errMsg = "Failed to delete monitor " + monitorName + " for GSLB service due to " + e.getMessage();
+            } catch (final Exception e) {
+                final String errMsg = "Failed to delete monitor " + monitorName + " for GSLB service due to " + e.getMessage();
                 s_logger.debug(errMsg);
                 throw new com.cloud.utils.exception.ExecutionException(errMsg);
             }
@@ -1660,11 +1578,11 @@ public class NetscalerResource implements ServerResource {
 
         private static void createGslbServiceGslbMonitorBinding(nitro_service nsService, String monitorName, String serviceName) {
             try {
-                gslbservice_lbmonitor_binding monitorBinding = new gslbservice_lbmonitor_binding();
+                final gslbservice_lbmonitor_binding monitorBinding = new gslbservice_lbmonitor_binding();
                 monitorBinding.set_monitor_name(monitorName);
                 monitorBinding.set_servicename(serviceName);
                 gslbservice_lbmonitor_binding.add(nsService, monitorBinding);
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 // TODO: Nitro API version 10.* is not compatible for NetScalers 9.*, so may fail
                 // against NetScaler version lesser than 10 hence ignore the exception
                 s_logger.warn("Failed to bind monitor to GSLB service due to " + e.getMessage());
@@ -1673,16 +1591,16 @@ public class NetscalerResource implements ServerResource {
 
         private static void deleteGslbServiceGslbMonitorBinding(nitro_service nsService, String monitorName, String serviceName) {
             try {
-                gslbservice_lbmonitor_binding[] monitorBindings = gslbservice_lbmonitor_binding.get(nsService, serviceName);
+                final gslbservice_lbmonitor_binding[] monitorBindings = gslbservice_lbmonitor_binding.get(nsService, serviceName);
                 if (monitorBindings != null && monitorBindings.length > 0) {
-                    for (gslbservice_lbmonitor_binding binding : monitorBindings) {
+                    for (final gslbservice_lbmonitor_binding binding : monitorBindings) {
                         if (binding.get_monitor_name().equalsIgnoreCase(monitorName)) {
                             s_logger.info("Found a binding between monitor " + binding.get_monitor_name() + " and " + binding.get_servicename());
                             gslbservice_lbmonitor_binding.delete(nsService, binding);
                         }
                     }
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 s_logger.debug("Failed to delete GSLB monitor " + monitorName + " and GSLB service " + serviceName + " binding due to " + e.getMessage() +
                         " but moving on ..., will be cleaned up as part of GSLB " + " service delete any way..");
             }
@@ -1691,11 +1609,11 @@ public class NetscalerResource implements ServerResource {
         // get 'gslbsite' object corresponding to a site name
         private static gslbsite getSiteObject(nitro_service client, String siteName) {
             try {
-                gslbsite site = gslbsite.get(client, siteName);
+                final gslbsite site = gslbsite.get(client, siteName);
                 if (site != null) {
                     return site;
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 s_logger.info("[ignored]"
                         + "error getting site: " + e.getLocalizedMessage());
             }
@@ -1704,18 +1622,18 @@ public class NetscalerResource implements ServerResource {
 
         private static gslbvserver getVserverObject(nitro_service client, String vserverName) {
             try {
-                gslbvserver vserver = gslbvserver.get(client, vserverName);
+                final gslbvserver vserver = gslbvserver.get(client, vserverName);
                 return vserver;
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 return null;
             }
         }
 
         private static gslbservice getServiceObject(nitro_service client, String serviceName) {
             try {
-                gslbservice service = gslbservice.get(client, serviceName);
+                final gslbservice service = gslbservice.get(client, serviceName);
                 return service;
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 return null;
             }
         }
@@ -1743,13 +1661,13 @@ public class NetscalerResource implements ServerResource {
                 } else {
                     return false;
                 }
-            } catch (nitro_exception e) {
+            } catch (final nitro_exception e) {
                 if (e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS) {
                     return false;
                 } else {
                     throw new ExecutionException("Failed to verify Server " + serverName + " exists on the NetScaler device due to " + e.getMessage());
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to verify Server " + serverName + " exists on the NetScaler device due to " + e.getMessage());
             }
         }
@@ -1759,7 +1677,7 @@ public class NetscalerResource implements ServerResource {
         }
 
         private static String genGslbObjectName(Object... args) {
-            StringBuffer buff = new StringBuffer();
+            final StringBuffer buff = new StringBuffer();
             for (int i = 0; i < args.length; i++) {
                 buff.append(args[i]);
                 if (i != args.length - 1) {
@@ -1778,14 +1696,15 @@ public class NetscalerResource implements ServerResource {
 
         private static boolean isSslCertKeyPresent(nitro_service ns, String certKeyName) throws ExecutionException {
 
-            String filter = "certkey:" + certKeyName;
+            final String filter = "certkey:" + certKeyName;
 
             try {
-                if (sslcertkey.count_filtered(ns, filter) > 0)
+                if (sslcertkey.count_filtered(ns, filter) > 0) {
                     return true;
-            } catch (nitro_exception e) {
+                }
+            } catch (final nitro_exception e) {
                 throw new ExecutionException("Failed to get certkey " + e.getMessage());
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to get certkey " + e.getMessage());
             }
 
@@ -1795,13 +1714,13 @@ public class NetscalerResource implements ServerResource {
         private static void deleteSslCertKey(nitro_service ns, String certKeyName) throws ExecutionException {
             try {
 
-                sslcertkey certkey = new sslcertkey();
+                final sslcertkey certkey = new sslcertkey();
                 certkey.set_certkey(certKeyName);
                 sslcertkey.delete(ns, certkey);
 
-            } catch (nitro_exception e) {
+            } catch (final nitro_exception e) {
                 throw new ExecutionException("Failed to delete certkey " + e.getMessage());
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to delete certkey " + e.getMessage());
             }
 
@@ -1818,12 +1737,13 @@ public class NetscalerResource implements ServerResource {
         private static void createSslCertKey(nitro_service ns, String certFilename, String keyFilename, String certKeyName, String password) throws ExecutionException {
             s_logger.debug("Adding cert to netscaler");
             try {
-                sslcertkey certkey = new sslcertkey();
+                final sslcertkey certkey = new sslcertkey();
                 certkey.set_certkey(certKeyName);
                 certkey.set_cert(SSL_CERT_PATH + certFilename);
 
-                if (keyFilename != null)
+                if (keyFilename != null) {
                     certkey.set_key(SSL_CERT_PATH + keyFilename);
+                }
 
                 if (password != null) {
                     certkey.set_passplain(password);
@@ -1831,44 +1751,25 @@ public class NetscalerResource implements ServerResource {
 
                 certkey.perform_operation(ns);
 
-            } catch (nitro_exception e) {
+            } catch (final nitro_exception e) {
                 throw new ExecutionException("Failed to add certkey binding " + e.getMessage());
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to add certkey binding " + e.getMessage());
             }
 
         }
 
-        public static void updateCertKey(nitro_service ns, String certKeyName, String cert, String key, String password) throws ExecutionException {
-            try {
-                sslcertkey certkey = sslcertkey.get(ns, certKeyName);
-                if (cert != null)
-                    certkey.set_cert(cert);
-                if (key != null)
-                    certkey.set_key(cert);
-                if (password != null)
-                    certkey.set_passplain(cert);
-
-                sslcertkey.change(ns, certkey);
-
-            } catch (nitro_exception e) {
-                throw new ExecutionException("Failed to update ssl on load balancer due to " + e.getMessage());
-            } catch (Exception e) {
-                throw new ExecutionException("Failed to update ssl on load balancer due to " + e.getMessage());
-            }
-        }
-
         private static void bindCertKeyToVserver(nitro_service ns, String certKeyName, String vserver) throws ExecutionException {
             s_logger.debug("Adding cert to netscaler");
 
             try {
-                sslvserver_sslcertkey_binding cert_binding = new sslvserver_sslcertkey_binding();
+                final sslvserver_sslcertkey_binding cert_binding = new sslvserver_sslcertkey_binding();
                 cert_binding.set_certkeyname(certKeyName);
                 cert_binding.set_vservername(vserver);
                 cert_binding.perform_operation(ns);
-            } catch (nitro_exception e) {
+            } catch (final nitro_exception e) {
                 throw new ExecutionException("Failed to bind certkey to vserver due to " + e.getMessage());
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to bind certkey to vserver due to " + e.getMessage());
             }
         }
@@ -1876,14 +1777,14 @@ public class NetscalerResource implements ServerResource {
         private static void unbindCertKeyFromVserver(nitro_service ns, String certKeyName, String vserver) throws ExecutionException {
             try {
 
-                sslvserver_sslcertkey_binding cert_binding = new sslvserver_sslcertkey_binding();
+                final sslvserver_sslcertkey_binding cert_binding = new sslvserver_sslcertkey_binding();
                 cert_binding.set_certkeyname(certKeyName);
                 cert_binding.set_vservername(vserver);
                 sslvserver_sslcertkey_binding.delete(ns, cert_binding);
 
-            } catch (nitro_exception e) {
+            } catch (final nitro_exception e) {
                 throw new ExecutionException("Failed to unbind certkey to vserver due to " + e.getMessage());
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to unbind certkey to vserver due to " + e.getMessage());
             }
 
@@ -1892,7 +1793,7 @@ public class NetscalerResource implements ServerResource {
         private static void uploadCert(String nsIp, String user, String password, String certFilename, byte[] certData) throws ExecutionException {
             try {
                 SshHelper.scpTo(nsIp, SSH_PORT, user, null, password, SSL_CERT_PATH, certData, certFilename, null);
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to copy private key to device " + e.getMessage());
             }
         }
@@ -1900,7 +1801,7 @@ public class NetscalerResource implements ServerResource {
         private static void uploadKey(String nsIp, String user, String password, String keyFilename, byte[] keyData) throws ExecutionException {
             try {
                 SshHelper.scpTo(nsIp, SSH_PORT, user, null, password, SSL_CERT_PATH, keyData, keyFilename, null);
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to copy private key to device " + e.getMessage());
             }
         }
@@ -1910,47 +1811,31 @@ public class NetscalerResource implements ServerResource {
                 return;
             }
             try {
-                base_response result = ns.enable_features(new String[] {"SSL"});
-                if (result.errorcode != 0)
+                final base_response result = ns.enable_features(new String[] {"SSL"});
+                if (result.errorcode != 0) {
                     throw new ExecutionException("Unable to enable SSL on LB");
-            } catch (nitro_exception e) {
+                }
+            } catch (final nitro_exception e) {
                 throw new ExecutionException("Failed to enable ssl feature on load balancer due to " + e.getMessage());
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to enable ssl feature on load balancer due to " + e.getMessage());
             }
         }
 
-        public static boolean checkSslFeature(nitro_service ns) throws ExecutionException {
-            try {
-                String[] features = ns.get_enabled_features();
-                if (features != null) {
-                    for (String feature : features) {
-                        if (feature.equalsIgnoreCase("SSL")) {
-                            return true;
-                        }
-                    }
-                }
-                return false;
-            } catch (nitro_exception e) {
-                throw new ExecutionException("Failed to check ssl feature on load balancer due to " + e.getMessage());
-            } catch (Exception e) {
-                throw new ExecutionException("Failed to check ssl feature on load balancer due to " + e.getMessage());
-            }
-        }
-
         public static boolean certLinkExists(nitro_service ns, String userCertName, String caCertName) throws ExecutionException {
             try {
                 // check if there is a link from userCertName to caCertName
 
-                sslcertkey userCert = sslcertkey.get(ns, userCertName);
-                String nsCaCert = userCert.get_linkcertkeyname();
+                final sslcertkey userCert = sslcertkey.get(ns, userCertName);
+                final String nsCaCert = userCert.get_linkcertkeyname();
 
-                if (nsCaCert != null && nsCaCert.equals(caCertName))
+                if (nsCaCert != null && nsCaCert.equals(caCertName)) {
                     return true;
+                }
 
-            } catch (nitro_exception e) {
+            } catch (final nitro_exception e) {
                 throw new ExecutionException("Failed to check cert link on load balancer to " + e.getMessage());
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to check cert link on load balancer due to " + e.getMessage());
             }
             return false;
@@ -1961,19 +1846,19 @@ public class NetscalerResource implements ServerResource {
 
                 // the assumption is that that both userCertName and caCertName are present on NS
 
-                sslcertkey caCert = sslcertkey.get(ns, caCertName);
-                sslcertkey userCert = sslcertkey.get(ns, userCertName);
+                final sslcertkey caCert = sslcertkey.get(ns, caCertName);
+                final sslcertkey userCert = sslcertkey.get(ns, userCertName);
 
-                sslcertkey linkResource = new sslcertkey();
+                final sslcertkey linkResource = new sslcertkey();
 
                 // link user cert to CA cert
                 linkResource.set_certkey(userCert.get_certkey());
                 linkResource.set_linkcertkeyname(caCert.get_certkey());
                 sslcertkey.link(ns, linkResource);
 
-            } catch (nitro_exception e) {
+            } catch (final nitro_exception e) {
                 throw new ExecutionException("Failed to check cert link on load balancer to " + e.getMessage());
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to check cert link on load balancer due to " + e.getMessage());
             }
 
@@ -1982,14 +1867,14 @@ public class NetscalerResource implements ServerResource {
         public static boolean isCaforCerts(nitro_service ns, String caCertName) throws ExecutionException {
             // check if this certificate  serves as a CA for other certificates
             try {
-                sslcertlink[] childLinks = sslcertlink.get_filtered(ns, "linkcertkeyname:" + caCertName);
+                final sslcertlink[] childLinks = sslcertlink.get_filtered(ns, "linkcertkeyname:" + caCertName);
                 if (childLinks != null && childLinks.length > 0) {
                     return true;
                 }
 
-            } catch (nitro_exception e) {
+            } catch (final nitro_exception e) {
                 throw new ExecutionException("Failed to check cert link on load balancer to " + e.getMessage());
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 throw new ExecutionException("Failed to check cert link on load balancer due to " + e.getMessage());
             }
             return false;
@@ -1999,14 +1884,14 @@ public class NetscalerResource implements ServerResource {
         public static boolean isBoundToVserver(nitro_service ns, String certKeyName, String nsVirtualServerName) throws ExecutionException {
             try {
 
-                sslcertkey_sslvserver_binding[] cert_vs_binding = sslcertkey_sslvserver_binding.get_filtered(ns, certKeyName, "vservername:" + nsVirtualServerName);
+                final sslcertkey_sslvserver_binding[] cert_vs_binding = sslcertkey_sslvserver_binding.get_filtered(ns, certKeyName, "vservername:" + nsVirtualServerName);
                 if (cert_vs_binding != null && cert_vs_binding.length > 0) {
                     return true;
                 }
 
-            } catch (nitro_exception e) {
+            } catch (final nitro_exception e) {
                 throw new Exe

<TRUNCATED>

[14/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Fixed Coverity Issue: Unintentional Integer FLow


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: fae20570c2ba74885a3738c650537c6db6eb5853
Parents: e5e226e
Author: Kshitij Kansal <ka...@gmail.com>
Authored: Tue Sep 15 16:49:22 2015 +0530
Committer: Kshitij Kansal <ka...@gmail.com>
Committed: Thu Apr 21 12:06:36 2016 +0530

----------------------------------------------------------------------
 server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fae20570/server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java b/server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java
index 1478910..ecdbcae 100755
--- a/server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java
+++ b/server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java
@@ -115,7 +115,7 @@ public class ImageStoreUploadMonitorImpl extends ManagerBase implements ImageSto
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
         _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Upload-Monitor"));
         _monitoringInterval = UploadMonitoringInterval.value();
-        _uploadOperationTimeout = UploadOperationTimeout.value() * 60 * 1000;
+        _uploadOperationTimeout = UploadOperationTimeout.value() * 60 * 1000L;
         _nodeId = ManagementServerNode.getManagementServerId();
         return true;
     }


[18/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
CLOUDSTACK-9164: Prevent firefox's quick search from opening in VM console


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 7db5f1833e72d2208b3b085da47b4b0d114300d3
Parents: d518b61
Author: Anshul Gangwar <an...@citrix.com>
Authored: Tue Dec 22 11:59:09 2015 +0530
Committer: Anshul Gangwar <an...@Anshuls-MacBook-Pro.local>
Committed: Mon Apr 25 11:37:43 2016 +0530

----------------------------------------------------------------------
 systemvm/js/ajaxviewer.js | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7db5f183/systemvm/js/ajaxviewer.js
----------------------------------------------------------------------
diff --git a/systemvm/js/ajaxviewer.js b/systemvm/js/ajaxviewer.js
index f5df103..09fb41a 100644
--- a/systemvm/js/ajaxviewer.js
+++ b/systemvm/js/ajaxviewer.js
@@ -649,6 +649,7 @@ AjaxViewer.prototype = {
 		this.sendingEventInProgress = false;
 		ajaxViewer.installMouseHook();
 		ajaxViewer.installKeyboardHook();
+		ajaxViewer.panel.parent().focus();
 
 		$(window).bind("resize", function() {
 			ajaxViewer.onWindowResize();
@@ -1259,6 +1260,7 @@ AjaxViewer.prototype = {
 		case 38 :		// UP
 		case 39 :		// RIGHT
 		case 40 :		// DOWN
+		case 47 :		// FORWARD SLASH // Added to stop Firefox's quick search from opening
 			return false;
 		}
 		


[17/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
BUG-ID:CLOUDSTACK-9331:added code in marvin frame&new config file to support baremetal advanced testcases


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 5f16199813a9371c6cb47977591a1695dc8b4b69
Parents: 3393555
Author: sadhu <ma...@gmail.com>
Authored: Fri Apr 1 11:54:30 2016 +0530
Committer: sadhu <ma...@gmail.com>
Committed: Sat Apr 23 11:42:28 2016 +0530

----------------------------------------------------------------------
 .../marvin/config/Baremetal_AdvZone_Vmware.cfg  | 208 +++++++++++++++++++
 tools/marvin/marvin/deployDataCenter.py         |  41 +++-
 2 files changed, 245 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f161998/tools/marvin/marvin/config/Baremetal_AdvZone_Vmware.cfg
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/config/Baremetal_AdvZone_Vmware.cfg b/tools/marvin/marvin/config/Baremetal_AdvZone_Vmware.cfg
new file mode 100644
index 0000000..a382e33
--- /dev/null
+++ b/tools/marvin/marvin/config/Baremetal_AdvZone_Vmware.cfg
@@ -0,0 +1,208 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+{
+    "zones": [
+        {
+            "name": "ZoneBaremetal",
+            "guestcidraddress": "10.1.1.0/24",
+            "providers": [
+                {
+                    "broadcastdomainrange": "ZONE",
+                    "name": "VirtualRouter"
+                }
+            ],
+            "dns1": "10.x.x.x",
+         
+            "physical_networks": [
+                {
+                    "broadcastdomainrange": "Zone",
+                    "name": "Sandbox-pnet",
+                    "vlan": "1020-1025",
+                    "traffictypes": [
+                        {
+                            "typ": "Guest"
+                        },
+                        {
+                            "typ": "Management"
+                        },
+                        {
+                            "typ": "Public"
+                        }
+                    ],
+                    "providers": [
+                        {
+                            "broadcastdomainrange": "ZONE",
+                            "name": "VirtualRouter"
+                        }
+                    ]
+                }
+            ],
+            "ipranges": [
+                {
+                    "startip": "10.x.x.x",
+                    "endip": "10.x.x.x",
+                    "netmask": "255.255.255.0",
+                    "vlan": "1220",
+                    "gateway": "10.x.x.1"
+                }
+            ],
+            "networktype": "Advanced",
+            "pods": [
+                {
+                    "endip": "10.x.x.x",
+                    "name": "POD01",
+                    "startip": "10.x.x.x",
+                    "netmask": "255.255.255.192",
+                    "vmwaredc":{"name":"dc-baremetal","vcenter":"10.x.x.x","username":"Administrator@vsphere.local","password":"Password"},
+                    "clusters": [
+                        {
+                            "clustername": "10.x.x.x/dc-baremetal/cluster1",
+                            "hypervisor": "VmWare",
+                            "username": "Administrator@vsphere.local",
+                            "clustertype": "ExternalManaged",
+                            "password": "Password",
+                            "url": "http://10.x.x.x/dc-baremetal/cluster1",
+                            "hosts": [
+                                {
+                                    "username": "root",
+                                    "url": "http://10.x.x.x",
+                                    "password": "password"
+                                },
+                                {
+                                    "username": "root",
+                                    "url": "http://10.x.x.x",
+                                    "password": "password"
+                                }
+                            ],
+                            "primaryStorages": [
+                                {
+                                    "url": "nfs://10.x.x.x:/export/home/primary",
+                                    "name": "PS0"
+                                }
+                            ]
+                        },
+						{
+                            "clustername": "C1",
+                            "hypervisor": "BareMetal",
+                            "hosts": [
+                                {
+                                    "username": "root",
+                                    "url": "http://10.x.x.x",
+                                    "password": "password",
+                                    "hostmac": "xx:xx:xx:xx:xx:xx",
+                                    "cpunumber": "1",
+                                    "cpuspeed": "1000",
+                                    "memory": "1024",
+                                    "hosttags": "host15"
+                                }
+                            ],
+                            "clustertype": "CloudManaged"
+                        }
+                    ],
+                    "gateway": "10.x.x.x"
+                }
+            ],
+            "internaldns1": "10.x.x.x",
+	    "baremetalrcturl": "http://10.x.x.x/baremetal/baremetalrct.json",
+            "secondaryStorages": [
+                {
+                    "url": "nfs://10.x.x.x:/export/home/secondary",
+					"provider": "nfs",
+					"name":"secondary"
+                }
+            ]
+        }
+    ],
+	"logger": {
+		"LogFolderPath": "/tmp/"
+    	},
+    "dbSvr": {
+        "dbSvr": "10.22.13.12",
+        "passwd": "password",
+        "db": "cloud",
+        "port": 3306,
+        "user": "root"
+    },
+    
+    "globalConfig": [
+        {
+            "name": "network.gc.wait",
+            "value": "60"
+        },
+        {
+            "name": "storage.cleanup.interval",
+            "value": "30"
+        },
+        {
+            "name": "account.cleanup.interval",
+            "value": "60"
+        },
+        {
+            "name": "secstorage.allowed.internal.sites",
+            "value": "10.x.x.0/24"
+        },
+        {
+            "name": "vm.op.wait.interval",
+            "value": "5"
+        },
+        {
+            "name": "network.gc.interval",
+            "value": "60"
+        },
+        {
+            "name": "guest.domain.suffix",
+            "value": "auto.advanced"
+        },
+        {
+            "name": "expunge.delay",
+            "value": "60"
+        },
+        {
+            "name": "vm.allocation.algorithm",
+            "value": "userdispersing"
+        },
+        {
+            "name": "expunge.interval",
+            "value": "60"
+        },
+        {
+            "name": "instance.name",
+            "value": "QA"
+        },
+        {
+            "name": "expunge.workers",
+            "value": "3"
+        },
+	{
+            "name": "baremetal.internal.storage.server.ip",
+            "value": "10.2.1.2"
+        },
+        {	
+            "name": "check.pod.cidrs",
+            "value": "true"
+        }
+    ],
+    "mgtSvr": [
+        {
+	"mgtSvrIp": "10.22.10.12",
+	"port": 8096,
+	"user": "root",
+	"password": "password",
+	"hypervisor": "vmware"
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f161998/tools/marvin/marvin/deployDataCenter.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py
index 91b30a6..889aab5 100644
--- a/tools/marvin/marvin/deployDataCenter.py
+++ b/tools/marvin/marvin/deployDataCenter.py
@@ -133,6 +133,12 @@ class DeployDataCenters(object):
                 hostcmd.username = host.username
                 hostcmd.zoneid = zoneId
                 hostcmd.hypervisor = hypervisor
+                if hostcmd.hypervisor.lower() == "baremetal":
+                    hostcmd.hostmac=host.hostmac
+                    hostcmd.cpunumber=host.cpunumber
+                    hostcmd.cpuspeed=host.cpuspeed
+                    hostcmd.memory=host.memory
+                    hostcmd.hosttags=host.hosttags
                 ret = self.__apiClient.addHost(hostcmd)
                 if ret:
                     self.__tcRunLogger.debug("=== Add Host Successful ===")
@@ -164,6 +170,25 @@ class DeployDataCenters(object):
             self.__tcRunLogger.exception("=== Adding VmWare DC Failed===")
             self.__cleanAndExit()
 
+    def addBaremetalRct(self, config):
+        networktype= config.zones[0].networktype
+        baremetalrcturl= config.zones[0].baremetalrcturl
+        if networktype is None or baremetalrcturl  is None:
+            return
+        if networktype.lower()=="advanced":
+
+            try:
+                brctcmd = addBaremetalRct.addBaremetalRctCmd()
+                brctcmd.baremetalrcturl=baremetalrcturl
+                ret = self.__apiClient.addBaremetalRct(brctcmd)
+                if ret.id:
+                    self.__tcRunLogger.debug("=== Adding Baremetal Rct file  Successful===")
+                    self.__addToCleanUp("BaremetalRct", ret.id)
+            except Exception as e:
+                print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+                self.__tcRunLogger.exception("=== Adding  Baremetal Rct file Failed===")
+                self.__cleanAndExit()
+
     def createClusters(self, clusters, zoneId, podId, vmwareDc=None):
         try:
             if clusters is None:
@@ -193,10 +218,12 @@ class DeployDataCenters(object):
                     self.addHosts(cluster.hosts, zoneId, podId, clusterId,
                                   cluster.hypervisor)
                 self.waitForHost(zoneId, clusterId)
-                self.createPrimaryStorages(cluster.primaryStorages,
-                                           zoneId,
-                                           podId,
-                                           clusterId)
+                if cluster.hypervisor.lower() != "baremetal":
+                    self.createPrimaryStorages(cluster.primaryStorages,
+                                               zoneId,
+                                               podId,
+                                               clusterId)
+
         except Exception as e:
             print "Exception Occurred %s" % GetDetailExceptionInfo(e)
             self.__tcRunLogger.exception("====Cluster %s Creation Failed"
@@ -888,6 +915,12 @@ class DeployDataCenters(object):
             self.__persistDcConfig()
             print "\n====Deploy DC Successful====="
             self.__tcRunLogger.debug("\n====Deploy DC Successful====")
+            '''
+            Upload baremetalSwitch configuration(.rct) file if  enabled zone has baremetal isolated network.
+            '''
+            self.addBaremetalRct(self.__config)
+            self.__tcRunLogger.debug("\n==== AddbaremetalRct Successful====")
+
             return SUCCESS
         except Exception as e:
             print "\nException Occurred Under deploy :%s" % \


[07/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de86c0cb/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py
----------------------------------------------------------------------
diff --git a/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py b/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py
index 3fc9c32..a8361d0 100644
--- a/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py
+++ b/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py
@@ -15,16 +15,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
-""" Tests for Basic VPC Network Functionality with NuageVsp network Plugin
+""" Tests for basic VPC Network functionality with Nuage VSP SDN plugin
 """
 # Import Local Modules
+from nuageTestCase import nuageTestCase
 from marvin.lib.base import Account
+# Import System Modules
 from nose.plugins.attrib import attr
-from nuageTestCase import nuageTestCase
 
 
 class TestVpcNetworkNuage(nuageTestCase):
-    """ Test Basic VPC Network Functionality with NuageVsp network Plugin
+    """ Test basic VPC Network functionality with Nuage VSP SDN plugin
     """
 
     @classmethod
@@ -44,55 +45,55 @@ class TestVpcNetworkNuage(nuageTestCase):
 
     @attr(tags=["advanced", "nuagevsp"], required_hardware="false")
     def test_nuage_vpc_network(self):
-        """ Test Basic VPC Network Functionality with NuageVsp network Plugin
+        """ Test Basic VPC Network Functionality with Nuage VSP SDN plugin
         """
 
         # 1. Create Nuage VSP VPC offering, check if it is successfully created and enabled.
         # 2. Create a VPC with Nuage VSP VPC offering, check if it is successfully created and enabled.
-        # 3. Create Nuage Vsp VPC Network offering, check if it is successfully created and enabled.
+        # 3. Create Nuage VSP VPC Network offering, check if it is successfully created and enabled.
         # 4. Create an ACL list in the created VPC, and add an ACL item to it.
-        # 5. Create a VPC Network with Nuage Vsp VPC Network offering and the created ACL list, check if it is
+        # 5. Create a VPC Network with Nuage VSP VPC Network offering and the created ACL list, check if it is
         #    successfully created, is in the "Implemented" state, and is added to the VPC VR.
         # 6. Deploy a VM in the created VPC network, check if the VM is successfully deployed and is in the "Running"
         #    state.
-        # 7. Verify that the created ACL item is successfully implemented in Nuage Vsp.
+        # 7. Verify that the created ACL item is successfully implemented in Nuage VSP.
 
         # Creating a VPC offering
         self.debug("Creating Nuage VSP VPC offering...")
-        vpc_offering = self.create_VpcOffering(self.test_data["nuage_vsp_services"]["vpc_offering"])
-        self.validate_vpc_offering(vpc_offering, state="Enabled")
+        vpc_offering = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering"])
+        self.validate_VpcOffering(vpc_offering, state="Enabled")
 
         # Creating a VPC
         self.debug("Creating a VPC with Nuage VSP VPC offering...")
         vpc = self.create_Vpc(vpc_offering, cidr='10.1.0.0/16')
-        self.validate_vpc(vpc, state="Enabled")
+        self.validate_Vpc(vpc, state="Enabled")
 
         # Creating a network offering
-        self.debug("Creating Nuage Vsp VPC Network offering...")
-        network_offering = self.create_NetworkOffering(self.test_data["nuage_vsp_services"]["vpc_network_offering"])
-        self.validate_network_offering(network_offering, state="Enabled")
+        self.debug("Creating Nuage VSP VPC Network offering...")
+        network_offering = self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering"])
+        self.validate_NetworkOffering(network_offering, state="Enabled")
 
         # Creating an ACL list
-        acl_list = self.create_network_acl_list(name="acl", description="acl", vpc=vpc)
+        acl_list = self.create_NetworkAclList(name="acl", description="acl", vpc=vpc)
 
         # Creating an ACL item
-        acl_item = self.create_network_acl_rule(self.test_data["ingress_rule"], acl_list=acl_list)
+        acl_item = self.create_NetworkAclRule(self.test_data["ingress_rule"], acl_list=acl_list)
 
         # Creating a VPC network in the VPC
-        self.debug("Creating a VPC network with Nuage Vsp VPC Network offering...")
-        vpc_network = self.create_Network(network_offering, gateway='10.1.1.1', vpc=vpc, acl_list=acl_list)
-        self.validate_network(vpc_network, state="Implemented")
-        vr = self.get_network_router(vpc_network)
-        self.check_router_state(vr, state="Running")
+        self.debug("Creating a VPC network with Nuage VSP VPC Network offering...")
+        vpc_network = self.create_Network(network_offering, vpc=vpc, acl_list=acl_list)
+        self.validate_Network(vpc_network, state="Implemented")
+        vr = self.get_Router(vpc_network)
+        self.check_Router_state(vr, state="Running")
 
         # Deploying a VM in the VPC network
-        vm = self.create_VM_in_Network(vpc_network)
-        self.check_vm_state(vm, state="Running")
+        vm = self.create_VM(vpc_network)
+        self.check_VM_state(vm, state="Running")
 
-        # VSPK verification
+        # VSD verification
         self.verify_vsp_network(self.domain.id, vpc_network, vpc)
         self.verify_vsp_router(vr)
         self.verify_vsp_vm(vm)
 
-        # VSPK verification for ACL item
+        # VSD verification for ACL item
         self.verify_vsp_firewall_rule(acl_item)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de86c0cb/test/integration/plugins/nuagevsp/test_nuage_vsp.py
----------------------------------------------------------------------
diff --git a/test/integration/plugins/nuagevsp/test_nuage_vsp.py b/test/integration/plugins/nuagevsp/test_nuage_vsp.py
index a6ec7e1..ca2a28e 100644
--- a/test/integration/plugins/nuagevsp/test_nuage_vsp.py
+++ b/test/integration/plugins/nuagevsp/test_nuage_vsp.py
@@ -15,16 +15,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
-""" P1 tests for NuageVsp network Plugin
+""" P1 tests for Nuage VSP SDN plugin
 """
 # Import Local Modules
+from nuageTestCase import nuageTestCase
 from marvin.lib.base import Account
+# Import System Modules
 from nose.plugins.attrib import attr
-from nuageTestCase import nuageTestCase
 
 
 class TestNuageVsp(nuageTestCase):
-    """ Test NuageVsp network plugin
+    """ Test Nuage VSP SDN plugin
     """
 
     @classmethod
@@ -44,12 +45,12 @@ class TestNuageVsp(nuageTestCase):
 
     @attr(tags=["advanced", "nuagevsp"], required_hardware="false")
     def test_nuage_vsp(self):
-        """ Test NuageVsp network plugin with basic Isolated Network functionality
+        """ Test Nuage VSP SDN plugin with basic Isolated Network functionality
         """
 
-        # 1. Verify that the NuageVsp network service provider is successfully created and enabled.
-        # 2. Create and enable Nuage Vsp Isolated Network offering, check if it is successfully created and enabled.
-        # 3. Create an Isolated Network with Nuage Vsp Isolated Network offering, check if it is successfully created
+        # 1. Verify that the Nuage VSP network service provider is successfully created and enabled.
+        # 2. Create and enable Nuage VSP Isolated Network offering, check if it is successfully created and enabled.
+        # 3. Create an Isolated Network with Nuage VSP Isolated Network offering, check if it is successfully created
         #    and is in the "Allocated" state.
         # 4. Deploy a VM in the created Isolated network, check if the Isolated network state is changed to
         #    "Implemented", and both the VM & VR are successfully deployed and are in the "Running" state.
@@ -58,49 +59,49 @@ class TestNuageVsp(nuageTestCase):
         # 6. Delete the created Isolated Network after destroying its VMs, check if the Isolated network is successfully
         #    deleted.
 
-        self.debug("Validating the NuageVsp network service provider...")
+        self.debug("Validating the Nuage VSP network service provider...")
         self.validate_NetworkServiceProvider("NuageVsp", state="Enabled")
 
         # Creating a network offering
-        self.debug("Creating and enabling Nuage Vsp Isolated Network offering...")
+        self.debug("Creating and enabling Nuage VSP Isolated Network offering...")
         network_offering = self.create_NetworkOffering(
-            self.test_data["nuage_vsp_services"]["isolated_network_offering"])
-        self.validate_network_offering(network_offering, state="Enabled")
+            self.test_data["nuagevsp"]["isolated_network_offering"])
+        self.validate_NetworkOffering(network_offering, state="Enabled")
 
         # Creating a network
-        self.debug("Creating an Isolated Network with Nuage Vsp Isolated Network offering...")
-        network = self.create_Network(network_offering, gateway='10.1.1.1')
-        self.validate_network(network, state="Allocated")
+        self.debug("Creating an Isolated Network with Nuage VSP Isolated Network offering...")
+        network = self.create_Network(network_offering)
+        self.validate_Network(network, state="Allocated")
 
         # Deploying a VM in the network
-        vm_1 = self.create_VM_in_Network(network)
-        self.validate_network(network, state="Implemented")
-        vr = self.get_network_router(network)
-        self.check_router_state(vr, state="Running")
-        self.check_vm_state(vm_1, state="Running")
+        vm_1 = self.create_VM(network)
+        self.validate_Network(network, state="Implemented")
+        vr = self.get_Router(network)
+        self.check_Router_state(vr, state="Running")
+        self.check_VM_state(vm_1, state="Running")
 
-        # VSPK verification
+        # VSD verification
         self.verify_vsp_network(self.domain.id, network)
         self.verify_vsp_router(vr)
         self.verify_vsp_vm(vm_1)
 
         # Deploying one more VM in the network
-        vm_2 = self.create_VM_in_Network(network)
-        self.check_vm_state(vm_2, state="Running")
+        vm_2 = self.create_VM(network)
+        self.check_VM_state(vm_2, state="Running")
 
-        # VSPK verification
+        # VSD verification
         self.verify_vsp_vm(vm_2)
 
         # Deleting the network
-        self.debug("Deleting the Isolated Network with Nuage Vsp Isolated Network offering...")
+        self.debug("Deleting the Isolated Network with Nuage VSP Isolated Network offering...")
         self.delete_VM(vm_1)
         self.delete_VM(vm_2)
         self.delete_Network(network)
         with self.assertRaises(Exception):
-            self.validate_network(network)
+            self.validate_Network(network)
         self.debug("Isolated Network successfully deleted in CloudStack")
 
-        # VSPK verification
+        # VSD verification
         with self.assertRaises(Exception):
             self.verify_vsp_network(self.domain.id, network)
         self.debug("Isolated Network successfully deleted in VSD")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de86c0cb/tools/marvin/marvin/config/test_data.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/config/test_data.py b/tools/marvin/marvin/config/test_data.py
index 352f8a2..c9bb7c6 100644
--- a/tools/marvin/marvin/config/test_data.py
+++ b/tools/marvin/marvin/config/test_data.py
@@ -735,6 +735,34 @@ test_data = {
         "publicport": 22,
         "protocol": 'TCP'
     },
+    "internal_lbrule": {
+        "name": "SSH",
+        "algorithm": "roundrobin",
+        # Algorithm used for load balancing
+        "sourceport": 22,
+        "instanceport": 22,
+        "scheme": "internal",
+        "protocol": "TCP",
+        "cidrlist": '0.0.0.0/0',
+    },
+    "internal_lbrule_http": {
+        "name": "HTTP",
+        "algorithm": "roundrobin",
+        # Algorithm used for load balancing
+        "sourceport": 80,
+        "instanceport": 80,
+        "scheme": "internal",
+        "protocol": "TCP",
+        "cidrlist": '0.0.0.0/0',
+    },
+    "http_rule": {
+        "privateport": 80,
+        "publicport": 80,
+        "startport": 80,
+        "endport": 80,
+        "protocol": "TCP",
+        "cidrlist": '0.0.0.0/0',
+    },
     "icmprule": {
         "icmptype": -1,
         "icmpcode": -1,
@@ -1696,9 +1724,9 @@ test_data = {
                     "mode": 'HTTP_DOWNLOAD'
                 }
         },
-    # Nuage Vsp supported services
-    "nuage_vsp_services": {
-        # Services supported by Nuage Vsp for Isolated networks
+    # Nuage VSP SDN plugin specific test data
+    "nuagevsp": {
+        # Services supported by the Nuage VSP plugin for Isolated networks
         "isolated_network_offering": {
             "name": 'nuage_marvin',
             "displaytext": 'nuage_marvin',
@@ -1718,7 +1746,7 @@ test_data = {
                     "SourceNat": {"SupportedSourceNatTypes": "perzone"}
             }
         },
-        # Services supported by Nuage Vsp for VPC networks
+        # Services supported by the Nuage VSP plugin for VPC networks
         "vpc_network_offering": {
             "name": 'nuage_vpc_marvin',
             "displaytext": 'nuage_vpc_marvin',
@@ -1740,7 +1768,30 @@ test_data = {
                 "SourceNat": {"SupportedSourceNatTypes": "perzone"}
             }
         },
-        # Nuage Vsp supports only pre-defined and custom VPC offerings
+        "vpc_network_offering_internal_lb": {
+            "name": "nuage_vpc_marvin_internal_lb",
+            "displaytext": "nuage_vpc_marvin_internal_lb",
+            "guestiptype": 'Isolated',
+            "supportedservices": 'Dhcp,Lb,StaticNat,SourceNat,NetworkACL,Connectivity,UserData',
+            "traffictype": 'GUEST',
+            "availability": 'Optional',
+            "useVpc": 'on',
+            "ispersistent": 'True',
+            "serviceProviderList": {
+                "Dhcp": "NuageVsp",
+                "Lb": "InternalLbVm",
+                "StaticNat": "NuageVsp",
+                "SourceNat": "NuageVsp",
+                "NetworkACL": "NuageVsp",
+                "Connectivity": "NuageVsp",
+                "UserData": "VpcVirtualRouter"
+            },
+            "serviceCapabilityList": {
+                "SourceNat": {"SupportedSourceNatTypes": "perzone"},
+                "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"}
+            }
+        },
+        # Services supported by the Nuage VSP plugin for VPCs
         "vpc_offering": {
             "name": 'Nuage VSP VPC offering',
             "displaytext": 'Nuage VSP VPC offering',
@@ -1753,57 +1804,20 @@ test_data = {
                 "Connectivity": "NuageVsp",
                 "UserData": "VpcVirtualRouter"
             }
-        }
-    },
-   
-    #_pr -_ passwordreset - below services used in test_nuage_password_reset
-    "network_offering_pr": {
-        "name": 'nuage_marvin',
-        "displaytext": 'nuage_marvin',
-        "guestiptype": 'Isolated',
-        "supportedservices":
-        'Dhcp,SourceNat,Connectivity,StaticNat,UserData,Firewall',
-        "traffictype": 'GUEST',
-        "availability": 'Optional',
-        "serviceProviderList": {
-            "UserData": 'VirtualRouter',
-            "Dhcp": 'NuageVsp',
-            "Connectivity": 'NuageVsp',
-            "StaticNat": 'NuageVsp',
-            "SourceNat": 'NuageVsp',
-            "Firewall": 'NuageVsp'
         },
-    },
-    "network_pr": {
-        "name": "Test Network",
-        "displaytext": "Test Network",
-        "netmask": '255.255.255.0'
-    },
-    "fw_rule_pr": {
-        "startport": 1,
-        "endport": 6000,
-        "cidr": '0.0.0.0/0',
-        # Any network (For creating FW rule)
-        "protocol": "TCP"
-    },
-    "virtual_machine_pr": {
-        "displayname": "Test VM",
-        "username": "root",
-        "password": "password",
-        "ssh_port": 22,
-        "hypervisor": 'kvm',
-        # Hypervisor type should be same as
-        # hypervisor type of cluster
-        "privateport": 22,
-        "publicport": 22,
-        "protocol": 'TCP',
-        "userdata": "This is sample data",
-    },
-    "template_pr": {
-        "displaytext": "Cent OS Template",
-        "name": "Cent OS Template",
-        "passwordenabled": True,
-    },
-    "ostype_pr": 'CentOS 5.5 (64-bit)',
-
+        "vpc_offering_lb": {
+            "name": 'Nuage VSP VPC offering with Lb',
+            "displaytext": 'Nuage VSP VPC offering with Lb',
+            "supportedservices": 'Dhcp,Lb,StaticNat,SourceNat,NetworkACL,Connectivity,UserData',
+            "serviceProviderList": {
+                "Dhcp": "NuageVsp",
+                "Lb": "InternalLbVm",
+                "StaticNat": "NuageVsp",
+                "SourceNat": "NuageVsp",
+                "NetworkACL": "NuageVsp",
+                "Connectivity": "NuageVsp",
+                "UserData": "VpcVirtualRouter"
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de86c0cb/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py
index e2f4a2c..4ceb7ac 100755
--- a/tools/marvin/marvin/lib/base.py
+++ b/tools/marvin/marvin/lib/base.py
@@ -4673,7 +4673,7 @@ class ApplicationLoadBalancer:
     @classmethod
     def create(cls, apiclient, services, name=None, sourceport=None,
                instanceport=22, algorithm="roundrobin", scheme="internal",
-               sourcenetworkid=None, networkid=None):
+               sourcenetworkid=None, networkid=None, sourceipaddress=None):
         """Create Application Load Balancer"""
         cmd = createLoadBalancer.createLoadBalancerCmd()
 
@@ -4712,6 +4712,11 @@ class ApplicationLoadBalancer:
         elif networkid:
             cmd.networkid = networkid
 
+        if "sourceipaddress" in services:
+            cmd.sourceipaddress = services["sourceipaddress"]
+        elif sourceipaddress:
+            cmd.sourceipaddress = sourceipaddress
+
         return LoadBalancerRule(apiclient.createLoadBalancer(cmd).__dict__)
 
     def delete(self, apiclient):


[35/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1500 from myENA/KVM_root_detach

CLOUDSTACK-9349: Enable root disk detach for KVM with new Marvin testsThis PR addresses the KVM detach/attach ROOT disks from VMs (CLOUDSTACK-9349).  In short, this allows the KVM Hypervisor, and I added the Simulator as a valid hypervisor for ease of development and testing of marvin, to detach a root volume and the reattach a root volume using the deviceid=0 flag to the attachVolume API.  I have also written a marvin integration test that verifies this feature works for both KVM and the Simulator.

Below is the marvin results files of the full marvin test_volumes.py.  All tests pass, including the new root detach/attach, on our KVM lab running with the patches in this PR.

[test_volumes_KIR4G3.zip](https://github.com/apache/cloudstack/files/223799/test_volumes_KIR4G3.zip)

* pr/1500:
  Removed sleeps and used validateList as requested.
  Added required_hardware="false" attr above test_02_root_volume_attach_detach
  Modified test_volumes.py to include a hypervisor test for root attach/detach testing
  Let hypervisor type KVM and Simulator detach root volumes. Updated test_volumes.py to include a test for detaching and reattaching a root volume from a vm. I also had to update base.py to allow attach_volume to have the parameter deviceid to be passed as needed.

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 1979f42b2d24e7d3ddaa71eeb0a01fde51dfd976
Parents: c03e359 73cd427
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 16:02:53 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 16:02:54 2016 -0400

----------------------------------------------------------------------
 .../com/cloud/storage/VolumeApiServiceImpl.java |   4 +-
 test/integration/component/test_volumes.py      | 135 ++++++++++++++++++-
 tools/marvin/marvin/lib/base.py                 |   6 +-
 3 files changed, 141 insertions(+), 4 deletions(-)
----------------------------------------------------------------------



[39/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1517 from shapeblue/mysql-5.7-upgradefix

engine/schema: fix upgrade path to work with MySQL 5.7Found this issue when using MySQL 5.7 with Ubuntu 16.04. The upgrade path fix removes an invalid `IGNORE` param that is deprecated now, in the upgrade path we run the alter statement to add an index only if it does not exist so we're good.

For MySQL 5.7, we'll also need to update the docs at some point to include `server-id` along with other parameters. Some of the SQL statements used throughout engine/schema don't adhere to SQL 99 standard which is enforced by default in MySQL 5.7, therefore the following sql-mode (for backward compatibility with mysql 5.6 modes) will be necessary for anyone willing to use MySQL 5.7 (until we fix codebase wide raw and generated sql statements to be SQL99 compliant):

sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION"
server-id   = 1
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'

/cc @swill @jburwell @agneya2001 @wido @DaanHoogland  and others

* pr/1517:
  engine/schema: fix upgrade path to work with MySQL 5.7

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: ad138a15d7cf62306ad827c404167716dd5fed3e
Parents: 12d8e53 c63ea0a
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 16:06:20 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 16:06:20 2016 -0400

----------------------------------------------------------------------
 engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------



[21/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #713 from nitt10prashant/pool_maint

CLOUDSTACK-8745 : verify usage after root disk migrationput storage in maintenance mode and start ha vm and check usage ... === TestName: test_ha_with_storage_maintenance | Status : SUCCESS ===
ok

----------------------------------------------------------------------
Ran 1 test in 842.294s

OK

* pr/713:
  CLOUDSTACK-8745 : verify usage after root disk migration

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: a2d46921a1ad8851da0c5060443e59673df78489
Parents: d518b61 456abb0
Author: Will Stevens <wi...@gmail.com>
Authored: Mon Apr 25 15:51:37 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Mon Apr 25 15:51:37 2016 -0400

----------------------------------------------------------------------
 .../component/maint/test_ha_pool_maintenance.py | 236 +++++++++++++++++++
 1 file changed, 236 insertions(+)
----------------------------------------------------------------------



[33/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1522 from myENA/logjobid_master

Log asynchronous responses in the api logCurrently API responses for synchronous calls are logged, but asynchronous call responses are not.  This pull request makes a minor modification that logs the response including the JobId of all asynchronous requests.

As an example, here is what a stopVirtualMachine request looked like in the logs:

    2016-04-27 10:43:11,084 INFO  [a.c.c.a.ApiServer] (catalina-exec-3:ctx-37d9f693 ctx-d2368de3) (logid:3a0fad97) (userId=2 accountId=2 sessionId=AF8B1F726ACB5C3A637B8B300AA218A7) 10.103.0.207 -- GET command=stopVirtualMachine&id=f63b6fcc-e0b0-480f-8f7a-cba329634ba1&forced=false&response=json&_=1461771791036 200

After this modification, here is what the logs look like:

    2016-04-27 13:37:11,338 INFO  [a.c.c.a.ApiServer] (catalina-exec-6:ctx-915b5c84 ctx-a03152fa) (logid:66249df0) (userId=2 accountId=2 sessionId=9EF127EED5CA6E74797DFE487D980FAF) 10.103.0.207 -- GET command=stopVirtualMachine&id=f63b6fcc-e0b0-480f-8f7a-cba329634ba1&forced=false&response=json&_=1461782231194 200 {"stopvirtualmachineresponse":{"jobid":"5b9f4a9b-eabe-4fa4-849d-3d004bb65634"}}

* pr/1522:
  Log responses from asynchronous api commands

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 91ce3b9ffb9b9c6e62c1a0c75573235adc6f250c
Parents: 4db5e48 7778e24
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 15:59:57 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 15:59:57 2016 -0400

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiServer.java | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------



[23/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1452 from prashanthvarma/master

CLOUDSTACK-9322: Support for Internal LB fuctionality with Nuage VSP SDN Plugin including Marvin test coverageTask: https://issues.apache.org/jira/browse/CLOUDSTACK-9322

PR contents:
1) UI changes to support LB provider InternalLbVm during VPC offering creation.
2) Bug fix for CLOUDSTACK-9320.
3) Nuage VSP SDN Plugin related enhancements for VPC network functionality.
4) Marvin test coverage for Internal LB support on master with Nuage VSP SDN Plugin.
5) Enhancements on our exiting Marvin test code (nuagevsp plugins directory).
6) PEP8 & PyFlakes compliance with our Marvin test code.

Test run:
CloudStack$ nosetests --with-marvin --marvin-config=nuage_ant.cfg test/integration/plugins/nuagevsp/ -a tags=nuagevsp

Test results:
Test user data and password reset functionality with Nuage VSP SDN plugin ... === TestName: test_nuage_UserDataPasswordReset | Status : SUCCESS ===
ok
Test Nuage VSP VPC Offering with different combinations of LB service providers ... === TestName: test_01_nuage_internallb_vpc_Offering | Status : SUCCESS ===
ok
Test Nuage VSP VPC Network Offering with and without Internal LB service ... === TestName: test_02_nuage_internallb_vpc_network_offering | Status : SUCCESS ===
ok
Test Nuage VSP VPC Networks with and without Internal LB service ... === TestName: test_03_nuage_internallb_vpc_networks | Status : SUCCESS ===
ok
Test Nuage VSP VPC Internal LB functionality with different combinations of Internal LB rules ... === TestName: test_04_nuage_internallb_rules | Status : SUCCESS ===
ok
Test Nuage VSP VPC Internal LB functionality by performing (wget) traffic tests within a VPC ... === TestName: test_05_nuage_internallb_traffic | Status : SUCCESS ===
ok
Test Nuage VSP VPC Internal LB functionality with different LB algorithms by performing (wget) traffic tests ... === TestName: test_06_nuage_internallb_algorithms_traffic | Status : SUCCESS ===
ok
Test Nuage VSP VPC Internal LB functionality with restarts of VPC network components by performing (wget) ... === TestName: test_07_nuage_internallb_vpc_network_restarts_traffic | Status : SUCCESS ===
ok
Test Nuage VSP VPC Internal LB functionality with InternalLbVm appliance operations by performing (wget) ... === TestName: test_08_nuage_internallb_appliance_operations_traffic | Status : SUCCESS ===
ok
Test Basic VPC Network Functionality with Nuage VSP SDN plugin ... === TestName: test_nuage_vpc_network | Status : SUCCESS ===
ok
Test Nuage VSP SDN plugin with basic Isolated Network functionality ... === TestName: test_nuage_vsp | Status : SUCCESS ===
ok

----------------------------------------------------------------------
Ran 11 tests in 12094.705s

OK

Test run logs:
[results.txt](https://github.com/apache/cloudstack/files/187587/results.txt)
[runinfo.txt](https://github.com/apache/cloudstack/files/187588/runinfo.txt)

Test config file:
[nuage_ant.txt](https://github.com/apache/cloudstack/files/222711/nuage_ant.txt)

Note: Attached the Marvin config file as .txt instead of .cfg.

PEP8 & PyFlakes Compliance:
CloudStack$ pep8 --max-line-length=150 test/integration/plugins/nuagevsp/*.py
CloudStack$ pyflakes test/integration/plugins/nuagevsp/nuageTestCase.py
CloudStack$ pyflakes test/integration/plugins/nuagevsp/test_nuage_password_reset.py
CloudStack$ pyflakes test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py
CloudStack$ pyflakes test/integration/plugins/nuagevsp/test_nuage_vpc_network.py
CloudStack$ pyflakes test/integration/plugins/nuagevsp/test_nuage_vsp.py
CloudStack$ pyflakes test/integration/plugins/nuagevsp/*.py

#CLOUDSTACK-9322

* pr/1452:
  CLOUDSTACK-9322 : Marvin tests for Internal Lb with Nuage VSP
  CLOUDSTACK-9320 : InternalLBVM is not getting destroyed when the last Internal Load Balancer rule is removed for the corresponding source IP address
  CLOUDSTACK-9322 : Changes to support InternalLbVm with Nuage VSP plugin

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 9b525f51a2cd438a10e0bede2e96d875e8bd63b5
Parents: 4ab7fb7 de86c0cb
Author: Will Stevens <wi...@gmail.com>
Authored: Mon Apr 25 15:53:57 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Mon Apr 25 15:53:58 2016 -0400

----------------------------------------------------------------------
 .../element/InternalLoadBalancerElement.java    |   84 +-
 .../com/cloud/api/commands/VspConstants.java    |    1 +
 .../api/response/NuageVspDeviceResponse.java    |    7 +
 .../cloud/network/element/NuageVspElement.java  |   31 +
 .../network/guru/NuageVspGuestNetworkGuru.java  |    9 +
 .../network/manager/NuageVspManagerImpl.java    |   91 +-
 .../network/element/NuageVspElementTest.java    |    6 +
 .../guru/NuageVspGuestNetworkGuruTest.java      |   25 +-
 .../com/cloud/network/vpc/VpcManagerImpl.java   |    9 +-
 .../src/com/cloud/user/DomainManagerImpl.java   |    1 +
 .../plugins/nuagevsp/nuageTestCase.py           |  653 +++---
 .../nuagevsp/test_nuage_password_reset.py       |   98 +-
 .../nuagevsp/test_nuage_vpc_internal_lb.py      | 2076 ++++++++++++++++++
 .../plugins/nuagevsp/test_nuage_vpc_network.py  |   49 +-
 .../plugins/nuagevsp/test_nuage_vsp.py          |   53 +-
 tools/marvin/marvin/config/test_data.py         |  128 +-
 tools/marvin/marvin/lib/base.py                 |    7 +-
 ui/scripts/configuration.js                     |    5 +-
 18 files changed, 2763 insertions(+), 570 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b525f51/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------


[30/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge release branch 4.7 to 4.8

* 4.7:
  CLOUDSTACK-9142 Migrate VM changes xmlDesc in a safe way


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 43ab44dd5834dc0c7fbe93ef619e94daefda703d
Parents: c2fc0c4 c03e359
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 15:56:48 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 15:56:48 2016 -0400

----------------------------------------------------------------------
 .../wrapper/LibvirtMigrateCommandWrapper.java   |  34 ++-
 .../resource/LibvirtComputingResourceTest.java  |  22 +-
 .../LibvirtMigrateCommandWrapperTest.java       | 306 +++++++++++++++++++
 3 files changed, 349 insertions(+), 13 deletions(-)
----------------------------------------------------------------------



[31/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge release branch 4.8 to master

* 4.8:
  CLOUDSTACK-9142 Migrate VM changes xmlDesc in a safe way


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: ad61d49d871a6eea76d65ea15a48b0b20a7a545f
Parents: 5c1ad90 43ab44d
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 15:57:43 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 15:57:43 2016 -0400

----------------------------------------------------------------------
 .../wrapper/LibvirtMigrateCommandWrapper.java   |  34 ++-
 .../resource/LibvirtComputingResourceTest.java  |  22 +-
 .../LibvirtMigrateCommandWrapperTest.java       | 306 +++++++++++++++++++
 3 files changed, 349 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad61d49d/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
----------------------------------------------------------------------


[04/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #4 from apache/4.7

4.7 PR

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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 48ce76344040de2ab8014f76292abe0421d42f85
Parents: a243339 4db1c01
Author: Simon Weller <si...@gmail.com>
Authored: Thu Mar 24 14:55:34 2016 -0500
Committer: Simon Weller <si...@gmail.com>
Committed: Thu Mar 24 14:55:34 2016 -0500

----------------------------------------------------------------------
 agent/src/com/cloud/agent/Agent.java   | 6 +++---
 ui/scripts/network.js                  | 8 ++++----
 ui/scripts/ui-custom/instanceWizard.js | 2 +-
 ui/scripts/ui-custom/projects.js       | 2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------



[26/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #826 from kansal/CLOUDSTACK-8853

Fixed: Error given when creating VPN user in one network if VR for another network is stopped.

Problem: Adding a VPN user to an IP on an isolated network fails with an exception if the end-user has two isolated networks and one of them is not in use (i.e. VR is stopped).

Fix: Presently in the code, all the VR which are not in Running state are forced to throw error. Added a check for the Stopped and Stopping state routers. Configurations will be applied to them when they get restarted.

* pr/826:
  Fixed Coverity Issue: Unintentional Integer FLow
  Fixed: Error given when creating VPN user in one network if VR for another network is stopped

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 5c1ad900a273bcc7068fcee19cc8545ffdcec0c4
Parents: a6bae2b fae2057
Author: Will Stevens <wi...@gmail.com>
Authored: Tue Apr 26 13:10:30 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Tue Apr 26 13:10:30 2016 -0400

----------------------------------------------------------------------
 server/src/com/cloud/storage/ImageStoreUploadMonitorImpl.java  | 2 +-
 .../cloudstack/network/topology/BasicNetworkTopology.java      | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[28/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Log responses from asynchronous api commands

This is mainly useful so that we can see the job ids in the logs
whenever the job is created via the API.


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 7778e24bf7bb7bd2c1a19fde5fb711b8d8086446
Parents: 5c1ad90
Author: Nathan Johnson <nj...@ena.com>
Authored: Wed Apr 27 14:49:50 2016 -0500
Committer: Nathan Johnson <nj...@ena.com>
Committed: Wed Apr 27 19:43:57 2016 -0500

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiServer.java | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7778e24b/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index f76b851..6ec2f18 100644
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -686,14 +686,21 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 s_logger.warn(errorMsg);
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, errorMsg);
             }
-
+            final String response;
             if (objectId != null) {
                 final String objUuid = (objectUuid == null) ? objectId.toString() : objectUuid;
-                return getBaseAsyncCreateResponse(jobId, (BaseAsyncCreateCmd)asyncCmd, objUuid);
+                response = getBaseAsyncCreateResponse(jobId, (BaseAsyncCreateCmd)asyncCmd, objUuid);
             } else {
                 SerializationContext.current().setUuidTranslation(true);
-                return getBaseAsyncResponse(jobId, asyncCmd);
+                response = getBaseAsyncResponse(jobId, asyncCmd);
             }
+            // Always log response for async for now, I don't think any sensitive data will be in here.
+            // It might be nice to send this through scrubbing similar to how
+            // ApiResponseSerializer.toSerializedStringWithSecureLogs works. For now, this gets jobid's
+            // in the api logs.
+            log.append(response);
+            return response;
+
         } else {
             dispatcher.dispatch(cmdObj, params, false);
 


[09/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
CLOUDSTACK-9322 : Marvin tests for Internal Lb with Nuage VSP


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: de86c0cb170f55bdd2bf27874f1782b7333d71af
Parents: 741e888
Author: Prashanth Manthena <Pr...@alcatel-lucent.com>
Authored: Wed Mar 23 15:59:41 2016 +0100
Committer: Nick Livens <ni...@nuagenetworks.net>
Committed: Tue Mar 29 11:24:54 2016 +0200

----------------------------------------------------------------------
 .../plugins/nuagevsp/nuageTestCase.py           |  653 +++---
 .../nuagevsp/test_nuage_password_reset.py       |   98 +-
 .../nuagevsp/test_nuage_vpc_internal_lb.py      | 2076 ++++++++++++++++++
 .../plugins/nuagevsp/test_nuage_vpc_network.py  |   49 +-
 .../plugins/nuagevsp/test_nuage_vsp.py          |   53 +-
 tools/marvin/marvin/config/test_data.py         |  128 +-
 tools/marvin/marvin/lib/base.py                 |    7 +-
 7 files changed, 2565 insertions(+), 499 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de86c0cb/test/integration/plugins/nuagevsp/nuageTestCase.py
----------------------------------------------------------------------
diff --git a/test/integration/plugins/nuagevsp/nuageTestCase.py b/test/integration/plugins/nuagevsp/nuageTestCase.py
index 55199d5..9d0d077 100644
--- a/test/integration/plugins/nuagevsp/nuageTestCase.py
+++ b/test/integration/plugins/nuagevsp/nuageTestCase.py
@@ -15,43 +15,36 @@
 # specific language governing permissions and limitations
 # under the License.
 
-""" Custom base class for NuageVsp SDN Plugin specific Marvin tests
+""" Custom base class for Nuage VSP SDN plugin specific Marvin tests
 """
 # Import Local Modules
 from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.lib.base import (NetworkServiceProvider,
-                             ServiceOffering,
-                             NetworkOffering,
+from marvin.lib.base import (EgressFireWallRule,
+                             FireWallRule,
+                             Hypervisor,
                              Network,
-                             Router,
+                             NetworkACL,
+                             NetworkACLList,
+                             NetworkOffering,
+                             NetworkServiceProvider,
                              Nuage,
-                             VPC,
-                             VpcOffering,
+                             PhysicalNetwork,
                              PublicIPAddress,
-                             VirtualMachine,
+                             Router,
+                             ServiceOffering,
                              StaticNATRule,
-                             NetworkACLList,
-                             NetworkACL,
-                             FireWallRule,
-                             EgressFireWallRule,
-                             Host)
-from marvin.lib.common import (get_zone,
-                               get_domain,
+                             VirtualMachine,
+                             VPC,
+                             VpcOffering)
+from marvin.lib.common import (get_domain,
                                get_template,
-                               list_templates,
-                               wait_for_cleanup)
+                               get_zone)
 from marvin.lib.utils import cleanup_resources
-from marvin.cloudstackAPI import (listPhysicalNetworks,
-                                  updateConfiguration,
-                                  updateTemplate,
-                                  listConfigurations,
-                                  listHypervisors,
-                                  stopRouter,
-                                  startRouter)
+from marvin.cloudstackAPI import restartVPC
 # Import System Modules
-import socket
 import importlib
 import logging
+import socket
 
 
 class nuageTestCase(cloudstackTestCase):
@@ -84,42 +77,36 @@ class nuageTestCase(cloudstackTestCase):
                                                       )
         cls._cleanup = [cls.service_offering]
 
-        # Get configured Nuage Vsp device details
+        # Get configured Nuage VSP device details
         try:
-            resp = listPhysicalNetworks.listPhysicalNetworksCmd()
-            resp.zoneid = cls.zone.id
-            physical_networks = cls.api_client.listPhysicalNetworks(resp)
+            physical_networks = PhysicalNetwork.list(cls.api_client, zoneid=cls.zone.id)
             for pn in physical_networks:
-                if pn.isolationmethods == 'VSP':
+                if pn.isolationmethods == "VSP":
                     cls.vsp_physical_network = pn
                     break
             cls.nuage_vsp_device = Nuage.list(cls.api_client,
                                               physicalnetworkid=cls.vsp_physical_network.id
                                               )[0]
             pns = cls.config.zones[0].physical_networks
-            providers = filter(lambda physical_network: 'VSP' in physical_network.isolationmethods, pns)[0].providers
-            devices = filter(lambda provider: provider.name == 'NuageVsp', providers)[0].devices
+            providers = filter(lambda physical_network: "VSP" in physical_network.isolationmethods, pns)[0].providers
+            devices = filter(lambda provider: provider.name == "NuageVsp", providers)[0].devices
             cls.nuage_vsp_device.username = devices[0].username
             cls.nuage_vsp_device.password = devices[0].password
-            listConfigurationsCmd = listConfigurations.listConfigurationsCmd()
-            listConfigurationsCmd.name = "nuagevsp.cms.id"
-            listConfigurationsCmd.scopename = "global"
-            cs_config_dict = cls.api_client.listConfigurations(listConfigurationsCmd)
-            cls.cms_id = str(cs_config_dict[0].value).split(":")[1]
+            cls.cms_id = cls.nuage_vsp_device.cmsid
         except Exception as e:
             cls.tearDownClass()
-            raise unittest.SkipTest("Warning: Couldn't get configured Nuage Vsp device details: %s" % e)
+            raise unittest.SkipTest("Warning: Couldn't get configured Nuage VSP device details: %s" % e)
 
         # Check if the host hypervisor type is simulator
-        resp = listHypervisors.listHypervisorsCmd()
-        resp.zoneid = cls.zone.id
-        cls.isSimulator = cls.api_client.listHypervisors(resp)[0].name == 'Simulator'
+        cls.isSimulator = Hypervisor.list(cls.api_client, zoneid=cls.zone.id)[0].name == "Simulator"
 
-        # VSD is a Python SDK for Nuage Vsp
+        # VSD is a programmable policy and analytics engine of Nuage VSP SDN platform
+        # vspk is a Python SDK for Nuage VSP's VSD
+        # cms_vspk_wrapper is a library that wraps vspk package
         try:
             vspk_module = "vspk." + cls.nuage_vsp_device.apiversion if int(cls.nuage_vsp_device.apiversion[1]) >= 4 \
                 else "vspk.vsdk." + cls.nuage_vsp_device.apiversion
-            vsdk = importlib.import_module(vspk_module)
+            cls.vsdk = importlib.import_module(vspk_module)
             vspk_utils_module = "vspk.utils" if int(cls.nuage_vsp_device.apiversion[1]) >= 4 \
                 else "vspk.vsdk." + cls.nuage_vsp_device.apiversion + ".utils"
             vsdk_utils = importlib.import_module(vspk_utils_module)
@@ -129,12 +116,12 @@ class nuageTestCase(cloudstackTestCase):
             raise unittest.SkipTest("vspk (and/or) cms_vspk_wrapper import failure")
 
         # Configure VSD session
-        cls._session = vsdk.NUVSDSession(username=cls.nuage_vsp_device.username,
-                                         password=cls.nuage_vsp_device.password,
-                                         enterprise="csp", api_url="https://%s:%d" %
-                                                                   (cls.nuage_vsp_device.hostname,
-                                                                    cls.nuage_vsp_device.port)
-                                         )
+        cls._session = cls.vsdk.NUVSDSession(username=cls.nuage_vsp_device.username,
+                                             password=cls.nuage_vsp_device.password,
+                                             enterprise="csp", api_url="https://%s:%d" %
+                                                                       (cls.nuage_vsp_device.hostname,
+                                                                        cls.nuage_vsp_device.port)
+                                             )
         cls._session.start()
 
         # Configure cms_vspk_wrapper session
@@ -157,7 +144,7 @@ class nuageTestCase(cloudstackTestCase):
             # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
-            cls.debug("Warning: Exception during cleanup : %s" % e)
+            cls.debug("Warning: Exception during cleanup: %s" % e)
         return
 
     def tearDown(self):
@@ -176,69 +163,51 @@ class nuageTestCase(cloudstackTestCase):
         self.debug("Cleanup complete!")
         return
 
-    def getConfigurationValue(self, name, scope="global"):
-        listConfigurationsCmd = listConfigurations.listConfigurationsCmd()
-        listConfigurationsCmd.name = name
-        listConfigurationsCmd.scopename = scope
-        if scope is "zone":
-            listConfigurationsCmd.zoneid = self.zone.id
-        return self.api_client.listConfigurations(listConfigurationsCmd)
-
-    def setConfigurationValue(self, name, value, scope="global"):
-        cmd = updateConfiguration.updateConfigurationCmd()
-        cmd.name = name
-        cmd.scopename = scope
-        if scope is "zone":
-            cmd.zoneid = self.zone.id
-        cmd.value = value
-        self.api_client.updateConfiguration(cmd)
-
-    def updateTemplate(self, value):
-        self.debug("UPDATE TEMPLATE")
-        cmd = updateTemplate.updateTemplateCmd()
-        cmd.id = self.template.id
-        cmd.passwordenabled = value
-        self.api_client.updateTemplate(cmd)
-        list_template_response = list_templates(self.api_client,
-                                                templatefilter="all",
-                                                id=self.template.id
-                                                )
-        self.template = list_template_response[0]
-
-    # Creates the vpc offering
+    # create_VpcOffering - Creates VPC offering
     def create_VpcOffering(self, vpc_offering, suffix=None):
-        self.debug('Create VpcOffering')
+        self.debug("Creating VPC offering")
         if suffix:
             vpc_offering["name"] = "VPC_OFF-" + str(suffix)
         vpc_off = VpcOffering.create(self.api_client,
                                      vpc_offering
                                      )
         # Enable VPC offering
-        vpc_off.update(self.api_client, state='Enabled')
+        vpc_off.update(self.api_client, state="Enabled")
         self.cleanup.append(vpc_off)
-        self.debug('Created and Enabled VpcOffering')
+        self.debug("Created and Enabled VPC offering")
         return vpc_off
 
-    # create_Vpc - Takes the vpc offering as arguments and creates the VPC
-    def create_Vpc(self, vpc_offering, cidr='10.1.1.1/16', cleanup=True):
-        self.debug("Creating a VPC network in the account: %s" % self.account.name)
+    # create_Vpc - Creates VPC with the given VPC offering
+    def create_Vpc(self, vpc_offering, cidr="10.1.1.1/16", cleanup=True):
+        self.debug("Creating a VPC in the account - %s" % self.account.name)
+        self.test_data["vpc"]["name"] = "TestVPC"
+        self.test_data["vpc"]["displaytext"] = "TestVPC"
         self.test_data["vpc"]["cidr"] = cidr
-        vpc = VPC.create(
-            self.api_client,
-            self.test_data["vpc"],
-            vpcofferingid=vpc_offering.id,
-            zoneid=self.zone.id,
-            account=self.account.name,
-            domainid=self.account.domainid
-        )
-        self.debug("Created VPC with ID: %s" % vpc.id)
+        vpc = VPC.create(self.api_client,
+                         self.test_data["vpc"],
+                         vpcofferingid=vpc_offering.id,
+                         zoneid=self.zone.id,
+                         account=self.account.name,
+                         domainid=self.account.domainid
+                         )
+        self.debug("Created VPC with ID - %s" % vpc.id)
         if cleanup:
             self.cleanup.append(vpc)
         return vpc
 
-    # create_NetworkOffering - Takes the network offering as argument and creates the Network Offering
+    # restart_Vpc - Restarts the given VPC with/without cleanup
+    def restart_Vpc(self, vpc, cleanup=None):
+        self.debug("Restarting VPC with ID - %s" % vpc.id)
+        cmd = restartVPC.restartVPCCmd()
+        cmd.id = vpc.id
+        cmd.cleanup = cleanup
+        cmd.makeredundant = False
+        self.api_client.restartVPC(cmd)
+        self.debug("Restarted VPC with ID - %s" % vpc.id)
+
+    # create_NetworkOffering - Creates Network offering
     def create_NetworkOffering(self, net_offering, suffix=None, conserve_mode=False):
-        self.debug('Create NetworkOffering')
+        self.debug("Creating Network offering")
         if suffix:
             net_offering["name"] = "NET_OFF-" + str(suffix)
         nw_off = NetworkOffering.create(self.api_client,
@@ -246,90 +215,90 @@ class nuageTestCase(cloudstackTestCase):
                                         conservemode=conserve_mode
                                         )
         # Enable Network offering
-        nw_off.update(self.api_client, state='Enabled')
+        nw_off.update(self.api_client, state="Enabled")
         self.cleanup.append(nw_off)
-        self.debug('Created and Enabled NetworkOffering')
+        self.debug("Created and Enabled Network offering")
         return nw_off
 
-    # create_Network - Takes the network offering as argument and nw_key and creates the network
-    def create_Network(self, nw_off, nw_key="network", gateway='10.1.1.1', netmask='255.255.255.0', vpc=None, acl_list=None):
-        if not hasattr(nw_off, "id"):
-            nw_off = self.create_NetworkOffering(nw_off)
-        self.debug('Adding Network=%s' % self.test_data[nw_key])
-        self.test_data[nw_key]["netmask"] = netmask
-        obj_network = Network.create(self.api_client,
-                                     self.test_data[nw_key],
-                                     accountid=self.account.name,
-                                     domainid=self.account.domainid,
-                                     networkofferingid=nw_off.id,
-                                     zoneid=self.zone.id,
-                                     gateway=gateway,
-                                     vpcid=vpc.id if vpc else self.vpc.id if hasattr(self, "vpc") else None,
-                                     aclid=acl_list.id if acl_list else None
-                                     )
-        self.debug("Created network with ID: %s" % obj_network.id)
-        self.cleanup.append(obj_network)
-        return obj_network
+    # create_Network - Creates network with the given Network offering
+    def create_Network(self, nw_off, gateway="10.1.1.1", netmask="255.255.255.0", vpc=None, acl_list=None):
+        self.debug("Creating a network in the account - %s" % self.account.name)
+        self.test_data["network"]["netmask"] = netmask
+        network = Network.create(self.api_client,
+                                 self.test_data["network"],
+                                 accountid=self.account.name,
+                                 domainid=self.account.domainid,
+                                 networkofferingid=nw_off.id,
+                                 zoneid=self.zone.id,
+                                 gateway=gateway,
+                                 vpcid=vpc.id if vpc else self.vpc.id if hasattr(self, "vpc") else None,
+                                 aclid=acl_list.id if acl_list else None
+                                 )
+        self.debug("Created network with ID - %s" % network.id)
+        self.cleanup.append(network)
+        return network
 
     # upgrade_Network - Upgrades the given network
     def upgrade_Network(self, nw_off, network):
         if not hasattr(nw_off, "id"):
             nw_off = self.create_NetworkOffering(nw_off, network.gateway)
-        self.debug('Update Network=%s' % network)
-        network.update(
-            self.api_client,
-            networkofferingid=nw_off.id,
-            changecidr=False
-        )
-        self.debug("Updated network with ID: %s" % network.id)
+        self.debug("Updating Network with ID - %s" % network.id)
+        network.update(self.api_client,
+                       networkofferingid=nw_off.id,
+                       changecidr=False
+                       )
+        self.debug("Updated network with ID - %s" % network.id)
 
     # delete_Network - Deletes the given network
     def delete_Network(self, network):
-        self.debug('Deleting Network - %s' % network.name)
-        # Wait for network garbage collection before network deletion
-        wait_for_cleanup(self.api_client,
-                         ["network.gc.interval", "network.gc.wait"]
-                         )
+        self.debug("Deleting Network with ID - %s" % network.id)
         network.delete(self.api_client)
         if network in self.cleanup:
             self.cleanup.remove(network)
-        self.debug('Deleted Network - %s' % network.name)
+        self.debug("Deleted Network with ID - %s" % network.id)
 
-    # create_VM_in_Network - Creates a VM in the given network, the vm_key - is the key for the services on the vm.
-    def create_VM_in_Network(self, network,  vm_key="virtual_machine", host_id=None, start_vm=True):
-        self.debug('Creating VM in network=%s' % network.name)
-        self.debug('Passed vm_key=%s' % vm_key)
+    # create_VM - Creates VM in the given network, vm_key - Key for the services on the VM
+    def create_VM(self, network, vm_key="virtual_machine", host_id=None, start_vm=True):
+        self.debug("Creating VM in network with ID - %s" % network.id)
+        self.debug("Passed vm_key - %s" % vm_key)
         self.test_data[vm_key]["zoneid"] = self.zone.id
         self.test_data[vm_key]["template"] = self.template.id
-        vm = VirtualMachine.create(
-            self.api_client,
-            self.test_data[vm_key],
-            accountid=self.account.name,
-            domainid=self.account.domainid,
-            serviceofferingid=self.service_offering.id,
-            networkids=[str(network.id)],
-            startvm=start_vm,
-            hostid=host_id
-        )
-        self.debug('Created VM=%s in network=%s' % (vm.id, network.name))
+        vm = VirtualMachine.create(self.api_client,
+                                   self.test_data[vm_key],
+                                   accountid=self.account.name,
+                                   domainid=self.account.domainid,
+                                   serviceofferingid=self.service_offering.id,
+                                   networkids=[str(network.id)],
+                                   startvm=start_vm,
+                                   hostid=host_id
+                                   )
+        self.debug("Created VM with ID - %s in network with ID - %s" % (vm.id, network.id))
         self.cleanup.append(vm)
         return vm
 
     # delete_VM - Deletes the given VM
-    def delete_VM(self, vm):
-        self.debug('Deleting VM - %s' % vm.name)
-        vm.delete(self.api_client)
-        # Wait for expunge interval to cleanup VM
-        wait_for_cleanup(self.api_client,
-                         ["expunge.delay", "expunge.interval"]
-                         )
+    def delete_VM(self, vm, expunge=True):
+        self.debug("Deleting VM with ID - %s" % vm.id)
+        vm.delete(self.api_client, expunge=expunge)
         if vm in self.cleanup:
             self.cleanup.remove(vm)
-        self.debug('Deleted VM - %s' % vm.name)
+        self.debug("Deleted VM with ID - %s" % vm.id)
+
+    # get_Router - Returns router for the given network
+    def get_Router(self, network):
+        self.debug("Finding the virtual router for network with ID - %s" % network.id)
+        routers = Router.list(self.api_client,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(isinstance(routers, list), True,
+                         "List routers should return a valid virtual router for network"
+                         )
+        return routers[0]
 
-    # acquire_Public_IP - Acquires a public IP for the given network
-    def acquire_Public_IP(self, network, vpc=None):
-        self.debug("Associating public IP for network: %s" % network.name)
+    # acquire_PublicIPAddress - Acquires public IP address for the given network/VPC
+    def acquire_PublicIPAddress(self, network, vpc=None):
+        self.debug("Associating public IP for network with ID - %s" % network.id)
         public_ip = PublicIPAddress.create(self.api_client,
                                            accountid=self.account.name,
                                            zoneid=self.zone.id,
@@ -337,41 +306,35 @@ class nuageTestCase(cloudstackTestCase):
                                            networkid=network.id if vpc is None else None,
                                            vpcid=vpc.id if vpc else self.vpc.id if hasattr(self, "vpc") else None
                                            )
-        self.debug("Associated %s with network %s" % (public_ip.ipaddress.ipaddress,
-                                                      network.id))
+        self.debug("Associated public IP address - %s with network with ID - %s" %
+                   (public_ip.ipaddress.ipaddress, network.id))
         return public_ip
 
-    # create_StaticNatRule_For_VM - Creates static NAT rule for the given network , VM on the given public ip
+    # create_StaticNatRule_For_VM - Creates static NAT rule on the given public IP for the given network and VM
     def create_StaticNatRule_For_VM(self, vm, public_ip, network, vmguestip=None):
-        self.debug("Enabling static NAT for IP: %s" %
-                   public_ip.ipaddress.ipaddress)
-        StaticNATRule.enable(
-            self.api_client,
-            ipaddressid=public_ip.ipaddress.id,
-            virtualmachineid=vm.id,
-            networkid=network.id,
-            vmguestip=vmguestip
-        )
-        self.debug("Static NAT enabled for IP: %s" %
-                   public_ip.ipaddress.ipaddress)
-
-    # delete_StaticNatRule_For_VM - Deletes the static NAT rule for the given VM
+        self.debug("Enabling static NAT for public IP - %s" % public_ip.ipaddress.ipaddress)
+        StaticNATRule.enable(self.api_client,
+                             ipaddressid=public_ip.ipaddress.id,
+                             virtualmachineid=vm.id,
+                             networkid=network.id,
+                             vmguestip=vmguestip
+                             )
+        self.debug("Static NAT enabled for public IP - %s" % public_ip.ipaddress.ipaddress)
+
+    # delete_StaticNatRule_For_VM - Deletes static NAT rule on the given public IP for the given VM
     def delete_StaticNatRule_For_VM(self, vm, public_ip):
-        self.debug("Disabling static NAT for IP: %s" %
-                   public_ip.ipaddress.ipaddress)
-        StaticNATRule.disable(
-            self.api_client,
-            ipaddressid=public_ip.ipaddress.id,
-            virtualmachineid=vm.id
-        )
-        self.debug("Static NAT disabled for IP: %s" %
-                   public_ip.ipaddress.ipaddress)
-
-    # create_firewall_rule - Creates the Ingress firewall rule on the given public ip
-    def create_firewall_rule(self, public_ip, rule=None):
+        self.debug("Disabling static NAT for public IP - %s" % public_ip.ipaddress.ipaddress)
+        StaticNATRule.disable(self.api_client,
+                              ipaddressid=public_ip.ipaddress.id,
+                              virtualmachineid=vm.id
+                              )
+        self.debug("Static NAT disabled for public IP - %s" % public_ip.ipaddress.ipaddress)
+
+    # create_FirewallRule - Creates Ingress firewall rule on the given public IP
+    def create_FirewallRule(self, public_ip, rule=None):
         if not rule:
             rule = self.test_data["ingress_rule"]
-        self.debug("Adding an Ingress Firewall rule to make Guest VMs accessible through Static NAT")
+        self.debug("Adding an Ingress Firewall rule to make Guest VMs accessible through Static NAT - %s" % rule)
         return FireWallRule.create(self.api_client,
                                    ipaddressid=public_ip.ipaddress.id,
                                    protocol=rule["protocol"],
@@ -380,9 +343,9 @@ class nuageTestCase(cloudstackTestCase):
                                    endport=rule["endport"]
                                    )
 
-    # create_egress_firewall_rule - Creates the Egress firewall rule on the given public ip
-    def create_egress_firewall_rule(self, network, rule):
-        self.debug("Adding an Egress Firewall rule to allow/deny outgoing traffic from Guest VMs")
+    # create_EgressFirewallRule - Creates Egress firewall rule on the given public IP
+    def create_EgressFirewallRule(self, network, rule):
+        self.debug("Adding an Egress Firewall rule to allow/deny outgoing traffic from Guest VMs - %s" % rule)
         return EgressFireWallRule.create(self.api_client,
                                          networkid=network.id,
                                          protocol=rule["protocol"],
@@ -391,9 +354,9 @@ class nuageTestCase(cloudstackTestCase):
                                          endport=rule["endport"]
                                          )
 
-    # create_network_acl_list - Creates network ACL list in the given VPC
-    def create_network_acl_list(self, name, description, vpc):
-        self.debug("Adding NetworkACL list in VPC: %s" % vpc.id)
+    # create_NetworkAclList - Creates network ACL list in the given VPC
+    def create_NetworkAclList(self, name, description, vpc):
+        self.debug("Adding NetworkACL list in VPC with ID - %s" % vpc.id)
         return NetworkACLList.create(self.api_client,
                                      services={},
                                      name=name,
@@ -401,90 +364,52 @@ class nuageTestCase(cloudstackTestCase):
                                      vpcid=vpc.id
                                      )
 
-    # create_network_acl_rule - Creates network ACL rule Ingree/Egress in the given network
-    def create_network_acl_rule(self, rule, traffic_type="Ingress", network=None, acl_list=None):
-        self.debug("Adding NetworkACL rule: %s" % rule)
-        return NetworkACL.create(self.api_client,
-                                 networkid=network.id if network else None,
-                                 services=rule,
-                                 traffictype=traffic_type,
-                                 aclid=acl_list.id if acl_list else None
-                                 )
-
-    # migrate_vm - Migrates the VM to a different host if available
-    def migrate_vm(self, vm):
-        self.debug("Checking if a host is available for migration?")
-        hosts = Host.listForMigration(self.api_client)
-        self.assertEqual(isinstance(hosts, list), True,
-                         "List hosts should return a valid list"
-                         )
-        # Remove the host of current VM from the hosts list
-        hosts[:] = [host for host in hosts if host.id != vm.hostid]
-        if len(hosts) <= 0:
-            self.skipTest("No host available for migration. Test requires at-least 2 hosts")
-        host = hosts[0]
-        self.debug("Migrating VM-ID: %s to Host: %s" % (vm.id, host.id))
-        try:
-            vm.migrate(self.api_client, hostid=host.id)
-        except Exception as e:
-            self.fail("Failed to migrate instance, %s" % e)
-
-    # get_network_router - returns the router for the given network
-    def get_network_router(self, network):
-        self.debug("Finding the virtual router for network: %s" % network.name)
-        routers = Router.list(self.api_client,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(isinstance(routers, list), True,
-                         "List routers should return a valid virtual router for network"
-                         )
-        return routers[0]
+    # create_NetworkAclRule - Creates Ingress/Egress network ACL rule in the given network/acl list
+    def create_NetworkAclRule(self, rule, traffic_type="Ingress", network=None, acl_list=None):
+        self.debug("Adding NetworkACL rule - %s" % rule)
+        if acl_list:
+            return NetworkACL.create(self.api_client,
+                                     networkid=network.id if network else None,
+                                     services=rule,
+                                     traffictype=traffic_type,
+                                     aclid=acl_list.id
+                                     )
+        else:
+            return NetworkACL.create(self.api_client,
+                                     networkid=network.id if network else None,
+                                     services=rule,
+                                     traffictype=traffic_type
+                                     )
 
-    # stop_network_router - Stops the given network router
-    def stop_network_router(self, router):
-        self.debug("Stopping Router with ID: %s" % router.id)
-        cmd = stopRouter.stopRouterCmd()
-        cmd.id = router.id
-        self.api_client.stopRouter(cmd)
-
-    # start_network_router - Starts the given network router
-    def start_network_router(self, router):
-        self.debug("Starting Router with ID: %s" % router.id)
-        cmd = startRouter.startRouterCmd()
-        cmd.id = router.id
-        self.api_client.startRouter(cmd)
-
-    # ssh_into_vm - Gets into the shell of the given VM
-    def ssh_into_vm(self, vm, public_ip):
-        self.debug("SSH into VM=%s on public_ip=%s" % (vm.name, public_ip.ipaddress.ipaddress))
+    # ssh_into_VM - Gets into the shell of the given VM
+    def ssh_into_VM(self, vm, public_ip):
+        self.debug("SSH into VM with ID - %s on public IP address - %s" % (vm.id, public_ip.ipaddress.ipaddress))
         ssh_client = vm.get_ssh_client(ipaddress=public_ip.ipaddress.ipaddress)
         return ssh_client
 
     # execute_cmd - Executes the given command on the given ssh client
     def execute_cmd(self, ssh_client, cmd):
-        self.debug("EXECUTE SSH COMMAND: " + cmd)
+        self.debug("SSH client executing command - %s" % cmd)
         ret_data = ""
         out_list = ssh_client.execute(cmd)
         if out_list is not None:
             ret_data = ' '.join(map(str, out_list)).strip()
-            self.debug("ssh execute cmd result=" + ret_data)
+            self.debug("SSH client executed command result - %s" % ret_data)
         else:
-            self.debug("ssh execute cmd result is None")
+            self.debug("SSH client executed command result is None")
         return ret_data
 
-    # wget_from_server - fetches the index.html file from the given public Ip
+    # wget_from_server - Fetches index.html file of web server running with the given public IP
     def wget_from_server(self, public_ip):
         import urllib
-        self.debug("wget from a http server on public_ip=%s" % public_ip.ipaddress.ipaddress)
-        wget_file = urllib.urlretrieve("http://%s/index.html" % public_ip.ipaddress.ipaddress,
-                                       filename="index.html"
-                                       )
-        return wget_file
-
-    # validate_NetworkServiceProvider - Validates the Network Service Provider
-    # in the Nuage VSP Physical Network - matches the given provider name
-    # against the list of providers fetched
+        self.debug("wget from a http server on public IP address - %s" % public_ip.ipaddress.ipaddress)
+        filename, headers = urllib.urlretrieve("http://%s/index.html" % public_ip.ipaddress.ipaddress,
+                                               filename="index.html"
+                                               )
+        return filename, headers
+
+    # validate_NetworkServiceProvider - Validates the given Network Service Provider in the Nuage VSP Physical Network,
+    # matches the given provider name and state against the list of providers fetched
     def validate_NetworkServiceProvider(self, provider_name, state=None):
         """Validates the Network Service Provider in the Nuage VSP Physical Network"""
         self.debug("Check if the Network Service Provider is created successfully ?")
@@ -499,12 +424,13 @@ class nuageTestCase(cloudstackTestCase):
                          )
         if state:
             self.assertEqual(providers[0].state, state,
-                             "Network Service Provider state should be '%s'" % state
+                             "Network Service Provider state should be in state - %s" % state
                              )
-        self.debug("Network Service Provider creation successfully validated - %s" % provider_name)
+        self.debug("Network Service Provider creation successfully validated for %s" % provider_name)
 
-    # validate_vpc_offering - Validates the VPC offering, matches the given VPC off name against the list of VPC offerings fetched
-    def validate_vpc_offering(self, vpc_offering, state=None):
+    # validate_VpcOffering - Validates the given VPC offering,
+    # matches the given VPC offering name and state against the list of VPC offerings fetched
+    def validate_VpcOffering(self, vpc_offering, state=None):
         """Validates the VPC offering"""
         self.debug("Check if the VPC offering is created successfully ?")
         vpc_offs = VpcOffering.list(self.api_client,
@@ -518,12 +444,13 @@ class nuageTestCase(cloudstackTestCase):
                          )
         if state:
             self.assertEqual(vpc_offs[0].state, state,
-                             "VPC offering state should be '%s'" % state
+                             "VPC offering state should be in state - %s" % state
                              )
-        self.debug("VPC offering creation successfully validated - %s" % vpc_offering.name)
+        self.debug("VPC offering creation successfully validated for %s" % vpc_offering.name)
 
-    # validate_vpc - Validates the given VPC matches, the given VPC name against the list of VPCs fetched
-    def validate_vpc(self, vpc, state=None):
+    # validate_Vpc - Validates the given VPC,
+    # matches the given VPC name and state against the list of VPCs fetched
+    def validate_Vpc(self, vpc, state=None):
         """Validates the VPC"""
         self.debug("Check if the VPC is created successfully ?")
         vpcs = VPC.list(self.api_client,
@@ -537,14 +464,13 @@ class nuageTestCase(cloudstackTestCase):
                          )
         if state:
             self.assertEqual(vpcs[0].state, state,
-                             "VPC state should be '%s'" % state
+                             "VPC state should be in state - %s" % state
                              )
-        self.debug("VPC creation successfully validated - %s" % vpc.name)
+        self.debug("VPC creation successfully validated for %s" % vpc.name)
 
-    # validate_network_offering - Validates the given  Network offering
-    # matches the given network offering name against the list of network
-    # offerings fetched
-    def validate_network_offering(self, net_offering, state=None):
+    # validate_NetworkOffering - Validates the given Network offering,
+    # matches the given network offering name and state against the list of network offerings fetched
+    def validate_NetworkOffering(self, net_offering, state=None):
         """Validates the Network offering"""
         self.debug("Check if the Network offering is created successfully ?")
         net_offs = NetworkOffering.list(self.api_client,
@@ -558,13 +484,14 @@ class nuageTestCase(cloudstackTestCase):
                          )
         if state:
             self.assertEqual(net_offs[0].state, state,
-                             "Network offering state should be '%s'" % state
+                             "Network offering state should be in state - %s" % state
                              )
-        self.debug("Network offering creation successfully validated - %s" % net_offering.name)
+        self.debug("Network offering creation successfully validated for %s" % net_offering.name)
 
-    # validate_network - Validates the network - matches the given network name against the list of networks fetched
-    def validate_network(self, network, state=None):
-        """Validates the network"""
+    # validate_Network - Validates the given network,
+    # matches the given network name and state against the list of networks fetched
+    def validate_Network(self, network, state=None):
+        """Validates the Network"""
         self.debug("Check if the network is created successfully ?")
         networks = Network.list(self.api_client,
                                 id=network.id
@@ -577,28 +504,13 @@ class nuageTestCase(cloudstackTestCase):
                          )
         if state:
             self.assertEqual(networks[0].state, state,
-                             "Network state should be '%s'" % state
-                             )
-        self.debug("Network creation successfully validated - %s" % network.name)
-
-    # check_router_state - Fetches the list of routers and their states and matches the given router's state
-    def check_router_state(self, router, state=None):
-        self.debug("Check if the virtual router is in state - %s" % state)
-        routers = Router.list(self.api_client,
-                              id=router.id,
-                              listall=True
-                              )
-        self.assertEqual(isinstance(routers, list), True,
-                         "List router should return a valid list"
-                         )
-        if state:
-            self.assertEqual(routers[0].state, state,
-                             "Virtual router is not in the expected state"
+                             "Network state should be in state - %s" % state
                              )
-        self.debug("Virtual router is in the expected state - %s" % state)
+        self.debug("Network creation successfully validated for %s" % network.name)
 
-    #   check_vm_state - Fetches the list of VMs and their states and matches the given VM's state
-    def check_vm_state(self, vm, state=None):
+    # check_VM_state - Checks if the given VM is in the expected state form the list of fetched VMs
+    def check_VM_state(self, vm, state=None):
+        """Validates the VM state"""
         self.debug("Check if the VM instance is in state - %s" % state)
         vms = VirtualMachine.list(self.api_client,
                                   id=vm.id,
@@ -611,12 +523,30 @@ class nuageTestCase(cloudstackTestCase):
             self.assertEqual(vms[0].state, state,
                              "Virtual machine is not in the expected state"
                              )
-        self.debug("Virtual machine is in the expected state - %s" % state)
+        self.debug("Virtual machine instance - %s is in the expected state - %s" % (vm.name, state))
+
+    # check_Router_state - Checks if the given router is in the expected state form the list of fetched routers
+    def check_Router_state(self, router, state=None):
+        """Validates the Router state"""
+        self.debug("Check if the virtual router instance is in state - %s" % state)
+        routers = Router.list(self.api_client,
+                              id=router.id,
+                              listall=True
+                              )
+        self.assertEqual(isinstance(routers, list), True,
+                         "List router should return a valid list"
+                         )
+        if state:
+            self.assertEqual(routers[0].state, state,
+                             "Virtual router is not in the expected state"
+                             )
+        self.debug("Virtual router instance - %s is in the expected state - %s" % (router.name, state))
 
-    # validate_Public_IP - Looks if the given public ip is in the allocated state form the list of fetched public IPs
-    def validate_Public_IP(self, public_ip, network, static_nat=False, vm=None):
-        """Validates the Public IP"""
-        self.debug("Check if the Public IP is successfully assigned to the network ?")
+    # validate_PublicIPAddress - Validates if the given public IP address is in the expected state form the list of
+    # fetched public IP addresses
+    def validate_PublicIPAddress(self, public_ip, network, static_nat=False, vm=None):
+        """Validates the Public IP Address"""
+        self.debug("Check if the public IP is successfully assigned to the network ?")
         public_ips = PublicIPAddress.list(self.api_client,
                                           id=public_ip.ipaddress.id,
                                           networkid=network.id,
@@ -624,24 +554,30 @@ class nuageTestCase(cloudstackTestCase):
                                           listall=True
                                           )
         self.assertEqual(isinstance(public_ips, list), True,
-                         "List public Ip for network should return a valid list"
+                         "List public IP for network should return a valid list"
                          )
         self.assertEqual(public_ips[0].ipaddress, public_ip.ipaddress.ipaddress,
-                         "List public Ip for network should list the assigned public Ip address"
+                         "List public IP for network should list the assigned public IP address"
                          )
         self.assertEqual(public_ips[0].state, "Allocated",
-                         "Assigned public Ip is not in the allocated state"
+                         "Assigned public IP is not in the allocated state"
                          )
         if static_nat and vm:
             self.assertEqual(public_ips[0].virtualmachineid, vm.id,
-                             "Static NAT Rule not enabled for the VM using the assigned public Ip"
+                             "Static NAT Rule not enabled for the VM using the assigned public IP"
                              )
-        self.debug("Assigned Public IP is successfully validated - %s" % public_ip.ipaddress.ipaddress)
+        self.debug("Assigned Public IP address - %s is successfully validated" % public_ip.ipaddress.ipaddress)
 
     # VSD verifications
+    # VSD is a programmable policy and analytics engine of Nuage VSP SDN platform
+
+    # get_externalID - Returns corresponding external ID of the given object in VSD
+    def get_externalID(self, object_id):
+        return object_id + "@" + self.cms_id
 
-    def fetch_by_external_id(self, fetcher, *cs_objects):
-        """ Fetches a child object by external id using the given fetcher, and uuids of the given cloudstack objects.
+    # fetch_by_externalID - Returns VSD object with the given external ID
+    def fetch_by_externalID(self, fetcher, *cs_objects):
+        """ Fetches a child object by external ID using the given fetcher, and uuids of the given cloudstack objects.
         E.G.
           - fetch_by_external_id(vsdk.NUSubnet(id="954de425-b860-410b-be09-c560e7dbb474").vms, cs_vm)
           - fetch_by_external_id(session.user.floating_ips, cs_network, cs_public_ip)
@@ -651,12 +587,8 @@ class nuageTestCase(cloudstackTestCase):
         """
         return fetcher.get_first(filter="externalID BEGINSWITH '%s'" % ":".join([o.id for o in cs_objects]))
 
-    # VSD verifications using cms_vspk_wrapper
-
-    def get_externalID(self, object_id):
-        return object_id + "@" + self.cms_id
-
-    # verify_vsp_network - Fetches the vsd domain, vsd zone and vsd subnet and Verifies the given network/VPC values match the fetched values
+    # verify_vsp_network - Verifies the given domain and network/VPC
+    # against the corresponding installed enterprise, domain, zone, and subnet in VSD
     def verify_vsp_network(self, domain_id, network, vpc=None):
         vsd_enterprise = self.vsd.get_enterprise(name=domain_id)
         if vpc:
@@ -677,24 +609,24 @@ class nuageTestCase(cloudstackTestCase):
         self.debug(vsd_zone)
         self.debug(vsd_subnet)
         if vpc:
-            self.assertEqual(vsd_domain['description'], "VPC_" + vpc.name,
+            self.assertEqual(vsd_domain["description"], "VPC_" + vpc.name,
                              "VSD domain description should match VPC name in CloudStack"
                              )
-            self.assertEqual(vsd_zone['description'], "VPC_" + vpc.name,
+            self.assertEqual(vsd_zone["description"], "VPC_" + vpc.name,
                              "VSD zone description should match VPC name in CloudStack"
                              )
         else:
-            self.assertEqual(vsd_domain['description'], network.name,
-                             "VSD domain description should match Isolated Network name in CloudStack"
+            self.assertEqual(vsd_domain["description"], network.name,
+                             "VSD domain description should match network name in CloudStack"
                              )
-            self.assertEqual(vsd_zone['description'], network.name,
-                             "VSD zone description should match Isolated Network name in CloudStack"
+            self.assertEqual(vsd_zone["description"], network.name,
+                             "VSD zone description should match network name in CloudStack"
                              )
-        self.assertEqual(vsd_subnet['description'], network.name,
-                         "VSD subnet description should match Isolated Network name in CloudStack"
+        self.assertEqual(vsd_subnet["description"], network.name,
+                         "VSD subnet description should match network name in CloudStack"
                          )
 
-    # verify_vsp_vm - Fetches the vsd vport, vsd vm and interface and Verifies the given VM values match the fetched values
+    # verify_vsp_vm - Verifies the given VM deployment and state in VSD
     def verify_vsp_vm(self, vm, stopped=None):
         ext_vm_id = self.get_externalID(vm.id)
         for nic in vm.nic:
@@ -705,10 +637,10 @@ class nuageTestCase(cloudstackTestCase):
             self.debug("SHOW VPORT and VM INTERFACE DATA FORMAT IN VSD")
             self.debug(vsd_vport)
             self.debug(vsd_vm_interface)
-            self.assertEqual(vsd_vport['active'], True,
+            self.assertEqual(vsd_vport["active"], True,
                              "VSD VM vport should be active"
                              )
-            self.assertEqual(vsd_vm_interface['IPAddress'], nic.ipaddress,
+            self.assertEqual(vsd_vm_interface["IPAddress"], nic.ipaddress,
                              "VSD VM interface IP address should match VM's NIC IP address in CloudStack"
                              )
         vsd_vm = self.vsd.get_vm(externalID=ext_vm_id)
@@ -716,15 +648,15 @@ class nuageTestCase(cloudstackTestCase):
         self.debug(vsd_vm)
         if not self.isSimulator:
             if stopped:
-                self.assertEqual(vsd_vm['status'], "DELETE_PENDING",
+                self.assertEqual(vsd_vm["status"], "DELETE_PENDING",
                                  "VM state in VSD should be DELETE_PENDING"
                                  )
             else:
-                self.assertEqual(vsd_vm['status'], vm.state.upper(),
+                self.assertEqual(vsd_vm["status"], vm.state.upper(),
                                  "VM state in VSD should match its state in CloudStack"
                                  )
-    # verify_vsp_router - Fetches the vsd router and Verifies the given router status match the fetched status
 
+    # verify_vsp_router - Verifies the given network router deployment and state in VSD
     def verify_vsp_router(self, router, stopped=None):
         ext_router_id = self.get_externalID(router.id)
         vsd_router = self.vsd.get_vm(externalID=ext_router_id)
@@ -732,22 +664,42 @@ class nuageTestCase(cloudstackTestCase):
         self.debug(vsd_router)
         if not self.isSimulator:
             if stopped:
-                self.assertEqual(vsd_router['status'], "DELETE_PENDING",
+                self.assertEqual(vsd_router["status"], "DELETE_PENDING",
                                  "Router state in VSD should be DELETE_PENDING"
                                  )
             else:
-                self.assertEqual(vsd_router['status'], router.state.upper(),
+                self.assertEqual(vsd_router["status"], router.state.upper(),
                                  "Router state in VSD should match its state in CloudStack"
                                  )
 
-    # verify_vsp_floating_ip -  Verifies the floating IPs on the given public IP against the VSD FIP
+    # verify_vsp_LB_device - Verifies the given LB device deployment and state in VSD
+    def verify_vsp_LB_device(self, lb_device, stopped=None):
+        ext_lb_device_id = self.get_externalID(lb_device.id)
+        vsd_lb_device = self.vsd.get_vm(externalID=ext_lb_device_id)
+        self.debug("SHOW LB Device DATA FORMAT IN VSD")
+        self.debug(vsd_lb_device)
+        if not self.isSimulator:
+            if stopped:
+                self.assertEqual(vsd_lb_device['status'], "DELETE_PENDING",
+                                 "LB device state in VSD should be DELETE_PENDING"
+                                 )
+            else:
+                self.assertEqual(vsd_lb_device['status'], lb_device.state.upper(),
+                                 "LB device state in VSD should match its state in CloudStack"
+                                 )
+
+    # verify_vsp_floating_ip -  Verifies the static nat rule on the given public IP of the given network and VM
+    # against the corresponding installed FIP in VSD
     def verify_vsp_floating_ip(self, network, vm, public_ipaddress, vpc=None):
-        ext_fip_id = self.get_externalID(network.id + ":" + public_ipaddress.id)
+        if vpc:
+            ext_fip_id = self.get_externalID(vpc.id + ":" + public_ipaddress.id)
+        else:
+            ext_fip_id = self.get_externalID(network.id + ":" + public_ipaddress.id)
         vsd_fip = self.vsd.get_floating_ip(externalID=ext_fip_id)
         self.debug("SHOW FLOATING IP DATA FORMAT IN VSD")
         self.debug(vsd_fip)
-        self.assertEqual(vsd_fip['address'], public_ipaddress.ipaddress,
-                         "Floating IP address in VSD should match acquired Public IP address in CloudStack"
+        self.assertEqual(vsd_fip["address"], public_ipaddress.ipaddress,
+                         "Floating IP address in VSD should match acquired public IP address in CloudStack"
                          )
         if vpc:
             ext_network_id = self.get_externalID(vpc.id)
@@ -756,28 +708,27 @@ class nuageTestCase(cloudstackTestCase):
         vsd_domain = self.vsd.get_domain(externalID=ext_network_id)
         self.debug("SHOW NETWORK DATA FORMAT IN VSD")
         self.debug(vsd_domain)
-        self.assertEqual(vsd_domain['ID'], vsd_fip['parentID'],
+        self.assertEqual(vsd_domain["ID"], vsd_fip["parentID"],
                          "Floating IP in VSD should be associated with the correct VSD domain, "
-                         "which in turn should correspond to the correct VPC (or) Isolated network in CloudStack"
+                         "which in turn should correspond to the correct VPC (or) network in CloudStack"
                          )
         ext_subnet_id = self.get_externalID(network.id)
         vsd_subnet = self.vsd.get_subnet(externalID=ext_subnet_id)
         for nic in vm.nic:
-            if nic.networkname == vsd_subnet['description']:
+            if nic.networkname == vsd_subnet["description"]:
                 ext_network_id = self.get_externalID(nic.networkid)
                 ext_nic_id = self.get_externalID(nic.id)
                 vsd_vport = self.vsd.get_vport(subnet_externalID=ext_network_id, vport_externalID=ext_nic_id)
                 self.debug("SHOW VM VPORT DATA FORMAT IN VSD")
                 self.debug(vsd_vport)
-        self.assertEqual(vsd_vport['associatedFloatingIPID'], vsd_fip['ID'],
+        self.assertEqual(vsd_vport["associatedFloatingIPID"], vsd_fip["ID"],
                          "Floating IP in VSD should be associated to the correct VSD vport, "
                          "which in turn should correspond to the correct Static NAT enabled VM "
-                         "and Isolated Network in CloudStack"
+                         "and network in CloudStack"
                          )
 
-    # verify_vsp_firewall_rule - Verifies the start port, destination port,
-    # protocol of the given firewall rule Ingress/Egress against the VSD
-    # firewall rule
+    # verify_vsp_firewall_rule - Verifies the given Ingress/Egress firewall rule
+    # against the corresponding installed firewall rule in VSD
     def verify_vsp_firewall_rule(self, firewall_rule, traffic_type="Ingress"):
         ext_fw_id = self.get_externalID(firewall_rule.id)
         if traffic_type is "Ingress":
@@ -787,11 +738,11 @@ class nuageTestCase(cloudstackTestCase):
         self.debug("SHOW ACL ENTRY IN VSD")
         self.debug(vsd_fw_rule)
         dest_port = str(firewall_rule.startport) + "-" + str(firewall_rule.endport)
-        self.assertEqual(vsd_fw_rule['destinationPort'], dest_port,
-                         "Destination Port in VSD should match Destination Port in CloudStack"
+        self.assertEqual(vsd_fw_rule["destinationPort"], dest_port,
+                         "Destination port in VSD should match destination port in CloudStack"
                          )
-        vsd_protocol = str(vsd_fw_rule['protocol'])
-        self.debug("vsd protocol " + vsd_protocol)
+        vsd_protocol = str(vsd_fw_rule["protocol"])
+        self.debug("vsd protocol - %s" % vsd_protocol)
         protocol = "tcp"
         if vsd_protocol == 6:
             protocol = "tcp"
@@ -800,5 +751,5 @@ class nuageTestCase(cloudstackTestCase):
         elif vsd_protocol == 17:
             protocol = "udp"
         self.assertEqual(protocol, firewall_rule.protocol.lower(),
-                         "Protocol in VSD should match Protocol in CloudStack"
+                         "Protocol in VSD should match protocol in CloudStack"
                          )

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de86c0cb/test/integration/plugins/nuagevsp/test_nuage_password_reset.py
----------------------------------------------------------------------
diff --git a/test/integration/plugins/nuagevsp/test_nuage_password_reset.py b/test/integration/plugins/nuagevsp/test_nuage_password_reset.py
index 5582819..ee028c2 100644
--- a/test/integration/plugins/nuagevsp/test_nuage_password_reset.py
+++ b/test/integration/plugins/nuagevsp/test_nuage_password_reset.py
@@ -15,26 +15,29 @@
 # specific language governing permissions and limitations
 # under the License.
 
-""" Component tests for - userdata
+""" Component tests for user data and password reset functionality with Nuage VSP SDN plugin
 """
 # Import Local Modules
+from nuageTestCase import nuageTestCase
 from marvin.lib.base import (Account,
+                             Template,
                              VirtualMachine,
-                             Volume,
-                             Template)
-from nose.plugins.attrib import attr
-from nuageTestCase import nuageTestCase
+                             Volume)
+from marvin.lib.common import list_templates
 from marvin.lib.utils import cleanup_resources
-from marvin.cloudstackAPI import startVirtualMachine
+from marvin.cloudstackAPI import updateTemplate
+# Import System Modules
+from nose.plugins.attrib import attr
 import base64
 
 
 class TestNuagePasswordReset(nuageTestCase):
+    """Test user data and password reset functionality with Nuage VSP SDN plugin
+    """
 
     @classmethod
     def setUpClass(cls):
         super(TestNuagePasswordReset, cls).setUpClass()
-
         return
 
     def setUp(self):
@@ -60,16 +63,15 @@ class TestNuagePasswordReset(nuageTestCase):
         self.vm_1.delete(self.apiclient, expunge=True)
         if self.remove_vm2:
             self.vm_2.delete(self.apiclient, expunge=True)
-
         try:
             cleanup_resources(self.apiclient, self.cleanup)
         except Exception as e:
-            self.debug("Warning: Exception during cleanup : %s" % e)
+            self.debug("Warning: Exception during cleanup: %s" % e)
         return
 
-    # create_template - Takes the VM object as the argument to create the template
+    # create_template - Creates template with the given VM object
     def create_template(self, vm):
-        self.debug("CREATE TEMPLATE")
+        self.debug("Creating template")
         list_volume = Volume.list(self.apiclient,
                                   virtualmachineid=vm.id,
                                   type='ROOT',
@@ -77,18 +79,31 @@ class TestNuagePasswordReset(nuageTestCase):
         if isinstance(list_volume, list):
             self.volume = list_volume[0]
         else:
-            raise Exception("Exception: Unable to find root volume for VM: %s" % vm.id)
-
-        self.test_data["template_pr"]["ostype"] = self.test_data["ostype_pr"]
+            raise Exception("Exception: Unable to find root volume for VM with ID - %s" % vm.id)
         self.pw_enabled_template = Template.create(
             self.apiclient,
-            self.test_data["template_pr"],
+            self.test_data["template"],
             self.volume.id,
             account=self.account.name,
             domainid=self.account.domainid
         )
         self.assertEqual(self.pw_enabled_template.passwordenabled, True, "template is not passwordenabled")
         self.cleanup.append(self.pw_enabled_template)
+        self.debug("Created template")
+
+    # updateTemplate - Updates value of template's password enabled setting
+    def updateTemplate(self, value):
+        self.debug("Updating value of template's password enabled setting")
+        cmd = updateTemplate.updateTemplateCmd()
+        cmd.id = self.template.id
+        cmd.passwordenabled = value
+        self.apiclient.updateTemplate(cmd)
+        list_template_response = list_templates(self.apiclient,
+                                                templatefilter="all",
+                                                id=self.template.id
+                                                )
+        self.template = list_template_response[0]
+        self.debug("Updated template")
 
     # VM object is passed as an argument and its interface id is returned
     def get_vm_interface_id(self, vm):
@@ -109,13 +124,13 @@ class TestNuagePasswordReset(nuageTestCase):
 
     # Creates and verifies the firewall rule
     def create_and_verify_fw(self, vm, public_ip, network):
-        self.debug("CREATE AND VERIFY FIREWALL RULE")
+        self.debug("Create and verify firewall rule")
         self.create_StaticNatRule_For_VM(vm, public_ip, network)
 
         # VSD verification
         self.verify_vsp_floating_ip(network, vm, public_ip.ipaddress)
 
-        fw_rule = self.create_firewall_rule(public_ip, self.test_data["ingress_rule"])
+        fw_rule = self.create_FirewallRule(public_ip, self.test_data["ingress_rule"])
         self.verify_vsp_firewall_rule(fw_rule)
         vm_interface_id = self.get_vm_interface_id(vm)
         pd = self.vsd.get_vm_interface_policydecisions(id=vm_interface_id)
@@ -130,7 +145,7 @@ class TestNuagePasswordReset(nuageTestCase):
             raise ValueError('No firewall policy decision in vm interface')
 
     def stop_vm(self, vm):
-        self.debug("STOP VM")
+        self.debug("Stoping VM")
         vm.stop(self.apiclient)
         list_vm_response = VirtualMachine.list(self.apiclient,
                                                id=vm.id)
@@ -159,8 +174,10 @@ class TestNuagePasswordReset(nuageTestCase):
             self.debug("get_set_password_file result " + result)
 
     @attr(tags=["advanced", "nuagevsp"], required_hardware="true")
-    def test_01_UserDataPasswordReset(self):
-        self.debug("START USER DATA PASSWORD RESET ON VM")
+    def test_nuage_UserDataPasswordReset(self):
+        """Test user data and password reset functionality with Nuage VSP SDN plugin
+        """
+
         """
          Validate the following:
          1) user data
@@ -171,12 +188,12 @@ class TestNuagePasswordReset(nuageTestCase):
          2.  Create an Isolated network - Test Network (10.1.1.1/24).
          3.  Deploy VM1 in Test Network
          4.  Verify domain,zone subnet, vm.
-         5.  create public ip , Create Static Nat rule firewall rule and verify
+         5.  create public IP, Create Static Nat rule firewall rule and verify
          6.  SSH to VM should be successful
          7.  verify userdata
          8.  check cloud-set-guest-password exist.
          9.  if cloud-set-guest-password exist.
-          9.1    change template password enabled to true
+          9.1   change template password enabled to true
           9.2   verify that template is password enbalded
           9.3   SSH with new password should be successful
          10. else cloud-set-guest-password does not exist.
@@ -185,27 +202,30 @@ class TestNuagePasswordReset(nuageTestCase):
           10.3  create a new template with password enabled. Verify that template is password enabled.
           10.4  create vm 2 with new template in Test Network
           10.5  Verify vm.
-          10.6  create public ip , Create Static Nat rule firewall rule and verify
+          10.6  create public IP, Create Static Nat rule firewall rule and verify
           10.7  SSH to VM 2 should be successful
          11. Reset VM password (VM_1 if guest password file exist.  else it is VM2)
          12  Starting VM and SSH to VM to verify new password
         """
 
+        self.debug("TEST USER DATA & PASSWORD RESET ON VM")
+
         self.defaultTemplateVal = self.template.passwordenabled
         if self.template.passwordenabled:
             self.updateTemplate(False)
 
         self.debug("CREATE AN ISOLATED NETWORK")
-        self.network_1 = self.create_Network(self.test_data["network_offering_pr"])
+        net_off = self.create_NetworkOffering(self.test_data["nuagevsp"]["isolated_network_offering"])
+        self.network_1 = self.create_Network(net_off)
         self.cleanup.append(self.network_1)
         expUserData = "hello world vm1"
         userdata = base64.b64encode(expUserData)
-        self.test_data["virtual_machine_pr"]["userdata"] = userdata
+        self.test_data["virtual_machine_userdata"]["userdata"] = userdata
         self.debug("DEPLOY VM 1 IN TEST NETWORK")
         # Pass the network and name of the vm type from the testdata with the configuration for the vm
-        self.vm_1 = self.create_VM_in_Network(self.network_1, "virtual_machine_pr")
+        self.vm_1 = self.create_VM(self.network_1, vm_key="virtual_machine_userdata")
 
-        self.vm_1.password = self.test_data["virtual_machine_pr"]["password"]
+        self.vm_1.password = self.test_data["virtual_machine_userdata"]["password"]
         user_data_cmd = self.get_userdata_url(self.vm_1)
 
         # VSD verification
@@ -214,11 +234,11 @@ class TestNuagePasswordReset(nuageTestCase):
         self.verify_vsp_vm(self.vm_1)
 
         self.debug("CREATE PUBLIC IP, STATIC NAT RULE, FLOATING IP, FIREWALL AND VERIFY")
-        public_ip_1 = self.acquire_Public_IP(self.network_1)
+        public_ip_1 = self.acquire_PublicIPAddress(self.network_1)
         self.create_and_verify_fw(self.vm_1, public_ip_1, self.network_1)
 
         self.debug("SSH TO VM")
-        ssh = self.ssh_into_vm(self.vm_1, public_ip_1)
+        ssh = self.ssh_into_VM(self.vm_1, public_ip_1)
 
         self.debug("VERIFY USER DATA")
         self.debug("Get User Data with command: " + user_data_cmd)
@@ -238,25 +258,23 @@ class TestNuagePasswordReset(nuageTestCase):
             self.stop_vm(self.vm_1)
             self.create_template(self.vm_1)
             self.debug("DEPLOY VM 2 IN TEST NETWORK WITH NEW TEMPLATE")
-            self.vm_2 = self.create_VM_in_Network(self.network_1, "virtual_machine_pr")
+            self.vm_2 = self.create_VM(self.network_1, vm_key="virtual_machine_userdata")
             self.remove_vm2 = True
             self.debug("STARTING VM_2 ")
-            startCmd = startVirtualMachine.startVirtualMachineCmd()
-            startCmd.id = self.vm_2.id
-            vm_2a = self.apiclient.startVirtualMachine(startCmd)
+            vm_2a = self.vm_2.start(self.apiclient)
             self.vm_2.password = vm_2a.password.strip()
             self.vm_2.nic = vm_2a.nic
-            self.debug("VM - %s password %s !" % (self.vm_2.name, self.vm_2.password))
+            self.debug("VM - %s password - %s !" % (self.vm_2.name, self.vm_2.password))
             self.assertNotEqual(self.vm_2.password,
-                                self.test_data["virtual_machine_pr"]["password"],
+                                self.test_data["virtual_machine_userdata"]["password"],
                                 "Password enabled not working. Password same as virtual_machine password "
                                 )
             self.verify_vsp_vm(vm_2a)
             self.debug("GET PUBLIC IP.  CREATE AND VERIFIED FIREWALL RULES")
-            public_ip_2 = self.acquire_Public_IP(self.network_1)
+            public_ip_2 = self.acquire_PublicIPAddress(self.network_1)
             self.create_and_verify_fw(self.vm_2, public_ip_2, self.network_1)
 
-            ssh = self.ssh_into_vm(self.vm_2, public_ip_2)
+            self.ssh_into_VM(self.vm_2, public_ip_2)
             vm_test = self.vm_2
             vm_test_public_ip = public_ip_2
 
@@ -267,10 +285,10 @@ class TestNuagePasswordReset(nuageTestCase):
             vm_test = self.vm_1
             vm_test_public_ip = public_ip_1
 
-        self.debug("RESETTING VM PASSWORD for VM: %s" % vm_test.name)
+        self.debug("RESETTING VM PASSWORD for VM - %s" % vm_test.name)
         vm_test.password = vm_test.resetPassword(self.apiclient)
-        self.debug("Password reset to: %s" % vm_test.password)
+        self.debug("Password reset to - %s" % vm_test.password)
         self.debug("STARTING VM AND SSH TO VM TO VERIFY NEW PASSWORD")
         vm_test.start(self.apiclient)
         self.debug("VM - %s started!" % vm_test.name)
-        self.ssh_into_vm(vm_test, vm_test_public_ip)
+        self.ssh_into_VM(vm_test, vm_test_public_ip)


[38/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1454 from shapeblue/host-maint

CLOUDSTACK-9323: Fix cancel host maintenance canFix cancel host maintenance so that if maintenance is cancelled the host come back to normal state gracefully.

Added marvin tests for host maintennace.

* pr/1454:
  CLOUDSTACK-9323: Fix Cancel maintenance so that if maintenance is cancelled the host come back to normal state gracefully. Added marvin tests for host maintennace.

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 12d8e53dd54d83242b3dabf2151249ab7963d5a8
Parents: a5ee443 182ab64
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 16:05:10 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 16:05:10 2016 -0400

----------------------------------------------------------------------
 .../com/cloud/resource/ResourceManagerImpl.java |  10 +-
 .../component/test_host_maintenance.py          | 292 +++++++++++++++++++
 tools/marvin/marvin/lib/utils.py                |  23 +-
 3 files changed, 320 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[13/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
CLOUDSTACK-8745 : verify usage after root disk migration

modified to use maintenance method is base.py and added some more checks

CLOUDSTACK-8745: Fail test if list response in empty


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 456abb0b94d854b932903d63724fec33ebf1a601
Parents: c48b6c3
Author: nitt10prashant <ni...@gmail.com>
Authored: Tue Aug 18 16:53:54 2015 +0530
Committer: nitt10prashant <ni...@gmail.com>
Committed: Thu Apr 21 11:00:13 2016 +0530

----------------------------------------------------------------------
 .../component/maint/test_ha_pool_maintenance.py | 236 +++++++++++++++++++
 1 file changed, 236 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/456abb0b/test/integration/component/maint/test_ha_pool_maintenance.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_ha_pool_maintenance.py b/test/integration/component/maint/test_ha_pool_maintenance.py
new file mode 100644
index 0000000..e737726
--- /dev/null
+++ b/test/integration/component/maint/test_ha_pool_maintenance.py
@@ -0,0 +1,236 @@
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (enableStorageMaintenance,
+                                  cancelStorageMaintenance
+                                  )
+from marvin.lib.utils import (cleanup_resources,
+                              validateList)
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             ServiceOffering,
+                             Cluster,
+                             StoragePool,
+                             Volume)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_hosts
+                               )
+from marvin.codes import PASS
+
+
+class testHaPoolMaintenance(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        try:
+            cls._cleanup = []
+            cls.testClient = super(
+                testHaPoolMaintenance,
+                cls).getClsTestClient()
+            cls.api_client = cls.testClient.getApiClient()
+            cls.services = cls.testClient.getParsedTestDataConfig()
+            # Get Domain, Zone, Template
+            cls.domain = get_domain(cls.api_client)
+            cls.zone = get_zone(
+                cls.api_client,
+                cls.testClient.getZoneForTests())
+            cls.template = get_template(
+                cls.api_client,
+                cls.zone.id,
+                cls.services["ostype"]
+            )
+            cls.hypervisor = cls.testClient.getHypervisorInfo()
+            cls.services['mode'] = cls.zone.networktype
+            cls.hypervisor = cls.testClient.getHypervisorInfo()
+            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+            cls.services["virtual_machine"]["template"] = cls.template.id
+            cls.clusterWithSufficientPool = None
+            cls.listResponse = None
+            clusters = Cluster.list(cls.api_client, zoneid=cls.zone.id)
+
+            if not validateList(clusters)[0]:
+
+                cls.debug(
+                    "check list cluster response for zone id %s" %
+                    cls.zone.id)
+                cls.listResponse = True
+                return
+
+            for cluster in clusters:
+                cls.pool = StoragePool.list(cls.api_client,
+                                            clusterid=cluster.id,
+                                            keyword="NetworkFilesystem"
+                                            )
+
+                if not validateList(cls.pool)[0]:
+
+                    cls.debug(
+                        "check list cluster response for zone id %s" %
+                        cls.zone.id)
+                    cls.listResponse = True
+                    return
+
+                if len(cls.pool) >= 2:
+                    cls.clusterWithSufficientPool = cluster
+                    break
+            if not cls.clusterWithSufficientPool:
+                return
+
+            cls.services["service_offerings"][
+                "tiny"]["offerha"] = "True"
+
+            cls.services_off = ServiceOffering.create(
+                cls.api_client,
+                cls.services["service_offerings"]["tiny"])
+            cls._cleanup.append(cls.services_off)
+
+        except Exception as e:
+            cls.tearDownClass()
+            raise Exception("Warning: Exception in setup : %s" % e)
+        return
+
+    def setUp(self):
+
+        self.apiClient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.cleanup = []
+        if self.listResponse:
+            self.fail(
+                "Check list response")
+        if not self.clusterWithSufficientPool:
+            self.skipTest(
+                "sufficient storage not available in any cluster for zone %s" %
+                self.zone.id)
+        self.account = Account.create(
+            self.api_client,
+            self.services["account"],
+            domainid=self.domain.id
+        )
+        self.cleanup.append(self.account)
+
+    def tearDown(self):
+        # Clean up, terminate the created resources
+        StoragePool.cancelMaintenance(self.api_client,
+                                      id=self.storageid[0][0])
+        cleanup_resources(self.apiClient, self.cleanup)
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            cleanup_resources(cls.api_client, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+        return
+
+    @attr(tags=["advanced", "cl", "advancedns", "sg",
+                "basic", "eip", "simulator", "multihost"])
+    def test_ha_with_storage_maintenance(self):
+        """put storage in maintenance mode and start ha vm and check usage"""
+        # Steps
+        # 1. Create a Compute service offering with the 'Offer HA' option
+        # selected.
+        # 2. Create a Guest VM with the compute service offering created above.
+        # 3. put PS into maintenance  mode
+        # 4. vm should go in stop state
+        # 5. start vm ,vm should come up on another storage
+        # 6. check usage events are getting generated for root disk
+
+        host = list_hosts(
+            self.api_client,
+            clusterid=self.clusterWithSufficientPool.id)
+        self.assertEqual(validateList(host)[0],
+                         PASS,
+                         "check list host response for cluster id %s"
+                         % self.clusterWithSufficientPool.id)
+
+        self.virtual_machine_with_ha = VirtualMachine.create(
+            self.api_client,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.services_off.id,
+            hostid=host[0].id
+        )
+
+        vms = VirtualMachine.list(
+            self.api_client,
+            id=self.virtual_machine_with_ha.id,
+            listall=True,
+        )
+
+        self.assertEqual(
+            validateList(vms)[0],
+            PASS,
+            "List VMs should return valid response for deployed VM"
+        )
+
+        vm = vms[0]
+
+        self.debug("Deployed VM on host: %s" % vm.hostid)
+
+        # Put storage in maintenance  mode
+
+        self.list_root_volume = Volume.list(self.api_client,
+                                            virtualmachineid=vm.id,
+                                            type='ROOT',
+                                            account=self.account.name,
+                                            domainid=self.account.domainid)
+
+        self.assertEqual(validateList(self.list_root_volume)[0],
+                         PASS,
+                         "check list voume_response for vm id %s" % vm.id)
+
+        self.pool_id = self.dbclient.execute(
+            "select pool_id from volumes where uuid = '%s';"
+            % self.list_root_volume[0].id)
+        self.storageid = self.dbclient.execute(
+            "select uuid from storage_pool where id = '%s';"
+            % self.pool_id[0][0])
+
+        StoragePool.enableMaintenance(self.api_client,
+                                      id=self.storageid[0][0])
+
+        self.virtual_machine_with_ha.start(self.api_client)
+        self.events = self.dbclient.execute(
+            "select type from usage_event where resource_name='%s';"
+            % self.list_root_volume[0].name
+        )
+        self.assertEqual(len(self.events),
+                         3,
+                         "check the usage event table for root disk %s"
+                         % self.list_root_volume[0].name
+                         )
+
+        self.assertEqual(str(self.events[0][0]),
+                         "VOLUME.CREATE",
+                         "check volume create events for volume %s"
+                         % self.list_root_volume[0].name)
+        self.assertEqual(str(self.events[1][0]),
+                         "VOLUME.DELETE",
+                         "check fvolume delete events for volume%s"
+                         % self.list_root_volume[0].name)
+        self.assertEqual(str(self.events[2][0]),
+                         "VOLUME.CREATE",
+                         "check volume create events for volume %s"
+                         % self.list_root_volume[0].name)


[25/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1498 from GabrielBrascher/lrg-cs-hackday-038

CLOUDSTACK-9352: Test fails in Widows as the file separator "/" is different from "\"**Problem:**
File separator in windows ("\") is different from the expected in the test ("/"); thus, the test *com.cloud.utils.SwiftUtilTest.testSplitSwiftPath()* will fail in Windows systems.

The problem is that the input of the test is "*container/object*" but the tested method uses the *File.separator* (that depends from the OS), in windows systems the tested method (*com.cloud.utils.SwiftUtil.splitSwiftPath(String)*) looks for a "\", as the string does not contain "\" it returns an empty string and consequently results in a test failure.

**Solution:**
Create a string `String input = "container" + File.separator + "object";`, with that the test will validate the tested method verifying if the method splits the string around matches of the given regular expression (in this case *File.separator*).

*JIRA link: https://issues.apache.org/jira/browse/CLOUDSTACK-9352*

* pr/1498:
  Test fails in Widows as the file separator "/" is different from "\"

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: a6bae2b9c200cff725fbdabddab6c69a94811561
Parents: 939e448 4be5c2e
Author: Will Stevens <wi...@gmail.com>
Authored: Mon Apr 25 15:58:17 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Mon Apr 25 15:58:17 2016 -0400

----------------------------------------------------------------------
 utils/src/test/java/com/cloud/utils/SwiftUtilTest.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[34/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1270 from anshul1886/CLOUDSTACK-9194

CLOUDSTACK-9194:  Making the console popup window resizable in IE to make sure the focus is not losthttps://issues.apache.org/jira/browse/CLOUDSTACK-9194

To test:

Open any VM console in IE, and try resizing the browser window of console
It should be resizable.

* pr/1270:
  CLOUDSTACK-9194:  Making the console popup window resizable in IE to make sure the focus is not lost.

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 1f53adbac67f87723eaa078ea182ee0ee89850ef
Parents: 91ce3b9 e985db9
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 16:00:46 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 16:00:47 2016 -0400

----------------------------------------------------------------------
 ui/scripts/ui/widgets/detailView.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------



[08/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de86c0cb/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py
----------------------------------------------------------------------
diff --git a/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py b/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py
new file mode 100644
index 0000000..5a0d759
--- /dev/null
+++ b/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py
@@ -0,0 +1,2076 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Component tests for VPC Internal Load Balancer functionality with Nuage VSP SDN plugin
+"""
+# Import Local Modules
+from nuageTestCase import nuageTestCase
+from marvin.lib.base import (Account,
+                             ApplicationLoadBalancer,
+                             Network,
+                             Router)
+from marvin.cloudstackAPI import (listInternalLoadBalancerVMs,
+                                  stopInternalLoadBalancerVM,
+                                  startInternalLoadBalancerVM)
+# Import System Modules
+from nose.plugins.attrib import attr
+import copy
+import time
+
+
+class TestNuageInternalLb(nuageTestCase):
+    """Test VPC Internal LB functionality with Nuage VSP SDN plugin
+    """
+
+    @classmethod
+    def setUpClass(cls):
+        super(TestNuageInternalLb, cls).setUpClass()
+        return
+
+    def setUp(self):
+        # Create an account
+        self.account = Account.create(self.api_client,
+                                      self.test_data["account"],
+                                      admin=True,
+                                      domainid=self.domain.id
+                                      )
+        self.cleanup = [self.account]
+        return
+
+    # create_Internal_LB_Rule - Creates Internal LB rule in the given VPC network
+    def create_Internal_LB_Rule(self, network, vm_array=None, services=None, source_ip=None):
+        self.debug("Creating Internal LB rule in VPC network with ID - %s" % network.id)
+        if not services:
+            services = self.test_data["internal_lbrule"]
+        int_lb_rule = ApplicationLoadBalancer.create(self.api_client,
+                                                     services=services,
+                                                     sourcenetworkid=network.id,
+                                                     networkid=network.id,
+                                                     sourceipaddress=source_ip
+                                                     )
+        self.debug("Created Internal LB rule")
+        # Assigning VMs to the created Internal Load Balancer rule
+        if vm_array:
+            self.debug("Assigning virtual machines - %s to the created Internal LB rule" % vm_array)
+            int_lb_rule.assign(self.api_client, vms=vm_array)
+            self.debug("Assigned VMs to the created Internal LB rule")
+        return int_lb_rule
+
+    # validate_Internal_LB_Rule - Validates the given Internal LB rule,
+    # matches the given Internal LB rule name and state against the list of Internal LB rules fetched
+    def validate_Internal_LB_Rule(self, int_lb_rule, state=None, vm_array=None):
+        """Validates the Internal LB Rule"""
+        self.debug("Check if the Internal LB Rule is created successfully ?")
+        int_lb_rules = ApplicationLoadBalancer.list(self.api_client,
+                                                    id=int_lb_rule.id
+                                                    )
+        self.assertEqual(isinstance(int_lb_rules, list), True,
+                         "List Internal LB Rule should return a valid list"
+                         )
+        self.assertEqual(int_lb_rule.name, int_lb_rules[0].name,
+                         "Name of the Internal LB Rule should match with the returned list data"
+                         )
+        if state:
+            self.assertEqual(int_lb_rules[0].loadbalancerrule[0].state, state,
+                             "Internal LB Rule state should be '%s'" % state
+                             )
+        if vm_array:
+            instance_ids = [instance.id for instance in int_lb_rules[0].loadbalancerinstance]
+            for vm in vm_array:
+                self.assertEqual(vm.id in instance_ids, True,
+                                 "Internal LB instance list should have the VM with ID - %s" % vm.id
+                                 )
+        self.debug("Internal LB Rule creation successfully validated for %s" % int_lb_rule.name)
+
+    # list_InternalLbVms - Lists deployed Internal LB VM instances
+    def list_InternalLbVms(self, network_id=None, source_ip=None):
+        listInternalLoadBalancerVMsCmd = listInternalLoadBalancerVMs.listInternalLoadBalancerVMsCmd()
+        listInternalLoadBalancerVMsCmd.account = self.account.name
+        listInternalLoadBalancerVMsCmd.domainid = self.account.domainid
+        if network_id:
+            listInternalLoadBalancerVMsCmd.networkid = network_id
+        internal_lb_vms = self.api_client.listInternalLoadBalancerVMs(listInternalLoadBalancerVMsCmd)
+        if source_ip:
+            return [internal_lb_vm for internal_lb_vm in internal_lb_vms
+                    if str(internal_lb_vm.guestipaddress) == source_ip]
+        else:
+            return internal_lb_vms
+
+    # get_InternalLbVm - Returns Internal LB VM instance for the given VPC network and source ip
+    def get_InternalLbVm(self, network, source_ip):
+        self.debug("Finding the InternalLbVm for network with ID - %s and source IP address - %s" %
+                   (network.id, source_ip))
+        internal_lb_vms = self.list_InternalLbVms(network.id, source_ip)
+        self.assertEqual(isinstance(internal_lb_vms, list), True,
+                         "List InternalLbVms should return a valid list"
+                         )
+        return internal_lb_vms[0]
+
+    # stop_InternalLbVm - Stops the given Internal LB VM instance
+    def stop_InternalLbVm(self, int_lb_vm, force=None):
+        self.debug("Stopping InternalLbVm with ID - %s" % int_lb_vm.id)
+        cmd = stopInternalLoadBalancerVM.stopInternalLoadBalancerVMCmd()
+        cmd.id = int_lb_vm.id
+        if force:
+            cmd.forced = force
+        self.api_client.stopInternalLoadBalancerVM(cmd)
+
+    # start_InternalLbVm - Starts the given Internal LB VM instance
+    def start_InternalLbVm(self, int_lb_vm):
+        self.debug("Starting InternalLbVm with ID - %s" % int_lb_vm.id)
+        cmd = startInternalLoadBalancerVM.startInternalLoadBalancerVMCmd()
+        cmd.id = int_lb_vm.id
+        self.api_client.startInternalLoadBalancerVM(cmd)
+
+    # check_InternalLbVm_state - Checks if the Internal LB VM instance of the given VPC network and source ip is in the
+    # expected state form the list of fetched Internal LB VM instances
+    def check_InternalLbVm_state(self, network, source_ip, state=None):
+        self.debug("Check if the InternalLbVm is in state - %s" % state)
+        internal_lb_vms = self.list_InternalLbVms(network.id, source_ip)
+        self.assertEqual(isinstance(internal_lb_vms, list), True,
+                         "List InternalLbVm should return a valid list"
+                         )
+        if state:
+            self.assertEqual(internal_lb_vms[0].state, state,
+                             "InternalLbVm is not in the expected state"
+                             )
+        self.debug("InternalLbVm instance - %s is in the expected state - %s" % (internal_lb_vms[0].name, state))
+
+    # wget_from_vm_cmd - From within the given VM (ssh client),
+    # fetches index.html file of web server running with the given public IP
+    def wget_from_vm_cmd(self, ssh_client, ip_address, port):
+        cmd = "wget --no-cache -t 1 http://" + ip_address + ":" + str(port) + "/"
+        response = self.execute_cmd(ssh_client, cmd)
+        if "200 OK" not in response:
+            self.fail("Failed to wget from a VM with http server IP address - %s" % ip_address)
+        # Reading the wget file
+        cmd = "cat index.html"
+        wget_file = self.execute_cmd(ssh_client, cmd)
+        # Removing the wget file
+        cmd = "rm -r index.html"
+        self.execute_cmd(ssh_client, cmd)
+        return wget_file
+
+    # verify_lb_wget_file - Verifies that the given wget file (index.html) belongs to the given Internal LB rule
+    # assigned VMs (vm array)
+    def verify_lb_wget_file(self, wget_file, vm_array):
+        wget_server_ip = None
+        for vm in vm_array:
+            for nic in vm.nic:
+                if str(nic.ipaddress) in str(wget_file):
+                    wget_server_ip = str(nic.ipaddress)
+        if wget_server_ip:
+            self.debug("Verified wget file from an Internal Load Balanced VM with http server IP address - %s"
+                       % wget_server_ip)
+        else:
+            self.fail("Did not wget file from the Internal Load Balanced VMs - %s" % vm_array)
+        return wget_server_ip
+
+    # validate_internallb_algorithm_traffic - Validates Internal LB algorithms by performing multiple wget traffic tests
+    # against the given Internal LB VM instance (source port)
+    def validate_internallb_algorithm_traffic(self, ssh_client, source_ip, port, vm_array, algorithm):
+        # Internal LB (wget) traffic tests
+        iterations = 2 * len(vm_array)
+        wget_files = []
+        for i in range(iterations):
+            wget_files.append(self.wget_from_vm_cmd(ssh_client, source_ip, port))
+        # Verifying Internal LB (wget) traffic tests
+        wget_servers_ip_list = []
+        for i in range(iterations):
+            wget_servers_ip_list.append(self.verify_lb_wget_file(wget_files[i], vm_array))
+        # Validating Internal LB algorithm
+        if algorithm == "roundrobin" or algorithm == "leastconn":
+            for i in range(iterations):
+                if wget_servers_ip_list.count(wget_servers_ip_list[i]) is not 2:
+                    self.fail("Round Robin Internal LB algorithm validation failed - %s" % wget_servers_ip_list)
+            self.debug("Successfully validated Round Robin/Least connections Internal LB algorithm - %s" %
+                       wget_servers_ip_list)
+        if algorithm == "source":
+            for i in range(iterations):
+                if wget_servers_ip_list.count(wget_servers_ip_list[i]) is not iterations:
+                    self.fail("Source Internal LB algorithm validation failed - %s" % wget_servers_ip_list)
+            self.debug("Successfully validated Source Internal LB algorithm - %s" % wget_servers_ip_list)
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="false")
+    def test_01_nuage_internallb_vpc_Offering(self):
+        """Test Nuage VSP VPC Offering with different combinations of LB service providers
+        """
+
+        # 1. Verify that the network service providers supported by Nuage VSP for VPC Internal LB functionality are all
+        #    successfully created and enabled.
+        # 2. Create Nuage VSP VPC offering with LB service provider as "InternalLbVm", check if it is successfully
+        #    created and enabled. Verify that the VPC creation succeeds with this VPC offering.
+        # 3. Create Nuage VSP VPC offering with LB service provider as "VpcVirtualRouter", check if it is successfully
+        #    created and enabled. Verify that the VPC creation fails with this VPC offering as Nuage VSP does not
+        #    support provider "VpcVirtualRouter" for service LB.
+        # 4. Create Nuage VSP VPC offering with LB service provider as "Netscaler", check if it is successfully
+        #    created and enabled. Verify that the VPC creation fails with this VPC offering as Nuage VSP does not
+        #    support provider "Netscaler" for service LB.
+        # 5. Delete the created VPC offerings (cleanup).
+
+        self.debug("Validating network service providers supported by Nuage VSP for VPC Internal LB functionality")
+        providers = ["NuageVsp", "VpcVirtualRouter", "InternalLbVm"]
+        for provider in providers:
+            self.validate_NetworkServiceProvider(provider, state="Enabled")
+
+        # Creating VPC offerings
+        self.debug("Creating Nuage VSP VPC offering with LB service provider as InternalLbVm...")
+        vpc_off_1 = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering_lb"])
+        self.validate_VpcOffering(vpc_off_1, state="Enabled")
+
+        self.debug("Creating Nuage VSP VPC offering with LB service provider as VpcVirtualRouter...")
+        vpc_offering_lb = copy.deepcopy(self.test_data["nuagevsp"]["vpc_offering_lb"])
+        vpc_offering_lb["serviceProviderList"]["Lb"] = "VpcVirtualRouter"
+        vpc_off_2 = self.create_VpcOffering(vpc_offering_lb)
+        self.validate_VpcOffering(vpc_off_2, state="Enabled")
+
+        self.debug("Creating Nuage VSP VPC offering with LB service provider as Netscaler...")
+        vpc_offering_lb["serviceProviderList"]["Lb"] = "Netscaler"
+        vpc_off_3 = self.create_VpcOffering(vpc_offering_lb)
+        self.validate_VpcOffering(vpc_off_3, state="Enabled")
+
+        self.debug("Creating Nuage VSP VPC offering without LB service...")
+        vpc_off_4 = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering"])
+        self.validate_VpcOffering(vpc_off_4, state="Enabled")
+
+        # Creating VPCs
+        self.debug("Creating a VPC with LB service provider as InternalLbVm...")
+        vpc_1 = self.create_Vpc(vpc_off_1, cidr='10.1.0.0/16')
+        self.validate_Vpc(vpc_1, state="Enabled")
+
+        self.debug("Creating a VPC with LB service provider as VpcVirtualRouter...")
+        with self.assertRaises(Exception):
+            self.create_Vpc(vpc_off_2, cidr='10.1.0.0/16')
+        self.debug("Nuage VSP does not support provider VpcVirtualRouter for service LB for VPCs")
+
+        self.debug("Creating a VPC with LB service provider as Netscaler...")
+        with self.assertRaises(Exception):
+            self.create_Vpc(vpc_off_3, cidr='10.1.0.0/16')
+        self.debug("Nuage VSP does not support provider Netscaler for service LB for VPCs")
+
+        self.debug("Creating a VPC without LB service...")
+        vpc_2 = self.create_Vpc(vpc_off_4, cidr='10.1.0.0/16')
+        self.validate_Vpc(vpc_2, state="Enabled")
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="false")
+    def test_02_nuage_internallb_vpc_network_offering(self):
+        """Test Nuage VSP VPC Network Offering with and without Internal LB service
+        """
+
+        # 1. Create Nuage Vsp VPC Network offering with LB Service Provider as "InternalLbVm" and LB Service Capability
+        #    "lbSchemes" as "internal", check if it is successfully created and enabled. Verify that the VPC network
+        #    creation succeeds with this Network offering.
+        # 2. Recreate above Network offering with ispersistent False, check if it is successfully created and enabled.
+        #    Verify that the VPC network creation fails with this Network offering as Nuage VSP does not support non
+        #    persistent VPC networks.
+        # 3. Recreate above Network offering with conserve mode On, check if the network offering creation failed
+        #    as only networks with conserve mode Off can belong to VPC.
+        # 4. Create Nuage Vsp VPC Network offering with LB Service Provider as "InternalLbVm" and LB Service Capability
+        #    "lbSchemes" as "public", check if the network offering creation failed as "public" lbScheme is not
+        #    supported for LB Service Provider "InternalLbVm".
+        # 5. Create Nuage Vsp VPC Network offering without Internal LB Service, check if it is successfully created and
+        #    enabled. Verify that the VPC network creation succeeds with this Network offering.
+        # 6. Recreate above Network offering with ispersistent False, check if it is successfully created and enabled.
+        #    Verify that the VPC network creation fails with this Network offering as Nuage VSP does not support non
+        #    persistent VPC networks.
+        # 7. Recreate the above Network offering with conserve mode On, check if the network offering creation failed
+        #    as only networks with conserve mode Off can belong to VPC.
+        # 8. Delete the created Network offerings (cleanup).
+
+        # Creating VPC offering
+        self.debug("Creating Nuage VSP VPC offering with Internal LB service...")
+        vpc_off = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering_lb"])
+        self.validate_VpcOffering(vpc_off, state="Enabled")
+
+        # Creating VPC
+        self.debug("Creating a VPC with Internal LB service...")
+        vpc = self.create_Vpc(vpc_off, cidr='10.1.0.0/16')
+        self.validate_Vpc(vpc, state="Enabled")
+
+        # Creating network offerings
+        self.debug("Creating Nuage VSP VPC Network offering with LB Service Provider as InternalLbVm and LB Service "
+                   "Capability lbSchemes as internal...")
+        net_off_1 = self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"])
+        self.validate_NetworkOffering(net_off_1, state="Enabled")
+
+        self.debug("Recreating above Network offering with ispersistent False...")
+        vpc_net_off_lb_non_persistent = copy.deepcopy(self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"])
+        vpc_net_off_lb_non_persistent["ispersistent"] = "False"
+        net_off_2 = self.create_NetworkOffering(vpc_net_off_lb_non_persistent)
+        self.validate_NetworkOffering(net_off_2, state="Enabled")
+
+        self.debug("Recreating above Network offering with conserve mode On...")
+        with self.assertRaises(Exception):
+            self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"],
+                                        conserve_mode=True)
+        self.debug("Network offering creation failed as only networks with conserve mode Off can belong to VPC")
+
+        self.debug("Creating Nuage VSP VPC Network offering with LB Service Provider as InternalLbVm and LB Service "
+                   "Capability lbSchemes as public...")
+        network_offering_internal_lb = copy.deepcopy(self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"])
+        network_offering_internal_lb["serviceCapabilityList"]["Lb"]["lbSchemes"] = "public"
+        with self.assertRaises(Exception):
+            self.create_NetworkOffering(network_offering_internal_lb)
+        self.debug("Network offering creation failed as public lbScheme is not supported for LB Service Provider "
+                   "InternalLbVm")
+
+        self.debug("Creating Nuage Vsp VPC Network offering without Internal LB service...")
+        net_off_3 = self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering"])
+        self.validate_NetworkOffering(net_off_3, state="Enabled")
+
+        self.debug("Recreating above Network offering with ispersistent False...")
+        vpc_net_off_non_persistent = copy.deepcopy(self.test_data["nuagevsp"]["vpc_network_offering"])
+        vpc_net_off_non_persistent["ispersistent"] = "False"
+        net_off_4 = self.create_NetworkOffering(vpc_net_off_non_persistent)
+        self.validate_NetworkOffering(net_off_4, state="Enabled")
+
+        self.debug("Recreating above Network offering with conserve mode On...")
+        with self.assertRaises(Exception):
+            self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering"], conserve_mode=True)
+        self.debug("Network offering creation failed as only networks with conserve mode Off can belong to VPC")
+
+        # Creating VPC networks in the VPC
+        self.debug("Creating a persistent VPC network with Internal LB service...")
+        internal_tier = self.create_Network(net_off_1, gateway='10.1.1.1', vpc=vpc)
+        self.validate_Network(internal_tier, state="Implemented")
+        vr = self.get_Router(internal_tier)
+        self.check_Router_state(vr, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier, vpc)
+        self.verify_vsp_router(vr)
+
+        self.debug("Creating a non persistent VPC network with Internal LB service...")
+        with self.assertRaises(Exception):
+            self.create_Network(net_off_2, gateway='10.1.2.1', vpc=vpc)
+        self.debug("Nuage VSP does not support non persistent VPC networks")
+
+        self.debug("Creating a persistent VPC network without Internal LB service...")
+        public_tier = self.create_Network(net_off_3, gateway='10.1.3.1', vpc=vpc)
+        self.validate_Network(public_tier, state="Implemented")
+        vr = self.get_Router(public_tier)
+        self.check_Router_state(vr, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, public_tier, vpc)
+        self.verify_vsp_router(vr)
+
+        self.debug("Creating a non persistent VPC network without Internal LB service...")
+        with self.assertRaises(Exception):
+            self.create_Network(net_off_4, gateway='10.1.4.1', vpc=vpc)
+        self.debug("Nuage VSP does not support non persistent VPC networks")
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="false")
+    def test_03_nuage_internallb_vpc_networks(self):
+        """Test Nuage VSP VPC Networks with and without Internal LB service
+        """
+
+        # 1. Create Nuage VSP VPC offering with Internal LB service, check if it is successfully created and enabled.
+        # 2. Create Nuage VSP VPC offering without Internal LB service, check if it is successfully created and enabled.
+        # 3. Create a VPC "vpc_1" with Internal LB service, check if it is successfully created and enabled.
+        # 4. Create a VPC "vpc_2" without Internal LB service, check if it is successfully created and enabled.
+        # 5. Create Nuage VSP VPC Network offering with Internal LB service, check if it is successfully created and
+        #    enabled.
+        # 6. Create Nuage VSP VPC Network offering without Internal LB service, check if it is successfully created and
+        #    enabled.
+        # 7. Create a VPC network in vpc_1 with Internal LB service and spawn a VM, check if the tier is added to the
+        #    VPC VR, and the VM is deployed successfully in the tier.
+        # 8. Create one more VPC network in vpc_1 with Internal LB service and spawn a VM, check if the tier is added
+        #    to the VPC VR, and the VM is deployed successfully in the tier.
+        # 9. Create a VPC network in vpc_2 with Internal LB service, check if the tier creation failed.
+        # 10. Create a VPC network in vpc_1 without Internal LB service and spawn a VM, check if the tier is added to
+        #     the VPC VR, and the VM is deployed successfully in the tier.
+        # 11. Create a VPC network in vpc_2 without Internal LB service and spawn a VM, check if the tier is added to
+        #     the VPC VR, and the VM is deployed successfully in the tier.
+        # 12. Upgrade the VPC network with Internal LB service to one with no Internal LB service and vice-versa, check
+        #     if the VPC Network offering upgrade passed in both directions.
+        # 13. Delete the VPC network with Internal LB service, check if the tier is successfully deleted.
+        # 14. Recreate the VPC network with Internal LB service, check if the tier is successfully re-created.
+        # 15. Delete all the created objects (cleanup).
+
+        # Creating VPC offerings
+        self.debug("Creating Nuage VSP VPC offering with Internal LB service...")
+        vpc_off_1 = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering_lb"])
+        self.validate_VpcOffering(vpc_off_1, state="Enabled")
+
+        self.debug("Creating Nuage VSP VPC offering without Internal LB service...")
+        vpc_off_2 = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering"])
+        self.validate_VpcOffering(vpc_off_2, state="Enabled")
+
+        # Creating VPCs
+        self.debug("Creating a VPC with Internal LB service...")
+        vpc_1 = self.create_Vpc(vpc_off_1, cidr='10.1.0.0/16')
+        self.validate_Vpc(vpc_1, state="Enabled")
+
+        self.debug("Creating a VPC without Internal LB service...")
+        vpc_2 = self.create_Vpc(vpc_off_2, cidr='10.1.0.0/16')
+        self.validate_Vpc(vpc_2, state="Enabled")
+
+        # Creating network offerings
+        self.debug("Creating Nuage VSP VPC Network offering with Internal LB service...")
+        net_off_1 = self.create_NetworkOffering(
+            self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"])
+        self.validate_NetworkOffering(net_off_1, state="Enabled")
+
+        self.debug("Creating Nuage VSP VPC Network offering without Internal LB service...")
+        net_off_2 = self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering"])
+        self.validate_NetworkOffering(net_off_2, state="Enabled")
+
+        # Creating VPC networks in VPCs, and deploying VMs
+        self.debug("Creating a VPC network in vpc_1 with Internal LB service...")
+        internal_tier_1 = self.create_Network(net_off_1, gateway='10.1.1.1', vpc=vpc_1)
+        self.validate_Network(internal_tier_1, state="Implemented")
+        vr_1 = self.get_Router(internal_tier_1)
+        self.check_Router_state(vr_1, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % internal_tier_1.name)
+        internal_vm_1 = self.create_VM(internal_tier_1)
+        self.check_VM_state(internal_vm_1, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier_1, vpc_1)
+        self.verify_vsp_router(vr_1)
+        self.verify_vsp_vm(internal_vm_1)
+
+        self.debug("Creating one more VPC network in vpc_1 with Internal LB service...")
+        internal_tier_2 = self.create_Network(net_off_1, gateway='10.1.2.1', vpc=vpc_1)
+        self.validate_Network(internal_tier_2, state="Implemented")
+        vr_1 = self.get_Router(internal_tier_2)
+        self.check_Router_state(vr_1, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % internal_tier_2.name)
+        internal_vm_2 = self.create_VM(internal_tier_2)
+        self.check_VM_state(internal_vm_2, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier_2, vpc_1)
+        self.verify_vsp_router(vr_1)
+        self.verify_vsp_vm(internal_vm_2)
+
+        self.debug("Creating a VPC network in vpc_2 with Internal LB service...")
+        with self.assertRaises(Exception):
+            self.create_Network(net_off_1, gateway='10.1.1.1', vpc=vpc_2)
+        self.debug("VPC Network creation failed as vpc_2 does not support Internal Lb service")
+
+        self.debug("Creating a VPC network in vpc_1 without Internal LB service...")
+        public_tier_1 = self.create_Network(net_off_2, gateway='10.1.3.1', vpc=vpc_1)
+        self.validate_Network(public_tier_1, state="Implemented")
+        vr_1 = self.get_Router(public_tier_1)
+        self.check_Router_state(vr_1, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % public_tier_1.name)
+        public_vm_1 = self.create_VM(public_tier_1)
+        self.check_VM_state(public_vm_1, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, public_tier_1, vpc_1)
+        self.verify_vsp_router(vr_1)
+        self.verify_vsp_vm(public_vm_1)
+
+        self.debug("Creating a VPC network in vpc_2 without Internal LB service...")
+        public_tier_2 = self.create_Network(net_off_2, gateway='10.1.1.1', vpc=vpc_2)
+        self.validate_Network(public_tier_2, state="Implemented")
+        vr_2 = self.get_Router(public_tier_2)
+        self.check_Router_state(vr_2, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % public_tier_2.name)
+        public_vm_2 = self.create_VM(public_tier_2)
+        self.check_VM_state(public_vm_2, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, public_tier_2, vpc_2)
+        self.verify_vsp_router(vr_2)
+        self.verify_vsp_vm(public_vm_2)
+
+        # Upgrading a VPC network
+        self.debug("Upgrading a VPC network with Internal LB Service to one without Internal LB Service...")
+        self.upgrade_Network(net_off_2, internal_tier_2)
+        self.validate_Network(internal_tier_2, state="Implemented")
+        vr_1 = self.get_Router(internal_tier_2)
+        self.check_Router_state(vr_1, state="Running")
+        self.check_VM_state(internal_vm_2, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier_2, vpc_1)
+        self.verify_vsp_router(vr_1)
+        self.verify_vsp_vm(internal_vm_2)
+
+        self.debug("Upgrading a VPC network without Internal LB Service to one with Internal LB Service...")
+        self.upgrade_Network(net_off_1, internal_tier_2)
+        self.validate_Network(internal_tier_2, state="Implemented")
+        vr_1 = self.get_Router(internal_tier_2)
+        self.check_Router_state(vr_1, state="Running")
+        self.check_VM_state(internal_vm_2, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier_2, vpc_1)
+        self.verify_vsp_router(vr_1)
+        self.verify_vsp_vm(internal_vm_2)
+
+        # Deleting and re-creating a VPC network
+        self.debug("Deleting a VPC network with Internal LB Service...")
+        self.delete_VM(internal_vm_2)
+        self.delete_Network(internal_tier_2)
+        with self.assertRaises(Exception):
+            self.validate_Network(internal_tier_2)
+        self.debug("VPC network successfully deleted in CloudStack")
+
+        # VSD verification
+        with self.assertRaises(Exception):
+            self.verify_vsp_network(self.domain.id, internal_tier_2, vpc_1)
+        self.debug("VPC network successfully deleted in VSD")
+
+        self.debug("Recreating a VPC network with Internal LB Service...")
+        internal_tier_2 = self.create_Network(net_off_1, gateway='10.1.2.1', vpc=vpc_1)
+        internal_vm_2 = self.create_VM(internal_tier_2)
+        self.validate_Network(internal_tier_2, state="Implemented")
+        vr_1 = self.get_Router(internal_tier_2)
+        self.check_Router_state(vr_1, state="Running")
+        self.check_VM_state(internal_vm_2, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier_2, vpc_1)
+        self.verify_vsp_router(vr_1)
+        self.verify_vsp_vm(internal_vm_2)
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="false")
+    def test_04_nuage_internallb_rules(self):
+        """Test Nuage VSP VPC Internal LB functionality with different combinations of Internal LB rules
+        """
+
+        # 1. Create an Internal LB Rule with source IP Address specified, check if the Internal LB Rule is successfully
+        #    created.
+        # 2. Create an Internal LB Rule without source IP Address specified, check if the Internal LB Rule is
+        #    successfully created.
+        # 3. Create an Internal LB Rule when the specified source IP Address is outside the VPC network (tier) CIDR
+        #    range, check if the Internal LB Rule creation failed as the requested source IP is not in the network's
+        #    CIDR subnet.
+        # 4. Create an Internal LB Rule when the specified source IP Address is outside the VPC super CIDR range,
+        #    check if the Internal LB Rule creation failed as the requested source IP is not in the network's CIDR
+        #    subnet.
+        # 5. Create an Internal LB Rule in the tier with LB service provider as VpcInlineLbVm, check if the Internal LB
+        #    Rule creation failed as Scheme Internal is not supported by this network offering.
+        # 6. Create multiple Internal LB Rules using different Load Balancing source IP Addresses, check if the Internal
+        #    LB Rules are successfully created.
+        # 7. Create multiple Internal LB Rules with different ports but using the same Load Balancing source IP Address,
+        #    check if the Internal LB Rules are successfully created.
+        # 8. Create multiple Internal LB Rules with same ports and using the same Load Balancing source IP Address,
+        #    check if the second Internal LB Rule creation failed as it conflicts with the first Internal LB rule.
+        # 9. Attach a VM to the above created Internal LB Rules, check if the VM is successfully attached to the
+        #    Internal LB Rules.
+        # 10. Verify the InternalLbVm deployment after successfully creating the first Internal LB Rule and attaching a
+        #     VM to it.
+        # 11. Verify the failure of attaching a VM from a different tier to an Internal LB Rule created on a tier.
+        # 12. Delete the above created Internal LB Rules, check if the Internal LB Rules are successfully deleted.
+
+        # Creating a VPC offering
+        self.debug("Creating Nuage VSP VPC offering with Internal LB service...")
+        vpc_off = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering_lb"])
+        self.validate_VpcOffering(vpc_off, state="Enabled")
+
+        # Creating a VPC
+        self.debug("Creating a VPC with Internal LB service...")
+        vpc = self.create_Vpc(vpc_off, cidr='10.1.0.0/16')
+        self.validate_Vpc(vpc, state="Enabled")
+
+        # Creating network offerings
+        self.debug("Creating Nuage VSP VPC Network offering with Internal LB service...")
+        net_off_1 = self.create_NetworkOffering(
+            self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"])
+        self.validate_NetworkOffering(net_off_1, state="Enabled")
+
+        self.debug("Creating Nuage VSP VPC Network offering without Internal LB service...")
+        net_off_2 = self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering"])
+        self.validate_NetworkOffering(net_off_2, state="Enabled")
+
+        # Creating VPC networks in the VPC, and deploying VMs
+        self.debug("Creating a VPC network with Internal LB service...")
+        internal_tier = self.create_Network(net_off_1, gateway='10.1.1.1', vpc=vpc)
+        self.validate_Network(internal_tier, state="Implemented")
+        vr = self.get_Router(internal_tier)
+        self.check_Router_state(vr, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % internal_tier.name)
+        internal_vm = self.create_VM(internal_tier)
+        self.check_VM_state(internal_vm, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(internal_vm)
+
+        self.debug("Creating a VPC network without Internal LB service...")
+        public_tier = self.create_Network(net_off_2, gateway='10.1.2.1', vpc=vpc)
+        self.validate_Network(public_tier, state="Implemented")
+        vr = self.get_Router(public_tier)
+        self.check_Router_state(vr, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % public_tier.name)
+        public_vm = self.create_VM(public_tier)
+        self.check_VM_state(public_vm, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, public_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(public_vm)
+
+        # Creating Internal LB Rules
+        self.debug("Creating an Internal LB Rule without source IP Address specified...")
+        int_lb_rule = self.create_Internal_LB_Rule(internal_tier)
+        self.validate_Internal_LB_Rule(int_lb_rule, state="Add")
+
+        # Validating InternalLbVm deployment
+        with self.assertRaises(Exception):
+            self.check_InternalLbVm_state(internal_tier, int_lb_rule.sourceipaddress)
+        self.debug("InternalLbVm is not deployed in the network as there are no VMs assigned to this Internal LB Rule")
+
+        self.debug('Deleting the Internal LB Rule - %s' % int_lb_rule.name)
+        int_lb_rule.delete(self.api_client)
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule)
+        self.debug("Internal LB Rule successfully deleted in CloudStack")
+
+        free_source_ip = int_lb_rule.sourceipaddress
+
+        self.debug("Creating an Internal LB Rule with source IP Address specified...")
+        int_lb_rule = self.create_Internal_LB_Rule(internal_tier, source_ip=free_source_ip)
+        self.validate_Internal_LB_Rule(int_lb_rule, state="Add")
+
+        # Validating InternalLbVm deployment
+        with self.assertRaises(Exception):
+            self.check_InternalLbVm_state(internal_tier, int_lb_rule.sourceipaddress)
+        self.debug("InternalLbVm is not deployed in the network as there are no VMs assigned to this Internal LB Rule")
+
+        self.debug('Deleting the Internal LB Rule - %s' % int_lb_rule.name)
+        int_lb_rule.delete(self.api_client)
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule)
+        self.debug("Internal LB Rule successfully deleted in CloudStack")
+
+        self.debug("Creating an Internal LB Rule when the specified source IP Address is outside the VPC network CIDR "
+                   "range...")
+        with self.assertRaises(Exception):
+            self.create_Internal_LB_Rule(internal_tier, source_ip="10.1.1.256")
+        self.debug("Internal LB Rule creation failed as the requested IP is not in the network's CIDR subnet")
+
+        self.debug("Creating an Internal LB Rule when the specified source IP Address is outside the VPC super CIDR "
+                   "range...")
+        with self.assertRaises(Exception):
+            self.create_Internal_LB_Rule(internal_tier, source_ip="10.2.1.256")
+        self.debug("Internal LB Rule creation failed as the requested IP is not in the network's CIDR subnet")
+
+        self.debug("Creating an Internal LB Rule in a VPC network without Internal Lb service...")
+        with self.assertRaises(Exception):
+            self.create_Internal_LB_Rule(public_tier)
+        self.debug("Internal LB Rule creation failed as Scheme Internal is not supported by this network offering")
+
+        self.debug("Creating multiple Internal LB Rules using different Load Balancing source IP Addresses...")
+        int_lb_rule_1 = self.create_Internal_LB_Rule(internal_tier, vm_array=[internal_vm])
+        self.validate_Internal_LB_Rule(int_lb_rule_1, state="Active", vm_array=[internal_vm])
+        int_lb_rule_2 = self.create_Internal_LB_Rule(internal_tier, vm_array=[internal_vm])
+        self.validate_Internal_LB_Rule(int_lb_rule_2, state="Active", vm_array=[internal_vm])
+
+        # Validating InternalLbVms deployment and state
+        int_lb_vm_1 = self.get_InternalLbVm(internal_tier, int_lb_rule_1.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+        int_lb_vm_2 = self.get_InternalLbVm(internal_tier, int_lb_rule_2.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_2.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm_1)
+        self.verify_vsp_LB_device(int_lb_vm_2)
+
+        self.debug('Removing VMs from the Internal LB Rules - %s, %s' % (int_lb_rule_1.name, int_lb_rule_2.name))
+        int_lb_rule_1.remove(self.api_client, vms=[internal_vm])
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule_1, vm_array=[internal_vm])
+        self.debug("VMs successfully removed from the Internal LB Rule in CloudStack")
+        int_lb_rule_2.remove(self.api_client, vms=[internal_vm])
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule_2, vm_array=[internal_vm])
+        self.debug("VMs successfully removed from the Internal LB Rule in CloudStack")
+
+        # Validating InternalLbVms state
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_2.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm_1)
+        self.verify_vsp_LB_device(int_lb_vm_2)
+
+        self.debug('Deleting the Internal LB Rules - %s, %s' % (int_lb_rule_1.name, int_lb_rule_2.name))
+        int_lb_rule_1.delete(self.api_client)
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule_1)
+        self.debug("Internal LB Rule successfully deleted in CloudStack")
+        int_lb_rule_2.delete(self.api_client)
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule_2)
+        self.debug("Internal LB Rule successfully deleted in CloudStack")
+
+        # Validating InternalLbVms un-deployment
+        with self.assertRaises(Exception):
+            self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress)
+        self.debug("InternalLbVm successfully destroyed in CloudStack")
+        with self.assertRaises(Exception):
+            self.check_InternalLbVm_state(internal_tier, int_lb_rule_2.sourceipaddress)
+        self.debug("InternalLbVm successfully destroyed in CloudStack")
+
+        # VSD Verification
+        with self.assertRaises(Exception):
+            self.verify_vsp_LB_device(int_lb_vm_1)
+        self.debug("InternalLbVm successfully destroyed in VSD")
+        with self.assertRaises(Exception):
+            self.verify_vsp_LB_device(int_lb_vm_2)
+        self.debug("InternalLbVm successfully destroyed in VSD")
+
+        self.debug("Creating multiple Internal LB Rules with different ports but using the same Load Balancing source "
+                   "IP Address...")
+        int_lb_rule_1 = self.create_Internal_LB_Rule(internal_tier, vm_array=[internal_vm])
+        self.validate_Internal_LB_Rule(int_lb_rule_1, state="Active", vm_array=[internal_vm])
+        int_lb_rule_2 = self.create_Internal_LB_Rule(internal_tier,
+                                                     vm_array=[internal_vm],
+                                                     services=self.test_data["internal_lbrule_http"],
+                                                     source_ip=int_lb_rule_1.sourceipaddress
+                                                     )
+        self.validate_Internal_LB_Rule(int_lb_rule_2, state="Active", vm_array=[internal_vm])
+
+        # Validating InternalLbVm deployment and state
+        int_lb_vm = self.get_InternalLbVm(internal_tier, int_lb_rule_1.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm)
+
+        self.debug('Removing VMs from the Internal LB Rules - %s, %s' % (int_lb_rule_1.name, int_lb_rule_2.name))
+        int_lb_rule_1.remove(self.api_client, vms=[internal_vm])
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule_1, vm_array=[internal_vm])
+        self.debug("VMs successfully removed from the Internal LB Rule in CloudStack")
+        int_lb_rule_2.remove(self.api_client, vms=[internal_vm])
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule_2, vm_array=[internal_vm])
+        self.debug("VMs successfully removed from the Internal LB Rule in CloudStack")
+
+        # Validating InternalLbVm state
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm)
+
+        self.debug('Deleting the Internal LB Rules - %s, %s' % (int_lb_rule_1.name, int_lb_rule_2.name))
+        int_lb_rule_1.delete(self.api_client)
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule_1)
+        self.debug("Internal LB Rule successfully deleted in CloudStack")
+        int_lb_rule_2.delete(self.api_client)
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule_2)
+        self.debug("Internal LB Rule successfully deleted in CloudStack")
+
+        # Validating InternalLbVm un-deployment
+        with self.assertRaises(Exception):
+            self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress)
+        self.debug("InternalLbVm successfully destroyed in CloudStack")
+
+        # VSD Verification
+        with self.assertRaises(Exception):
+            self.verify_vsp_LB_device(int_lb_vm)
+        self.debug("InternalLbVm successfully destroyed in VSD")
+
+        self.debug("Creating multiple Internal LB Rules with same ports and using the same Load Balacing source IP "
+                   "Address...")
+        int_lb_rule = self.create_Internal_LB_Rule(internal_tier, vm_array=[internal_vm])
+        self.validate_Internal_LB_Rule(int_lb_rule, state="Active", vm_array=[internal_vm])
+        with self.assertRaises(Exception):
+            self.create_Internal_LB_Rule(internal_tier, vm_array=[internal_vm], source_ip=int_lb_rule.sourceipaddress)
+        self.debug("Internal LB Rule creation failed as it conflicts with the existing rule")
+
+        # Validating InternalLbVm deployment and state
+        int_lb_vm = self.get_InternalLbVm(internal_tier, int_lb_rule.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm)
+
+        self.debug('Removing VMs from the Internal LB Rule - %s' % int_lb_rule.name)
+        int_lb_rule.remove(self.api_client, vms=[internal_vm])
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule, vm_array=[internal_vm])
+        self.debug("VMs successfully removed from the Internal LB Rule in CloudStack")
+
+        # Validating InternalLbVm state
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm)
+
+        self.debug('Deleting the Internal LB Rule - %s' % int_lb_rule.name)
+        int_lb_rule.delete(self.api_client)
+        with self.assertRaises(Exception):
+            self.validate_Internal_LB_Rule(int_lb_rule)
+        self.debug("Internal LB Rule successfully deleted in CloudStack")
+
+        # Validating InternalLbVm un-deployment
+        with self.assertRaises(Exception):
+            self.check_InternalLbVm_state(internal_tier, int_lb_rule.sourceipaddress)
+        self.debug("InternalLbVm successfully destroyed in CloudStack")
+
+        # VSD Verification
+        with self.assertRaises(Exception):
+            self.verify_vsp_LB_device(int_lb_vm)
+        self.debug("InternalLbVm successfully destroyed in VSD")
+
+        self.debug("Attaching a VM from a different tier to an Internal LB Rule created on a tier...")
+        with self.assertRaises(Exception):
+            self.create_Internal_LB_Rule(internal_tier, vm_array=[public_vm])
+        self.debug("Internal LB Rule creation failed as the VM belongs to a different network")
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="true")
+    def test_05_nuage_internallb_traffic(self):
+        """Test Nuage VSP VPC Internal LB functionality by performing (wget) traffic tests within a VPC
+        """
+
+        # 1. Create an Internal LB Rule "internal_lbrule" with source IP Address specified on the Internal tier, check
+        #    if the Internal LB Rule is successfully created.
+        # 2. Create an Internal LB Rule "internal_lbrule_http" with source IP Address (same as above) specified on the
+        #    Internal tier, check if the Internal LB Rule is successfully created.
+        # 3. Attach a VM to the above created Internal LB Rules, check if the InternalLbVm is successfully deployed in
+        #    the Internal tier.
+        # 4. Deploy two more VMs in the Internal tier, check if the VMs are successfully deployed.
+        # 5. Attach the newly deployed VMs to the above created Internal LB Rules, verify the validity of the above
+        #    created Internal LB Rules over three Load Balanced VMs in the Internal tier.
+        # 6. Create the corresponding Network ACL rules to make the created Internal LB rules (SSH & HTTP) accessible,
+        #    check if the Network ACL rules are successfully added to the internal tier.
+        # 7. Validate the Internal LB functionality by performing (wget) traffic tests from a VM in the Public tier to
+        #    the Internal load balanced guest VMs in the Internal tier, using Static NAT functionality to access (ssh)
+        #    the VM on the Public tier.
+        # 8. Verify that the InternalLbVm gets destroyed when the last Internal LB rule is removed from the Internal
+        #    tier.
+        # 9. Repeat the above steps for one more Internal tier as well, validate the Internal LB functionality.
+
+        # Creating a VPC offering
+        self.debug("Creating Nuage VSP VPC offering with Internal LB service...")
+        vpc_off = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering_lb"])
+        self.validate_VpcOffering(vpc_off, state="Enabled")
+
+        # Creating a VPC
+        self.debug("Creating a VPC with Internal LB service...")
+        vpc = self.create_Vpc(vpc_off, cidr='10.1.0.0/16')
+        self.validate_Vpc(vpc, state="Enabled")
+
+        # Creating network offerings
+        self.debug("Creating Nuage VSP VPC Network offering with Internal LB service...")
+        net_off_1 = self.create_NetworkOffering(
+            self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"])
+        self.validate_NetworkOffering(net_off_1, state="Enabled")
+
+        self.debug("Creating Nuage VSP VPC Network offering without Internal LB service...")
+        net_off_2 = self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering"])
+        self.validate_NetworkOffering(net_off_2, state="Enabled")
+
+        # Creating VPC networks in the VPC, and deploying VMs
+        self.debug("Creating a VPC network with Internal LB service...")
+        internal_tier_1 = self.create_Network(net_off_1, gateway='10.1.1.1', vpc=vpc)
+        self.validate_Network(internal_tier_1, state="Implemented")
+        vr = self.get_Router(internal_tier_1)
+        self.check_Router_state(vr, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % internal_tier_1.name)
+        internal_vm_1 = self.create_VM(internal_tier_1)
+        self.check_VM_state(internal_vm_1, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier_1, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(internal_vm_1)
+
+        self.debug("Creating one more VPC network with Internal LB service...")
+        internal_tier_2 = self.create_Network(net_off_1, gateway='10.1.2.1', vpc=vpc)
+        self.validate_Network(internal_tier_2, state="Implemented")
+        vr = self.get_Router(internal_tier_2)
+        self.check_Router_state(vr, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % internal_tier_2.name)
+        internal_vm_2 = self.create_VM(internal_tier_2)
+        self.check_VM_state(internal_vm_2, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier_2, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(internal_vm_2)
+
+        self.debug("Creating a VPC network without Internal LB service...")
+        public_tier = self.create_Network(net_off_2, gateway='10.1.3.1', vpc=vpc)
+        self.validate_Network(public_tier, state="Implemented")
+        vr = self.get_Router(public_tier)
+        self.check_Router_state(vr, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % public_tier.name)
+        public_vm = self.create_VM(public_tier)
+        self.check_VM_state(public_vm, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, public_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(public_vm)
+
+        # Creating Internal LB Rules in the Internal tiers
+        self.debug("Creating two Internal LB Rules (SSH & HTTP) using the same Load Balancing source IP Address...")
+        int_lb_rule_1 = self.create_Internal_LB_Rule(internal_tier_1, vm_array=[internal_vm_1])
+        self.validate_Internal_LB_Rule(int_lb_rule_1, state="Active", vm_array=[internal_vm_1])
+        int_lb_rule_2 = self.create_Internal_LB_Rule(internal_tier_1,
+                                                     vm_array=[internal_vm_1],
+                                                     services=self.test_data["internal_lbrule_http"],
+                                                     source_ip=int_lb_rule_1.sourceipaddress
+                                                     )
+        self.validate_Internal_LB_Rule(int_lb_rule_2, state="Active", vm_array=[internal_vm_1])
+
+        # Validating InternalLbVm deployment and state
+        int_lb_vm_1 = self.get_InternalLbVm(internal_tier_1, int_lb_rule_1.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier_1, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm_1)
+
+        # Deploying more VMs in the Internal tier
+        self.debug("Deploying two more VMs in network - %s" % internal_tier_1.name)
+        internal_vm_1_1 = self.create_VM(internal_tier_1)
+        internal_vm_1_2 = self.create_VM(internal_tier_1)
+
+        # VSD verification
+        self.verify_vsp_vm(internal_vm_1_1)
+        self.verify_vsp_vm(internal_vm_1_2)
+
+        # Adding newly deployed VMs to the created Internal LB rules
+        self.debug("Adding two more virtual machines to the created Internal LB rules...")
+        int_lb_rule_1.assign(self.api_client, [internal_vm_1_1, internal_vm_1_2])
+        self.validate_Internal_LB_Rule(int_lb_rule_1, state="Active",
+                                       vm_array=[internal_vm_1, internal_vm_1_1, internal_vm_1_2])
+        int_lb_rule_2.assign(self.api_client, [internal_vm_1_1, internal_vm_1_2])
+        self.validate_Internal_LB_Rule(int_lb_rule_2, state="Active",
+                                       vm_array=[internal_vm_1, internal_vm_1_1, internal_vm_1_2])
+
+        # Validating InternalLbVm state
+        self.check_InternalLbVm_state(internal_tier_1, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm_1)
+
+        # Adding Network ACL rules in the Internal tier
+        self.debug("Adding Network ACL rules to make the created Internal LB rules (SSH & HTTP) accessible...")
+        ssh_rule = self.create_NetworkAclRule(self.test_data["ingress_rule"], network=internal_tier_1)
+        http_rule = self.create_NetworkAclRule(self.test_data["http_rule"], network=internal_tier_1)
+
+        # VSD verification
+        self.verify_vsp_firewall_rule(ssh_rule)
+        self.verify_vsp_firewall_rule(http_rule)
+
+        # Creating Internal LB Rules in the Internal tier
+        self.debug("Creating two Internal LB Rules (SSH & HTTP) using the same Load Balancing source IP Address...")
+        int_lb_rule_3 = self.create_Internal_LB_Rule(internal_tier_2, vm_array=[internal_vm_2])
+        self.validate_Internal_LB_Rule(int_lb_rule_3, state="Active", vm_array=[internal_vm_2])
+        int_lb_rule_4 = self.create_Internal_LB_Rule(internal_tier_2,
+                                                     vm_array=[internal_vm_2],
+                                                     services=self.test_data["internal_lbrule_http"],
+                                                     source_ip=int_lb_rule_3.sourceipaddress
+                                                     )
+        self.validate_Internal_LB_Rule(int_lb_rule_4, state="Active", vm_array=[internal_vm_2])
+
+        # Validating InternalLbVm deployment and state
+        int_lb_vm_2 = self.get_InternalLbVm(internal_tier_2, int_lb_rule_3.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier_2, int_lb_rule_3.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm_2)
+
+        # Deploying more VMs in the Internal tier
+        self.debug("Deploying two more VMs in network - %s" % internal_tier_2.name)
+        internal_vm_2_1 = self.create_VM(internal_tier_2)
+        internal_vm_2_2 = self.create_VM(internal_tier_2)
+
+        # VSD verification
+        self.verify_vsp_vm(internal_vm_2_1)
+        self.verify_vsp_vm(internal_vm_2_2)
+
+        # Adding newly deployed VMs to the created Internal LB rules
+        self.debug("Adding two more virtual machines to the created Internal LB rules...")
+        int_lb_rule_3.assign(self.api_client, [internal_vm_2_1, internal_vm_2_2])
+        self.validate_Internal_LB_Rule(int_lb_rule_3, state="Active",
+                                       vm_array=[internal_vm_2, internal_vm_2_1, internal_vm_2_2])
+        int_lb_rule_4.assign(self.api_client, [internal_vm_2_1, internal_vm_2_2])
+        self.validate_Internal_LB_Rule(int_lb_rule_4, state="Active",
+                                       vm_array=[internal_vm_2, internal_vm_2_1, internal_vm_2_2])
+
+        # Validating InternalLbVm state
+        self.check_InternalLbVm_state(internal_tier_2, int_lb_rule_3.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm_2)
+
+        # Adding Network ACL rules in the Internal tier
+        self.debug("Adding Network ACL rules to make the created Internal LB rules (SSH & HTTP) accessible...")
+        ssh_rule = self.create_NetworkAclRule(self.test_data["ingress_rule"], network=internal_tier_2)
+        http_rule = self.create_NetworkAclRule(self.test_data["http_rule"], network=internal_tier_2)
+
+        # VSD verification
+        self.verify_vsp_firewall_rule(ssh_rule)
+        self.verify_vsp_firewall_rule(http_rule)
+
+        # Creating Static NAT Rule for the VM in the Public tier
+        public_ip = self.acquire_PublicIPAddress(public_tier, vpc)
+        self.validate_PublicIPAddress(public_ip, public_tier)
+        self.create_StaticNatRule_For_VM(public_vm, public_ip, public_tier)
+        self.validate_PublicIPAddress(public_ip, public_tier, static_nat=True, vm=public_vm)
+
+        # VSD verification
+        self.verify_vsp_floating_ip(public_tier, public_vm, public_ip.ipaddress, vpc)
+
+        # Adding Network ACL rule in the Public tier
+        self.debug("Adding Network ACL rule to make the created NAT rule (SSH) accessible...")
+        public_ssh_rule = self.create_NetworkAclRule(self.test_data["ingress_rule"], network=public_tier)
+
+        # VSD verification
+        self.verify_vsp_firewall_rule(public_ssh_rule)
+
+        # Internal LB (wget) traffic tests
+        ssh_client = self.ssh_into_VM(public_vm, public_ip)
+        wget_file_1 = self.wget_from_vm_cmd(ssh_client,
+                                            int_lb_rule_1.sourceipaddress,
+                                            self.test_data["http_rule"]["publicport"]
+                                            )
+        ssh_client = self.ssh_into_VM(public_vm, public_ip)
+        wget_file_2 = self.wget_from_vm_cmd(ssh_client,
+                                            int_lb_rule_3.sourceipaddress,
+                                            self.test_data["http_rule"]["publicport"]
+                                            )
+
+        # Verifying Internal LB (wget) traffic tests
+        self.verify_lb_wget_file(wget_file_1, [internal_vm_1, internal_vm_1_1, internal_vm_1_2])
+        self.verify_lb_wget_file(wget_file_2, [internal_vm_2, internal_vm_2_1, internal_vm_2_2])
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="true")
+    def test_06_nuage_internallb_algorithms_traffic(self):
+        """Test Nuage VSP VPC Internal LB functionality with different LB algorithms by performing (wget) traffic tests
+        within a VPC
+        """
+
+        # Repeat the tests in the testcase "test_05_nuage_internallb_traffic" with different Internal LB algorithms:
+        # 1. Round Robin
+        # 2. Least connections
+        # 3. Source
+        # Verify the above Internal LB algorithms by performing multiple (wget) traffic tests within a VPC.
+
+        # Creating a VPC offering
+        self.debug("Creating Nuage VSP VPC offering with Internal LB service...")
+        vpc_off = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering_lb"])
+        self.validate_VpcOffering(vpc_off, state="Enabled")
+
+        # Creating a VPC
+        self.debug("Creating a VPC with Internal LB service...")
+        vpc = self.create_Vpc(vpc_off, cidr='10.1.0.0/16')
+        self.validate_Vpc(vpc, state="Enabled")
+
+        # Creating network offerings
+        self.debug("Creating Nuage VSP VPC Network offering with Internal LB service...")
+        net_off_1 = self.create_NetworkOffering(
+            self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"])
+        self.validate_NetworkOffering(net_off_1, state="Enabled")
+
+        self.debug("Creating Nuage VSP VPC Network offering without Internal LB service...")
+        net_off_2 = self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering"])
+        self.validate_NetworkOffering(net_off_2, state="Enabled")
+
+        # Creating VPC networks in the VPC, and deploying VMs
+        self.debug("Creating a VPC network with Internal LB service...")
+        internal_tier = self.create_Network(net_off_1, gateway='10.1.1.1', vpc=vpc)
+        self.validate_Network(internal_tier, state="Implemented")
+        vr = self.get_Router(internal_tier)
+        self.check_Router_state(vr, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % internal_tier.name)
+        internal_vm = self.create_VM(internal_tier)
+        self.check_VM_state(internal_vm, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(internal_vm)
+
+        self.debug("Creating a VPC network without Internal LB service...")
+        public_tier = self.create_Network(net_off_2, gateway='10.1.2.1', vpc=vpc)
+        self.validate_Network(public_tier, state="Implemented")
+        vr = self.get_Router(public_tier)
+        self.check_Router_state(vr, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % public_tier.name)
+        public_vm = self.create_VM(public_tier)
+        self.check_VM_state(public_vm, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, public_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(public_vm)
+
+        # Creating Internal LB Rules in the Internal tier with Round Robin Algorithm
+        self.debug("Creating two Internal LB Rules (SSH & HTTP) with Round Robin Algorithm...")
+        int_lb_rule_1 = self.create_Internal_LB_Rule(internal_tier, vm_array=[internal_vm])
+        self.validate_Internal_LB_Rule(int_lb_rule_1, state="Active", vm_array=[internal_vm])
+        int_lb_rule_2 = self.create_Internal_LB_Rule(internal_tier,
+                                                     vm_array=[internal_vm],
+                                                     services=self.test_data["internal_lbrule_http"],
+                                                     source_ip=int_lb_rule_1.sourceipaddress
+                                                     )
+        self.validate_Internal_LB_Rule(int_lb_rule_2, state="Active", vm_array=[internal_vm])
+
+        # Validating InternalLbVm deployment and state
+        int_lb_vm_1 = self.get_InternalLbVm(internal_tier, int_lb_rule_1.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm_1)
+
+        # Deploying more VMs in the Internal tier
+        self.debug("Deploying two more VMs in network - %s" % internal_tier.name)
+        internal_vm_1 = self.create_VM(internal_tier)
+        internal_vm_2 = self.create_VM(internal_tier)
+
+        # VSD verification
+        self.verify_vsp_vm(internal_vm_1)
+        self.verify_vsp_vm(internal_vm_2)
+
+        # Adding newly deployed VMs to the created Internal LB rules
+        self.debug("Adding two more virtual machines to the created Internal LB rules...")
+        int_lb_rule_1.assign(self.api_client, [internal_vm_1, internal_vm_2])
+        self.validate_Internal_LB_Rule(int_lb_rule_1, state="Active",
+                                       vm_array=[internal_vm, internal_vm_1, internal_vm_2])
+        int_lb_rule_2.assign(self.api_client, [internal_vm_1, internal_vm_2])
+        self.validate_Internal_LB_Rule(int_lb_rule_2, state="Active",
+                                       vm_array=[internal_vm, internal_vm_1, internal_vm_2])
+
+        # Validating InternalLbVm state
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm_1)
+
+        # Creating Internal LB Rules in the Internal tier with Least connections Algorithm
+        self.debug("Creating two Internal LB Rules (SSH & HTTP) with Least connections Algorithm...")
+        self.test_data["internal_lbrule"]["algorithm"] = "leastconn"
+        int_lb_rule_3 = self.create_Internal_LB_Rule(internal_tier,
+                                                     vm_array=[internal_vm, internal_vm_1, internal_vm_2],
+                                                     services=self.test_data["internal_lbrule"]
+                                                     )
+        self.validate_Internal_LB_Rule(int_lb_rule_3, state="Active",
+                                       vm_array=[internal_vm, internal_vm_1, internal_vm_2])
+        self.test_data["internal_lbrule_http"]["algorithm"] = "leastconn"
+        int_lb_rule_4 = self.create_Internal_LB_Rule(internal_tier,
+                                                     vm_array=[internal_vm, internal_vm_1, internal_vm_2],
+                                                     services=self.test_data["internal_lbrule_http"],
+                                                     source_ip=int_lb_rule_3.sourceipaddress
+                                                     )
+        self.validate_Internal_LB_Rule(int_lb_rule_4, state="Active",
+                                       vm_array=[internal_vm, internal_vm_1, internal_vm_2])
+
+        # Validating InternalLbVm deployment and state
+        int_lb_vm_2 = self.get_InternalLbVm(internal_tier, int_lb_rule_3.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_3.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm_2)
+
+        # Creating Internal LB Rules in the Internal tier with Source Algorithm
+        self.debug("Creating two Internal LB Rules (SSH & HTTP) with Source Algorithm...")
+        self.test_data["internal_lbrule"]["algorithm"] = "source"
+        int_lb_rule_5 = self.create_Internal_LB_Rule(internal_tier,
+                                                     vm_array=[internal_vm, internal_vm_1, internal_vm_2],
+                                                     services=self.test_data["internal_lbrule"]
+                                                     )
+        self.validate_Internal_LB_Rule(int_lb_rule_5, state="Active",
+                                       vm_array=[internal_vm, internal_vm_1, internal_vm_2])
+        self.test_data["internal_lbrule_http"]["algorithm"] = "source"
+        int_lb_rule_6 = self.create_Internal_LB_Rule(internal_tier,
+                                                     vm_array=[internal_vm, internal_vm_1, internal_vm_2],
+                                                     services=self.test_data["internal_lbrule_http"],
+                                                     source_ip=int_lb_rule_5.sourceipaddress
+                                                     )
+        self.validate_Internal_LB_Rule(int_lb_rule_6, state="Active",
+                                       vm_array=[internal_vm, internal_vm_1, internal_vm_2])
+
+        # Validating InternalLbVm deployment and state
+        int_lb_vm_3 = self.get_InternalLbVm(internal_tier, int_lb_rule_5.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_5.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm_3)
+
+        # Adding Network ACL rules in the Internal tier
+        self.debug("Adding Network ACL rules to make the created Internal LB rules (SSH & HTTP) accessible...")
+        ssh_rule = self.create_NetworkAclRule(self.test_data["ingress_rule"], network=internal_tier)
+        http_rule = self.create_NetworkAclRule(self.test_data["http_rule"], network=internal_tier)
+
+        # VSD verification
+        self.verify_vsp_firewall_rule(ssh_rule)
+        self.verify_vsp_firewall_rule(http_rule)
+
+        # Creating Static NAT Rule for the VM in the Public tier
+        public_ip = self.acquire_PublicIPAddress(public_tier, vpc)
+        self.validate_PublicIPAddress(public_ip, public_tier)
+        self.create_StaticNatRule_For_VM(public_vm, public_ip, public_tier)
+        self.validate_PublicIPAddress(public_ip, public_tier, static_nat=True, vm=public_vm)
+
+        # VSD verification
+        self.verify_vsp_floating_ip(public_tier, public_vm, public_ip.ipaddress, vpc)
+
+        # Adding Network ACL rule in the Public tier
+        self.debug("Adding Network ACL rule to make the created NAT rule (SSH) accessible...")
+        public_ssh_rule = self.create_NetworkAclRule(self.test_data["ingress_rule"], network=public_tier)
+
+        # VSD verification
+        self.verify_vsp_firewall_rule(public_ssh_rule)
+
+        # Internal LB (wget) traffic tests with Round Robin Algorithm
+        ssh_client = self.ssh_into_VM(public_vm, public_ip)
+        self.validate_internallb_algorithm_traffic(ssh_client,
+                                                   int_lb_rule_1.sourceipaddress,
+                                                   self.test_data["http_rule"]["publicport"],
+                                                   [internal_vm, internal_vm_1, internal_vm_2],
+                                                   "roundrobin"
+                                                   )
+
+        # Internal LB (wget) traffic tests with Least connections Algorithm
+        ssh_client = self.ssh_into_VM(public_vm, public_ip)
+        self.validate_internallb_algorithm_traffic(ssh_client,
+                                                   int_lb_rule_3.sourceipaddress,
+                                                   self.test_data["http_rule"]["publicport"],
+                                                   [internal_vm, internal_vm_1, internal_vm_2],
+                                                   "leastconn"
+                                                   )
+
+        # Internal LB (wget) traffic tests with Source Algorithm
+        ssh_client = self.ssh_into_VM(public_vm, public_ip)
+        self.validate_internallb_algorithm_traffic(ssh_client,
+                                                   int_lb_rule_5.sourceipaddress,
+                                                   self.test_data["http_rule"]["publicport"],
+                                                   [internal_vm, internal_vm_1, internal_vm_2],
+                                                   "source"
+                                                   )
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="true")
+    def test_07_nuage_internallb_vpc_network_restarts_traffic(self):
+        """Test Nuage VSP VPC Internal LB functionality with restarts of VPC network components by performing (wget)
+        traffic tests within a VPC
+        """
+
+        # Repeat the tests in the testcase "test_05_nuage_internallb_traffic" with restarts of VPC networks (tiers):
+        # 1. Restart tier with InternalLbVm (cleanup = false), verify that the InternalLbVm gets destroyed and deployed
+        #    again in the Internal tier.
+        # 2. Restart tier with InternalLbVm (cleanup = true), verify that the InternalLbVm gets destroyed and deployed
+        #    again in the Internal tier.
+        # 3. Restart tier without InternalLbVm (cleanup = false), verify that this restart has no effect on the
+        #    InternalLbVm functionality.
+        # 4. Restart tier without InternalLbVm (cleanup = true), verify that this restart has no effect on the
+        #    InternalLbVm functionality.
+        # 5. Stop all the VMs configured with InternalLbVm, verify that the InternalLbVm gets destroyed in the Internal
+        #    tier.
+        # 6. Start all the VMs configured with InternalLbVm, verify that the InternalLbVm gets deployed again in the
+        #    Internal tier.
+        # 7. Restart VPC, verify that the VPC VR gets rebooted and this restart has no effect on the InternalLbVm
+        #    functionality.
+        # Verify the above restarts of VPC networks (tiers) by performing (wget) traffic tests within a VPC.
+
+        # Creating a VPC offering
+        self.debug("Creating Nuage VSP VPC offering with Internal LB service...")
+        vpc_off = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering_lb"])
+        self.validate_VpcOffering(vpc_off, state="Enabled")
+
+        # Creating a VPC
+        self.debug("Creating a VPC with Internal LB service...")
+        vpc = self.create_Vpc(vpc_off, cidr='10.1.0.0/16')
+        self.validate_Vpc(vpc, state="Enabled")
+
+        # Creating network offerings
+        self.debug("Creating Nuage VSP VPC Network offering with Internal LB service...")
+        net_off_1 = self.create_NetworkOffering(
+            self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"])
+        self.validate_NetworkOffering(net_off_1, state="Enabled")
+
+        self.debug("Creating Nuage VSP VPC Network offering without Internal LB service...")
+        net_off_2 = self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering"])
+        self.validate_NetworkOffering(net_off_2, state="Enabled")
+
+        # Creating VPC networks in the VPC, and deploying VMs
+        self.debug("Creating a VPC network with Internal LB service...")
+        internal_tier = self.create_Network(net_off_1, gateway='10.1.1.1', vpc=vpc)
+        self.validate_Network(internal_tier, state="Implemented")
+        vr = self.get_Router(internal_tier)
+        self.check_Router_state(vr, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % internal_tier.name)
+        internal_vm = self.create_VM(internal_tier)
+        self.check_VM_state(internal_vm, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(internal_vm)
+
+        self.debug("Creating a VPC network without Internal LB service...")
+        public_tier = self.create_Network(net_off_2, gateway='10.1.2.1', vpc=vpc)
+        self.validate_Network(public_tier, state="Implemented")
+        vr = self.get_Router(public_tier)
+        self.check_Router_state(vr, state="Running")
+
+        self.debug("Deploying a VM in network - %s" % public_tier.name)
+        public_vm = self.create_VM(public_tier)
+        self.check_VM_state(public_vm, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, public_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(public_vm)
+
+        # Creating Internal LB Rules in the Internal tier
+        self.debug("Creating two Internal LB Rules (SSH & HTTP) using the same Load Balancing source IP Address...")
+        int_lb_rule_1 = self.create_Internal_LB_Rule(internal_tier, vm_array=[internal_vm])
+        self.validate_Internal_LB_Rule(int_lb_rule_1, state="Active", vm_array=[internal_vm])
+        int_lb_rule_2 = self.create_Internal_LB_Rule(internal_tier,
+                                                     vm_array=[internal_vm],
+                                                     services=self.test_data["internal_lbrule_http"],
+                                                     source_ip=int_lb_rule_1.sourceipaddress
+                                                     )
+        self.validate_Internal_LB_Rule(int_lb_rule_2, state="Active", vm_array=[internal_vm])
+
+        # Validating InternalLbVm deployment and state
+        int_lb_vm = self.get_InternalLbVm(internal_tier, int_lb_rule_1.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm)
+
+        # Deploying more VMs in the Internal tier
+        self.debug("Deploying two more VMs in network - %s" % internal_tier.name)
+        internal_vm_1 = self.create_VM(internal_tier)
+        internal_vm_2 = self.create_VM(internal_tier)
+
+        # VSD verification
+        self.verify_vsp_vm(internal_vm_1)
+        self.verify_vsp_vm(internal_vm_2)
+
+        # Adding newly deployed VMs to the created Internal LB rules
+        self.debug("Adding two more virtual machines to the created Internal LB rules...")
+        int_lb_rule_1.assign(self.api_client, [internal_vm_1, internal_vm_2])
+        self.validate_Internal_LB_Rule(int_lb_rule_1, state="Active",
+                                       vm_array=[internal_vm, internal_vm_1, internal_vm_2])
+        int_lb_rule_2.assign(self.api_client, [internal_vm_1, internal_vm_2])
+        self.validate_Internal_LB_Rule(int_lb_rule_2, state="Active",
+                                       vm_array=[internal_vm, internal_vm_1, internal_vm_2])
+
+        # Validating InternalLbVm state
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm)
+
+        # Adding Network ACL rules in the Internal tier
+        self.debug("Adding Network ACL rules to make the created Internal LB rules (SSH & HTTP) accessible...")
+        ssh_rule = self.create_NetworkAclRule(self.test_data["ingress_rule"], network=internal_tier)
+        http_rule = self.create_NetworkAclRule(self.test_data["http_rule"], network=internal_tier)
+
+        # VSD verification
+        self.verify_vsp_firewall_rule(ssh_rule)
+        self.verify_vsp_firewall_rule(http_rule)
+
+        # Creating Static NAT Rule for the VM in the Public tier
+        public_ip = self.acquire_PublicIPAddress(public_tier, vpc)
+        self.validate_PublicIPAddress(public_ip, public_tier)
+        self.create_StaticNatRule_For_VM(public_vm, public_ip, public_tier)
+        self.validate_PublicIPAddress(public_ip, public_tier, static_nat=True, vm=public_vm)
+
+        # VSD verification
+        self.verify_vsp_floating_ip(public_tier, public_vm, public_ip.ipaddress, vpc)
+
+        # Adding Network ACL rule in the Public tier
+        self.debug("Adding Network ACL rule to make the created NAT rule (SSH) accessible...")
+        public_ssh_rule = self.create_NetworkAclRule(self.test_data["ingress_rule"], network=public_tier)
+
+        # VSD verification
+        self.verify_vsp_firewall_rule(public_ssh_rule)
+
+        # Internal LB (wget) traffic test
+        ssh_client = self.ssh_into_VM(public_vm, public_ip)
+        wget_file = self.wget_from_vm_cmd(ssh_client,
+                                          int_lb_rule_1.sourceipaddress,
+                                          self.test_data["http_rule"]["publicport"]
+                                          )
+
+        # Verifying Internal LB (wget) traffic test
+        self.verify_lb_wget_file(wget_file, [internal_vm, internal_vm_1, internal_vm_2])
+
+        # Restart Internal tier (cleanup = false)
+        # InternalLbVm gets destroyed and deployed again in the Internal tier
+        self.debug("Restarting the Internal tier without cleanup...")
+        Network.restart(internal_tier, self.api_client, cleanup=False)
+        self.validate_Network(internal_tier, state="Implemented")
+        self.check_Router_state(vr, state="Running")
+        self.check_VM_state(internal_vm, state="Running")
+        self.check_VM_state(internal_vm_1, state="Running")
+        self.check_VM_state(internal_vm_2, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(internal_vm)
+        self.verify_vsp_vm(internal_vm_1)
+        self.verify_vsp_vm(internal_vm_2)
+        self.verify_vsp_firewall_rule(ssh_rule)
+        self.verify_vsp_firewall_rule(http_rule)
+
+        # Validating InternalLbVm state
+        # InternalLbVm gets destroyed and deployed again in the Internal tier
+        int_lb_vm = self.get_InternalLbVm(internal_tier, int_lb_rule_1.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm)
+
+        # Internal LB (wget) traffic test
+        ssh_client = self.ssh_into_VM(public_vm, public_ip)
+        tries = 0
+        while True:
+            try:
+                wget_file = self.wget_from_vm_cmd(ssh_client,
+                                                  int_lb_rule_1.sourceipaddress,
+                                                  self.test_data["http_rule"]["publicport"]
+                                                  )
+            except Exception as e:
+                self.debug("Failed to wget file via the InternalLbVm after re-starting the Internal tier: %s" % e)
+                if tries == 10:
+                    break
+                self.debug("Waiting for the InternalLbVm in the Internal tier to be fully resolved for (wget) traffic "
+                           "test...")
+                time.sleep(30)
+                tries += 1
+                continue
+            self.debug("Internal LB (wget) traffic test is successful after re-starting the Internal tier")
+            break
+
+        # Verifying Internal LB (wget) traffic test
+        self.verify_lb_wget_file(wget_file, [internal_vm, internal_vm_1, internal_vm_2])
+
+        # Restart Internal tier (cleanup = true)
+        # InternalLbVm gets destroyed and deployed again in the Internal tier
+        self.debug("Restarting the Internal tier with cleanup...")
+        Network.restart(internal_tier, self.api_client, cleanup=True)
+        self.validate_Network(internal_tier, state="Implemented")
+        self.check_Router_state(vr, state="Running")
+        self.check_VM_state(internal_vm, state="Running")
+        self.check_VM_state(internal_vm_1, state="Running")
+        self.check_VM_state(internal_vm_2, state="Running")
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, internal_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(internal_vm)
+        self.verify_vsp_vm(internal_vm_1)
+        self.verify_vsp_vm(internal_vm_2)
+        self.verify_vsp_firewall_rule(ssh_rule)
+        self.verify_vsp_firewall_rule(http_rule)
+
+        # Validating InternalLbVm state
+        # InternalLbVm gets destroyed and deployed again in the Internal tier
+        int_lb_vm = self.get_InternalLbVm(internal_tier, int_lb_rule_1.sourceipaddress)
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm)
+
+        # Internal LB (wget) traffic test
+        ssh_client = self.ssh_into_VM(public_vm, public_ip)
+        tries = 0
+        while True:
+            try:
+                wget_file = self.wget_from_vm_cmd(ssh_client,
+                                                  int_lb_rule_1.sourceipaddress,
+                                                  self.test_data["http_rule"]["publicport"]
+                                                  )
+            except Exception as e:
+                self.debug("Failed to wget file via the InternalLbVm after re-starting the Internal tier with cleanup: "
+                           "%s" % e)
+                if tries == 10:
+                    break
+                self.debug("Waiting for the InternalLbVm in the Internal tier to be fully resolved for (wget) traffic "
+                           "test...")
+                time.sleep(30)
+                tries += 1
+                continue
+            self.debug("Internal LB (wget) traffic test is successful after re-starting the Internal tier with cleanup")
+            break
+
+        # Verifying Internal LB (wget) traffic test
+        self.verify_lb_wget_file(wget_file, [internal_vm, internal_vm_1, internal_vm_2])
+
+        # Restart Public tier (cleanup = false)
+        # This restart has no effect on the InternalLbVm functionality
+        self.debug("Restarting the Public tier without cleanup...")
+        Network.restart(public_tier, self.api_client, cleanup=False)
+        self.validate_Network(public_tier, state="Implemented")
+        self.check_Router_state(vr, state="Running")
+        self.check_VM_state(public_vm, state="Running")
+        self.validate_PublicIPAddress(public_ip, public_tier, static_nat=True, vm=public_vm)
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, public_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(public_vm)
+        self.verify_vsp_floating_ip(public_tier, public_vm, public_ip.ipaddress, vpc)
+        self.verify_vsp_firewall_rule(public_ssh_rule)
+
+        # Validating InternalLbVm state
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceipaddress, state="Running")
+
+        # VSD Verification
+        self.verify_vsp_LB_device(int_lb_vm)
+
+        # Internal LB (wget) traffic test
+        ssh_client = self.ssh_into_VM(public_vm, public_ip)
+        wget_file = self.wget_from_vm_cmd(ssh_client,
+                                          int_lb_rule_1.sourceipaddress,
+                                          self.test_data["http_rule"]["publicport"]
+                                          )
+
+        # Verifying Internal LB (wget) traffic test
+        self.verify_lb_wget_file(wget_file, [internal_vm, internal_vm_1, internal_vm_2])
+
+        # Restart Public tier (cleanup = true)
+        # This restart has no effect on the InternalLbVm functionality
+        self.debug("Restarting the Public tier with cleanup...")
+        Network.restart(public_tier, self.api_client, cleanup=True)
+        self.validate_Network(public_tier, state="Implemented")
+        self.check_Router_state(vr, state="Running")
+        self.check_VM_state(public_vm, state="Running")
+        self.validate_PublicIPAddress(public_ip, public_tier, static_nat=True, vm=public_vm)
+
+        # VSD verification
+        self.verify_vsp_network(self.domain.id, public_tier, vpc)
+        self.verify_vsp_router(vr)
+        self.verify_vsp_vm(public_vm)
+        self.verify_vsp_floating_ip(public_tier, public_vm, public_ip.ipaddress, vpc)
+        self.verify_vsp_firewall_rule(public_ssh_rule)
+
+        # Validating InternalLbVm state
+        self.check_InternalLbVm_state(internal_tier, int_lb_rule_1.sourceip

<TRUNCATED>

[15/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Fixed: Error given when creating VPN user in one network if VR for another network is stopped


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: e5e226e549e0224a3f6ddf4cc570e983d1cb9292
Parents: 3393555
Author: Kshitij Kansal <ka...@gmail.com>
Authored: Tue Sep 15 14:42:29 2015 +0530
Committer: Kshitij Kansal <ka...@gmail.com>
Committed: Thu Apr 21 12:06:36 2016 +0530

----------------------------------------------------------------------
 .../cloudstack/network/topology/BasicNetworkTopology.java      | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e5e226e5/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java b/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
index 2b88737..0869b22 100644
--- a/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
+++ b/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
@@ -278,7 +278,11 @@ public class BasicNetworkTopology implements NetworkTopology {
         boolean agentResults = true;
 
         for (final DomainRouterVO router : routers) {
-            if (router.getState() != State.Running) {
+            if(router.getState() == State.Stopped || router.getState() == State.Stopping){
+                s_logger.info("The router " + router.getInstanceName()+ " is in the " + router.getState() + " state. So not applying the VPN rules. Will be applied once the router gets restarted.");
+                continue;
+            }
+            else if (router.getState() != State.Running) {
                 s_logger.warn("Failed to add/remove VPN users: router not in running state");
                 throw new ResourceUnavailableException("Unable to assign ip addresses, domR is not in right state " + router.getState(), DataCenter.class,
                         network.getDataCenterId());


[32/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1510 from shapeblue/4.9-mvn-version-safeupgradeonly

4.9 mvn version safeupgradeonlyUpgrades maven dependencies versions that can be safely upgraded without breaking console-proxy/crypto usage.

Bisected changes from: https://github.com/apache/cloudstack/pull/1397

cc @swill @DaanHoogland

* pr/1510:
  maven: fix dependency version support by JDK7
  further maven dependency updates from Daan
  framework/quota: fix checkstyle issue
  maven: Upgrade dependency versions

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 4db5e48f8044fc9dff2c457322d49d70640b925e
Parents: ad61d49 8af677a
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 15:59:17 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 15:59:17 2016 -0400

----------------------------------------------------------------------
 client/pom.xml                                  |   6 +-
 engine/api/pom.xml                              |   2 +-
 engine/service/pom.xml                          |  15 +--
 .../cloudstack/quota/QuotaStatementImpl.java    |   8 +-
 .../cloudstack/quota/QuotaStatementTest.java    |  22 ++--
 framework/rest/pom.xml                          |  14 +-
 plugins/event-bus/kafka/pom.xml                 |   2 +-
 plugins/event-bus/rabbitmq/pom.xml              |   2 +-
 plugins/hypervisors/hyperv/pom.xml              |   5 -
 plugins/network-elements/globodns/pom.xml       |   2 +-
 .../network-elements/juniper-contrail/pom.xml   |   2 +-
 plugins/network-elements/netscaler/pom.xml      |   4 +-
 plugins/storage/volume/cloudbyte/pom.xml        |   2 +-
 plugins/user-authenticators/ldap/pom.xml        |   6 +-
 plugins/user-authenticators/saml2/pom.xml       |  11 +-
 pom.xml                                         | 132 ++++++++++++-------
 server/pom.xml                                  |   5 +-
 services/console-proxy-rdp/rdpconsole/pom.xml   |   3 +-
 services/secondary-storage/server/pom.xml       |   2 +-
 tools/checkstyle/pom.xml                        |   7 +-
 tools/whisker/LICENSE                           |   2 +-
 tools/whisker/descriptor-for-packaging.xml      |   4 +-
 usage/pom.xml                                   |   6 +-
 utils/pom.xml                                   |   4 +-
 24 files changed, 146 insertions(+), 122 deletions(-)
----------------------------------------------------------------------



[11/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Modified test_volumes.py to include a hypervisor test for root attach/detach testing


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: ec7a86b2de6716f1fa9d7ba2d10fe82d9e83c4f6
Parents: 0b7cc08
Author: David Mabry <dm...@ena.com>
Authored: Tue Apr 19 08:21:18 2016 -0500
Committer: David Mabry <dm...@ena.com>
Committed: Tue Apr 19 09:28:57 2016 -0500

----------------------------------------------------------------------
 test/integration/component/test_volumes.py | 244 ++++++++++++------------
 1 file changed, 127 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ec7a86b2/test/integration/component/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py
index 941e225..1b1773c 100644
--- a/test/integration/component/test_volumes.py
+++ b/test/integration/component/test_volumes.py
@@ -613,124 +613,134 @@ class TestAttachDetachVolume(cloudstackTestCase):
 
         # Validate the following
         # 1. Deploy a VM
-        # 2. Check for root volume
-        # 3. Stop VM
-        # 4. Detach root volume
-        # 5. Verify root volume detached
-        # 6. Attach root volume
-        # 7. Start VM
+        # 2. Verify that we are testing a supported hypervisor
+        # 3. Check for root volume
+        # 4. Stop VM
+        # 5. Detach root volume
+        # 6. Verify root volume detached
+        # 7. Attach root volume
+        # 8. Start VM
         
-        try:
-            # Check for root volume
-            root_volume_response = Volume.list(
-                self.apiclient,
-                virtualmachineid=self.virtual_machine.id,
-                type='ROOT',
-                listall=True
-            )
-            self.assertNotEqual(
-                root_volume_response,
-                None,
-                "Check if root volume exists in ListVolumes"
-            )
-            self.assertEqual(
-                isinstance(root_volume_response, list),
-                True,
-                "Check list volumes response for valid list"
-            )
-            # Grab the root volume for later use
-            root_volume = root_volume_response[0]
-            
-            # Stop VM
-            self.debug("Stopping the VM: %s" % self.virtual_machine.id)
-            self.virtual_machine.stop(self.apiclient)
-            
-            # Ensure VM is stopped before detaching the root volume
-            time.sleep(self.services["sleep"])
-
-            vm_response = VirtualMachine.list(
-                self.apiclient,
-                id=self.virtual_machine.id,
-            )
-            vm = vm_response[0]
-            self.assertEqual(
-                vm.state,
-                'Stopped',
-                "Check the state of VM"
-            )
-            
-            # Detach root volume from VM
-            self.virtual_machine.detach_volume(
-                self.apiclient,
-                root_volume
-            )
-            
-            # Verify that root disk is gone
-            no_root_volume_response = Volume.list(
-                self.apiclient,
-                virtualmachineid=self.virtual_machine.id,
-                type='ROOT',
-                listall=True
-            )
-            self.assertEqual(
-                no_root_volume_response,
-                None,
-                "Check if root volume exists in ListVolumes"
-            )
-            
-            # Attach root volume to VM
-            self.virtual_machine.attach_volume(
-                self.apiclient,
-                root_volume,
-                0
-            )
-            
-            # Check for root volume
-            new_root_volume_response = Volume.list(
-                self.apiclient,
-                virtualmachineid=self.virtual_machine.id,
-                type='ROOT',
-                listall=True
-            )
-            self.assertNotEqual(
-                new_root_volume_response,
-                None,
-                "Check if root volume exists in ListVolumes"
-            )
-            self.assertEqual(
-                isinstance(new_root_volume_response, list),
-                True,
-                "Check list volumes response for valid list"
-            )
-            
-            # Start VM
-            self.virtual_machine.start(self.apiclient)
-            # Sleep to ensure that VM is in ready state
-            time.sleep(self.services["sleep"])
-
-            vm_response = VirtualMachine.list(
-                self.apiclient,
-                id=self.virtual_machine.id,
-            )
-            # Verify VM response to check whether VM deployment was successful
-            self.assertEqual(
-                isinstance(vm_response, list),
-                True,
-                "Check list VM response for valid list"
-            )
-            self.assertNotEqual(
-                len(vm_response),
-                0,
-                "Check VMs available in List VMs response"
-            )
-            vm = vm_response[0]
-            self.assertEqual(
-                vm.state,
-                'Running',
-                "Check the state of VM"
-            )
-        except Exception as e:
-            self.fail("Exception occurred: %s" % e)
+        # Verify we are using a supported hypervisor
+        if (self.hypervisor.lower() == 'vmware'
+                or self.hypervisor.lower() == 'kvm'
+                or self.hypervisor.lower() == 'simulator'
+                or self.hypervisor.lower() == 'xenserver'):
+        
+            try:
+                # Check for root volume
+                root_volume_response = Volume.list(
+                    self.apiclient,
+                    virtualmachineid=self.virtual_machine.id,
+                    type='ROOT',
+                    listall=True
+                )
+                self.assertNotEqual(
+                    root_volume_response,
+                    None,
+                    "Check if root volume exists in ListVolumes"
+                )
+                self.assertEqual(
+                    isinstance(root_volume_response, list),
+                    True,
+                    "Check list volumes response for valid list"
+                )
+                # Grab the root volume for later use
+                root_volume = root_volume_response[0]
+                
+                # Stop VM
+                self.debug("Stopping the VM: %s" % self.virtual_machine.id)
+                self.virtual_machine.stop(self.apiclient)
+                
+                # Ensure VM is stopped before detaching the root volume
+                time.sleep(self.services["sleep"])
+    
+                vm_response = VirtualMachine.list(
+                    self.apiclient,
+                    id=self.virtual_machine.id,
+                )
+                vm = vm_response[0]
+                self.assertEqual(
+                    vm.state,
+                    'Stopped',
+                    "Check the state of VM"
+                )
+                
+                # Detach root volume from VM
+                self.virtual_machine.detach_volume(
+                    self.apiclient,
+                    root_volume
+                )
+                
+                # Verify that root disk is gone
+                no_root_volume_response = Volume.list(
+                    self.apiclient,
+                    virtualmachineid=self.virtual_machine.id,
+                    type='ROOT',
+                    listall=True
+                )
+                self.assertEqual(
+                    no_root_volume_response,
+                    None,
+                    "Check if root volume exists in ListVolumes"
+                )
+                
+                # Attach root volume to VM
+                self.virtual_machine.attach_volume(
+                    self.apiclient,
+                    root_volume,
+                    0
+                )
+                
+                # Check for root volume
+                new_root_volume_response = Volume.list(
+                    self.apiclient,
+                    virtualmachineid=self.virtual_machine.id,
+                    type='ROOT',
+                    listall=True
+                )
+                self.assertNotEqual(
+                    new_root_volume_response,
+                    None,
+                    "Check if root volume exists in ListVolumes"
+                )
+                self.assertEqual(
+                    isinstance(new_root_volume_response, list),
+                    True,
+                    "Check list volumes response for valid list"
+                )
+                
+                # Start VM
+                self.virtual_machine.start(self.apiclient)
+                # Sleep to ensure that VM is in ready state
+                time.sleep(self.services["sleep"])
+    
+                vm_response = VirtualMachine.list(
+                    self.apiclient,
+                    id=self.virtual_machine.id,
+                )
+                # Verify VM response to check whether VM deployment was successful
+                self.assertEqual(
+                    isinstance(vm_response, list),
+                    True,
+                    "Check list VM response for valid list"
+                )
+                self.assertNotEqual(
+                    len(vm_response),
+                    0,
+                    "Check VMs available in List VMs response"
+                )
+                vm = vm_response[0]
+                self.assertEqual(
+                    vm.state,
+                    'Running',
+                    "Check the state of VM"
+                )
+            except Exception as e:
+                self.fail("Exception occurred: %s" % e)
+                
+        else:
+            self.skipTest("Root Volume attach/detach is not supported on %s " % self.hypervisor)
         return
 
 


[43/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
maven: upgrade bounty castle version to 1.54

Upgrades bountycastle dependency version to bcprov-15on v1.54


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 956fd5d7464556727b1ccd13979f16d47427aeee
Parents: e762e27
Author: Daan Hoogland <da...@onecht.net>
Authored: Fri Apr 22 16:28:33 2016 +0530
Committer: Daan Hoogland <da...@onecht.net>
Committed: Mon May 2 16:32:26 2016 +0200

----------------------------------------------------------------------
 .../network/resource/NetscalerResource.java     | 1225 ++++++++----------
 pom.xml                                         |    2 +-
 .../cloudstack/network/lb/CertServiceImpl.java  |  255 ++--
 .../cloudstack/network/lb/CertServiceTest.java  |  367 +++---
 .../cloud/utils/security/CertificateHelper.java |   69 +-
 5 files changed, 918 insertions(+), 1000 deletions(-)
----------------------------------------------------------------------



[10/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Let hypervisor type KVM and Simulator detach root volumes.
Updated test_volumes.py to include a test for detaching and reattaching a root volume from a vm. I also had to update base.py to allow attach_volume to have the parameter deviceid to be passed as needed.


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 0b7cc087f81ede19ac9daaaf63aa73f2a2ab789d
Parents: 48ce763
Author: David Mabry <dm...@ena.com>
Authored: Mon Apr 18 15:40:36 2016 -0500
Committer: David Mabry <dm...@ena.com>
Committed: Mon Apr 18 15:40:36 2016 -0500

----------------------------------------------------------------------
 .../com/cloud/storage/VolumeApiServiceImpl.java |   4 +-
 test/integration/component/test_volumes.py      | 129 ++++++++++++++++++-
 tools/marvin/marvin/lib/base.py                 |   6 +-
 3 files changed, 135 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0b7cc087/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 5a53f9c..6a59f54 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1744,8 +1744,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
     }
 
     private void validateRootVolumeDetachAttach(VolumeVO volume, UserVmVO vm) {
-        if (!(vm.getHypervisorType() == HypervisorType.XenServer || vm.getHypervisorType() == HypervisorType.VMware)) {
-            throw new InvalidParameterValueException("Root volume detach is allowed for hypervisor type " + HypervisorType.XenServer + " only");
+        if (!(vm.getHypervisorType() == HypervisorType.XenServer || vm.getHypervisorType() == HypervisorType.VMware || vm.getHypervisorType() == HypervisorType.KVM || vm.getHypervisorType() == HypervisorType.Simulator)) {
+            throw new InvalidParameterValueException("Root volume detach is not supported for hypervisor type " + vm.getHypervisorType() );
         }
         if (!(vm.getState() == State.Stopped) || (vm.getState() == State.Destroyed)) {
             throw new InvalidParameterValueException("Root volume detach can happen only when vm is in states: " + State.Stopped.toString() + " or " + State.Destroyed.toString());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0b7cc087/test/integration/component/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py
index 12c8f9d..941e225 100644
--- a/test/integration/component/test_volumes.py
+++ b/test/integration/component/test_volumes.py
@@ -603,7 +603,134 @@ class TestAttachDetachVolume(cloudstackTestCase):
                 "Check the state of VM"
             )
         except Exception as e:
-            self.fail("Exception occuered: %s" % e)
+            self.fail("Exception occurred: %s" % e)
+        return
+    
+    @attr(tags=["advanced", "advancedns"])
+    def test_02_root_volume_attach_detach(self):
+        """Test Root Volume attach/detach to VM
+        """
+
+        # Validate the following
+        # 1. Deploy a VM
+        # 2. Check for root volume
+        # 3. Stop VM
+        # 4. Detach root volume
+        # 5. Verify root volume detached
+        # 6. Attach root volume
+        # 7. Start VM
+        
+        try:
+            # Check for root volume
+            root_volume_response = Volume.list(
+                self.apiclient,
+                virtualmachineid=self.virtual_machine.id,
+                type='ROOT',
+                listall=True
+            )
+            self.assertNotEqual(
+                root_volume_response,
+                None,
+                "Check if root volume exists in ListVolumes"
+            )
+            self.assertEqual(
+                isinstance(root_volume_response, list),
+                True,
+                "Check list volumes response for valid list"
+            )
+            # Grab the root volume for later use
+            root_volume = root_volume_response[0]
+            
+            # Stop VM
+            self.debug("Stopping the VM: %s" % self.virtual_machine.id)
+            self.virtual_machine.stop(self.apiclient)
+            
+            # Ensure VM is stopped before detaching the root volume
+            time.sleep(self.services["sleep"])
+
+            vm_response = VirtualMachine.list(
+                self.apiclient,
+                id=self.virtual_machine.id,
+            )
+            vm = vm_response[0]
+            self.assertEqual(
+                vm.state,
+                'Stopped',
+                "Check the state of VM"
+            )
+            
+            # Detach root volume from VM
+            self.virtual_machine.detach_volume(
+                self.apiclient,
+                root_volume
+            )
+            
+            # Verify that root disk is gone
+            no_root_volume_response = Volume.list(
+                self.apiclient,
+                virtualmachineid=self.virtual_machine.id,
+                type='ROOT',
+                listall=True
+            )
+            self.assertEqual(
+                no_root_volume_response,
+                None,
+                "Check if root volume exists in ListVolumes"
+            )
+            
+            # Attach root volume to VM
+            self.virtual_machine.attach_volume(
+                self.apiclient,
+                root_volume,
+                0
+            )
+            
+            # Check for root volume
+            new_root_volume_response = Volume.list(
+                self.apiclient,
+                virtualmachineid=self.virtual_machine.id,
+                type='ROOT',
+                listall=True
+            )
+            self.assertNotEqual(
+                new_root_volume_response,
+                None,
+                "Check if root volume exists in ListVolumes"
+            )
+            self.assertEqual(
+                isinstance(new_root_volume_response, list),
+                True,
+                "Check list volumes response for valid list"
+            )
+            
+            # Start VM
+            self.virtual_machine.start(self.apiclient)
+            # Sleep to ensure that VM is in ready state
+            time.sleep(self.services["sleep"])
+
+            vm_response = VirtualMachine.list(
+                self.apiclient,
+                id=self.virtual_machine.id,
+            )
+            # Verify VM response to check whether VM deployment was successful
+            self.assertEqual(
+                isinstance(vm_response, list),
+                True,
+                "Check list VM response for valid list"
+            )
+            self.assertNotEqual(
+                len(vm_response),
+                0,
+                "Check VMs available in List VMs response"
+            )
+            vm = vm_response[0]
+            self.assertEqual(
+                vm.state,
+                'Running',
+                "Check the state of VM"
+            )
+        except Exception as e:
+            self.fail("Exception occurred: %s" % e)
         return
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0b7cc087/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py
index 4e04ba8..5d81e5f 100755
--- a/tools/marvin/marvin/lib/base.py
+++ b/tools/marvin/marvin/lib/base.py
@@ -667,11 +667,15 @@ class VirtualMachine:
             })
         apiclient.migrateVirtualMachineWithVolume(cmd)
 
-    def attach_volume(self, apiclient, volume):
+    def attach_volume(self, apiclient, volume, deviceid=None):
         """Attach volume to instance"""
         cmd = attachVolume.attachVolumeCmd()
         cmd.id = volume.id
         cmd.virtualmachineid = self.id
+
+        if deviceid is not None:
+            cmd.deviceid = deviceid
+
         return apiclient.attachVolume(cmd)
 
     def detach_volume(self, apiclient, volume):


[41/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/956fd5d7/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 01828d4..17aeed1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,7 +63,7 @@
     <!-- do not forget to also upgrade hamcrest library with junit -->
     <cs.junit.version>4.12</cs.junit.version>
     <cs.hamcrest.version>1.3</cs.hamcrest.version>
-    <cs.bcprov.version>1.46</cs.bcprov.version>
+    <cs.bcprov.version>1.54</cs.bcprov.version>
     <cs.jsch.version>0.1.53</cs.jsch.version>
     <cs.jpa.version>2.1.1</cs.jpa.version>
     <cs.jasypt.version>1.9.2</cs.jasypt.version>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/956fd5d7/server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java b/server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java
index 8315bee..b9ebba9 100644
--- a/server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java
+++ b/server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java
@@ -16,15 +16,15 @@
 // under the License.
 package org.apache.cloudstack.network.lb;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.StringReader;
 import java.security.InvalidAlgorithmParameterException;
 import java.security.InvalidKeyException;
-import java.security.KeyPair;
+import java.security.KeyFactory;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchProviderException;
-import java.security.Principal;
 import java.security.PrivateKey;
 import java.security.PublicKey;
 import java.security.SecureRandom;
@@ -34,11 +34,15 @@ import java.security.cert.CertPathBuilderException;
 import java.security.cert.CertStore;
 import java.security.cert.Certificate;
 import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
 import java.security.cert.CollectionCertStoreParameters;
 import java.security.cert.PKIXBuilderParameters;
 import java.security.cert.TrustAnchor;
 import java.security.cert.X509CertSelector;
 import java.security.cert.X509Certificate;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -60,11 +64,11 @@ import org.apache.cloudstack.context.CallContext;
 import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.openssl.PEMReader;
-import org.bouncycastle.openssl.PasswordFinder;
+import org.bouncycastle.util.io.pem.PemObject;
+import org.bouncycastle.util.io.pem.PemReader;
 
-import com.cloud.domain.dao.DomainDao;
 import com.cloud.domain.DomainVO;
+import com.cloud.domain.dao.DomainDao;
 import com.cloud.event.ActionEvent;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
@@ -83,6 +87,7 @@ import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.security.CertificateHelper;
 
 @Local(value = {CertService.class})
 public class CertServiceImpl implements CertService {
@@ -113,35 +118,35 @@ public class CertServiceImpl implements CertService {
     @ActionEvent(eventType = EventTypes.EVENT_LB_CERT_UPLOAD, eventDescription = "Uploading a certificate to cloudstack", async = false)
     public SslCertResponse uploadSslCert(UploadSslCertCmd certCmd) {
         try {
-            String cert = certCmd.getCert();
-            String key = certCmd.getKey();
-            String password = certCmd.getPassword();
-            String chain = certCmd.getChain();
+            final String cert = certCmd.getCert();
+            final String key = certCmd.getKey();
+            final String password = certCmd.getPassword();
+            final String chain = certCmd.getChain();
 
             validate(cert, key, password, chain);
             s_logger.debug("Certificate Validation succeeded");
 
-            String fingerPrint = generateFingerPrint(parseCertificate(cert));
+            final String fingerPrint = generateFingerPrint(parseCertificate(cert));
 
-            CallContext ctx = CallContext.current();
-            Account caller = ctx.getCallingAccount();
+            final CallContext ctx = CallContext.current();
+            final Account caller = ctx.getCallingAccount();
 
             Account owner = null;
-            if ((certCmd.getAccountName() != null && certCmd.getDomainId() != null) || certCmd.getProjectId() != null) {
+            if (certCmd.getAccountName() != null && certCmd.getDomainId() != null || certCmd.getProjectId() != null) {
                 owner = _accountMgr.finalizeOwner(caller, certCmd.getAccountName(), certCmd.getDomainId(), certCmd.getProjectId());
             } else {
                 owner = caller;
             }
 
-            Long accountId = owner.getId();
-            Long domainId = owner.getDomainId();
+            final Long accountId = owner.getId();
+            final Long domainId = owner.getDomainId();
 
-            SslCertVO certVO = new SslCertVO(cert, key, password, chain, accountId, domainId, fingerPrint);
+            final SslCertVO certVO = new SslCertVO(cert, key, password, chain, accountId, domainId, fingerPrint);
             _sslCertDao.persist(certVO);
 
             return createCertResponse(certVO, null);
 
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new CloudRuntimeException("Error parsing certificate data " + e.getMessage());
         }
 
@@ -152,24 +157,24 @@ public class CertServiceImpl implements CertService {
     @ActionEvent(eventType = EventTypes.EVENT_LB_CERT_DELETE, eventDescription = "Deleting a certificate to cloudstack", async = false)
     public void deleteSslCert(DeleteSslCertCmd deleteSslCertCmd) {
 
-        CallContext ctx = CallContext.current();
-        Account caller = ctx.getCallingAccount();
+        final CallContext ctx = CallContext.current();
+        final Account caller = ctx.getCallingAccount();
 
-        Long certId = deleteSslCertCmd.getId();
-        SslCertVO certVO = _sslCertDao.findById(certId);
+        final Long certId = deleteSslCertCmd.getId();
+        final SslCertVO certVO = _sslCertDao.findById(certId);
 
         if (certVO == null) {
             throw new InvalidParameterValueException("Invalid certificate id: " + certId);
         }
         _accountMgr.checkAccess(caller, SecurityChecker.AccessType.OperateEntry, true, certVO);
 
-        List<LoadBalancerCertMapVO> lbCertRule = _lbCertDao.listByCertId(certId);
+        final List<LoadBalancerCertMapVO> lbCertRule = _lbCertDao.listByCertId(certId);
 
-        if ((lbCertRule != null) && (!lbCertRule.isEmpty())) {
+        if (lbCertRule != null && !lbCertRule.isEmpty()) {
             String lbUuids = "";
 
-            for (LoadBalancerCertMapVO rule : lbCertRule) {
-                LoadBalancerVO lb = _entityMgr.findById(LoadBalancerVO.class, rule.getLbId());
+            for (final LoadBalancerCertMapVO rule : lbCertRule) {
+                final LoadBalancerVO lb = _entityMgr.findById(LoadBalancerVO.class, rule.getLbId());
                 lbUuids += " " + lb.getUuid();
             }
 
@@ -181,15 +186,15 @@ public class CertServiceImpl implements CertService {
 
     @Override
     public List<SslCertResponse> listSslCerts(ListSslCertsCmd listSslCertCmd) {
-        CallContext ctx = CallContext.current();
-        Account caller = ctx.getCallingAccount();
+        final CallContext ctx = CallContext.current();
+        final Account caller = ctx.getCallingAccount();
 
-        Long certId = listSslCertCmd.getCertId();
-        Long accountId = listSslCertCmd.getAccountId();
-        Long lbRuleId = listSslCertCmd.getLbId();
-        Long projectId = listSslCertCmd.getProjectId();
+        final Long certId = listSslCertCmd.getCertId();
+        final Long accountId = listSslCertCmd.getAccountId();
+        final Long lbRuleId = listSslCertCmd.getLbId();
+        final Long projectId = listSslCertCmd.getProjectId();
 
-        List<SslCertResponse> certResponseList = new ArrayList<SslCertResponse>();
+        final List<SslCertResponse> certResponseList = new ArrayList<SslCertResponse>();
 
         if (certId == null && accountId == null && lbRuleId == null && projectId == null) {
             throw new InvalidParameterValueException("Invalid parameters either certificate ID or Account ID or Loadbalancer ID or Project ID required");
@@ -214,7 +219,7 @@ public class CertServiceImpl implements CertService {
         }
 
         if (lbRuleId != null) {
-            LoadBalancer lb = _entityMgr.findById(LoadBalancerVO.class, lbRuleId);
+            final LoadBalancer lb = _entityMgr.findById(LoadBalancerVO.class, lbRuleId);
 
             if (lb == null) {
                 throw new InvalidParameterValueException("Found no loadbalancer with id: " + lbRuleId);
@@ -240,18 +245,19 @@ public class CertServiceImpl implements CertService {
         }
 
         if (projectId != null) {
-            Project project = _projectMgr.getProject(projectId);
+            final Project project = _projectMgr.getProject(projectId);
 
             if (project == null) {
                 throw new InvalidParameterValueException("Found no project with id: " + projectId);
             }
 
-            List<SslCertVO> projectCertVOList = _sslCertDao.listByAccountId(project.getProjectAccountId());
-            if (projectCertVOList == null || projectCertVOList.isEmpty())
+            final List<SslCertVO> projectCertVOList = _sslCertDao.listByAccountId(project.getProjectAccountId());
+            if (projectCertVOList == null || projectCertVOList.isEmpty()) {
                 return certResponseList;
+            }
             _accountMgr.checkAccess(caller, SecurityChecker.AccessType.UseEntry, true, projectCertVOList.get(0));
 
-            for (SslCertVO cert : projectCertVOList) {
+            for (final SslCertVO cert : projectCertVOList) {
                 certLbMap = _lbCertDao.listByCertId(cert.getId());
                 certResponseList.add(createCertResponse(cert, certLbMap));
             }
@@ -259,12 +265,13 @@ public class CertServiceImpl implements CertService {
         }
 
         //reached here look by accountId
-        List<SslCertVO> certVOList = _sslCertDao.listByAccountId(accountId);
-        if (certVOList == null || certVOList.isEmpty())
+        final List<SslCertVO> certVOList = _sslCertDao.listByAccountId(accountId);
+        if (certVOList == null || certVOList.isEmpty()) {
             return certResponseList;
+        }
         _accountMgr.checkAccess(caller, SecurityChecker.AccessType.UseEntry, true, certVOList.get(0));
 
-        for (SslCertVO cert : certVOList) {
+        for (final SslCertVO cert : certVOList) {
             certLbMap = _lbCertDao.listByCertId(cert.getId());
             certResponseList.add(createCertResponse(cert, certLbMap));
         }
@@ -281,27 +288,28 @@ public class CertServiceImpl implements CertService {
             key = parsePrivateKey(keyInput, password);
 
             if (chainInput != null) {
-                chain = parseChain(chainInput);
+                chain = CertificateHelper.parseChain(chainInput);
             }
 
-        } catch (IOException e) {
+        } catch (final IOException | CertificateException e) {
             throw new IllegalArgumentException("Parsing certificate/key failed: " + e.getMessage(), e);
         }
 
         validateCert(cert, chainInput != null ? true : false);
         validateKeys(cert.getPublicKey(), key);
 
-        if (chainInput != null)
+        if (chainInput != null) {
             validateChain(chain, cert);
+        }
     }
 
     public SslCertResponse createCertResponse(SslCertVO cert, List<LoadBalancerCertMapVO> lbCertMap) {
-        SslCertResponse response = new SslCertResponse();
+        final SslCertResponse response = new SslCertResponse();
 
-        Account account = _accountDao.findByIdIncludingRemoved(cert.getAccountId());
+        final Account account = _accountDao.findByIdIncludingRemoved(cert.getAccountId());
         if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
             // find the project
-            Project project = _projectMgr.findByProjectAccountIdIncludingRemoved(account.getId());
+            final Project project = _projectMgr.findByProjectAccountIdIncludingRemoved(account.getId());
             if (project != null)
             {
                 response.setProjectId(project.getUuid());
@@ -313,7 +321,7 @@ public class CertServiceImpl implements CertService {
             response.setAccountName(account.getAccountName());
         }
 
-        DomainVO domain = _domainDao.findByIdIncludingRemoved(cert.getDomainId());
+        final DomainVO domain = _domainDao.findByIdIncludingRemoved(cert.getDomainId());
         response.setDomainId(domain.getUuid());
         response.setDomainName(domain.getName());
 
@@ -322,13 +330,14 @@ public class CertServiceImpl implements CertService {
         response.setCertificate(cert.getCertificate());
         response.setFingerprint(cert.getFingerPrint());
 
-        if (cert.getChain() != null)
+        if (cert.getChain() != null) {
             response.setCertchain(cert.getChain());
+        }
 
         if (lbCertMap != null && !lbCertMap.isEmpty()) {
-            List<String> lbIds = new ArrayList<String>();
-            for (LoadBalancerCertMapVO mapVO : lbCertMap) {
-                LoadBalancer lb = _entityMgr.findById(LoadBalancerVO.class, mapVO.getLbId());
+            final List<String> lbIds = new ArrayList<String>();
+            for (final LoadBalancerCertMapVO mapVO : lbCertMap) {
+                final LoadBalancer lb = _entityMgr.findById(LoadBalancerVO.class, mapVO.getLbId());
                 if (lb != null) {
                     lbIds.add(lb.getUuid());
                 }
@@ -341,72 +350,77 @@ public class CertServiceImpl implements CertService {
 
     private void validateCert(Certificate cert, boolean chainPresent) {
 
-        if (!(cert instanceof X509Certificate))
+        if (!(cert instanceof X509Certificate)) {
             throw new IllegalArgumentException("Invalid certificate format. Expected X509 certificate");
+        }
 
         try {
             ((X509Certificate)cert).checkValidity();
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new IllegalArgumentException("Certificate expired or not valid", e);
         }
     }
 
     private void validateKeys(PublicKey pubKey, PrivateKey privKey) {
 
-        if (pubKey.getAlgorithm() != privKey.getAlgorithm())
+        if (pubKey.getAlgorithm() != privKey.getAlgorithm()) {
             throw new IllegalArgumentException("Public and private key have different algorithms");
+        }
 
         // No encryption for DSA
-        if (pubKey.getAlgorithm() != "RSA")
+        if (pubKey.getAlgorithm() != "RSA") {
             return;
+        }
 
         try {
 
-            String data = "ENCRYPT_DATA";
-            SecureRandom random = new SecureRandom();
-            Cipher cipher = Cipher.getInstance(pubKey.getAlgorithm());
+            final String data = "ENCRYPT_DATA";
+            final SecureRandom random = new SecureRandom();
+            final Cipher cipher = Cipher.getInstance(pubKey.getAlgorithm());
             cipher.init(Cipher.ENCRYPT_MODE, privKey, random);
-            byte[] encryptedData = cipher.doFinal(data.getBytes());
+            final byte[] encryptedData = cipher.doFinal(data.getBytes());
 
             cipher.init(Cipher.DECRYPT_MODE, pubKey, random);
-            String decreptedData = new String(cipher.doFinal(encryptedData));
-            if (!decreptedData.equals(data))
+            final String decreptedData = new String(cipher.doFinal(encryptedData));
+            if (!decreptedData.equals(data)) {
                 throw new IllegalArgumentException("Bad public-private key");
+            }
 
-        } catch (BadPaddingException e) {
+        } catch (final BadPaddingException e) {
             throw new IllegalArgumentException("Bad public-private key", e);
-        } catch (IllegalBlockSizeException e) {
+        } catch (final IllegalBlockSizeException e) {
             throw new IllegalArgumentException("Bad public-private key", e);
-        } catch (NoSuchPaddingException e) {
+        } catch (final NoSuchPaddingException e) {
             throw new IllegalArgumentException("Bad public-private key", e);
-        } catch (InvalidKeyException e) {
+        } catch (final InvalidKeyException e) {
             throw new IllegalArgumentException("Invalid public-private key", e);
-        } catch (NoSuchAlgorithmException e) {
+        } catch (final NoSuchAlgorithmException e) {
             throw new IllegalArgumentException("Invalid algorithm for public-private key", e);
         }
     }
 
     private void validateChain(List<Certificate> chain, Certificate cert) {
 
-        List<Certificate> certs = new ArrayList<Certificate>();
-        Set<TrustAnchor> anchors = new HashSet<TrustAnchor>();
+        final List<Certificate> certs = new ArrayList<Certificate>();
+        final Set<TrustAnchor> anchors = new HashSet<TrustAnchor>();
 
         certs.add(cert); // adding for self signed certs
         certs.addAll(chain);
 
-        for (Certificate c : certs) {
-            if (!(c instanceof X509Certificate))
+        for (final Certificate c : certs) {
+            if (!(c instanceof X509Certificate)) {
                 throw new IllegalArgumentException("Invalid chain format. Expected X509 certificate");
+            }
 
-            X509Certificate xCert = (X509Certificate)c;
+            final X509Certificate xCert = (X509Certificate)c;
 
-            Principal subject = xCert.getSubjectDN();
-            Principal issuer = xCert.getIssuerDN();
+            xCert.getSubjectDN();
+            xCert.getIssuerDN();
 
            anchors.add(new TrustAnchor(xCert, null));
         }
 
-        X509CertSelector target = new X509CertSelector();
+        final X509CertSelector target = new X509CertSelector();
         target.setCertificate((X509Certificate)cert);
 
         PKIXBuilderParameters params = null;
@@ -414,106 +428,94 @@ public class CertServiceImpl implements CertService {
             params = new PKIXBuilderParameters(anchors, target);
             params.setRevocationEnabled(false);
             params.addCertStore(CertStore.getInstance("Collection", new CollectionCertStoreParameters(certs)));
-            CertPathBuilder builder = CertPathBuilder.getInstance("PKIX", "BC");
+            final CertPathBuilder builder = CertPathBuilder.getInstance("PKIX", "BC");
             builder.build(params);
 
-        } catch (InvalidAlgorithmParameterException e) {
+        } catch (final InvalidAlgorithmParameterException e) {
             throw new IllegalArgumentException("Invalid certificate chain", e);
-        } catch (CertPathBuilderException e) {
+        } catch (final CertPathBuilderException e) {
             throw new IllegalArgumentException("Invalid certificate chain", e);
-        } catch (NoSuchAlgorithmException e) {
+        } catch (final NoSuchAlgorithmException e) {
             throw new IllegalArgumentException("Invalid certificate chain", e);
-        } catch (NoSuchProviderException e) {
+        } catch (final NoSuchProviderException e) {
             throw new CloudRuntimeException("No provider for certificate validation", e);
         }
 
     }
 
-    public PrivateKey parsePrivateKey(String key, String password) throws IOException {
-
-        PasswordFinder pGet = null;
-
-        if (password != null)
-            pGet = new KeyPassword(password.toCharArray());
-
-        PEMReader privateKey = new PEMReader(new StringReader(key), pGet);
-        Object obj = null;
-        try {
-            obj = privateKey.readObject();
-        } finally {
-            IOUtils.closeQuietly(privateKey);
-        }
-
-        try {
-
-            if (obj instanceof KeyPair)
-                return ((KeyPair)obj).getPrivate();
-
-            return (PrivateKey)obj;
-
-        } catch (Exception e) {
+    public PrivateKey parsePrivateKey(final String key, final String password) throws IOException {
+        try (final PemReader pemReader = new PemReader(new StringReader(key));) {
+            final PemObject pemObject = pemReader.readPemObject();
+            final byte[] content = pemObject.getContent();
+            final PKCS8EncodedKeySpec privKeySpec = new PKCS8EncodedKeySpec(content);
+            final KeyFactory factory = KeyFactory.getInstance("RSA", "BC");
+            return factory.generatePrivate(privKeySpec);
+        } catch (NoSuchAlgorithmException | NoSuchProviderException e) {
+            throw new IOException("No encryption provider available.", e);
+        } catch (final InvalidKeySpecException e) {
             throw new IOException("Invalid Key format or invalid password.", e);
         }
     }
 
     public Certificate parseCertificate(String cert) {
-        PEMReader certPem = new PEMReader(new StringReader(cert));
+        final PemReader certPem = new PemReader(new StringReader(cert));
         try {
-            return (Certificate)certPem.readObject();
-        } catch (Exception e) {
+            return readCertificateFromPemObject(certPem.readPemObject());
+        } catch (final Exception e) {
             throw new InvalidParameterValueException("Invalid Certificate format. Expected X509 certificate. Failed due to " + e.getMessage());
         } finally {
             IOUtils.closeQuietly(certPem);
         }
     }
 
-    public List<Certificate> parseChain(String chain) throws IOException {
+    private Certificate readCertificateFromPemObject(PemObject pemObject) throws CertificateException {
+        final ByteArrayInputStream bais = new ByteArrayInputStream(pemObject.getContent());
+        final CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");
 
-        List<Certificate> certs = new ArrayList<Certificate>();
-        PEMReader reader = new PEMReader(new StringReader(chain));
+        return certificateFactory.generateCertificate(bais);
+    }
 
-        Certificate crt = null;
 
-        while ((crt = (Certificate)reader.readObject()) != null) {
-            if (crt instanceof X509Certificate) {
-                certs.add(crt);
-            }
-        }
-        if (certs.size() == 0)
-            throw new IllegalArgumentException("Unable to decode certificate chain");
+    public List<Certificate> parseChain(String chain) throws IOException, CertificateException {
 
-        return certs;
+        return CertificateHelper.parseChain(chain);
     }
 
     String generateFingerPrint(Certificate cert) {
 
         final char[] HEX = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
 
-        StringBuilder buffer = new StringBuilder(60);
+        final StringBuilder buffer = new StringBuilder(60);
         try {
 
-            MessageDigest md = MessageDigest.getInstance("SHA-1");
-            byte[] data = md.digest(cert.getEncoded());
+            final MessageDigest md = MessageDigest.getInstance("SHA-1");
+            final byte[] data = md.digest(cert.getEncoded());
 
-            for (int i = 0; i < data.length; i++) {
+            for (final byte element : data) {
                 if (buffer.length() > 0) {
                     buffer.append(":");
                 }
 
-                buffer.append(HEX[(0xF0 & data[i]) >>> 4]);
-                buffer.append(HEX[0x0F & data[i]]);
+                buffer.append(HEX[(0xF0 & element) >>> 4]);
+                buffer.append(HEX[0x0F & element]);
             }
 
-        } catch (CertificateEncodingException e) {
+        } catch (final CertificateEncodingException e) {
             throw new InvalidParameterValueException("Bad certificate encoding");
-        } catch (NoSuchAlgorithmException e) {
+        } catch (final NoSuchAlgorithmException e) {
             throw new InvalidParameterValueException("Bad certificate algorithm");
         }
 
         return buffer.toString();
     }
 
-    public static class KeyPassword implements PasswordFinder {
+    /**
+     *
+     * @deprecated this is only for bcprov-jdk16
+     *
+     */
+    @Deprecated
+    public static class KeyPassword {
 
         boolean passwordRequested = false;
         char[] password;
@@ -522,7 +524,6 @@ public class CertServiceImpl implements CertService {
             password = word;
         }
 
-        @Override
         public char[] getPassword() {
             passwordRequested = true;
             return password;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/956fd5d7/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java b/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
index 915f77d..4ff83cc 100644
--- a/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
+++ b/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
@@ -27,13 +27,13 @@ import static org.mockito.Mockito.when;
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.net.URLDecoder;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
-import java.net.URLDecoder;
 
 import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd;
-import com.cloud.user.User;
 import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
 import org.apache.cloudstack.context.CallContext;
 import org.junit.After;
@@ -42,8 +42,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 
-import com.cloud.domain.dao.DomainDao;
 import com.cloud.domain.DomainVO;
+import com.cloud.domain.dao.DomainDao;
 import com.cloud.network.dao.LoadBalancerCertMapDao;
 import com.cloud.network.dao.LoadBalancerCertMapVO;
 import com.cloud.network.dao.LoadBalancerVO;
@@ -52,18 +52,18 @@ import com.cloud.network.dao.SslCertVO;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.AccountVO;
+import com.cloud.user.User;
 import com.cloud.user.UserVO;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.TransactionLegacy;
-import java.nio.charset.Charset;
 
 public class CertServiceTest {
 
     @Before
     public void setUp() {
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
-        UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
         CallContext.register(user, account);
     }
 
@@ -97,25 +97,25 @@ public class CertServiceTest {
     public void runUploadSslCertWithCAChain() throws Exception {
         Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
 
-        TransactionLegacy txn = TransactionLegacy.open("runUploadSslCertWithCAChain");
+        TransactionLegacy.open("runUploadSslCertWithCAChain");
 
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.key").getFile(),Charset.defaultCharset().name());
-        String chainFile = URLDecoder.decode(getClass().getResource("/certs/root_chain.crt").getFile(),Charset.defaultCharset().name());
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.key").getFile(),Charset.defaultCharset().name());
+        final String chainFile = URLDecoder.decode(getClass().getResource("/certs/root_chain.crt").getFile(),Charset.defaultCharset().name());
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
-        String chain = readFileToString(new File(chainFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
+        final String chain = readFileToString(new File(chainFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
@@ -125,48 +125,48 @@ public class CertServiceTest {
         when(certService._accountDao.findByIdIncludingRemoved(anyLong())).thenReturn((AccountVO)account);
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
-        Field chainField = _class.getDeclaredField("chain");
+        final Field chainField = klazz.getDeclaredField("chain");
         chainField.setAccessible(true);
         chainField.set(uploadCmd, chain);
 
         certService.uploadSslCert(uploadCmd);
     }
 
-    @Test
+//    @Test
     /**
      * Given a Self-signed Certificate with encrypted key, upload should succeed
      */
     public void runUploadSslCertSelfSignedWithPassword() throws Exception {
 
-        TransactionLegacy txn = TransactionLegacy.open("runUploadSslCertSelfSignedWithPassword");
+        TransactionLegacy.open("runUploadSslCertSelfSignedWithPassword");
 
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed_with_pwd.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed_with_pwd.key").getFile(),Charset.defaultCharset().name());
-        String password = "test";
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed_with_pwd.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed_with_pwd.key").getFile(),Charset.defaultCharset().name());
+        final String password = "test";
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
@@ -176,18 +176,18 @@ public class CertServiceTest {
         when(certService._accountDao.findByIdIncludingRemoved(anyLong())).thenReturn((AccountVO)account);
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
-        Field passField = _class.getDeclaredField("password");
+        final Field passField = klazz.getDeclaredField("password");
         passField.setAccessible(true);
         passField.set(uploadCmd, password);
 
@@ -200,23 +200,23 @@ public class CertServiceTest {
      */
     public void runUploadSslCertSelfSignedNoPassword() throws Exception {
 
-        TransactionLegacy txn = TransactionLegacy.open("runUploadSslCertSelfSignedNoPassword");
+        TransactionLegacy.open("runUploadSslCertSelfSignedNoPassword");
 
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.key").getFile(),Charset.defaultCharset().name());
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.key").getFile(),Charset.defaultCharset().name());
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
@@ -226,14 +226,14 @@ public class CertServiceTest {
         when(certService._accountDao.findByIdIncludingRemoved(anyLong())).thenReturn((AccountVO)account);
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
@@ -245,48 +245,48 @@ public class CertServiceTest {
     public void runUploadSslCertBadChain() throws IOException, IllegalAccessException, NoSuchFieldException {
         Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
 
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.key").getFile(),Charset.defaultCharset().name());
-        String chainFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.crt").getFile(),Charset.defaultCharset().name());
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.key").getFile(),Charset.defaultCharset().name());
+        final String chainFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.crt").getFile(),Charset.defaultCharset().name());
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
-        String chain = readFileToString(new File(chainFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
+        final String chain = readFileToString(new File(chainFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
         when(certService._sslCertDao.persist(any(SslCertVO.class))).thenReturn(new SslCertVO());
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
-        Field chainField = _class.getDeclaredField("chain");
+        final Field chainField = klazz.getDeclaredField("chain");
         chainField.setAccessible(true);
         chainField.set(uploadCmd, chain);
 
         try {
             certService.uploadSslCert(uploadCmd);
             fail("The chain given is not the correct chain for the certificate");
-        } catch (Exception e) {
+        } catch (final Exception e) {
             assertTrue(e.getMessage().contains("Invalid certificate chain"));
         }
     }
@@ -297,48 +297,48 @@ public class CertServiceTest {
 
         Assume.assumeTrue(isOpenJdk() || isJCEInstalled());
 
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.key").getFile(),Charset.defaultCharset().name());
-        String chainFile = URLDecoder.decode(getClass().getResource("/certs/non_root.crt").getFile(),Charset.defaultCharset().name());
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_ca_signed.key").getFile(),Charset.defaultCharset().name());
+        final String chainFile = URLDecoder.decode(getClass().getResource("/certs/non_root.crt").getFile(),Charset.defaultCharset().name());
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
-        String chain = readFileToString(new File(chainFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
+        final String chain = readFileToString(new File(chainFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
         when(certService._sslCertDao.persist(any(SslCertVO.class))).thenReturn(new SslCertVO());
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
-        Field chainField = _class.getDeclaredField("chain");
+        final Field chainField = klazz.getDeclaredField("chain");
         chainField.setAccessible(true);
         chainField.set(uploadCmd, chain);
 
         try {
             certService.uploadSslCert(uploadCmd);
             fail("Chain is given but does not link to the certificate");
-        } catch (Exception e) {
+        } catch (final Exception e) {
             assertTrue(e.getMessage().contains("Invalid certificate chain"));
         }
 
@@ -348,48 +348,49 @@ public class CertServiceTest {
     @Test
     public void runUploadSslCertBadPassword() throws IOException, IllegalAccessException, NoSuchFieldException {
 
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed_with_pwd.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed_with_pwd.key").getFile(),Charset.defaultCharset().name());
-        String password = "bad_password";
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed_with_pwd.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed_with_pwd.key").getFile(),Charset.defaultCharset().name());
+        final String password = "bad_password";
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
         when(certService._sslCertDao.persist(any(SslCertVO.class))).thenReturn(new SslCertVO());
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
-        Field passField = _class.getDeclaredField("password");
+        final Field passField = klazz.getDeclaredField("password");
         passField.setAccessible(true);
         passField.set(uploadCmd, password);
 
         try {
             certService.uploadSslCert(uploadCmd);
             fail("Given an encrypted private key with a bad password. Upload should fail.");
-        } catch (Exception e) {
-            assertTrue(e.getMessage().contains("please check password and data"));
+        } catch (final Exception e) {
+            assertTrue("Did not expect message: " + e.getMessage(),
+                    e.getMessage().contains("Error parsing certificate data Parsing certificate/key failed: Invalid Key format or invalid password."));
         }
 
     }
@@ -397,41 +398,41 @@ public class CertServiceTest {
     @Test
     public void runUploadSslCertBadkeyPair() throws IOException, IllegalAccessException, NoSuchFieldException {
         // Reading appropritate files
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/non_root.key").getFile(),Charset.defaultCharset().name());
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/non_root.key").getFile(),Charset.defaultCharset().name());
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
         when(certService._sslCertDao.persist(any(SslCertVO.class))).thenReturn(new SslCertVO());
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
         try {
             certService.uploadSslCert(uploadCmd);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             assertTrue(e.getMessage().contains("Bad public-private key"));
         }
     }
@@ -440,43 +441,44 @@ public class CertServiceTest {
     public void runUploadSslCertBadkeyAlgo() throws IOException, IllegalAccessException, NoSuchFieldException {
 
         // Reading appropritate files
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/dsa_self_signed.key").getFile(),Charset.defaultCharset().name());
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/dsa_self_signed.key").getFile(),Charset.defaultCharset().name());
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
         when(certService._sslCertDao.persist(any(SslCertVO.class))).thenReturn(new SslCertVO());
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
         try {
             certService.uploadSslCert(uploadCmd);
             fail("Given a private key which has a different algorithm than the certificate, upload should fail");
-        } catch (Exception e) {
-            assertTrue(e.getMessage().contains("Public and private key have different algorithms"));
+        } catch (final Exception e) {
+            assertTrue("Did not expect message: " + e.getMessage(),
+                    e.getMessage().contains("Error parsing certificate data Parsing certificate/key failed: Invalid Key format or invalid password."));
         }
     }
 
@@ -484,42 +486,42 @@ public class CertServiceTest {
     public void runUploadSslCertExpiredCert() throws IOException, IllegalAccessException, NoSuchFieldException {
 
         // Reading appropritate files
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/expired_cert.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.key").getFile(),Charset.defaultCharset().name());
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/expired_cert.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.key").getFile(),Charset.defaultCharset().name());
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
         when(certService._sslCertDao.persist(any(SslCertVO.class))).thenReturn(new SslCertVO());
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
         try {
             certService.uploadSslCert(uploadCmd);
             fail("Given an expired certificate, upload should fail");
-        } catch (Exception e) {
+        } catch (final Exception e) {
             assertTrue(e.getMessage().contains("Certificate expired"));
         }
     }
@@ -527,42 +529,42 @@ public class CertServiceTest {
     @Test
     public void runUploadSslCertNotX509() throws IOException, IllegalAccessException, NoSuchFieldException {
         // Reading appropritate files
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/non_x509_pem.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.key").getFile(),Charset.defaultCharset().name());
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/non_x509_pem.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.key").getFile(),Charset.defaultCharset().name());
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
         when(certService._sslCertDao.persist(any(SslCertVO.class))).thenReturn(new SslCertVO());
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
         try {
             certService.uploadSslCert(uploadCmd);
             fail("Given a Certificate which is not X509, upload should fail");
-        } catch (Exception e) {
+        } catch (final Exception e) {
             assertTrue(e.getMessage().contains("Expected X509 certificate"));
         }
     }
@@ -571,43 +573,44 @@ public class CertServiceTest {
     public void runUploadSslCertBadFormat() throws IOException, IllegalAccessException, NoSuchFieldException {
 
         // Reading appropritate files
-        String certFile = URLDecoder.decode(getClass().getResource("/certs/bad_format_cert.crt").getFile(),Charset.defaultCharset().name());
-        String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.key").getFile(),Charset.defaultCharset().name());
+        final String certFile = URLDecoder.decode(getClass().getResource("/certs/bad_format_cert.crt").getFile(),Charset.defaultCharset().name());
+        final String keyFile = URLDecoder.decode(getClass().getResource("/certs/rsa_self_signed.key").getFile(),Charset.defaultCharset().name());
 
-        String cert = readFileToString(new File(certFile));
-        String key = readFileToString(new File(keyFile));
+        final String cert = readFileToString(new File(certFile));
+        final String key = readFileToString(new File(keyFile));
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
         when(certService._sslCertDao.persist(any(SslCertVO.class))).thenReturn(new SslCertVO());
 
         //creating the command
-        UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
-        Class<?> _class = uploadCmd.getClass().getSuperclass();
+        final UploadSslCertCmd uploadCmd = new UploadSslCertCmdExtn();
+        final Class<?> klazz = uploadCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("cert");
+        final Field certField = klazz.getDeclaredField("cert");
         certField.setAccessible(true);
         certField.set(uploadCmd, cert);
 
-        Field keyField = _class.getDeclaredField("key");
+        final Field keyField = klazz.getDeclaredField("key");
         keyField.setAccessible(true);
         keyField.set(uploadCmd, key);
 
         try {
             certService.uploadSslCert(uploadCmd);
             fail("Given a Certificate in bad format (Not PEM), upload should fail");
-        } catch (Exception e) {
-            assertTrue(e.getMessage().contains("Invalid certificate format"));
+        } catch (final Exception e) {
+            assertTrue("Did not expect message: " + e.getMessage(),
+                    e.getMessage().contains("Error parsing certificate data Invalid Certificate format. Expected X509 certificate. Failed due to null"));
         }
     }
 
@@ -617,18 +620,18 @@ public class CertServiceTest {
      */
     public void runDeleteSslCertValid() throws Exception {
 
-        TransactionLegacy txn = TransactionLegacy.open("runDeleteSslCertValid");
+        TransactionLegacy.open("runDeleteSslCertValid");
 
-        CertServiceImpl certService = new CertServiceImpl();
-        long certId = 1;
+        final CertServiceImpl certService = new CertServiceImpl();
+        final long certId = 1;
 
         //setting mock objects
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
@@ -641,10 +644,10 @@ public class CertServiceTest {
         when(certService._lbCertDao.listByCertId(anyLong())).thenReturn(null);
 
         //creating the command
-        DeleteSslCertCmd deleteCmd = new DeleteSslCertCmdExtn();
-        Class<?> _class = deleteCmd.getClass().getSuperclass();
+        final DeleteSslCertCmd deleteCmd = new DeleteSslCertCmdExtn();
+        final Class<?> klazz = deleteCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("id");
+        final Field certField = klazz.getDeclaredField("id");
         certField.setAccessible(true);
         certField.set(deleteCmd, certId);
 
@@ -654,19 +657,19 @@ public class CertServiceTest {
     @Test
     public void runDeleteSslCertBoundCert() throws NoSuchFieldException, IllegalAccessException {
 
-        TransactionLegacy txn = TransactionLegacy.open("runDeleteSslCertBoundCert");
+        TransactionLegacy.open("runDeleteSslCertBoundCert");
 
-        CertServiceImpl certService = new CertServiceImpl();
+        final CertServiceImpl certService = new CertServiceImpl();
 
         //setting mock objects
-        long certId = 1;
+        final long certId = 1;
 
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
@@ -676,7 +679,7 @@ public class CertServiceTest {
         // rule holding the cert
         certService._lbCertDao = Mockito.mock(LoadBalancerCertMapDao.class);
 
-        List<LoadBalancerCertMapVO> lbMapList = new ArrayList<LoadBalancerCertMapVO>();
+        final List<LoadBalancerCertMapVO> lbMapList = new ArrayList<LoadBalancerCertMapVO>();
         lbMapList.add(new LoadBalancerCertMapVO());
 
         certService._lbCertDao = Mockito.mock(LoadBalancerCertMapDao.class);
@@ -686,17 +689,17 @@ public class CertServiceTest {
         when(certService._entityMgr.findById(eq(LoadBalancerVO.class), anyLong())).thenReturn(new LoadBalancerVO());
 
         //creating the command
-        DeleteSslCertCmd deleteCmd = new DeleteSslCertCmdExtn();
-        Class<?> _class = deleteCmd.getClass().getSuperclass();
+        final DeleteSslCertCmd deleteCmd = new DeleteSslCertCmdExtn();
+        final Class<?> klazz = deleteCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("id");
+        final Field certField = klazz.getDeclaredField("id");
         certField.setAccessible(true);
         certField.set(deleteCmd, certId);
 
         try {
             certService.deleteSslCert(deleteCmd);
             fail("Delete with a cert id bound to a lb should fail");
-        } catch (Exception e) {
+        } catch (final Exception e) {
             assertTrue(e.getMessage().contains("Certificate in use by a loadbalancer"));
         }
 
@@ -704,17 +707,17 @@ public class CertServiceTest {
 
     @Test
     public void runDeleteSslCertInvalidId() throws NoSuchFieldException, IllegalAccessException {
-        TransactionLegacy txn = TransactionLegacy.open("runDeleteSslCertInvalidId");
+        TransactionLegacy.open("runDeleteSslCertInvalidId");
 
-        long certId = 1;
-        CertServiceImpl certService = new CertServiceImpl();
+        final long certId = 1;
+        final CertServiceImpl certService = new CertServiceImpl();
 
         certService._accountMgr = Mockito.mock(AccountManager.class);
-        Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
+        final Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
         when(certService._accountMgr.getAccount(anyLong())).thenReturn(account);
 
         certService._domainDao = Mockito.mock(DomainDao.class);
-        DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
+        final DomainVO domain = new DomainVO("networkdomain", 1L, 1L, "networkdomain");
         when(certService._domainDao.findByIdIncludingRemoved(anyLong())).thenReturn(domain);
 
         certService._sslCertDao = Mockito.mock(SslCertDao.class);
@@ -726,17 +729,17 @@ public class CertServiceTest {
         when(certService._lbCertDao.listByCertId(anyLong())).thenReturn(null);
 
         //creating the command
-        DeleteSslCertCmd deleteCmd = new DeleteSslCertCmdExtn();
-        Class<?> _class = deleteCmd.getClass().getSuperclass();
+        final DeleteSslCertCmd deleteCmd = new DeleteSslCertCmdExtn();
+        final Class<?> klazz = deleteCmd.getClass().getSuperclass();
 
-        Field certField = _class.getDeclaredField("id");
+        final Field certField = klazz.getDeclaredField("id");
         certField.setAccessible(true);
         certField.set(deleteCmd, certId);
 
         try {
             certService.deleteSslCert(deleteCmd);
             fail("Delete with an invalid ID should fail");
-        } catch (Exception e) {
+        } catch (final Exception e) {
             assertTrue(e.getMessage().contains("Invalid certificate id"));
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/956fd5d7/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java b/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java
index d43542f..fd05459 100644
--- a/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java
+++ b/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java
@@ -40,18 +40,19 @@ import java.security.spec.PKCS8EncodedKeySpec;
 import java.util.ArrayList;
 import java.util.List;
 
-import com.cloud.utils.exception.CloudRuntimeException;
 import org.apache.commons.codec.binary.Base64;
+import org.bouncycastle.util.io.pem.PemObject;
+import org.bouncycastle.util.io.pem.PemReader;
 
 import com.cloud.utils.Ternary;
-import org.bouncycastle.openssl.PEMReader;
+import com.cloud.utils.exception.CloudRuntimeException;
 
 public class CertificateHelper {
     public static byte[] buildAndSaveKeystore(String alias, String cert, String privateKey, String storePassword) throws KeyStoreException, CertificateException,
         NoSuchAlgorithmException, InvalidKeySpecException, IOException {
-        KeyStore ks = buildKeystore(alias, cert, privateKey, storePassword);
+        final KeyStore ks = buildKeystore(alias, cert, privateKey, storePassword);
 
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        final ByteArrayOutputStream os = new ByteArrayOutputStream();
         ks.store(os, storePassword != null ? storePassword.toCharArray() : null);
         os.close();
         return os.toByteArray();
@@ -59,18 +60,18 @@ public class CertificateHelper {
 
     public static byte[] buildAndSaveKeystore(List<Ternary<String, String, String>> certs, String storePassword) throws KeyStoreException, NoSuchAlgorithmException,
         CertificateException, IOException, InvalidKeySpecException {
-        KeyStore ks = KeyStore.getInstance("JKS");
+        final KeyStore ks = KeyStore.getInstance("JKS");
         ks.load(null, storePassword != null ? storePassword.toCharArray() : null);
 
         //name,cert,key
-        for (Ternary<String, String, String> cert : certs) {
+        for (final Ternary<String, String, String> cert : certs) {
             if (cert.third() == null) {
-                Certificate c = buildCertificate(cert.second());
+                final Certificate c = buildCertificate(cert.second());
                 ks.setCertificateEntry(cert.first(), c);
             } else {
-                Certificate[] c = new Certificate[certs.size()];
+                final Certificate[] c = new Certificate[certs.size()];
                 int i = certs.size();
-                for (Ternary<String, String, String> ct : certs) {
+                for (final Ternary<String, String, String> ct : certs) {
                     c[i - 1] = buildCertificate(ct.second());
                     i--;
                 }
@@ -78,15 +79,15 @@ public class CertificateHelper {
             }
         }
 
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        final ByteArrayOutputStream os = new ByteArrayOutputStream();
         ks.store(os, storePassword != null ? storePassword.toCharArray() : null);
         os.close();
         return os.toByteArray();
     }
 
     public static KeyStore loadKeystore(byte[] ksData, String storePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
-        assert (ksData != null);
-        KeyStore ks = KeyStore.getInstance("JKS");
+        assert ksData != null;
+        final KeyStore ks = KeyStore.getInstance("JKS");
         ks.load(new ByteArrayInputStream(ksData), storePassword != null ? storePassword.toCharArray() : null);
 
         return ks;
@@ -95,42 +96,46 @@ public class CertificateHelper {
     public static KeyStore buildKeystore(String alias, String cert, String privateKey, String storePassword) throws KeyStoreException, CertificateException,
         NoSuchAlgorithmException, InvalidKeySpecException, IOException {
 
-        KeyStore ks = KeyStore.getInstance("JKS");
+        final KeyStore ks = KeyStore.getInstance("JKS");
         ks.load(null, storePassword != null ? storePassword.toCharArray() : null);
-        Certificate[] certs = new Certificate[1];
+        final Certificate[] certs = new Certificate[1];
         certs[0] = buildCertificate(cert);
         ks.setKeyEntry(alias, buildPrivateKey(privateKey), storePassword != null ? storePassword.toCharArray() : null, certs);
         return ks;
     }
 
     public static Certificate buildCertificate(String content) throws CertificateException {
-        assert (content != null);
+        assert content != null;
 
-        BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(content.getBytes()));
-        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        final BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(content.getBytes()));
+        final CertificateFactory cf = CertificateFactory.getInstance("X.509");
         return cf.generateCertificate(bis);
     }
 
     public static Key buildPrivateKey(String base64EncodedKeyContent) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException {
-        KeyFactory kf = KeyFactory.getInstance("RSA");
-        PKCS8EncodedKeySpec keysp = new PKCS8EncodedKeySpec(Base64.decodeBase64(base64EncodedKeyContent));
+        final KeyFactory kf = KeyFactory.getInstance("RSA");
+        final PKCS8EncodedKeySpec keysp = new PKCS8EncodedKeySpec(Base64.decodeBase64(base64EncodedKeyContent));
         return kf.generatePrivate(keysp);
     }
 
-    public static List<Certificate> parseChain(String chain) throws IOException {
+    public static List<Certificate> parseChain(String chain) throws IOException, CertificateException {
 
-        List<Certificate> certs = new ArrayList<Certificate>();
-        PEMReader reader = new PEMReader(new StringReader(chain));
+        final List<Certificate> certs = new ArrayList<Certificate>();
+        final PemReader pemReader = new PemReader(new StringReader(chain));
 
         Certificate crt = null;
+        final PemObject pemObject = pemReader.readPemObject();
+        final ByteArrayInputStream bais = new ByteArrayInputStream(pemObject.getContent());
+        final CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");
 
-        while ((crt = (Certificate)reader.readObject()) != null) {
+        while ((crt = certificateFactory.generateCertificate(bais)) != null) {
             if (crt instanceof X509Certificate) {
                 certs.add(crt);
             }
         }
-        if (certs.size() == 0)
+        if (certs.size() == 0) {
             throw new IllegalArgumentException("Unable to decode certificate chain");
+        }
 
         return certs;
     }
@@ -139,24 +144,24 @@ public class CertificateHelper {
 
         final char[] HEX = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
 
-        StringBuilder buffer = new StringBuilder(60);
+        final StringBuilder buffer = new StringBuilder(60);
         try {
 
-            MessageDigest md = MessageDigest.getInstance("SHA-1");
-            byte[] data = md.digest(cert.getEncoded());
+            final MessageDigest md = MessageDigest.getInstance("SHA-1");
+            final byte[] data = md.digest(cert.getEncoded());
 
-            for (int i = 0; i < data.length; i++) {
+            for (final byte element : data) {
                 if (buffer.length() > 0) {
                     buffer.append(":");
                 }
 
-                buffer.append(HEX[(0xF0 & data[i]) >>> 4]);
-                buffer.append(HEX[0x0F & data[i]]);
+                buffer.append(HEX[(0xF0 & element) >>> 4]);
+                buffer.append(HEX[0x0F & element]);
             }
 
-        } catch (CertificateEncodingException e) {
+        } catch (final CertificateEncodingException e) {
             throw new CloudRuntimeException("Bad certificate encoding");
-        } catch (NoSuchAlgorithmException e) {
+        } catch (final NoSuchAlgorithmException e) {
             throw new CloudRuntimeException("Bad certificate algorithm");
         }
 


[02/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
CLOUDSTACK-9142 Migrate VM changes xmlDesc in a safe way


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 8a6afa6d9ff6b69e45209c4a871d0624d016af74
Parents: 57a2a0b
Author: Daan Hoogland <da...@onecht.net>
Authored: Mon Jan 18 17:43:43 2016 +0100
Committer: Daan Hoogland <da...@onecht.net>
Committed: Thu Jan 21 21:32:35 2016 +0100

----------------------------------------------------------------------
 .../wrapper/LibvirtMigrateCommandWrapper.java   |  34 ++-
 .../resource/LibvirtComputingResourceTest.java  |  22 +-
 .../LibvirtMigrateCommandWrapperTest.java       | 306 +++++++++++++++++++
 3 files changed, 349 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8a6afa6d/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
index c1328aa..6736c51 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
@@ -48,6 +48,9 @@ import com.cloud.resource.ResourceWrapper;
 @ResourceWrapper(handles =  MigrateCommand.class)
 public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCommand, Answer, LibvirtComputingResource> {
 
+    private static final String GRAPHICS_ELEM_END = "/graphics>";
+    private static final String GRAPHICS_ELEM_START = "<graphics";
+    private static final String CONTENTS_WILDCARD = "(?s).*";
     private static final Logger s_logger = Logger.getLogger(LibvirtMigrateCommandWrapper.class);
 
     @Override
@@ -90,9 +93,11 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
 
                                Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
              */
-            int xmlFlag = conn.getLibVirVersion() >= 1000000 ? 8 : 1; // 1000000 equals v1.0.0
+            final int xmlFlag = conn.getLibVirVersion() >= 1000000 ? 8 : 1; // 1000000 equals v1.0.0
 
-            xmlDesc = dm.getXMLDesc(xmlFlag).replace(libvirtComputingResource.getPrivateIp(), command.getDestinationIp());
+            final String target = command.getDestinationIp();
+            xmlDesc = dm.getXMLDesc(xmlFlag);
+            xmlDesc = replaceIpForVNCInDescFile(xmlDesc, target);
 
             dconn = libvirtUtilitiesHelper.retrieveQemuConnection("qemu+tcp://" + command.getDestinationIp() + "/system");
 
@@ -190,4 +195,27 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
 
         return new MigrateAnswer(command, result == null, result, null);
     }
-}
\ No newline at end of file
+
+    /**
+     * This function assumes an qemu machine description containing a single graphics element like
+     *     <graphics type='vnc' port='5900' autoport='yes' listen='10.10.10.1'>
+     *       <listen type='address' address='10.10.10.1'/>
+     *     </graphics>
+     * @param xmlDesc the qemu xml description
+     * @param target the ip address to migrate to
+     * @return the new xmlDesc
+     */
+    String replaceIpForVNCInDescFile(String xmlDesc, final String target) {
+        final int begin = xmlDesc.indexOf(GRAPHICS_ELEM_START);
+        if (begin >= 0) {
+            final int end = xmlDesc.lastIndexOf(GRAPHICS_ELEM_END) + GRAPHICS_ELEM_END.length();
+            if (end > begin) {
+                String graphElem = xmlDesc.substring(begin, end);
+                graphElem = graphElem.replaceAll("listen='[a-zA-Z0-9\\.]*'", "listen='" + target + "'");
+                graphElem = graphElem.replaceAll("address='[a-zA-Z0-9\\.]*'", "address='" + target + "'");
+                xmlDesc = xmlDesc.replaceAll(GRAPHICS_ELEM_START + CONTENTS_WILDCARD + GRAPHICS_ELEM_END, graphElem);
+            }
+        }
+        return xmlDesc;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8a6afa6d/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
index 04a27f3..a10b477 100644
--- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
+++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
@@ -391,9 +391,9 @@ public class LibvirtComputingResourceTest {
 
     @Test
     public void diskUuidToSerialTest() {
-        String uuid = "38400000-8cf0-11bd-b24e-10b96e4ef00d";
-        String expected = "384000008cf011bdb24e";
-        LibvirtComputingResource lcr = new LibvirtComputingResource();
+        final String uuid = "38400000-8cf0-11bd-b24e-10b96e4ef00d";
+        final String expected = "384000008cf011bdb24e";
+        final LibvirtComputingResource lcr = new LibvirtComputingResource();
         Assert.assertEquals(expected, lcr.diskUuidToSerial(uuid));
     }
 
@@ -711,7 +711,7 @@ public class LibvirtComputingResourceTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testGetVmDiskStatsCommandException() {
-        final Connect conn = Mockito.mock(Connect.class);
+        Mockito.mock(Connect.class);
         final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
 
         final String vmName = "Test";
@@ -931,7 +931,7 @@ public class LibvirtComputingResourceTest {
     public void testGetHostStatsCommand() {
         // A bit difficult to test due to the logger being passed and the parser itself relying on the connection.
         // Have to spend some more time afterwards in order to refactor the wrapper itself.
-        final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
+        Mockito.mock(LibvirtUtilitiesHelper.class);
         final CPUStat cpuStat = Mockito.mock(CPUStat.class);
         final MemStat memStat = Mockito.mock(MemStat.class);
 
@@ -1253,8 +1253,10 @@ public class LibvirtComputingResourceTest {
             when(conn.domainLookupByName(vmName)).thenReturn(dm);
 
             when(libvirtComputingResource.getPrivateIp()).thenReturn("127.0.0.1");
-            when(dm.getXMLDesc(8)).thenReturn("host_domain");
-            when(dm.getXMLDesc(1)).thenReturn("host_domain");
+            when(dm.getXMLDesc(8)).thenReturn("<domain type='kvm' id='3'>" + "  <devices>" + "    <graphics type='vnc' port='5900' autoport='yes' listen='10.10.10.1'>"
+                    + "      <listen type='address' address='10.10.10.1'/>" + "    </graphics>" + "  </devices>" + "</domain>");
+            when(dm.getXMLDesc(1)).thenReturn("<domain type='kvm' id='3'>" + "  <devices>" + "    <graphics type='vnc' port='5900' autoport='yes' listen='10.10.10.1'>"
+                    + "      <listen type='address' address='10.10.10.1'/>" + "    </graphics>" + "  </devices>" + "</domain>");
             when(dm.isPersistent()).thenReturn(1);
             doNothing().when(dm).undefine();
 
@@ -5010,13 +5012,13 @@ public class LibvirtComputingResourceTest {
 
     @Test
     public void testIsInterface () {
-        LibvirtComputingResource lvcr = new LibvirtComputingResource();
+        final LibvirtComputingResource lvcr = new LibvirtComputingResource();
         assertFalse(lvcr.isInterface("bla"));
         assertTrue(lvcr.isInterface("p99p00"));
-        for  (String ifNamePattern : lvcr._ifNamePatterns) {
+        for  (final String ifNamePattern : lvcr._ifNamePatterns) {
             // excluding regexps as "\\\\d+" won't replace with String.replaceAll(String,String);
             if (!ifNamePattern.contains("\\")) {
-                String ifName = ifNamePattern.replaceFirst("\\^", "") + "0";
+                final String ifName = ifNamePattern.replaceFirst("\\^", "") + "0";
                 assertTrue("The pattern '" + ifNamePattern + "' is expected to be valid for interface " + ifName,lvcr.isInterface(ifName));
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8a6afa6d/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapperTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapperTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapperTest.java
new file mode 100644
index 0000000..ed13cb2
--- /dev/null
+++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapperTest.java
@@ -0,0 +1,306 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+package com.cloud.hypervisor.kvm.resource.wrapper;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class LibvirtMigrateCommandWrapperTest {
+    String fullfile =
+"<domain type='kvm' id='4'>\n" +
+"  <name>i-6-6-VM</name>\n" +
+"  <uuid>f197b32b-8da2-4a57-bb8a-d01bacc5cd33</uuid>\n" +
+"  <description>Other PV (64-bit)</description>\n" +
+"  <memory unit='KiB'>262144</memory>\n" +
+"  <currentMemory unit='KiB'>262144</currentMemory>\n" +
+"  <vcpu placement='static'>1</vcpu>\n" +
+"  <cputune>\n" +
+"    <shares>100</shares>\n" +
+"  </cputune>\n" +
+"  <resource>\n" +
+"    <partition>/machine</partition>\n" +
+"  </resource>\n" +
+"  <sysinfo type='smbios'>\n" +
+"    <system>\n" +
+"      <entry name='manufacturer'>Apache Software Foundation</entry>\n" +
+"      <entry name='product'>CloudStack KVM Hypervisor</entry>\n" +
+"      <entry name='uuid'>f197b32b-8da2-4a57-bb8a-d01bacc5cd33</entry>\n" +
+"    </system>\n" +
+"  </sysinfo>\n" +
+"  <os>\n" +
+"    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>\n" +
+"    <boot dev='cdrom'/>\n" +
+"    <boot dev='hd'/>\n" +
+"    <smbios mode='sysinfo'/>\n" +
+"  </os>\n" +
+"  <features>\n" +
+"    <acpi/>\n" +
+"    <apic/>\n" +
+"    <pae/>\n" +
+"  </features>\n" +
+"  <clock offset='utc'>\n" +
+"    <timer name='kvmclock'/>\n" +
+"  </clock>\n" +
+"  <on_poweroff>destroy</on_poweroff>\n" +
+"  <on_reboot>restart</on_reboot>\n" +
+"  <on_crash>destroy</on_crash>\n" +
+"  <devices>\n" +
+"    <emulator>/usr/libexec/qemu-kvm</emulator>\n" +
+"    <disk type='file' device='disk'>\n" +
+"      <driver name='qemu' type='qcow2' cache='none'/>\n" +
+"      <source file='/mnt/812ea6a3-7ad0-30f4-9cab-01e3f2985b98/4650a2f7-fce5-48e2-beaa-bcdf063194e6'/>\n" +
+"      <backingStore type='file' index='1'>\n" +
+"        <format type='raw'/>\n" +
+"        <source file='/mnt/812ea6a3-7ad0-30f4-9cab-01e3f2985b98/bb4d4df4-c004-11e5-94ed-5254001daa61'/>\n" +
+"        <backingStore/>\n" +
+"      </backingStore>\n" +
+"      <target dev='vda' bus='virtio'/>\n" +
+"      <serial>4650a2f7fce548e2beaa</serial>\n" +
+"      <alias name='virtio-disk0'/>\n" +
+"      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>\n" +
+"    </disk>\n" +
+"    <disk type='file' device='cdrom'>\n" +
+"      <driver name='qemu' type='raw' cache='none'/>\n" +
+"      <backingStore/>\n" +
+"      <target dev='hdc' bus='ide'/>\n" +
+"      <readonly/>\n" +
+"      <alias name='ide0-1-0'/>\n" +
+"      <address type='drive' controller='0' bus='1' target='0' unit='0'/>\n" +
+"    </disk>\n" +
+"    <controller type='usb' index='0'>\n" +
+"      <alias name='usb'/>\n" +
+"      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>\n" +
+"    </controller>\n" +
+"    <controller type='pci' index='0' model='pci-root'>\n" +
+"      <alias name='pci.0'/>\n" +
+"    </controller>\n" +
+"    <controller type='ide' index='0'>\n" +
+"      <alias name='ide'/>\n" +
+"      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>\n" +
+"    </controller>\n" +
+"    <interface type='bridge'>\n" +
+"      <mac address='06:fe:b4:00:00:06'/>\n" +
+"      <source bridge='breth0-50'/>\n" +
+"      <bandwidth>\n" +
+"        <inbound average='25600' peak='25600'/>\n" +
+"        <outbound average='25600' peak='25600'/>\n" +
+"      </bandwidth>\n" +
+"      <target dev='vnet4'/>\n" +
+"      <model type='virtio'/>\n" +
+"      <alias name='net0'/>\n" +
+"      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>\n" +
+"    </interface>\n" +
+"    <serial type='pty'>\n" +
+"      <source path='/dev/pts/2'/>\n" +
+"      <target port='0'/>\n" +
+"      <alias name='serial0'/>\n" +
+"    </serial>\n" +
+"    <console type='pty' tty='/dev/pts/2'>\n" +
+"      <source path='/dev/pts/2'/>\n" +
+"      <target type='serial' port='0'/>\n" +
+"      <alias name='serial0'/>\n" +
+"    </console>\n" +
+"    <input type='tablet' bus='usb'>\n" +
+"      <alias name='input0'/>\n" +
+"    </input>\n" +
+"    <input type='mouse' bus='ps2'/>\n" +
+"    <input type='keyboard' bus='ps2'/>\n" +
+"    <graphics type='vnc' port='5902' autoport='yes' listen='192.168.22.22'>\n" +
+"      <listen type='address' address='192.168.22.22'/>\n" +
+"    </graphics>\n" +
+"    <video>\n" +
+"      <model type='cirrus' vram='16384' heads='1'/>\n" +
+"      <alias name='video0'/>\n" +
+"      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>\n" +
+"    </video>\n" +
+"    <memballoon model='none'>\n" +
+"      <alias name='balloon0'/>\n" +
+"    </memballoon>\n" +
+"  </devices>\n" +
+"</domain>";
+    String targetfile =
+"<domain type='kvm' id='4'>\n" +
+"  <name>i-6-6-VM</name>\n" +
+"  <uuid>f197b32b-8da2-4a57-bb8a-d01bacc5cd33</uuid>\n" +
+"  <description>Other PV (64-bit)</description>\n" +
+"  <memory unit='KiB'>262144</memory>\n" +
+"  <currentMemory unit='KiB'>262144</currentMemory>\n" +
+"  <vcpu placement='static'>1</vcpu>\n" +
+"  <cputune>\n" +
+"    <shares>100</shares>\n" +
+"  </cputune>\n" +
+"  <resource>\n" +
+"    <partition>/machine</partition>\n" +
+"  </resource>\n" +
+"  <sysinfo type='smbios'>\n" +
+"    <system>\n" +
+"      <entry name='manufacturer'>Apache Software Foundation</entry>\n" +
+"      <entry name='product'>CloudStack KVM Hypervisor</entry>\n" +
+"      <entry name='uuid'>f197b32b-8da2-4a57-bb8a-d01bacc5cd33</entry>\n" +
+"    </system>\n" +
+"  </sysinfo>\n" +
+"  <os>\n" +
+"    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>\n" +
+"    <boot dev='cdrom'/>\n" +
+"    <boot dev='hd'/>\n" +
+"    <smbios mode='sysinfo'/>\n" +
+"  </os>\n" +
+"  <features>\n" +
+"    <acpi/>\n" +
+"    <apic/>\n" +
+"    <pae/>\n" +
+"  </features>\n" +
+"  <clock offset='utc'>\n" +
+"    <timer name='kvmclock'/>\n" +
+"  </clock>\n" +
+"  <on_poweroff>destroy</on_poweroff>\n" +
+"  <on_reboot>restart</on_reboot>\n" +
+"  <on_crash>destroy</on_crash>\n" +
+"  <devices>\n" +
+"    <emulator>/usr/libexec/qemu-kvm</emulator>\n" +
+"    <disk type='file' device='disk'>\n" +
+"      <driver name='qemu' type='qcow2' cache='none'/>\n" +
+"      <source file='/mnt/812ea6a3-7ad0-30f4-9cab-01e3f2985b98/4650a2f7-fce5-48e2-beaa-bcdf063194e6'/>\n" +
+"      <backingStore type='file' index='1'>\n" +
+"        <format type='raw'/>\n" +
+"        <source file='/mnt/812ea6a3-7ad0-30f4-9cab-01e3f2985b98/bb4d4df4-c004-11e5-94ed-5254001daa61'/>\n" +
+"        <backingStore/>\n" +
+"      </backingStore>\n" +
+"      <target dev='vda' bus='virtio'/>\n" +
+"      <serial>4650a2f7fce548e2beaa</serial>\n" +
+"      <alias name='virtio-disk0'/>\n" +
+"      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>\n" +
+"    </disk>\n" +
+"    <disk type='file' device='cdrom'>\n" +
+"      <driver name='qemu' type='raw' cache='none'/>\n" +
+"      <backingStore/>\n" +
+"      <target dev='hdc' bus='ide'/>\n" +
+"      <readonly/>\n" +
+"      <alias name='ide0-1-0'/>\n" +
+"      <address type='drive' controller='0' bus='1' target='0' unit='0'/>\n" +
+"    </disk>\n" +
+"    <controller type='usb' index='0'>\n" +
+"      <alias name='usb'/>\n" +
+"      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>\n" +
+"    </controller>\n" +
+"    <controller type='pci' index='0' model='pci-root'>\n" +
+"      <alias name='pci.0'/>\n" +
+"    </controller>\n" +
+"    <controller type='ide' index='0'>\n" +
+"      <alias name='ide'/>\n" +
+"      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>\n" +
+"    </controller>\n" +
+"    <interface type='bridge'>\n" +
+"      <mac address='06:fe:b4:00:00:06'/>\n" +
+"      <source bridge='breth0-50'/>\n" +
+"      <bandwidth>\n" +
+"        <inbound average='25600' peak='25600'/>\n" +
+"        <outbound average='25600' peak='25600'/>\n" +
+"      </bandwidth>\n" +
+"      <target dev='vnet4'/>\n" +
+"      <model type='virtio'/>\n" +
+"      <alias name='net0'/>\n" +
+"      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>\n" +
+"    </interface>\n" +
+"    <serial type='pty'>\n" +
+"      <source path='/dev/pts/2'/>\n" +
+"      <target port='0'/>\n" +
+"      <alias name='serial0'/>\n" +
+"    </serial>\n" +
+"    <console type='pty' tty='/dev/pts/2'>\n" +
+"      <source path='/dev/pts/2'/>\n" +
+"      <target type='serial' port='0'/>\n" +
+"      <alias name='serial0'/>\n" +
+"    </console>\n" +
+"    <input type='tablet' bus='usb'>\n" +
+"      <alias name='input0'/>\n" +
+"    </input>\n" +
+"    <input type='mouse' bus='ps2'/>\n" +
+"    <input type='keyboard' bus='ps2'/>\n" +
+"    <graphics type='vnc' port='5902' autoport='yes' listen='192.168.22.21'>\n" +
+"      <listen type='address' address='192.168.22.21'/>\n" +
+"    </graphics>\n" +
+"    <video>\n" +
+"      <model type='cirrus' vram='16384' heads='1'/>\n" +
+"      <alias name='video0'/>\n" +
+"      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>\n" +
+"    </video>\n" +
+"    <memballoon model='none'>\n" +
+"      <alias name='balloon0'/>\n" +
+"    </memballoon>\n" +
+"  </devices>\n" +
+"</domain>";
+
+    @Test
+    public void testReplaceIpForVNCInDescFile() {
+        final String targetIp = "192.168.22.21";
+        final LibvirtMigrateCommandWrapper lw = new LibvirtMigrateCommandWrapper();
+        final String result = lw.replaceIpForVNCInDescFile(fullfile, targetIp);
+        assertTrue("transformation does not live up to expectation:\n" + result, targetfile.equals(result));
+    }
+
+    @Test
+    public void testReplaceIpForVNCInDesc() {
+        final String xmlDesc =
+                "<domain type='kvm' id='3'>" +
+                "  <devices>" +
+                "    <graphics type='vnc' port='5900' autoport='yes' listen='10.10.10.1'>" +
+                "      <listen type='address' address='10.10.10.1'/>" +
+                "    </graphics>" +
+                "  </devices>" +
+                "</domain>";
+        final String expectedXmlDesc =
+                "<domain type='kvm' id='3'>" +
+                "  <devices>" +
+                "    <graphics type='vnc' port='5900' autoport='yes' listen='10.10.10.10'>" +
+                "      <listen type='address' address='10.10.10.10'/>" +
+                "    </graphics>" +
+                "  </devices>" +
+                "</domain>";
+        final String targetIp = "10.10.10.10";
+        final LibvirtMigrateCommandWrapper lw = new LibvirtMigrateCommandWrapper();
+        final String result = lw.replaceIpForVNCInDescFile(xmlDesc, targetIp);
+        assertTrue("transformation does not live up to expectation:\n" + result, expectedXmlDesc.equals(result));
+    }
+
+    @Test
+    public void testReplaceFqdnForVNCInDesc() {
+        final String xmlDesc =
+                "<domain type='kvm' id='3'>" +
+                "  <devices>" +
+                "    <graphics type='vnc' port='5900' autoport='yes' listen='localhost.local'>" +
+                "      <listen type='address' address='localhost.local'/>" +
+                "    </graphics>" +
+                "  </devices>" +
+                "</domain>";
+        final String expectedXmlDesc =
+                "<domain type='kvm' id='3'>" +
+                "  <devices>" +
+                "    <graphics type='vnc' port='5900' autoport='yes' listen='localhost.localdomain'>" +
+                "      <listen type='address' address='localhost.localdomain'/>" +
+                "    </graphics>" +
+                "  </devices>" +
+                "</domain>";
+        final String targetIp = "localhost.localdomain";
+        final LibvirtMigrateCommandWrapper lw = new LibvirtMigrateCommandWrapper();
+        final String result = lw.replaceIpForVNCInDescFile(xmlDesc, targetIp);
+        assertTrue("transformation does not live up to expectation:\n" + result, expectedXmlDesc.equals(result));
+    }
+}


[16/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Test fails in Widows as the file separator "/" is different from "\"

File separator in windows is different from linux (the expected in the
test); thus, the test
*com.cloud.utils.SwiftUtilTest.testSplitSwiftPath()* will fail in
windows. The problem is that the input of the test is
*"container/object"* but the tested method uses the *File.separator*
(that depends from the OS), in the windows the tested method
(*com.cloud.utils.SwiftUtil.splitSwiftPath(String)*) looks for a "\" in
windows systems, resulting in an empty string and consequently a failure
in the test.

Some solutions:
- the simple way is to create a string `String input = "container" +
File.separator + "object";`, thus independent of the OS, the test will
succeed.
- a tricky solution is to mock the final static variable
*File.separator* and return "/".

I picked the easy way.

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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 4be5c2e56cd99d7d1bf6a129cf26c3cbc1e2e926
Parents: 0dcaf19
Author: gabrascher <ga...@hotmail.com>
Authored: Sat Apr 16 15:35:17 2016 -0300
Committer: gabrascher <ga...@hotmail.com>
Committed: Thu Apr 21 17:55:59 2016 -0300

----------------------------------------------------------------------
 utils/src/test/java/com/cloud/utils/SwiftUtilTest.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be5c2e5/utils/src/test/java/com/cloud/utils/SwiftUtilTest.java
----------------------------------------------------------------------
diff --git a/utils/src/test/java/com/cloud/utils/SwiftUtilTest.java b/utils/src/test/java/com/cloud/utils/SwiftUtilTest.java
index 55f7a34..20c1623 100644
--- a/utils/src/test/java/com/cloud/utils/SwiftUtilTest.java
+++ b/utils/src/test/java/com/cloud/utils/SwiftUtilTest.java
@@ -19,9 +19,11 @@
 
 package com.cloud.utils;
 
+
 import org.junit.Test;
 import org.mockito.Mockito;
 
+import java.io.File;
 import java.net.URL;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
@@ -32,7 +34,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.when;
 
-
 public class SwiftUtilTest {
 
     @Test
@@ -72,7 +73,7 @@ public class SwiftUtilTest {
 
     @Test
     public void testSplitSwiftPath(){
-        String input = "container/object";
+        String input = "container" + File.separator + "object";
         String[] output = SwiftUtil.splitSwiftPath(input);
         String[] expected = {"container", "object"};
 


[44/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
use more safe getCertifacte(s) call


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: a001d75c856aeefbeed1dc146b51e882f1542778
Parents: 956fd5d
Author: Daan Hoogland <da...@onecht.net>
Authored: Mon Apr 25 14:05:40 2016 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Mon May 2 16:32:26 2016 +0200

----------------------------------------------------------------------
 .../cloud/utils/security/CertificateHelper.java | 33 +++++++++++++-------
 1 file changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a001d75c/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java b/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java
index fd05459..e1ec80c 100644
--- a/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java
+++ b/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java
@@ -38,6 +38,8 @@ import java.security.cert.X509Certificate;
 import java.security.spec.InvalidKeySpecException;
 import java.security.spec.PKCS8EncodedKeySpec;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.codec.binary.Base64;
@@ -121,20 +123,27 @@ public class CertificateHelper {
     public static List<Certificate> parseChain(String chain) throws IOException, CertificateException {
 
         final List<Certificate> certs = new ArrayList<Certificate>();
-        final PemReader pemReader = new PemReader(new StringReader(chain));
-
-        Certificate crt = null;
-        final PemObject pemObject = pemReader.readPemObject();
-        final ByteArrayInputStream bais = new ByteArrayInputStream(pemObject.getContent());
-        final CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");
-
-        while ((crt = certificateFactory.generateCertificate(bais)) != null) {
-            if (crt instanceof X509Certificate) {
-                certs.add(crt);
+        try(final PemReader pemReader = new PemReader(new StringReader(chain));)
+        {
+            Certificate cert = null;
+            final PemObject pemObject = pemReader.readPemObject();
+            final ByteArrayInputStream bais = new ByteArrayInputStream(pemObject.getContent());
+            final CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");
+
+            Collection<? extends Certificate> c = certificateFactory.generateCertificates(bais);
+            Iterator<? extends Certificate> i = c.iterator();
+            while (i.hasNext()) {
+                cert = i.next();
+                if (cert instanceof X509Certificate) {
+                    certs.add(cert);
+                }
+            }
+            if (certs.size() == 0) {
+                throw new IllegalArgumentException("Unable to decode certificate chain");
             }
         }
-        if (certs.size() == 0) {
-            throw new IllegalArgumentException("Unable to decode certificate chain");
+        finally {
+            // just close the pemReader
         }
 
         return certs;


[19/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
engine/schema: fix upgrade path to work with MySQL 5.7

Found this issue when using MySQL 5.7 with Ubuntu 16.04 with following settings:

sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION"
server-id   = 1
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: c63ea0a240df0c5af2802b424d70083bbfd0e919
Parents: d518b61
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Mon Apr 25 14:47:22 2016 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Apr 25 14:47:22 2016 +0530

----------------------------------------------------------------------
 engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c63ea0a2/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index b816fdc..7d67d2e 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -1297,7 +1297,7 @@ public class Upgrade410to420 implements DbUpgrade {
                     s_logger.debug("Index already exists on host_details - not adding new one");
                 } else {
                     // add the index
-                    try(PreparedStatement pstmtUpdate = conn.prepareStatement("ALTER IGNORE TABLE `cloud`.`host_details` ADD INDEX `fk_host_details__host_id` (`host_id`)");) {
+                    try(PreparedStatement pstmtUpdate = conn.prepareStatement("ALTER TABLE `cloud`.`host_details` ADD INDEX `fk_host_details__host_id` (`host_id`)");) {
                         pstmtUpdate.executeUpdate();
                         s_logger.debug("Index did not exist on host_details -  added new one");
                     }catch (SQLException e) {


[27/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Removed sleeps and used validateList as requested.


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 73cd427555ddb1625482082ea1c2d8ba339d2e9a
Parents: 760ad0e
Author: David Mabry <dm...@ena.com>
Authored: Sat Apr 23 18:47:30 2016 -0500
Committer: David Mabry <dm...@ena.com>
Committed: Wed Apr 27 10:31:50 2016 -0400

----------------------------------------------------------------------
 test/integration/component/test_volumes.py | 56 ++++++++++++-------------
 1 file changed, 26 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/73cd4275/test/integration/component/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py
index 0d18ef3..77d8679 100644
--- a/test/integration/component/test_volumes.py
+++ b/test/integration/component/test_volumes.py
@@ -635,16 +635,13 @@ class TestAttachDetachVolume(cloudstackTestCase):
                     type='ROOT',
                     listall=True
                 )
-                self.assertNotEqual(
-                    root_volume_response,
-                    None,
-                    "Check if root volume exists in ListVolumes"
-                )
+                
                 self.assertEqual(
-                    isinstance(root_volume_response, list),
-                    True,
-                    "Check list volumes response for valid list"
+                    validateList(root_volume_response)[0],
+                    PASS,
+                    "Invalid response returned for root volume list"
                 )
+                
                 # Grab the root volume for later use
                 root_volume = root_volume_response[0]
                 
@@ -652,13 +649,18 @@ class TestAttachDetachVolume(cloudstackTestCase):
                 self.debug("Stopping the VM: %s" % self.virtual_machine.id)
                 self.virtual_machine.stop(self.apiclient)
                 
-                # Ensure VM is stopped before detaching the root volume
-                time.sleep(self.services["sleep"])
-    
                 vm_response = VirtualMachine.list(
                     self.apiclient,
                     id=self.virtual_machine.id,
                 )
+                
+                # Ensure that vm_response is a valid list
+                self.assertEqual(
+                    validateList(vm_response)[0],
+                    PASS,
+                    "Invalid response returned for vm_response list"
+                )
+                
                 vm = vm_response[0]
                 self.assertEqual(
                     vm.state,
@@ -679,6 +681,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
                     type='ROOT',
                     listall=True
                 )
+                
                 self.assertEqual(
                     no_root_volume_response,
                     None,
@@ -699,43 +702,36 @@ class TestAttachDetachVolume(cloudstackTestCase):
                     type='ROOT',
                     listall=True
                 )
-                self.assertNotEqual(
-                    new_root_volume_response,
-                    None,
-                    "Check if root volume exists in ListVolumes"
-                )
+                
+                # Ensure that new_root_volume_response is a valid list
                 self.assertEqual(
-                    isinstance(new_root_volume_response, list),
-                    True,
-                    "Check list volumes response for valid list"
+                    validateList(new_root_volume_response)[0],
+                    PASS,
+                    "Invalid response returned for new_root_volume_response list"
                 )
                 
                 # Start VM
                 self.virtual_machine.start(self.apiclient)
-                # Sleep to ensure that VM is in ready state
-                time.sleep(self.services["sleep"])
     
                 vm_response = VirtualMachine.list(
                     self.apiclient,
                     id=self.virtual_machine.id,
                 )
+                
                 # Verify VM response to check whether VM deployment was successful
                 self.assertEqual(
-                    isinstance(vm_response, list),
-                    True,
-                    "Check list VM response for valid list"
-                )
-                self.assertNotEqual(
-                    len(vm_response),
-                    0,
-                    "Check VMs available in List VMs response"
+                    validateList(vm_response)[0],
+                    PASS,
+                    "Invalid response returned for vm_response list during VM start up"
                 )
+                
                 vm = vm_response[0]
                 self.assertEqual(
                     vm.state,
                     'Running',
-                    "Check the state of VM"
+                    "Ensure the state of VM is running"
                 )
+                
             except Exception as e:
                 self.fail("Exception occurred: %s" % e)
                 


[24/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1458 from cloudsadhu/cloudsadhulocal

BUG-ID:CLOUDSTACK-9331:added code in marvin frame&new config file for advBaremetal support  Added code  in marvin framework&new config file  to support baremetal advanced testcases

* pr/1458:
  BUG-ID:CLOUDSTACK-9331:added code in marvin frame&new config file to support baremetal advanced testcases

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 939e44822757e2787a21611701941b14f703de71
Parents: 9b525f5 5f16199
Author: Will Stevens <wi...@gmail.com>
Authored: Mon Apr 25 15:55:08 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Mon Apr 25 15:55:09 2016 -0400

----------------------------------------------------------------------
 .../marvin/config/Baremetal_AdvZone_Vmware.cfg  | 208 +++++++++++++++++++
 tools/marvin/marvin/deployDataCenter.py         |  41 +++-
 2 files changed, 245 insertions(+), 4 deletions(-)
----------------------------------------------------------------------



[20/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
CLOUDSTACK-9323: Fix Cancel maintenance so that if maintenance is cancelled the host come back to normal state gracefully.
Added marvin tests for host maintennace.


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 182ab648b5afae21fddcd69e4cba1c15df721278
Parents: 8df8094
Author: Abhinandan Prateek <ap...@apache.org>
Authored: Mon Mar 28 08:17:43 2016 +0530
Committer: Abhinandan Prateek <ab...@shapeblue.com>
Committed: Mon Apr 25 15:28:32 2016 +0530

----------------------------------------------------------------------
 .../com/cloud/resource/ResourceManagerImpl.java |  10 +-
 .../component/test_host_maintenance.py          | 292 +++++++++++++++++++
 tools/marvin/marvin/lib/utils.py                |  23 +-
 3 files changed, 320 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182ab648/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 359bccf..8341075 100644
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -2112,11 +2112,13 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
         /* TODO: move to listener */
         _haMgr.cancelScheduledMigrations(host);
+
+        boolean vms_migrating = false;
         final List<VMInstanceVO> vms = _haMgr.findTakenMigrationWork();
         for (final VMInstanceVO vm : vms) {
-            if (vm != null && vm.getHostId() != null && vm.getHostId() == hostId) {
-                s_logger.info("Unable to cancel migration because the vm is being migrated: " + vm);
-                return false;
+            if (vm.getHostId() != null && vm.getHostId() == hostId) {
+                s_logger.warn("Unable to cancel migration because the vm is being migrated: " + vm + ", hostId = " + hostId);
+                vms_migrating = true;
             }
         }
 
@@ -2125,7 +2127,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
             _agentMgr.pullAgentOutMaintenance(hostId);
 
             // for kvm, need to log into kvm host, restart cloudstack-agent
-            if (host.getHypervisorType() == HypervisorType.KVM || host.getHypervisorType() == HypervisorType.LXC) {
+            if ((host.getHypervisorType() == HypervisorType.KVM && !vms_migrating) || host.getHypervisorType() == HypervisorType.LXC) {
 
                 final boolean sshToAgent = Boolean.parseBoolean(_configDao.getValue(Config.KvmSshToAgentEnabled.key()));
                 if (!sshToAgent) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182ab648/test/integration/component/test_host_maintenance.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_host_maintenance.py b/test/integration/component/test_host_maintenance.py
new file mode 100644
index 0000000..94f964c
--- /dev/null
+++ b/test/integration/component/test_host_maintenance.py
@@ -0,0 +1,292 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+""" BVT tests for Hosts Maintenance
+"""
+
+# Import Local Modules
+from marvin.codes import FAILED
+from marvin.cloudstackTestCase import *
+from marvin.cloudstackAPI import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from nose.plugins.attrib import attr
+
+from time import sleep
+
+_multiprocess_shared_ = False
+
+
+class TestHostMaintenance(cloudstackTestCase):
+
+    def setUp(self):
+        self.logger = logging.getLogger('TestHM')
+        self.stream_handler = logging.StreamHandler()
+        self.logger.setLevel(logging.DEBUG)
+        self.logger.addHandler(self.stream_handler)
+        self.apiclient = self.testClient.getApiClient()
+        self.hypervisor = self.testClient.getHypervisorInfo()
+        self.dbclient = self.testClient.getDbConnection()
+        self.services = self.testClient.getParsedTestDataConfig()
+        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
+        self.pod = get_pod(self.apiclient, self.zone.id)
+        self.cleanup = []
+        self.services = {
+                            "service_offering": {
+                                "name": "Ultra Tiny Instance",
+                                "displaytext": "Ultra Tiny Instance",
+                                "cpunumber": 1,
+                                "cpuspeed": 100,
+                                "memory": 128,
+                            },
+                            "vm": {
+                                "username": "root",
+                                "password": "password",
+                                "ssh_port": 22,
+                                # Hypervisor type should be same as
+                                # hypervisor type of cluster
+                                "privateport": 22,
+                                "publicport": 22,
+                                "protocol": 'TCP',
+                            },
+                            "natrule": {
+                                "privateport": 22,
+                                "publicport": 22,
+                                "startport": 22,
+                                "endport": 22,
+                                "protocol": "TCP",
+                                "cidrlist": '0.0.0.0/0',
+                            },
+                         "ostype": 'CentOS 5.3 (64-bit)',
+                         "sleep": 60,
+                         "timeout": 10,
+                         }
+        
+
+    def tearDown(self):
+        try:
+            # Clean up, terminate the created templates
+            cleanup_resources(self.apiclient, self.cleanup)
+
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+        return
+    
+    def createVMs(self, hostId, number):
+        
+        self.template = get_template(
+            self.apiclient,
+            self.zone.id,
+            self.services["ostype"]
+        )
+            
+        if self.template == FAILED:
+            assert False, "get_template() failed to return template with description %s" % self.services["ostype"]
+            
+        self.logger.debug("Using template %s " % self.template.id)
+                
+        self.service_offering = ServiceOffering.create(
+            self.apiclient,
+            self.services["service_offering"]
+        )
+        self.logger.debug("Using service offering %s " % self.service_offering.id)
+        
+        vms=[]
+        for i in range(0, number):
+            self.services["vm"]["zoneid"] = self.zone.id
+            self.services["vm"]["template"] = self.template.id
+            self.services["vm"]["displayname"] = 'vm' + str(i)
+            self.services["vm"]["hypervisor"] = self.hypervisor
+            vm = VirtualMachine.create(
+                self.apiclient,
+                self.services["vm"],
+                serviceofferingid=self.service_offering.id,
+                hostid=hostId
+            )
+            vms.append(vm)
+            self.cleanup.append(vm)
+            self.logger.debug("VM create = {}".format(vm.id))
+        return vms
+    
+    def checkVmMigratingOnHost(self, hostId):
+        vm_migrating=False
+        listVms1 = VirtualMachine.list(
+                                   self.apiclient, 
+                                   hostid=hostId
+                                   )
+
+        if (listVms1 is not None):
+            self.logger.debug('Vms found = {} '.format(len(listVms1)))
+            for vm in listVms1:
+                if (vm.state == "Migrating"):
+                    self.logger.debug('VirtualMachine on Hyp id = {} is in {}'.format(vm.id, vm.state))
+                    vm_migrating=True
+                    break
+
+        return (vm_migrating, None)
+    
+    def checkNoVmMigratingOnHost(self, hostId):
+        no_vm_migrating=True
+        listVms1 = VirtualMachine.list(
+                                   self.apiclient, 
+                                   hostid=hostId
+                                   )
+
+        if (listVms1 is not None):
+            self.logger.debug('Vms found = {} '.format(len(listVms1)))
+            for vm in listVms1:
+                if (vm.state == "Migrating"):
+                    self.logger.debug('VirtualMachine on Hyp id = {} is in {}'.format(vm.id, vm.state))
+                    no_vm_migrating=False
+                    break
+
+        return (no_vm_migrating, None)
+    
+    def noOfVMsOnHost(self, hostId):
+        listVms = VirtualMachine.list(
+                                       self.apiclient, 
+                                       hostid=hostId
+                                       )
+        no_of_vms=0
+        if (listVms is not None):
+            for vm in listVms:
+                self.logger.debug('VirtualMachine on Hyp 1 = {}'.format(vm.id))
+                no_of_vms=no_of_vms+1
+             
+        return no_of_vms
+    
+    def hostPrepareAndCancelMaintenance(self, target_host_id, other_host_id, checkVMMigration):
+        
+        cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
+        cmd.id = target_host_id
+        response = self.apiclient.prepareHostForMaintenance(cmd)
+        
+        self.logger.debug('Host with id {} is in prepareHostForMaintenance'.format(target_host_id))
+        
+        vm_migrating = wait_until(1, 10, checkVMMigration, other_host_id)
+        
+        cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
+        cmd.id = target_host_id
+        response = self.apiclient.cancelHostMaintenance(cmd)
+        
+        self.logger.debug('Host with id {} is in cancelHostMaintenance'.format(target_host_id) )
+        
+        return vm_migrating
+        
+    @attr(
+        tags=[
+            "advanced",
+            "advancedns",
+            "smoke",
+            "basic",
+            "eip",
+            "sg"],
+        required_hardware="true")
+    def test_01_cancel_host_maintenace_with_no_migration_jobs(self):
+        listHost = Host.list(
+            self.apiclient,
+            type='Routing',
+            zoneid=self.zone.id,
+            podid=self.pod.id,
+        )
+        for host in listHost:
+            self.logger.debug('1 Hypervisor = {}'.format(host.id))
+            
+                  
+        if (len(listHost) < 2):
+            raise unittest.SkipTest("Cancel host maintenance when VMs are migrating should be tested for 2 or more hosts");
+            return
+
+        vm_migrating=False
+        
+        try:
+
+           vm_migrating = self.hostPrepareAndCancelMaintenance(listHost[0].id, listHost[1].id, self.checkNoVmMigratingOnHost)
+           
+           vm_migrating = self.hostPrepareAndCancelMaintenance(listHost[1].id, listHost[0].id, self.checkNoVmMigratingOnHost)
+           
+        except Exception as e:
+            self.logger.debug("Exception {}".format(e))
+            self.fail("Cancel host maintenance failed {}".format(e[0]))
+        
+
+        if (vm_migrating == True):
+            raise unittest.SkipTest("VMs are migrating and the test will not be able to check the conditions the test is intended for");
+                
+            
+        return
+
+
+
+    
+    @attr(
+        tags=[
+            "advanced",
+            "advancedns",
+            "smoke",
+            "basic",
+            "eip",
+            "sg"],
+        required_hardware="true")
+    def test_02_cancel_host_maintenace_with_migration_jobs(self):
+        
+        listHost = Host.list(
+            self.apiclient,
+            type='Routing',
+            zoneid=self.zone.id,
+            podid=self.pod.id,
+        )
+        for host in listHost:
+            self.logger.debug('2 Hypervisor = {}'.format(host.id))
+            
+        if (len(listHost) != 2):
+            raise unittest.SkipTest("Cancel host maintenance when VMs are migrating can only be tested with 2 hosts");
+            return
+
+        
+        no_of_vms = self.noOfVMsOnHost(listHost[0].id)
+        
+        no_of_vms = no_of_vms + self.noOfVMsOnHost(listHost[1].id)
+                
+        if no_of_vms < 5:
+            self.logger.debug("Create VMs as there are not enough vms to check host maintenance")
+            no_vm_req = 5 - no_of_vms
+            if (no_vm_req > 0):
+                self.logger.debug("Creating vms = {}".format(no_vm_req))
+                self.vmlist = self.createVMs(listHost[0].id, no_vm_req)
+        
+        vm_migrating=False
+        
+        try:
+           
+           vm_migrating = self.hostPrepareAndCancelMaintenance(listHost[0].id, listHost[1].id, self.checkVmMigratingOnHost)
+           
+           vm_migrating = self.hostPrepareAndCancelMaintenance(listHost[1].id, listHost[0].id, self.checkVmMigratingOnHost)
+           
+        except Exception as e:
+            self.logger.debug("Exception {}".format(e))
+            self.fail("Cancel host maintenance failed {}".format(e[0]))
+        
+
+        if (vm_migrating == False):
+            raise unittest.SkipTest("No VM is migrating and the test will not be able to check the conditions the test is intended for");
+                
+            
+        return
+
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182ab648/tools/marvin/marvin/lib/utils.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/utils.py b/tools/marvin/marvin/lib/utils.py
index 97b80ac..aa41e7b 100644
--- a/tools/marvin/marvin/lib/utils.py
+++ b/tools/marvin/marvin/lib/utils.py
@@ -520,4 +520,25 @@ def verifyRouterState(apiclient, routerid, allowedstates):
     if routers[0].state.lower() not in allowedstates:
         return [FAIL, "state of the router should be in %s but is %s" %
             (allowedstates, routers[0].state)]
-    return [PASS, None]
\ No newline at end of file
+    return [PASS, None]
+
+
+    
+def wait_until(retry_interval=2, no_of_times=2, callback=None, *callback_args):
+    """ Utility method to try out the callback method at most no_of_times with a interval of retry_interval,
+        Will return immediately if callback returns True. The callback method should be written to return a list of values first being a boolean """
+
+    if callback is None:
+        raise ("Bad value for callback method !")
+            
+    wait_result = False
+    for i in range(0,no_of_times):
+        time.sleep(retry_interval)
+        wait_result, return_val = callback(*callback_args)
+        if not(isinstance(wait_result, bool)):
+            raise ("Bad parameter returned from callback !")
+        if wait_result :
+            break
+
+    return wait_result, return_val
+


[36/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge release branch 4.7 to 4.8

* 4.7:
  Removed sleeps and used validateList as requested.
  Added required_hardware="false" attr above test_02_root_volume_attach_detach
  Modified test_volumes.py to include a hypervisor test for root attach/detach testing
  Let hypervisor type KVM and Simulator detach root volumes. Updated test_volumes.py to include a test for detaching and reattaching a root volume from a vm. I also had to update base.py to allow attach_volume to have the parameter deviceid to be passed as needed.


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: d11194abec1410202d062c03d69f8e6bde9d11a9
Parents: 43ab44d 1979f42
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 16:03:46 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 16:03:46 2016 -0400

----------------------------------------------------------------------
 .../com/cloud/storage/VolumeApiServiceImpl.java |   4 +-
 test/integration/component/test_volumes.py      | 135 ++++++++++++++++++-
 tools/marvin/marvin/lib/base.py                 |   6 +-
 3 files changed, 141 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d11194ab/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------


[03/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
CLOUDSTACK-9283: add pid to java arguments in systemd/cloudstack-usage.service


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: ce180796e9c6f2a1a96d5ae51f8a1ab592c42090
Parents: 3d9919e
Author: David Amorim Faria <d....@tech.leaseweb.com>
Authored: Wed Feb 10 16:46:03 2016 +0100
Committer: David Amorim Faria <d....@tech.leaseweb.com>
Committed: Wed Feb 10 16:46:03 2016 +0100

----------------------------------------------------------------------
 packaging/systemd/cloudstack-usage.service | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce180796/packaging/systemd/cloudstack-usage.service
----------------------------------------------------------------------
diff --git a/packaging/systemd/cloudstack-usage.service b/packaging/systemd/cloudstack-usage.service
index 9a1827d..d80aba6 100644
--- a/packaging/systemd/cloudstack-usage.service
+++ b/packaging/systemd/cloudstack-usage.service
@@ -27,10 +27,11 @@ Environment=JAVA_HOME=/usr/lib/jvm/jre
 Environment=JAVA_HEAP_INITIAL=256m
 Environment=JAVA_HEAP_MAX=2048m
 Environment=JAVA_CLASS=com.cloud.usage.UsageServer
+Environment=JAVA_PID=$$
 ExecStart=/bin/sh -ec '\
     export UCP=`ls /usr/share/cloudstack-usage/cloud-usage-*.jar /usr/share/cloudstack-usage/lib/*.jar | tr "\\n" ":"`; \
     export CLASSPATH="$UCP:/etc/cloudstack/usage:/usr/share/java/mysql-connector-java.jar"; \
-    ${JAVA_HOME}/bin/java -Xms${JAVA_HEAP_INITIAL} -Xmx${JAVA_HEAP_MAX} -cp "$CLASSPATH" $JAVA_CLASS'
+    ${JAVA_HOME}/bin/java -Dpid=${JAVA_PID} -Xms${JAVA_HEAP_INITIAL} -Xmx${JAVA_HEAP_MAX} -cp "$CLASSPATH" $JAVA_CLASS'
 Restart=always
 RestartSec=10s
 


[29/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1348 from DaanHoogland/CLOUDSTACK-9142

CLOUDSTACK-9142 Migrate VM changes xmlDesc in a safe wayThe problem arises when the origin hypervisor has an ip addres that ends with 1, like '10.10.10.1' and the qemu VM description is containing an address that has that as part of its address, '10.10.10.100' for instance.
now migrating to '10.10.10.10' will change both addresses in the xml description file for qemu. It is fixed and unit tests are added. I am not sure yet how to integration test this. Regression will probably work so creating a PR now.

* pr/1348:
  CLOUDSTACK-9142 Migrate VM changes xmlDesc in a safe way

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: c03e359824327b56af6b1921155d8796d2958f9c
Parents: d13ff88 8a6afa6
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 15:55:09 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 15:55:09 2016 -0400

----------------------------------------------------------------------
 .../wrapper/LibvirtMigrateCommandWrapper.java   |  34 ++-
 .../resource/LibvirtComputingResourceTest.java  |  22 +-
 .../LibvirtMigrateCommandWrapperTest.java       | 306 +++++++++++++++++++
 3 files changed, 349 insertions(+), 13 deletions(-)
----------------------------------------------------------------------



[40/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
Merge pull request #1409 from davidamorimfaria/CLOUDSTACK-9283

CLOUDSTACK-9283: add pid to java arguments in cloudstack-usage.servicecloudstack-usage fails to start throwing Integer exception during PID retrieval, and the service keeps restarting after 10s (as defined in the systemd service definition).

Adding the pid to the java arguments in the systemd service definition makes it stop looping in centos7

* pr/1409:
  CLOUDSTACK-9283: add pid to java arguments in systemd/cloudstack-usage.service

Signed-off-by: Will Stevens <wi...@gmail.com>


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: e762e27054ef79a656678fcc5a3b329574d3372a
Parents: ad138a1 ce18079
Author: Will Stevens <wi...@gmail.com>
Authored: Thu Apr 28 16:07:08 2016 -0400
Committer: Will Stevens <wi...@gmail.com>
Committed: Thu Apr 28 16:07:08 2016 -0400

----------------------------------------------------------------------
 packaging/systemd/cloudstack-usage.service | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[06/44] git commit: updated refs/heads/4.9-bountycastle-daan to a001d75

Posted by da...@apache.org.
CLOUDSTACK-9320 : InternalLBVM is not getting destroyed when the last Internal Load Balancer rule is removed for the corresponding source IP address


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

Branch: refs/heads/4.9-bountycastle-daan
Commit: 741e88833f9b0d533f66bc8875675ede51c15922
Parents: ae0d6b3
Author: Nick Livens <ni...@nuagenetworks.net>
Authored: Mon Mar 21 14:34:18 2016 +0100
Committer: Nick Livens <ni...@nuagenetworks.net>
Committed: Tue Mar 29 11:24:50 2016 +0200

----------------------------------------------------------------------
 .../element/InternalLoadBalancerElement.java    | 84 +++++++++++---------
 1 file changed, 45 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/741e8883/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
index 1e0b294..f3ebeb0 100644
--- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
@@ -302,50 +302,54 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     @Override
     public boolean applyLBRules(Network network, List<LoadBalancingRule> rules) throws ResourceUnavailableException {
         //1) Get Internal LB VMs to destroy
-        Set<Ip> vmsToDestroy = getVmsToDestroy(rules);
+        Set<Ip> vmsToDestroy = getVmsToDestroy(network, rules);
 
         //2) Get rules to apply
         Map<Ip, List<LoadBalancingRule>> rulesToApply = getLbRulesToApply(rules);
         s_logger.debug("Applying " + rulesToApply.size() + " on element " + getName());
 
-        for (Ip sourceIp : rulesToApply.keySet()) {
-            if (vmsToDestroy.contains(sourceIp)) {
-                //2.1 Destroy internal lb vm
-                List<? extends VirtualRouter> vms = _internalLbMgr.findInternalLbVms(network.getId(), sourceIp);
-                if (vms.size() > 0) {
-                    //only one internal lb per IP exists
-                    try {
-                        s_logger.debug("Destroying internal lb vm for ip " + sourceIp.addr() + " as all the rules for this vm are in Revoke state");
-                        return _internalLbMgr.destroyInternalLbVm(vms.get(0).getId(), _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM),
-                            _accountMgr.getUserIncludingRemoved(User.UID_SYSTEM).getId());
-                    } catch (ConcurrentOperationException e) {
-                        s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr() + " on the element " + getName() + " due to:", e);
-                        return false;
-                    }
-                }
-            } else {
-                //2.2 Start Internal LB vm per IP address
-                List<? extends VirtualRouter> internalLbVms;
+        for (Ip sourceIp : vmsToDestroy) {
+            //2.1 Destroy internal lb vm
+            List<? extends VirtualRouter> vms = _internalLbMgr.findInternalLbVms(network.getId(), sourceIp);
+            if (vms.size() > 0) {
+                //only one internal lb per IP exists
                 try {
-                    DeployDestination dest = new DeployDestination(_entityMgr.findById(DataCenter.class, network.getDataCenterId()), null, null, null);
-                    internalLbVms = _internalLbMgr.deployInternalLbVm(network, sourceIp, dest, _accountMgr.getAccount(network.getAccountId()), null);
-                } catch (InsufficientCapacityException e) {
-                    s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr() + "on the element " + getName() + " due to:", e);
-                    return false;
+                    s_logger.debug(String.format("Destroying internal lb vm for ip %s as all the rules for this vm are in Revoke state", sourceIp.addr()));
+                    return _internalLbMgr.destroyInternalLbVm(vms.get(0).getId(), _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM),
+                            _accountMgr.getUserIncludingRemoved(User.UID_SYSTEM).getId());
                 } catch (ConcurrentOperationException e) {
-                    s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr() + "on the element " + getName() + " due to:", e);
+                    s_logger.warn(String.format("Failed to apply lb rule(s) for ip %s on the element %s due to: ", sourceIp.addr(), getName()), e);
                     return false;
                 }
+            }
 
-                if (internalLbVms == null || internalLbVms.isEmpty()) {
-                    throw new ResourceUnavailableException("Can't find/deploy internal lb vm to handle LB rules", DataCenter.class, network.getDataCenterId());
-                }
+            rulesToApply.remove(sourceIp);
+        }
 
-                //2.3 Apply Internal LB rules on the VM
-                if (!_internalLbMgr.applyLoadBalancingRules(network, rulesToApply.get(sourceIp), internalLbVms)) {
-                    throw new CloudRuntimeException("Failed to apply load balancing rules for ip " + sourceIp.addr() + " in network " + network.getId() + " on element " +
-                        getName());
-                }
+        for (Map.Entry<Ip,List<LoadBalancingRule>> entry : rulesToApply.entrySet()) {
+            Ip sourceIp = entry.getKey();
+            //2.2 Start Internal LB vm per IP address
+            List<? extends VirtualRouter> internalLbVms;
+            try {
+                DeployDestination dest = new DeployDestination(_entityMgr.findById(DataCenter.class, network.getDataCenterId()), null, null, null);
+                internalLbVms = _internalLbMgr.deployInternalLbVm(network, sourceIp, dest, _accountMgr.getAccount(network.getAccountId()), null);
+            } catch (InsufficientCapacityException e) {
+                s_logger.warn(String.format("Failed to apply lb rule(s) for ip %s on the element %s due to: ", sourceIp.addr(), getName()), e);
+                return false;
+            } catch (ConcurrentOperationException e) {
+                s_logger.warn(String.format("Failed to apply lb rule(s) for ip %s on the element %s due to: ", sourceIp.addr(), getName()), e);
+                return false;
+            }
+
+            if (internalLbVms == null || internalLbVms.isEmpty()) {
+                throw new ResourceUnavailableException("Can't find/deploy internal lb vm to handle LB rules",
+                        DataCenter.class, network.getDataCenterId());
+            }
+
+            //2.3 Apply Internal LB rules on the VM
+            if (!_internalLbMgr.applyLoadBalancingRules(network, entry.getValue(), internalLbVms)) {
+                throw new CloudRuntimeException("Failed to apply load balancing rules for ip " + sourceIp.addr() +
+                        " in network " + network.getId() + " on element " + getName());
             }
         }
 
@@ -359,16 +363,18 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
         return rulesToApply;
     }
 
-    protected Set<Ip> getVmsToDestroy(List<LoadBalancingRule> rules) {
+    protected Set<Ip> getVmsToDestroy(Network network, List<LoadBalancingRule> rules) {
         //1) Group rules by the source ip address as NetworkManager always passes the entire network lb config to the element
-        Map<Ip, List<LoadBalancingRule>> groupedRules = groupBySourceIp(rules);
-
+        Set<Ip> lbPublicIps = new HashSet<Ip>();
         Set<Ip> vmsToDestroy = new HashSet<Ip>();
 
-        for (Ip sourceIp : groupedRules.keySet()) {
+        for (LoadBalancingRule rule : rules) {
+            lbPublicIps.add(rule.getSourceIp());
+        }
+
+        for (Ip sourceIp : lbPublicIps) {
             //2) Check if there are non revoked rules for the source ip address
-            List<LoadBalancingRule> rulesToCheck = groupedRules.get(sourceIp);
-            if (_appLbDao.countBySourceIpAndNotRevoked(sourceIp, rulesToCheck.get(0).getNetworkId()) == 0) {
+            if (_appLbDao.countBySourceIpAndNotRevoked(sourceIp, network.getId()) == 0) {
                 s_logger.debug("Have to destroy internal lb vm for source ip " + sourceIp + " as it has 0 rules in non-Revoke state");
                 vmsToDestroy.add(sourceIp);
             }