cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [1/3] Moving maintenance mode into component/maint
Date Mon, 17 Jun 2013 07:04:10 GMT
Updated Branches:
  refs/heads/master a3d585ea4 -> 0587d3a49


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0587d3a4/test/integration/component/test_host_high_availability.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_host_high_availability.py b/test/integration/component/test_host_high_availability.py
deleted file mode 100644
index 2fe07b1..0000000
--- a/test/integration/component/test_host_high_availability.py
+++ /dev/null
@@ -1,810 +0,0 @@
-# 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.
-
-""" P1 tests for dedicated Host high availability 
-"""
-#Import Local Modules
-from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-
-
-class Services:
-    """ Dedicated host HA test cases """
-
-    def __init__(self):
-        self.services = {
-            "account": {
-                "email": "test@test.com",
-                "firstname": "HA",
-                "lastname": "HA",
-                "username": "HA",
-                # Random characters are appended for unique
-                # username
-                "password": "password",
-            },
-            "service_offering_with_ha": {
-                "name": "Tiny Instance With HA Enabled",
-                "displaytext": "Tiny Instance",
-                "cpunumber": 1,
-                "cpuspeed": 100, # in MHz
-                "memory": 128, # In MBs
-            },
-            "service_offering_without_ha": {
-                "name": "Tiny Instance Without HA",
-                "displaytext": "Tiny Instance",
-                "cpunumber": 1,
-                "cpuspeed": 100, # in MHz
-                "memory": 128, # In MBs
-            },
-            "virtual_machine": {
-                "displayname": "VM",
-                "username": "root",
-                "password": "password",
-                "ssh_port": 22,
-                "hypervisor": 'XenServer',
-                # Hypervisor type should be same as
-                # hypervisor type of cluster
-                "privateport": 22,
-                "publicport": 22,
-                "protocol": 'TCP',
-            },
-            "ostype": 'CentOS 5.3 (64-bit)',
-            "timeout": 100,
-        }
-
-
-class TestHostHighAvailability(cloudstackTestCase):
-    """ Dedicated host HA test cases """
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-            TestHostHighAvailability,
-            cls
-        ).getClsTestClient().getApiClient()
-        cls.services = Services().services
-        # Get Zone, Domain and templates
-        cls.domain = get_domain(
-            cls.api_client,
-            cls.services
-        )
-        cls.zone = get_zone(
-            cls.api_client,
-            cls.services
-        )
-
-        cls.template = get_template(
-            cls.api_client,
-            cls.zone.id,
-            cls.services["ostype"]
-        )
-        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-        cls.services["virtual_machine"]["template"] = cls.template.id
-
-        cls.service_offering_with_ha = ServiceOffering.create(
-            cls.api_client,
-            cls.services["service_offering_with_ha"],
-            offerha=True
-        )
-
-        cls.service_offering_without_ha = ServiceOffering.create(
-            cls.api_client,
-            cls.services["service_offering_without_ha"],
-            offerha=False
-        )
-
-        cls._cleanup = [
-            cls.service_offering_with_ha,
-            cls.service_offering_without_ha,
-        ]
-        return
-
-    @classmethod
-    def tearDownClass(cls):
-        try:
-            #Cleanup resources used
-            cleanup_resources(cls.api_client, cls._cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    def setUp(self):
-        self.apiclient = self.testClient.getApiClient()
-        self.dbclient = self.testClient.getDbConnection()
-        self.account = Account.create(
-            self.apiclient,
-            self.services["account"],
-            admin=True,
-            domainid=self.domain.id
-        )
-        self.cleanup = [self.account]
-        return
-
-    def tearDown(self):
-        try:
-            #Clean up, terminate the created accounts, domains etc
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    @attr(configuration="ha.tag")
-    @attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator"])
-    def test_01_vm_deployment_with_compute_offering_with_ha_enabled(self):
-        """ Test VM deployments (Create HA enabled Compute Service Offering and VM) """
-
-        # 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.
-        # Validations,
-        #1. Ensure that the offering is created and that in the UI the 'Offer HA' field is enabled (Yes)
-        #The listServiceOffering API should list 'offerha' as true.
-        #2. Select the newly created VM and ensure that the Compute offering field value lists the compute service offering that was selected. 
-        #    Also, check that the HA Enabled field is enabled 'Yes'.
-
-        #list and validate above created service offering with Ha enabled
-        list_service_response = list_service_offering(
-            self.apiclient,
-            id=self.service_offering_with_ha.id
-        )
-        self.assertEqual(
-            isinstance(list_service_response, list),
-            True,
-            "listServiceOfferings returned invalid object in response."
-        )
-        self.assertNotEqual(
-            len(list_service_response),
-            0,
-            "listServiceOfferings returned empty list."
-        )
-        self.assertEqual(
-            list_service_response[0].offerha,
-            True,
-            "The service offering is not HA enabled"
-        )
-
-        #create virtual machine with the service offering with Ha enabled
-        virtual_machine = VirtualMachine.create(
-            self.apiclient,
-            self.services["virtual_machine"],
-            accountid=self.account.name,
-            domainid=self.account.domainid,
-            serviceofferingid=self.service_offering_with_ha.id
-        )
-        vms = VirtualMachine.list(
-            self.apiclient,
-            id=virtual_machine.id,
-            listall=True
-        )
-        self.assertEqual(
-            isinstance(vms, list),
-            True,
-            "listVirtualMachines returned invalid object in response."
-        )
-        self.assertNotEqual(
-            len(vms),
-            0,
-            "listVirtualMachines returned empty list."
-        )
-        self.debug("Deployed VM on host: %s" % vms[0].hostid)
-        self.assertEqual(
-            vms[0].haenable,
-            True,
-            "VM not created with HA enable tag"
-        )
-
-    @attr(configuration="ha.tag")
-    @attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
-    def test_02_no_vm_creation_on_host_with_haenabled(self):
-        """ Verify you can not create new VMs on hosts with an ha.tag """
-
-        # Steps,
-        #1. Fresh install CS (Bonita) that supports this feature
-        #2. Create Basic zone, pod, cluster, add 3 hosts to cluster (host1, host2, host3), secondary & primary Storage
-        #3. When adding host3, assign the HA host tag.
-        #4. You should already have a compute service offering with HA already create from above. If not, create one for HA.
-        #5. Create VMs with the service offering with and without the HA tag
-        # Validations,
-        #Check to make sure the newly created VM is not on any HA enabled hosts
-        #The  VM should be created only on host1 or host2 and never host3 (HA enabled)
-
-        #create and verify virtual machine with HA enabled service offering
-        virtual_machine_with_ha = VirtualMachine.create(
-            self.apiclient,
-            self.services["virtual_machine"],
-            accountid=self.account.name,
-            domainid=self.account.domainid,
-            serviceofferingid=self.service_offering_with_ha.id
-        )
-
-        vms = VirtualMachine.list(
-            self.apiclient,
-            id=virtual_machine_with_ha.id,
-            listall=True
-        )
-
-        self.assertEqual(
-            isinstance(vms, list),
-            True,
-            "listVirtualMachines returned invalid object in response."
-        )
-
-        self.assertNotEqual(
-            len(vms),
-            0,
-            "listVirtualMachines returned empty list."
-        )
-
-        vm = vms[0]
-
-        self.debug("Deployed VM on host: %s" % vm.hostid)
-
-        #validate the virtual machine created is host Ha enabled 
-        list_hosts_response = list_hosts(
-            self.apiclient,
-            id=vm.hostid
-        )
-        self.assertEqual(
-            isinstance(list_hosts_response, list),
-            True,
-            "listHosts returned invalid object in response."
-        )
-
-        self.assertNotEqual(
-            len(list_hosts_response),
-            0,
-            "listHosts retuned empty list in response."
-        )
-
-        self.assertEqual(
-            list_hosts_response[0].hahost,
-            False,
-            "VM created on HA enabled host."
-        )
-
-        #create and verify virtual machine with Ha disabled service offering
-        virtual_machine_without_ha = VirtualMachine.create(
-            self.apiclient,
-            self.services["virtual_machine"],
-            accountid=self.account.name,
-            domainid=self.account.domainid,
-            serviceofferingid=self.service_offering_without_ha.id
-        )
-
-        vms = VirtualMachine.list(
-            self.apiclient,
-            id=virtual_machine_without_ha.id,
-            listall=True
-        )
-
-        self.assertEqual(
-            isinstance(vms, list),
-            True,
-            "listVirtualMachines returned invalid object in response."
-        )
-
-        self.assertNotEqual(
-            len(vms),
-            0,
-            "listVirtualMachines returned empty list."
-        )
-
-        vm = vms[0]
-
-        self.debug("Deployed VM on host: %s" % vm.hostid)
-
-        #verify that the virtual machine created on the host is Ha disabled
-        list_hosts_response = list_hosts(
-            self.apiclient,
-            id=vm.hostid
-        )
-        self.assertEqual(
-            isinstance(list_hosts_response, list),
-            True,
-            "listHosts returned invalid object in response."
-        )
-
-        self.assertNotEqual(
-            len(list_hosts_response),
-            0,
-            "listHosts returned empty list."
-        )
-
-        host = list_hosts_response[0]
-
-        self.assertEqual(
-            host.hahost,
-            False,
-            "VM migrated to HA enabled host."
-        )
-
-    @attr(configuration="ha.tag")
-    @attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
-    def test_03_cant_migrate_vm_to_host_with_ha_positive(self):
-        """ Verify you can not migrate VMs to hosts with an ha.tag (positive) """
-
-        # 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. Select the VM and migrate VM to another host. Choose a 'Suitable' host (i.e. host2)
-        # Validations
-        #The option from the 'Migrate instance to another host' dialog box' should list host3 as 'Not Suitable' for migration.
-        #Confirm that the VM is migrated to the 'Suitable' host you selected (i.e. host2)
-
-        #create and verify the virtual machine with HA enabled service offering
-        virtual_machine_with_ha = VirtualMachine.create(
-            self.apiclient,
-            self.services["virtual_machine"],
-            accountid=self.account.name,
-            domainid=self.account.domainid,
-            serviceofferingid=self.service_offering_with_ha.id
-        )
-
-        vms = VirtualMachine.list(
-            self.apiclient,
-            id=virtual_machine_with_ha.id,
-            listall=True,
-        )
-
-        self.assertEqual(
-            isinstance(vms, list),
-            True,
-            "List VMs should return valid response for deployed VM"
-        )
-
-        self.assertNotEqual(
-            len(vms),
-            0,
-            "List VMs should return valid response for deployed VM"
-        )
-
-        vm = vms[0]
-
-        self.debug("Deployed VM on host: %s" % vm.hostid)
-
-        #Find out a Suitable host for VM migration
-        list_hosts_response = list_hosts(
-            self.apiclient,
-        )
-        self.assertEqual(
-            isinstance(list_hosts_response, list),
-            True,
-            "The listHosts API returned the invalid list"
-        )
-
-        self.assertNotEqual(
-            len(list_hosts_response),
-            0,
-            "The listHosts returned nothing."
-        )
-        suitableHost = None
-        for host in list_hosts_response:
-            if host.suitableformigration == True and host.hostid != vm.hostid:
-                suitableHost = host
-                break
-
-        self.assertTrue(suitableHost is not None, "suitablehost should not be None")
-
-        #Migration of the VM to a suitable host
-        self.debug("Migrating VM-ID: %s to Host: %s" % (self.vm.id, suitableHost.id))
-
-        cmd = migrateVirtualMachine.migrateVirtualMachineCmd()
-        cmd.hostid = suitableHost.id
-        cmd.virtualmachineid = self.vm.id
-        self.apiclient.migrateVirtualMachine(cmd)
-
-        #Verify that the VM migrated to a targeted Suitable host
-        list_vm_response = list_virtual_machines(
-            self.apiclient,
-            id=vm.id
-        )
-        self.assertEqual(
-            isinstance(list_vm_response, list),
-            True,
-            "The listVirtualMachines returned the invalid list."
-        )
-
-        self.assertNotEqual(
-            list_vm_response,
-            None,
-            "The listVirtualMachines API returned nothing."
-        )
-
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-            vm_response.id,
-            vm.id,
-            "The virtual machine id and the the virtual machine from listVirtualMachines is not matching."
-        )
-
-        self.assertEqual(
-            vm_response.hostid,
-            suitableHost.id,
-            "The VM is not migrated to targeted suitable host."
-        )
-
-    @attr(configuration="ha.tag")
-    @attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
-    def test_04_cant_migrate_vm_to_host_with_ha_negative(self):
-        """ Verify you can not migrate VMs to hosts with an ha.tag (negative) """
-
-        # 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. Select the VM and migrate VM to another host. Choose a 'Not Suitable' host.
-        # Validations,
-        #The option from the 'Migrate instance to another host' dialog box should list host3 as 'Not Suitable' for migration.
-        #By design, The Guest VM can STILL can be migrated to host3 if the admin chooses to do so.
-
-        #create and verify virtual machine with HA enabled service offering
-        virtual_machine_with_ha = VirtualMachine.create(
-            self.apiclient,
-            self.services["virtual_machine"],
-            accountid=self.account.name,
-            domainid=self.account.domainid,
-            serviceofferingid=self.service_offering_with_ha.id
-        )
-
-        vms = VirtualMachine.list(
-            self.apiclient,
-            id=virtual_machine_with_ha.id,
-            listall=True
-        )
-
-        self.assertEqual(
-            isinstance(vms, list),
-            True,
-            "The listVirtualMachines returned invalid object in response."
-        )
-
-        self.assertNotEqual(
-            len(vms),
-            0,
-            "The listVirtualMachines returned empty response."
-        )
-
-        vm = vms[0]
-
-        self.debug("Deployed VM on host: %s" % vm.hostid)
-
-        #Find out Non-Suitable host for VM migration
-        list_hosts_response = list_hosts(
-            self.apiclient,
-        )
-        self.assertEqual(
-            isinstance(list_hosts_response, list),
-            True,
-            "listHosts returned invalid object in response."
-        )
-
-        self.assertNotEqual(
-            len(list_hosts_response),
-            0,
-            "listHosts returned empty response."
-        )
-
-        notSuitableHost = None
-        for host in list_hosts_response:
-            if not host.suitableformigration and host.hostid != vm.hostid:
-                notSuitableHost = host
-                break
-
-        self.assertTrue(notSuitableHost is not None, "notsuitablehost should not be None")
-
-        #Migrate VM to Non-Suitable host
-        self.debug("Migrating VM-ID: %s to Host: %s" % (vm.id, notSuitableHost.id))
-
-        cmd = migrateVirtualMachine.migrateVirtualMachineCmd()
-        cmd.hostid = notSuitableHost.id
-        cmd.virtualmachineid = vm.id
-        self.apiclient.migrateVirtualMachine(cmd)
-
-        #Verify that the virtual machine got migrated to targeted Non-Suitable host
-        list_vm_response = list_virtual_machines(
-            self.apiclient,
-            id=vm.id
-        )
-        self.assertEqual(
-            isinstance(list_vm_response, list),
-            True,
-            "listVirtualMachine returned invalid object in response."
-        )
-
-        self.assertNotEqual(
-            len(list_vm_response),
-            0,
-            "listVirtualMachines returned empty response."
-        )
-
-        self.assertEqual(
-            list_vm_response[0].id,
-            vm.id,
-            "Virtual machine id with the virtual machine from listVirtualMachine is not matching."
-        )
-
-        self.assertEqual(
-            list_vm_response[0].hostid,
-            notSuitableHost.id,
-            "The detination host id of migrated VM is not matching."
-        )
-
-    @attr(configuration="ha.tag")
-    @attr(speed="slow")
-    @attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
-    def test_05_no_vm_with_ha_gets_migrated_to_ha_host_in_live_migration(self):
-        """ Verify that none of the VMs with HA enabled migrate to an ha tagged host during live migration """
-
-        # Steps,
-        #1. Fresh install CS that supports this feature
-        #2. Create Basic zone, pod, cluster, add 3 hosts to cluster (host1, host2, host3), secondary & primary Storage
-        #3. When adding host3, assign the HA host tag.
-        #4. Create VMs with and without the Compute Service Offering with the HA tag.
-        #5. Note the VMs on host1 and whether any of the VMs have their 'HA enabled' flags enabled.
-        #6. Put host1 into maintenance mode.
-        # Validations,
-        #1. Make sure the VMs are created on either host1 or host2 and not on host3
-        #2. Putting host1 into maintenance mode should trigger a live migration. Make sure the VMs are not migrated to HA enabled host3.
-
-        # create and verify virtual machine with HA disabled service offering
-        virtual_machine_with_ha = VirtualMachine.create(
-            self.apiclient,
-            self.services["virtual_machine"],
-            accountid=self.account.name,
-            domainid=self.account.domainid,
-            serviceofferingid=self.service_offering_with_ha.id
-        )
-
-        vms = VirtualMachine.list(
-            self.apiclient,
-            id=virtual_machine_with_ha.id,
-            listall=True
-        )
-
-        self.assertEqual(
-            isinstance(vms, list),
-            True,
-            "List VMs should return valid response for deployed VM"
-        )
-
-        self.assertNotEqual(
-            len(vms),
-            0,
-            "List VMs should return valid response for deployed VM"
-        )
-
-        vm_with_ha_enabled = vms[0]
-
-        #Verify the virtual machine got created on non HA host 
-        list_hosts_response = list_hosts(
-            self.apiclient,
-            id=vm_with_ha_enabled.hostid
-        )
-        self.assertEqual(
-            isinstance(list_hosts_response, list),
-            True,
-            "Check list response returns a valid list"
-        )
-
-        self.assertNotEqual(
-            len(list_hosts_response),
-            0,
-            "Check Host is available"
-        )
-
-        self.assertEqual(
-            list_hosts_response[0].hahost,
-            False,
-            "The virtual machine is not ha enabled so check if VM is created on host which is also not ha enabled"
-        )
-
-        #put the Host in maintainance mode
-        self.debug("Enabling maintenance mode for host %s" % vm_with_ha_enabled.hostid)
-        cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
-        cmd.id = vm_with_ha_enabled.hostid
-        self.apiclient.prepareHostForMaintenance(cmd)
-
-        timeout = self.services["timeout"]
-
-        #verify the VM live migration happened to another running host
-        self.debug("Waiting for VM to come up")
-        wait_for_vm(
-            self.apiclient,
-            virtualmachineid=vm_with_ha_enabled.id,
-            interval=timeout
-        )
-
-        vms = VirtualMachine.list(
-            self.apiclient,
-            id=vm_with_ha_enabled.id,
-            listall=True,
-        )
-
-        self.assertEqual(
-            isinstance(vms, list),
-            True,
-            "List VMs should return valid response for deployed VM"
-        )
-
-        self.assertNotEqual(
-            len(vms),
-            0,
-            "List VMs should return valid response for deployed VM"
-        )
-
-        vm_with_ha_enabled1 = vms[0]
-
-        list_hosts_response = list_hosts(
-            self.apiclient,
-            id=vm_with_ha_enabled1.hostid
-        )
-        self.assertEqual(
-            isinstance(list_hosts_response, list),
-            True,
-            "Check list response returns a valid list"
-        )
-
-        self.assertNotEqual(
-            len(list_hosts_response),
-            0,
-            "Check Host is available"
-        )
-
-        self.assertEqual(
-            list_hosts_response[0].hahost,
-            False,
-            "The virtual machine is not ha enabled so check if VM is created on host which is also not ha enabled"
-        )
-
-        self.debug("Disabling the maintenance mode for host %s" % vm_with_ha_enabled.hostid)
-        cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
-        cmd.id = vm_with_ha_enabled.hostid
-        self.apiclient.cancelHostMaintenance(cmd)
-
-    @attr(configuration="ha.tag")
-    @attr(speed="slow")
-    @attr(tags=["advanced", "advancedns", "sg", "basic", "eip", "simulator", "multihost"])
-    def test_06_no_vm_without_ha_gets_migrated_to_ha_host_in_live_migration(self):
-        """ Verify that none of the VMs without HA enabled migrate to an ha tagged host during live migration """
-
-        # Steps,
-        #1. Fresh install CS that supports this feature
-        #2. Create Basic zone, pod, cluster, add 3 hosts to cluster (host1, host2, host3), secondary & primary Storage
-        #3. When adding host3, assign the HA host tag.
-        #4. Create VMs with and without the Compute Service Offering with the HA tag.
-        #5. Note the VMs on host1 and whether any of the VMs have their 'HA enabled' flags enabled.
-        #6. Put host1 into maintenance mode.
-        # Validations,
-        #1. Make sure the VMs are created on either host1 or host2 and not on host3
-        #2. Putting host1 into maintenance mode should trigger a live migration. Make sure the VMs are not migrated to HA enabled host3.
-
-        # create and verify virtual machine with HA disabled service offering
-        virtual_machine_without_ha = VirtualMachine.create(
-            self.apiclient,
-            self.services["virtual_machine"],
-            accountid=self.account.name,
-            domainid=self.account.domainid,
-            serviceofferingid=self.service_offering_without_ha.id
-        )
-
-        vms = VirtualMachine.list(
-            self.apiclient,
-            id=virtual_machine_without_ha.id,
-            listall=True
-        )
-
-        self.assertEqual(
-            isinstance(vms, list),
-            True,
-            "List VMs should return valid response for deployed VM"
-        )
-
-        self.assertNotEqual(
-            len(vms),
-            0,
-            "List VMs should return valid response for deployed VM"
-        )
-
-        vm_with_ha_disabled = vms[0]
-
-        #Verify the virtual machine got created on non HA host 
-        list_hosts_response = list_hosts(
-            self.apiclient,
-            id=vm_with_ha_disabled.hostid
-        )
-        self.assertEqual(
-            isinstance(list_hosts_response, list),
-            True,
-            "Check list response returns a valid list"
-        )
-
-        self.assertNotEqual(
-            len(list_hosts_response),
-            0,
-            "Check Host is available"
-        )
-
-        self.assertEqual(
-            list_hosts_response[0].hahost,
-            False,
-            "The virtual machine is not ha enabled so check if VM is created on host which is also not ha enabled"
-        )
-
-        #put the Host in maintainance mode
-        self.debug("Enabling maintenance mode for host %s" % vm_with_ha_disabled.hostid)
-        cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
-        cmd.id = vm_with_ha_disabled.hostid
-        self.apiclient.prepareHostForMaintenance(cmd)
-
-        timeout = self.services["timeout"]
-
-        #verify the VM live migration happened to another running host
-        self.debug("Waiting for VM to come up")
-        wait_for_vm(
-            self.apiclient,
-            virtualmachineid=vm_with_ha_disabled.id,
-            interval=timeout
-        )
-
-        vms = VirtualMachine.list(
-            self.apiclient,
-            id=vm_with_ha_disabled.id,
-            listall=True
-        )
-
-        self.assertEqual(
-            isinstance(vms, list),
-            True,
-            "List VMs should return valid response for deployed VM"
-        )
-
-        self.assertNotEqual(
-            len(vms),
-            0,
-            "List VMs should return valid response for deployed VM"
-        )
-
-        list_hosts_response = list_hosts(
-            self.apiclient,
-            id=vms[0].hostid
-        )
-        self.assertEqual(
-            isinstance(list_hosts_response, list),
-            True,
-            "Check list response returns a valid list"
-        )
-
-        self.assertNotEqual(
-            len(list_hosts_response),
-            0,
-            "Check Host is available"
-        )
-
-        self.assertEqual(
-            list_hosts_response[0].hahost,
-            False,
-            "The virtual machine is not ha enabled so check if VM is created on host which is also not ha enabled"
-        )
-
-        self.debug("Disabling the maintenance mode for host %s" % vm_with_ha_disabled.hostid)
-        cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
-        cmd.id = vm_with_ha_disabled.hostid
-        self.apiclient.cancelHostMaintenance(cmd)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0587d3a4/test/integration/component/test_vpc.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc.py b/test/integration/component/test_vpc.py
index 3fc0cc5..acf7a8e 100644
--- a/test/integration/component/test_vpc.py
+++ b/test/integration/component/test_vpc.py
@@ -18,16 +18,12 @@
 """ Component tests for VPC functionality
 """
 #Import Local Modules
-import marvin
-import unittest
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackAPI import *
 from marvin.integration.lib.utils import *
 from marvin.integration.lib.base import *
 from marvin.integration.lib.common import *
-from marvin.remoteSSHClient import remoteSSHClient
-import datetime
 
 
 class Services:
@@ -331,7 +327,7 @@ class TestVPC(cloudstackTestCase):
 
     @attr(tags=["advanced", "intervlan"])
     def test_02_restart_vpc_with_networks(self):
-        """ Test restart VPC having with networks
+        """ Test restart VPC having networks
         """
 
         # Validate the following
@@ -2474,250 +2470,4 @@ class TestVPC(cloudstackTestCase):
              "Updation of VPC display text failed.")
 
 
-class TestVPCHostMaintenance(cloudstackTestCase):
 
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestVPCHostMaintenance,
-                               cls
-                               ).getClsTestClient().getApiClient()
-        cls.services = Services().services
-        # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
-        cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
-        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-        cls.services["virtual_machine"]["template"] = cls.template.id
-
-        cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
-        cls.vpc_off = VpcOffering.create(
-                                     cls.api_client,
-                                     cls.services["vpc_offering"]
-                                     )
-        cls.vpc_off.update(cls.api_client, state='Enabled')
-        hosts = Host.list(
-                          cls.api_client,
-                          zoneid=cls.zone.id,
-                          listall=True,
-                          type='Routing'
-                          )
-
-        if isinstance(hosts, list):
-            for host in hosts:
-                Host.enableMaintenance(
-                                   cls.api_client,
-                                   id=host.id
-                                   )
-
-                timeout = cls.services["timeout"]
-                while True:
-                    time.sleep(cls.services["sleep"])
-                    hosts_states = Host.list(
-                                     cls.api_client,
-                                     id=host.id,
-                                     listall=True
-                                     )
-                    if hosts_states[0].resourcestate == 'PrepareForMaintenance':
-                        # Wait for sometimetill host goes in maintenance state
-                        time.sleep(cls.services["sleep"])
-                    elif hosts_states[0].resourcestate == 'Maintenance':
-                        time.sleep(cls.services["sleep"])
-                        break
-                    elif timeout == 0:
-                        raise unittest.SkipTest(
-                        "Failed to enable maintenance mode on %s" % host.name)
-                    timeout = timeout - 1
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.vpc_off
-                        ]
-        return
-
-    @classmethod
-    def tearDownClass(cls):
-        try:
-            #Cleanup resources used
-            cleanup_resources(cls.api_client, cls._cleanup)
-            hosts = Host.list(
-                          cls.api_client,
-                          zoneid=cls.zone.id,
-                          listall=True,
-                          type='Routing'
-                          )
-            if isinstance(hosts, list):
-                for host in hosts:
-                    Host.cancelMaintenance(
-                                   cls.api_client,
-                                   id=host.id
-                                   )
-                hosts_states = Host.list(
-                                     cls.api_client,
-                                     id=host.id,
-                                     listall=True
-                                     )
-                if hosts_states[0].resourcestate != 'Enabled':
-                    raise Exception(
-                    "Failed to cancel maintenance mode on %s" % (host.name))
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    def setUp(self):
-        self.apiclient = self.testClient.getApiClient()
-        self.dbclient = self.testClient.getDbConnection()
-        self.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
-        self.cleanup = [self.account]
-        return
-
-    def tearDown(self):
-        try:
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
-            wait = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                   )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) + int(wait[0].value))
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    def validate_vpc_offering(self, vpc_offering):
-        """Validates the VPC offering"""
-
-        self.debug("Check if the VPC offering is created successfully?")
-        vpc_offs = VpcOffering.list(
-                                    self.apiclient,
-                                    id=vpc_offering.id
-                                    )
-        self.assertEqual(
-                         isinstance(vpc_offs, list),
-                         True,
-                         "List VPC offerings should return a valid list"
-                         )
-        self.assertEqual(
-                 vpc_offering.name,
-                 vpc_offs[0].name,
-                "Name of the VPC offering should match with listVPCOff data"
-                )
-        self.debug(
-                "VPC offering is created successfully - %s" %
-                                                        vpc_offering.name)
-        return
-
-    def validate_vpc_network(self, network, state=None):
-        """Validates the VPC network"""
-
-        self.debug("Check if the VPC network is created successfully?")
-        vpc_networks = VPC.list(
-                                    self.apiclient,
-                                    id=network.id
-                          )
-        self.assertEqual(
-                         isinstance(vpc_networks, list),
-                         True,
-                         "List VPC network should return a valid list"
-                         )
-        self.assertEqual(
-                 network.name,
-                 vpc_networks[0].name,
-                "Name of the VPC network should match with listVPC data"
-                )
-        if state:
-            self.assertEqual(
-                 vpc_networks[0].state,
-                 state,
-                "VPC state should be '%s'" % state
-                )
-        self.debug("VPC network validated - %s" % network.name)
-        return
-
-    @attr(tags=["advanced", "intervlan"])
-    def test_01_create_vpc_host_maintenance(self):
-        """ Test VPC when host is in maintenance mode
-        """
-
-        # Validate the following
-        # 1. Put the host in maintenance mode.
-        # 2. Attempt to Create a VPC with cidr - 10.1.1.1/16
-        # 3. VPC will be created but will be in "Disabled" state
-
-        self.debug("creating a VPC network in the account: %s" %
-                                                    self.account.name)
-        self.services["vpc"]["cidr"] = '10.1.1.1/16'
-        vpc = VPC.create(
-                         self.apiclient,
-                         self.services["vpc"],
-                         vpcofferingid=self.vpc_off.id,
-                         zoneid=self.zone.id,
-                         account=self.account.name,
-                         domainid=self.account.domainid
-                         )
-        self.validate_vpc_network(vpc, state='Disabled')
-        return
-
-    @attr(tags=["advanced", "intervlan"])
-    def test_02_create_vpc_wait_gc(self):
-        """ Test VPC when host is in maintenance mode and wait till nw gc
-        """
-
-        # Validate the following
-        # 1. Put the host in maintenance mode.
-        # 2. Attempt to Create a VPC with cidr - 10.1.1.1/16
-        # 3. Wait for the VPC GC thread to run.
-        # 3. VPC will be created but will be in "Disabled" state and should
-        #    get deleted
-
-        self.debug("creating a VPC network in the account: %s" %
-                                                    self.account.name)
-        self.services["vpc"]["cidr"] = '10.1.1.1/16'
-        vpc = VPC.create(
-                         self.apiclient,
-                         self.services["vpc"],
-                         vpcofferingid=self.vpc_off.id,
-                         zoneid=self.zone.id,
-                         account=self.account.name,
-                         domainid=self.account.domainid
-                         )
-        self.validate_vpc_network(vpc, state='Disabled')
-        interval = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
-        wait = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                   )
-        self.debug("Sleep till network gc thread runs..")
-        # Sleep to ensure that all resources are deleted
-        time.sleep(int(interval[0].value) + int(wait[0].value))
-        vpcs = VPC.list(
-                        self.apiclient,
-                        id=vpc.id,
-                        listall=True
-                        )
-        self.assertEqual(
-                         vpcs,
-                         None,
-                         "List VPC should not return anything after network gc"
-                         )
-        return

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0587d3a4/test/integration/component/test_vpc_host_maintenance.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_host_maintenance.py b/test/integration/component/test_vpc_host_maintenance.py
deleted file mode 100644
index d28b798..0000000
--- a/test/integration/component/test_vpc_host_maintenance.py
+++ /dev/null
@@ -1,889 +0,0 @@
-# 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 VM life cycle in VPC network functionality
-"""
-#Import Local Modules
-import marvin
-from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from marvin.remoteSSHClient import remoteSSHClient
-import datetime
-
-
-class Services:
-    """Test VM life cycle in VPC network services
-    """
-
-    def __init__(self):
-        self.services = {
-                         "account": {
-                                    "email": "test@test.com",
-                                    "firstname": "Test",
-                                    "lastname": "User",
-                                    "username": "test",
-                                    # Random characters are appended for unique
-                                    # username
-                                    "password": "password",
-                                    },
-                         "service_offering": {
-                                    "name": "Tiny Instance",
-                                    "displaytext": "Tiny Instance",
-                                    "cpunumber": 1,
-                                    "cpuspeed": 100,
-                                    "memory": 64,
-                                    },
-                        "service_offering_1": {
-                                    "name": "Tiny Instance- tagged host 1",
-                                    "displaytext": "Tiny off-tagged host2",
-                                    "cpunumber": 1,
-                                    "cpuspeed": 100,
-                                    "memory": 64,
-                                    "tags": "HOST_TAGS_HERE"
-                                    },
-                         "service_offering_2": {
-                                    "name": "Tiny Instance- tagged host 2",
-                                    "displaytext": "Tiny off-tagged host2",
-                                    "cpunumber": 1,
-                                    "cpuspeed": 100,
-                                    "memory": 64,
-                                    "tags": "HOST_TAGS_HERE"
-                                    },
-                         "network_offering": {
-                                    "name": 'VPC Network offering',
-                                    "displaytext": 'VPC Network off',
-                                    "guestiptype": 'Isolated',
-                                    "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Lb,UserData,StaticNat,NetworkACL',
-                                    "traffictype": 'GUEST',
-                                    "availability": 'Optional',
-                                    "useVpc": 'on',
-                                    "serviceProviderList": {
-                                            "Dhcp": 'VpcVirtualRouter',
-                                            "Dns": 'VpcVirtualRouter',
-                                            "SourceNat": 'VpcVirtualRouter',
-                                            "PortForwarding": 'VpcVirtualRouter',
-                                            "Lb": 'VpcVirtualRouter',
-                                            "UserData": 'VpcVirtualRouter',
-                                            "StaticNat": 'VpcVirtualRouter',
-                                            "NetworkACL": 'VpcVirtualRouter'
-                                        },
-                                },
-                         "network_offering_no_lb": {
-                                    "name": 'VPC Network offering',
-                                    "displaytext": 'VPC Network off',
-                                    "guestiptype": 'Isolated',
-                                    "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,UserData,StaticNat,NetworkACL',
-                                    "traffictype": 'GUEST',
-                                    "availability": 'Optional',
-                                    "useVpc": 'on',
-                                    "serviceProviderList": {
-                                            "Dhcp": 'VpcVirtualRouter',
-                                            "Dns": 'VpcVirtualRouter',
-                                            "SourceNat": 'VpcVirtualRouter',
-                                            "PortForwarding": 'VpcVirtualRouter',
-                                            "UserData": 'VpcVirtualRouter',
-                                            "StaticNat": 'VpcVirtualRouter',
-                                            "NetworkACL": 'VpcVirtualRouter'
-                                        },
-                                },
-                         "network_off_shared": {
-                                    "name": 'Shared Network offering',
-                                    "displaytext": 'Shared Network offering',
-                                    "guestiptype": 'Shared',
-                                    "traffictype": 'GUEST',
-                                    "availability": 'Optional',
-                                    "useVpc": 'on',
-                                    "specifyIpRanges": True,
-                                    "specifyVlan": True
-                                    },
-                         "vpc_offering": {
-                                    "name": 'VPC off',
-                                    "displaytext": 'VPC off',
-                                    "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Lb,UserData,StaticNat',
-                                },
-                         "vpc": {
-                                 "name": "TestVPC",
-                                 "displaytext": "TestVPC",
-                                 "cidr": '10.0.0.1/24'
-                                 },
-                         "network": {
-                                  "name": "Test Network",
-                                  "displaytext": "Test Network",
-                                  "netmask": '255.255.255.0',
-                                  "limit": 5,
-                                  # Max networks allowed as per hypervisor
-                                  # Xenserver -> 5, VMWare -> 9
-                                },
-                         "lbrule": {
-                                    "name": "SSH",
-                                    "alg": "leastconn",
-                                    # Algorithm used for load balancing
-                                    "privateport": 22,
-                                    "publicport": 2222,
-                                    "openfirewall": False,
-                                    "startport": 2222,
-                                    "endport": 2222,
-                                    "protocol": "TCP",
-                                    "cidrlist": '0.0.0.0/0',
-                                },
-                         "natrule": {
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "startport": 22,
-                                    "endport": 22,
-                                    "protocol": "TCP",
-                                    "cidrlist": '0.0.0.0/0',
-                                },
-                         "fw_rule": {
-                                    "startport": 1,
-                                    "endport": 6000,
-                                    "cidr": '0.0.0.0/0',
-                                    # Any network (For creating FW rule)
-                                    "protocol": "TCP"
-                                },
-                         "http_rule": {
-                                    "startport": 80,
-                                    "endport": 80,
-                                    "cidrlist": '0.0.0.0/0',
-                                    "protocol": "ICMP"
-                                },
-                         "virtual_machine": {
-                                    "displayname": "Test VM",
-                                    "username": "root",
-                                    "password": "password",
-                                    "ssh_port": 22,
-                                    "hypervisor": 'XenServer',
-                                    # Hypervisor type should be same as
-                                    # hypervisor type of cluster
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "protocol": 'TCP',
-                                    "userdata": 'This is sample data',
-                                },
-                         "ostype": 'CentOS 5.3 (64-bit)',
-                         # Cent OS 5.3 (64 bit)
-                         "sleep": 60,
-                         "timeout": 10,
-                         "mode": 'advanced'
-                    }
-
-
-class TestVMLifeCycleHostmaintenance(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestVMLifeCycleHostmaintenance,
-                               cls
-                               ).getClsTestClient().getApiClient()
-        cls.services = Services().services
-        # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
-        cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
-        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-        cls.services["virtual_machine"]["template"] = cls.template.id
-
-        cls.service_offering_1 = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering_1"]
-                                            )
-        cls.service_offering_2 = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering_2"]
-                                            )
-        cls.vpc_off = VpcOffering.create(
-                                     cls.api_client,
-                                     cls.services["vpc_offering"]
-                                     )
-        cls.vpc_off.update(cls.api_client, state='Enabled')
-
-        cls.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
-
-        cls.vpc_off = VpcOffering.create(
-                                     cls.api_client,
-                                     cls.services["vpc_offering"]
-                                     )
-
-        cls.vpc_off.update(cls.api_client, state='Enabled')
-
-        cls.services["vpc"]["cidr"] = '10.1.1.1/16'
-        cls.vpc = VPC.create(
-                         cls.api_client,
-                         cls.services["vpc"],
-                         vpcofferingid=cls.vpc_off.id,
-                         zoneid=cls.zone.id,
-                         account=cls.account.name,
-                         domainid=cls.account.domainid
-                         )
-
-        cls.nw_off = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=False
-                                            )
-        # Enable Network offering
-        cls.nw_off.update(cls.api_client, state='Enabled')
-
-        # Creating network using the network offering created
-        cls.network_1 = Network.create(
-                                cls.api_client,
-                                cls.services["network"],
-                                accountid=cls.account.name,
-                                domainid=cls.account.domainid,
-                                networkofferingid=cls.nw_off.id,
-                                zoneid=cls.zone.id,
-                                gateway='10.1.1.1',
-                                vpcid=cls.vpc.id
-                                )
-        cls.nw_off_no_lb = NetworkOffering.create(
-                                    cls.api_client,
-                                    cls.services["network_offering_no_lb"],
-                                    conservemode=False
-                                    )
-        # Enable Network offering
-        cls.nw_off_no_lb.update(cls.api_client, state='Enabled')
-
-        # Creating network using the network offering created
-        cls.network_2 = Network.create(
-                                cls.api_client,
-                                cls.services["network"],
-                                accountid=cls.account.name,
-                                domainid=cls.account.domainid,
-                                networkofferingid=cls.nw_off_no_lb.id,
-                                zoneid=cls.zone.id,
-                                gateway='10.1.2.1',
-                                vpcid=cls.vpc.id
-                                )
-        # Spawn an instance in that network
-        cls.vm_1 = VirtualMachine.create(
-                                  cls.api_client,
-                                  cls.services["virtual_machine"],
-                                  accountid=cls.account.name,
-                                  domainid=cls.account.domainid,
-                                  serviceofferingid=cls.service_offering_1.id,
-                                  networkids=[str(cls.network_1.id)]
-                                  )
-        # Spawn an instance in that network
-        cls.vm_2 = VirtualMachine.create(
-                                  cls.api_client,
-                                  cls.services["virtual_machine"],
-                                  accountid=cls.account.name,
-                                  domainid=cls.account.domainid,
-                                  serviceofferingid=cls.service_offering_1.id,
-                                  networkids=[str(cls.network_1.id)]
-                                  )
-        cls.vm_3 = VirtualMachine.create(
-                                  cls.api_client,
-                                  cls.services["virtual_machine"],
-                                  accountid=cls.account.name,
-                                  domainid=cls.account.domainid,
-                                  serviceofferingid=cls.service_offering_2.id,
-                                  networkids=[str(cls.network_2.id)]
-                                  )
-        routers = Router.list(
-                              cls.api_client,
-                              account=cls.account.name,
-                              domainid=cls.account.domainid,
-                              listall=True
-                              )
-        if isinstance(routers, list):
-            cls.vpcvr = routers[0]
-
-        cls._cleanup = [
-                        cls.service_offering_1,
-                        cls.service_offering_2,
-                        cls.nw_off,
-                        cls.nw_off_no_lb,
-                        ]
-        return
-
-    @classmethod
-    def tearDownClass(cls):
-        try:
-            cls.account.delete(cls.api_client)
-            wait_for_cleanup(cls.api_client, ["account.cleanup.interval"])
-            #Cleanup resources used
-            cleanup_resources(cls.api_client, cls._cleanup)
-
-            # Waiting for network cleanup to delete vpc offering
-            wait_for_cleanup(cls.api_client, ["network.gc.wait",
-                                              "network.gc.interval"])
-            cls.vpc_off.delete(cls.api_client)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    def setUp(self):
-
-        self.apiclient = self.testClient.getApiClient()
-        self.dbclient = self.testClient.getDbConnection()
-        self.debug("Check the status of VPC virtual router")
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=self.network_1.id,
-                              listall=True
-                              )
-        if not isinstance(routers, list):
-            raise Exception("No response from list routers API")
-
-        self.router = routers[0]
-        if self.router.state == "Running":
-            Router.stop(self.apiclient, id=self.router.id)
-
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    def validate_vm_deployment(self):
-        """Validates VM deployment on different hosts"""
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  account=self.account.name,
-                                  domainid=self.account.domainid,
-                                  networkid=self.network_1.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List VMs shall return a valid response"
-                         )
-        host_1 = vms[0].hostid
-        self.debug("Host for network 1: %s" % vms[0].hostid)
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  account=self.account.name,
-                                  domainid=self.account.domainid,
-                                  networkid=self.network_2.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List VMs shall return a valid response"
-                         )
-        host_2 = vms[0].hostid
-        self.debug("Host for network 2: %s" % vms[0].hostid)
-
-        self.assertNotEqual(
-                host_1,
-                host_2,
-                "Both the virtual machines should be deployed on diff hosts "
-                )
-        return
-
-    @attr(tags=["advanced", "intervlan"])
-    def test_01_enable_maintenance_with_vpc_nw(self):
-        """ Test enable Maintenance Mode on Hosts which have VPC elements
-        """
-
-        # Validate the following
-        # 1. Create a VPC with cidr - 10.1.1.1/16
-        # 2. Add network1(10.1.1.1/24) and network2(10.1.2.1/24) to this VPC.
-        # 3. Deploy vm1 and vm2 in network1 and vm3 and vm4 in network2. Make
-        #    sure vm1 and vm3 are deployed on one host in the cluster while
-        #    vm2 and vm4 are deployed on the other host in the cluster. This
-        #    can be done using host's tags & service offerings with host tags
-        # Steps:
-        # 1.Enable Maintenance on one of host on which VPCVR is present
-        # Validations:
-        # 1. Successfully push the host into maintenance mode.
-        # 2. VMs present on the above host should successfully migrate to the
-        #    other host present in the cluster
-
-        self.validate_vm_deployment()
-        self.debug("Stop the host on which the VPC virtual router is running")
-        try:
-            Host.enableMaintenance(self.apiclient, id=self.vpcvr.hostid)
-        except Exception as e:
-            self.fail("Failed to enable maintenance mode on host: %s" % e)
-
-        self.debug(
-            "Check if all instances belonging to the account are up again?")
-        routers = Router.list(
-                              self.apiclient,
-                              account=self.account.name,
-                              domainid=self.account.domainid,
-                              listall=True
-                              )
-        self.assertEqual(
-                         isinstance(routers, list),
-                         True,
-                         "List routers shall return a valid VPCVR for account"
-                         )
-        for router in routers:
-            self.assertEqual(
-                             router.state,
-                             "Running",
-                             "Router state should be running after migration"
-                             )
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  account=self.account.name,
-                                  domainid=self.account.domainid,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                    isinstance(vms, list),
-                    True,
-                    "VM response should return instances running for account"
-                    )
-        for vm in vms:
-            self.assertEqual(
-                             vm.state,
-                             "Ruuning",
-                             "Vm state should be running after migration"
-                             )
-        return
-
-    @attr(tags=["advanced", "intervlan"])
-    def test_02_cancel_maintenance(self):
-        """ Test cancel Maintenance Mode on the above Hosts + Migrate VMs Back
-        """
-
-        # Steps
-        # 1. Cancel Maintenance Mode on the host.
-        # 2. Migrate the VMs back onto the host on which Maintenance mode is
-        #    cancelled.
-        # Validate the following
-        # 1. Successfully cancel the Maintenance mode on the host.
-        # 2. Migrate the VMs back successfully onto the host.
-        # 3. Check that the network connectivity exists with the migrated VMs.
-
-        self.debug("Cancel host maintenence on which the VPCVR is running")
-        try:
-            Host.cancelMaintenance(self.apiclient, id=self.vpcvr.hostid)
-        except Exception as e:
-            self.fail("Failed to enable maintenance mode on host: %s" % e)
-
-        self.debug(
-            "Migrating the instances back to the host: %s" %
-                                                        self.vpcvr.hostid)
-        try:
-            cmd = migrateSystemVm.migrateSystemVmCmd()
-            cmd.hostid = self.vpcvr.hostid
-            cmd.virtualmachineid = self.vpcvr.id
-            self.apiclient.migrateSystemVm(cmd)
-        except Exception as e:
-            self.fail("Failed to migrate VPCVR back: %s" % e)
-
-        self.debug("Check the status of router after migration")
-        routers = Router.list(
-                              self.apiclient,
-                              id=self.vpcvr.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                         isinstance(routers, list),
-                         True,
-                         "List routers shall return the valid response"
-                         )
-        self.assertEqual(
-                         routers[0].state,
-                         "Running",
-                         "Router state should be running"
-                         )
-        #  TODO: Check for the network connectivity
-        return
-
-    @attr(tags=["advanced", "intervlan"])
-    def test_03_reconnect_host(self):
-        """ Test reconnect Host which has VPC elements
-        """
-
-        # Steps:
-        # 1.Reconnect one of the host on which VPC Virtual Router is present.
-        # Validate the following
-        # 1. Host should successfully reconnect.
-        # 2. Network connectivity to all the VMs on the host should not be
-        #    effected due to reconnection.
-
-        self.debug("Reconnecting the host where VPC VR is running")
-        try:
-            Host.reconnect(self.apiclient, id=self.vpcvr.hostid)
-        except Exception as e:
-            self.fail("Failed to reconnect to host: %s" % e)
-
-        self.debug("Check the status of router after migration")
-        routers = Router.list(
-                              self.apiclient,
-                              id=self.vpcvr.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                         isinstance(routers, list),
-                         True,
-                         "List routers shall return the valid response"
-                         )
-        self.assertEqual(
-                         routers[0].state,
-                         "Running",
-                         "Router state should be running"
-                         )
-        #  TODO: Check for the network connectivity
-        return
-
-
-class TestVPCNetworkRules(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestVPCNetworkRules,
-                               cls
-                               ).getClsTestClient().getApiClient()
-        cls.services = Services().services
-        # Get Zone, Domain and templates
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
-        cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
-        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-        cls.services["virtual_machine"]["template"] = cls.template.id
-
-        cls.service_offering_1 = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering_1"]
-                                            )
-        cls.service_offering_2 = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering_2"]
-                                            )
-        cls.vpc_off = VpcOffering.create(
-                                     cls.api_client,
-                                     cls.services["vpc_offering"]
-                                     )
-        cls.vpc_off.update(cls.api_client, state='Enabled')
-
-        cls.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
-
-        cls.vpc_off = VpcOffering.create(
-                                     cls.api_client,
-                                     cls.services["vpc_offering"]
-                                     )
-
-        cls.vpc_off.update(cls.api_client, state='Enabled')
-
-        cls.services["vpc"]["cidr"] = '10.1.1.1/16'
-        cls.vpc = VPC.create(
-                         cls.api_client,
-                         cls.services["vpc"],
-                         vpcofferingid=cls.vpc_off.id,
-                         zoneid=cls.zone.id,
-                         account=cls.account.name,
-                         domainid=cls.account.domainid
-                         )
-
-        cls.nw_off = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=False
-                                            )
-        # Enable Network offering
-        cls.nw_off.update(cls.api_client, state='Enabled')
-
-        # Creating network using the network offering created
-        cls.network_1 = Network.create(
-                                cls.api_client,
-                                cls.services["network"],
-                                accountid=cls.account.name,
-                                domainid=cls.account.domainid,
-                                networkofferingid=cls.nw_off.id,
-                                zoneid=cls.zone.id,
-                                gateway='10.1.1.1',
-                                vpcid=cls.vpc.id
-                                )
-        cls.nw_off_no_lb = NetworkOffering.create(
-                                    cls.api_client,
-                                    cls.services["network_offering_no_lb"],
-                                    conservemode=False
-                                    )
-        # Enable Network offering
-        cls.nw_off_no_lb.update(cls.api_client, state='Enabled')
-
-        # Creating network using the network offering created
-        cls.network_2 = Network.create(
-                                cls.api_client,
-                                cls.services["network"],
-                                accountid=cls.account.name,
-                                domainid=cls.account.domainid,
-                                networkofferingid=cls.nw_off_no_lb.id,
-                                zoneid=cls.zone.id,
-                                gateway='10.1.2.1',
-                                vpcid=cls.vpc.id
-                                )
-        # Spawn an instance in that network
-        cls.vm_1 = VirtualMachine.create(
-                                  cls.api_client,
-                                  cls.services["virtual_machine"],
-                                  accountid=cls.account.name,
-                                  domainid=cls.account.domainid,
-                                  serviceofferingid=cls.service_offering_1.id,
-                                  networkids=[str(cls.network_1.id)]
-                                  )
-        # Spawn an instance in that network
-        cls.vm_2 = VirtualMachine.create(
-                                  cls.api_client,
-                                  cls.services["virtual_machine"],
-                                  accountid=cls.account.name,
-                                  domainid=cls.account.domainid,
-                                  serviceofferingid=cls.service_offering_2.id,
-                                  networkids=[str(cls.network_1.id)]
-                                  )
-        cls.vm_3 = VirtualMachine.create(
-                                  cls.api_client,
-                                  cls.services["virtual_machine"],
-                                  accountid=cls.account.name,
-                                  domainid=cls.account.domainid,
-                                  serviceofferingid=cls.service_offering_1.id,
-                                  networkids=[str(cls.network_2.id)]
-                                  )
-        cls.vm_4 = VirtualMachine.create(
-                                  cls.api_client,
-                                  cls.services["virtual_machine"],
-                                  accountid=cls.account.name,
-                                  domainid=cls.account.domainid,
-                                  serviceofferingid=cls.service_offering_2.id,
-                                  networkids=[str(cls.network_2.id)]
-                                  )
-
-        cls._cleanup = [
-                        cls.service_offering_1,
-                        cls.service_offering_2,
-                        cls.nw_off,
-                        cls.nw_off_no_lb,
-                        ]
-        return
-
-    @classmethod
-    def tearDownClass(cls):
-        try:
-            cls.account.delete(cls.api_client)
-            wait_for_cleanup(cls.api_client, ["account.cleanup.interval"])
-            #Cleanup resources used
-            cleanup_resources(cls.api_client, cls._cleanup)
-
-            # Waiting for network cleanup to delete vpc offering
-            wait_for_cleanup(cls.api_client, ["network.gc.wait",
-                                              "network.gc.interval"])
-            cls.vpc_off.delete(cls.api_client)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    def setUp(self):
-
-        self.apiclient = self.testClient.getApiClient()
-        self.dbclient = self.testClient.getDbConnection()
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    def validate_vm_deployment(self):
-        """Validates VM deployment on different hosts"""
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  account=self.account.name,
-                                  domainid=self.account.domainid,
-                                  networkid=self.network_1.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List VMs shall return a valid response"
-                         )
-        host_1 = vms[0].hostid
-        self.debug("Host for network 1: %s" % vms[0].hostid)
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  account=self.account.name,
-                                  domainid=self.account.domainid,
-                                  networkid=self.network_2.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List VMs shall return a valid response"
-                         )
-        host_2 = vms[0].hostid
-        self.debug("Host for network 2: %s" % vms[0].hostid)
-
-        self.assertNotEqual(
-                host_1,
-                host_2,
-                "Both the virtual machines should be deployed on diff hosts "
-                )
-        return
-
-    @attr(tags=["advanced", "intervlan"])
-    def test_list_pf_rules_for_vpc(self):
-        """ Test List Port Forwarding Rules & vms belonging to a VPC
-        """
-
-        # Validate the following
-        # 1. Create a VPC with cidr - 10.1.1.1/16
-        # 2. Add network1(10.1.1.1/24) and network2(10.1.2.1/24) to this VPC.
-        # 3. Deploy vm1 and vm2 in network1 and vm3 and vm4 in network2.
-        #    Make sure vm1 and vm3 are deployed on one host in the cluster
-        #    while vm2 and vm4 are deployed on the other host in the cluster.
-        #    This can be done using host's tags and service offerings with
-        #    host tags.
-        # 4. Create a PF rule for vms in network1.
-        # 5. Create a PF rule for vms in network2.
-        # Steps:
-        # 1. List all the Port Forwarding Rules belonging to a VPC
-        # 2. Successfully List the Port Forwarding Rules belonging to the VPC
-        # 3. List the VMs on network1 for selection for the PF Rule
-        # 4. Successfully list the VMs for Port Forwarding Rule creation
-
-        self.debug("Associating public IP for network: %s" %
-                                                        self.network_1.name)
-        public_ip_1 = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=self.network_1.id,
-                                vpcid=self.vpc.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip_1.ipaddress.ipaddress,
-                                        self.network_1.id
-                                        ))
-
-        nat_rule_1 = NATRule.create(
-                                  self.apiclient,
-                                  self.vm_1,
-                                  self.services["natrule"],
-                                  ipaddressid=public_ip_1.ipaddress.id,
-                                  openfirewall=False,
-                                  networkid=self.network_1.id,
-                                  vpcid=self.vpc.id
-                                  )
-
-        self.debug("Associating public IP for network: %s" %
-                                                        self.network_2.name)
-        public_ip_2 = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=self.network_2.id,
-                                vpcid=self.vpc.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip_2.ipaddress.ipaddress,
-                                        self.network_2.id
-                                        ))
-
-        nat_rule_2 = NATRule.create(
-                                  self.apiclient,
-                                  self.vm_3,
-                                  self.services["natrule"],
-                                  ipaddressid=public_ip_2.ipaddress.id,
-                                  openfirewall=False,
-                                  networkid=self.network_2.id,
-                                  vpcid=self.vpc.id
-                                  )
-
-        self.debug("Listing all the PF rules belonging to VPC")
-        nat_rules = NATRule.list(
-                                 self.apiclient,
-                                 vpcid=self.vpc.id,
-                                 listall=True
-                                 )
-        self.assertEqual(
-                         isinstance(nat_rules, list),
-                         True,
-                         "List NAT rules should return the valid list"
-                         )
-        self.assertEqual(
-            len(nat_rules),
-            2,
-            "List NAT for VPC shall return all NAT rules belonging to VPC"
-            )
-        for nat_rule in nat_rules:
-            self.assertEqual(
-                             nat_rule.vpcid,
-                             self.vpc.id,
-                             "NAT rules should belong to VPC"
-                             )
-
-        self.debug(
-            "Listing all the VMs belonging to VPC for network: %s" %
-                                                        self.network_1.name)
-        vms = VirtualMachine.list(
-                                 self.apiclient,
-                                 networkid=self.network_1.id,
-                                 vpcid=self.vpc.id,
-                                 listall=True
-                                 )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List virtual machines should return the valid list"
-                         )
-        for vm in vms:
-            self.assertEqual(
-                        vm.networkid,
-                        self.network_1.id,
-                        "List VMs should return vms belonging to network_1"
-                        )
-        return
-


Mime
View raw message