Пример #1
0
    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
Пример #2
0
    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.api_client,
            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
Пример #3
0
    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,
                         start=False)
        self.validate_vpc_network(vpc, state='inactive')
        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
Пример #4
0
 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, id=vpc.id)
     self.assertEqual(isinstance(vpcs, list), True,
                      "List VPC should return a valid list")
     self.assertEqual(
         vpc.name, vpcs[0].name,
         "Name of the VPC should match with the returned list data")
     if state:
         self.assertEqual(vpcs[0].state, state,
                          "VPC state should be '%s'" % state)
     self.debug("VPC creation successfully validated - %s" % vpc.name)
Пример #5
0
 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,
                     id=vpc.id
                     )
     self.assertEqual(isinstance(vpcs, list), True,
                      "List VPC should return a valid list"
                      )
     self.assertEqual(vpc.name, vpcs[0].name,
                      "Name of the VPC should match with the returned list data"
                      )
     if state:
         self.assertEqual(vpcs[0].state, state,
                          "VPC state should be in state - %s" % state
                          )
     self.debug("VPC creation successfully validated for %s" % vpc.name)
    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,
            start=False
        )
        self.validate_vpc_network(vpc, state='inactive')
        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
Пример #7
0
 def validate_Vpc(self, vpc, state=None):
     """Validates the VPC"""
     self.debug("Validating the creation and state of VPC - %s" % vpc.name)
     vpcs = VPC.list(self.api_client,
                     id=vpc.id
                     )
     self.assertEqual(isinstance(vpcs, list), True,
                      "List VPC should return a valid list"
                      )
     self.assertEqual(vpc.name, vpcs[0].name,
                      "Name of the VPC should match with the returned "
                      "list data"
                      )
     if state:
         self.assertEqual(vpcs[0].state, state,
                          "VPC state should be '%s'" % state
                          )
     self.debug("Successfully validated the creation and state of VPC - %s"
                % vpc.name)
Пример #8
0
def CreateNetwork(self, networktype):
    """Create a network of given type (isolated/shared/isolated in VPC)"""

    network = None

    if networktype == ISOLATED_NETWORK:
        try:
            network = Network.create(
                self.apiclient, self.testdata["isolated_network"],
                networkofferingid=self.isolated_network_offering.id,
                accountid=self.account.name,
                domainid=self.account.domainid,
                zoneid=self.zone.id)
            self.cleanup.append(network)
        except Exception as e:
            self.fail("Isolated network creation failed because: %s" % e)

    elif networktype == SHARED_NETWORK:
        physical_network, vlan = get_free_vlan(self.apiclient, self.zone.id)

        # create network using the shared network offering created
        self.testdata["shared_network"]["acltype"] = "domain"
        self.testdata["shared_network"]["vlan"] = vlan
        self.testdata["shared_network"]["networkofferingid"] = \
            self.shared_network_offering.id
        self.testdata["shared_network"]["physicalnetworkid"] = \
            physical_network.id

        self.testdata["shared_network"] = \
            setSharedNetworkParams(self.testdata["shared_network"])

        try:
            network = Network.create(
                self.apiclient,
                self.testdata["shared_network"],
                networkofferingid=self.shared_network_offering.id,
                zoneid=self.zone.id)
            self.cleanup.append(network)
        except Exception as e:
            self.fail("Shared Network creation failed because: %s" % e)

    elif networktype == VPC_NETWORK:
        self.testdata["vpc"]["cidr"] = "10.1.1.1/16"
        self.debug("creating a VPC network in the account: %s" %
                   self.account.name)
        vpc = VPC.create(self.apiclient,
                         self.testdata["vpc"],
                         vpcofferingid=self.vpc_off.id,
                         zoneid=self.zone.id,
                         account=self.account.name,
                         domainid=self.account.domainid
                         )
        self.cleanup.append(vpc)
        self.vpcid = vpc.id
        vpcs = VPC.list(self.apiclient, id=vpc.id)
        self.assertEqual(
            validateList(vpcs)[0], PASS,
            "VPC list validation failed, vpc list is %s" % vpcs
        )

        network = Network.create(
            self.apiclient,
            self.testdata["isolated_network"],
            networkofferingid=self.isolated_network_offering_vpc.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            zoneid=self.zone.id,
            vpcid=vpc.id,
            gateway="10.1.1.1",
            netmask="255.255.255.0")
        self.cleanup.append(network)
    return network
Пример #9
0
    def test_01_create_tier_Vmxnet3(self):
        """
            Test to create vpc tier with nic type as Vmxnet3
            #1.Set global setting parameter "vmware.systemvm.nic.device.type"
            to "Vmxnet3"
            #2.Create VPC
            #3.Create one tier
            #4.Deploy one guest vm in the tier created in step3
        """
        if self.hypervisor.lower() not in ['vmware']:
            self.skipTest("This test can only run on vmware setup")

        nic_types = Configurations.list(
            self.apiclient,
            name="vmware.systemvm.nic.device.type"
        )
        self.assertEqual(validateList(nic_types)[0], PASS, "Invalid list config")
        nic_type = nic_types[0].value
        reset = False
        if nic_type.lower() != "vmxnet3":
            self.updateConfigurAndRestart("vmware.systemvm.nic.device.type", "Vmxnet3")
            reset = True

        self.services["vpc"]["cidr"] = "10.1.1.1/16"
        self.debug("creating a VPC network in the account: %s" %
                   self.account.name)
        try:
            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
            )
            vpc_res = VPC.list(self.apiclient, id=vpc.id)
            self.assertEqual(validateList(vpc_res)[0], PASS, "Invalid response from listvpc")

            self.network_offering = NetworkOffering.create(
                self.apiclient,
                self.services["network_offering"],
                conservemode=False
            )
            # Enable Network offering
            self.network_offering.update(self.apiclient, state='Enabled')
            self.cleanup.append(self.network_offering)

            gateway = vpc.cidr.split('/')[0]
            # Split the cidr to retrieve gateway
            # for eg. cidr = 10.0.0.1/24
            # Gateway = 10.0.0.1
            # Creating network using the network offering created
            self.debug("Creating network with network offering: %s" %
                       self.network_offering.id)
            network = Network.create(
                self.apiclient,
                self.services["network"],
                accountid=self.account.name,
                domainid=self.account.domainid,
                networkofferingid=self.network_offering.id,
                zoneid=self.zone.id,
                gateway=gateway,
                vpcid=vpc.id
            )
            self.debug("Created network with ID: %s" % network.id)
            vm = VirtualMachine.create(
                self.apiclient,
                self.services["virtual_machine"],
                accountid=self.account.name,
                domainid=self.account.domainid,
                serviceofferingid=self.service_offering.id,
                networkids=[str(network.id)]
            )
            self.assertIsNotNone(vm, "VM creation failed")
            self.debug("Deployed VM in network: %s" % network.id)
            vm_res = VirtualMachine.list(self.apiclient, id=vm.id)
            self.assertEqual(
                validateList(vm_res)[0],
                PASS,
                "list vm returned invalid response"
            )
            vr_res = Router.list(
                self.apiclient,
                vpcid=vpc.id,
                listall="true"
            )
            self.assertEqual(validateList(vr_res)[0], PASS, "list vrs failed for vpc")
            vr_linklocal_ip = vr_res[0].linklocalip
            result = get_process_status(
                self.apiclient.connection.mgtSvr,
                22,
                self.apiclient.connection.user,
                self.apiclient.connection.passwd,
                vr_linklocal_ip,
                'lspci | grep "Ethernet controller"',
                hypervisor=self.hypervisor
            )
            self.assertEqual(
                validateList(result)[0],
                PASS,
                "We didn't find NICS with adapter type VMXNET3"
            )
            reg = re.compile("VMware VMXNET3")
            count = 0
            for line in result:
                if reg.search(line):
                    count += 1
            self.assertEqual(
                count,
                3,
                "Not all NICs on VR are of type VMXNET3"
            )
        except Exception as e:
            self.fail("NIC creation failed for vpc tier with systemvm nic \
                        adapter type as Vmxnet3: %s" % e)
        finally:
            if reset:
                self.updateConfigurAndRestart("vmware.systemvm.nic.device.type", nic_type)
        return
Пример #10
0
def CreateNetwork(self, networktype):
    """Create a network of given type (isolated/shared/isolated in VPC)"""

    network = None

    if networktype == ISOLATED_NETWORK:
        try:
            network = Network.create(
                self.apiclient,
                self.testdata["isolated_network"],
                networkofferingid=self.isolated_network_offering.id,
                accountid=self.account.name,
                domainid=self.account.domainid,
                zoneid=self.zone.id)
            self.cleanup.append(network)
        except Exception as e:
            self.fail("Isolated network creation failed because: %s" % e)

    elif networktype == SHARED_NETWORK:
        physical_network, vlan = get_free_vlan(self.apiclient, self.zone.id)

        # create network using the shared network offering created
        self.testdata["shared_network"]["acltype"] = "domain"
        self.testdata["shared_network"]["vlan"] = vlan
        self.testdata["shared_network"]["networkofferingid"] = \
            self.shared_network_offering.id
        self.testdata["shared_network"]["physicalnetworkid"] = \
            physical_network.id

        self.testdata["shared_network"] = \
            setSharedNetworkParams(self.testdata["shared_network"])

        try:
            network = Network.create(
                self.apiclient,
                self.testdata["shared_network"],
                networkofferingid=self.shared_network_offering.id,
                zoneid=self.zone.id)
            self.cleanup.append(network)
        except Exception as e:
            self.fail("Shared Network creation failed because: %s" % e)

    elif networktype == VPC_NETWORK:
        self.testdata["vpc"]["cidr"] = "10.1.1.1/16"
        self.debug("creating a VPC network in the account: %s" %
                   self.account.name)
        vpc = VPC.create(self.apiclient,
                         self.testdata["vpc"],
                         vpcofferingid=self.vpc_off.id,
                         zoneid=self.zone.id,
                         account=self.account.name,
                         domainid=self.account.domainid)
        self.cleanup.append(vpc)
        self.vpcid = vpc.id
        vpcs = VPC.list(self.apiclient, id=vpc.id)
        self.assertEqual(
            validateList(vpcs)[0], PASS,
            "VPC list validation failed, vpc list is %s" % vpcs)

        network = Network.create(
            self.apiclient,
            self.testdata["isolated_network"],
            networkofferingid=self.isolated_network_offering_vpc.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            zoneid=self.zone.id,
            vpcid=vpc.id,
            gateway="10.1.1.1",
            netmask="255.255.255.0")
        self.cleanup.append(network)
    return network
Пример #11
0
    def test_01_create_tier_Vmxnet3(self):
        """
            Test to create vpc tier with nic type as Vmxnet3
            #1.Set global setting parameter "vmware.systemvm.nic.device.type"
            to "Vmxnet3"
            #2.Create VPC
            #3.Create one tier
            #4.Deploy one guest vm in the tier created in step3
        """
        if self.hypervisor.lower() not in ['vmware']:
            self.skipTest("This test can only run on vmware setup")

        nic_types = Configurations.list(self.apiclient,
                                        name="vmware.systemvm.nic.device.type")
        self.assertEqual(
            validateList(nic_types)[0], PASS, "Invalid list config")
        nic_type = nic_types[0].value
        reset = False
        if nic_type.lower() != "vmxnet3":
            self.updateConfigurAndRestart("vmware.systemvm.nic.device.type",
                                          "Vmxnet3")
            reset = True

        self.services["vpc"]["cidr"] = "10.1.1.1/16"
        self.debug("creating a VPC network in the account: %s" %
                   self.account.name)
        try:
            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)
            vpc_res = VPC.list(self.apiclient, id=vpc.id)
            self.assertEqual(
                validateList(vpc_res)[0], PASS,
                "Invalid response from listvpc")

            self.network_offering = NetworkOffering.create(
                self.apiclient,
                self.services["network_offering"],
                conservemode=False)
            # Enable Network offering
            self.network_offering.update(self.apiclient, state='Enabled')
            self.cleanup.append(self.network_offering)

            gateway = vpc.cidr.split('/')[0]
            # Split the cidr to retrieve gateway
            # for eg. cidr = 10.0.0.1/24
            # Gateway = 10.0.0.1
            # Creating network using the network offering created
            self.debug("Creating network with network offering: %s" %
                       self.network_offering.id)
            network = Network.create(
                self.apiclient,
                self.services["network"],
                accountid=self.account.name,
                domainid=self.account.domainid,
                networkofferingid=self.network_offering.id,
                zoneid=self.zone.id,
                gateway=gateway,
                vpcid=vpc.id)
            self.debug("Created network with ID: %s" % network.id)
            vm = VirtualMachine.create(
                self.apiclient,
                self.services["virtual_machine"],
                accountid=self.account.name,
                domainid=self.account.domainid,
                serviceofferingid=self.service_offering.id,
                networkids=[str(network.id)])
            self.assertIsNotNone(vm, "VM creation failed")
            self.debug("Deployed VM in network: %s" % network.id)
            vm_res = VirtualMachine.list(self.apiclient, id=vm.id)
            self.assertEqual(
                validateList(vm_res)[0], PASS,
                "list vm returned invalid response")
            vr_res = Router.list(self.apiclient, vpcid=vpc.id, listall="true")
            self.assertEqual(
                validateList(vr_res)[0], PASS, "list vrs failed for vpc")
            vr_linklocal_ip = vr_res[0].linklocalip
            result = get_process_status(self.apiclient.connection.mgtSvr,
                                        22,
                                        self.apiclient.connection.user,
                                        self.apiclient.connection.passwd,
                                        vr_linklocal_ip,
                                        'lspci | grep "Ethernet controller"',
                                        hypervisor=self.hypervisor)
            self.assertEqual(
                validateList(result)[0], PASS,
                "We didn't find NICS with adapter type VMXNET3")
            reg = re.compile("VMware VMXNET3")
            count = 0
            for line in result:
                if reg.search(line):
                    count += 1
            self.assertEqual(count, 3,
                             "Not all NICs on VR are of type VMXNET3")
        except Exception as e:
            self.fail("NIC creation failed for vpc tier with systemvm nic \
                        adapter type as Vmxnet3: %s" % e)
        finally:
            if reset:
                self.updateConfigurAndRestart(
                    "vmware.systemvm.nic.device.type", nic_type)
        return
    def setUpClass(cls):
                    
        
        cloudstackTestClient = super(
                                     TestMultipleVPNAccessonVPC,
                                     cls
                                    ).getClsTestClient()
        
        cls.debug("Obtain the Admin's API Client")                                
        cls.api_client = cloudstackTestClient.getApiClient()
        cls.debug("Get the dictionary information that will be used during CCP tests, from test_data.py present on the Client")
        cls.services = cloudstackTestClient.getParsedTestDataConfig()
        
        if cls.services is None:
            cls.debug("Services Object is None")
            raise Exception("Services Object is None")
        
        cls.debug("Procure the CloudStack Setup configuration Information")
        with open(cls.services["config_path"], 'rb') as fp:
            cls.pullconfig = json.load(fp)
        
        cls.debug("Update 'remote.access.vpn.client.iprange','remote.access.vpn.user.limit','max.account.primary.storage','max.account.public.ips','max.account.user.vms','max.account.volumes','max.account.cpus', Global Configuration Parameters")
        
        update_vpn_client_iprange = Configurations.update(
            cls.api_client, 
            name="remote.access.vpn.client.iprange", 
            value="10.1.2.1-10.1.2.120")
        
        cls.debug("'remote.access.vpn.client.iprange' Global Configuration Parameter Updated Successfully")
        
        update_vpn_user_limit = Configurations.update(
            cls.api_client,
            name="remote.access.vpn.user.limit", 
            value=str(int(cls.services["vpnclient_count"]*2))
        )    
        
        cls.debug("'remote.access.vpn.user.limit' Global Configuration Parameter Updated Successfully")

        update_max_account_primary_stg_limit = Configurations.update(
            cls.api_client,
            name="max.account.primary.storage", 
            value=str(int(cls.services["vpnclient_count"]*20 + 100))
        )
        cls.debug("'max.account.primary.storage' Global Configuration Parameter Updated Successfully")

        update_max_account_public_ips_limit = Configurations.update(
            cls.api_client,
            name="max.account.public.ips", 
            value=str(int(cls.services["vpnclient_count"]*2 + 10))
        )
        cls.debug("'max.account.public.ips' Global Configuration Parameter Updated Successfully")
        
        update_max_account_user_vms_limit = Configurations.update(
            cls.api_client,
            name="max.account.user.vms", 
            value=str(int(cls.services["vpnclient_count"]*2))
        )
        cls.debug("'max.account.user.vms' Global Configuration Parameter Updated Successfully")
        
        update_max_account_volumes_limit = Configurations.update(
            cls.api_client,
            name="max.account.volumes", 
            value=str(int(cls.services["vpnclient_count"]*2))
        )
        cls.debug("'max.account.volumes' Global Configuration Parameter Updated Successfully")

        update_max_account_cpus_limit = Configurations.update(
            cls.api_client,
            name="max.account.cpus", 
            value=str(int(cls.services["vpnclient_count"]*2))
        )
        cls.debug("'max.account.cpus' Global Configuration Parameter Updated Successfully")
        
        cls.debug("Restart the Management Server")
        TestMultipleVPNAccessonVPC.restart_mgmt_server(cls.services["config_path"])
        cls.debug("Completed restarting the Management Server")
        
        cls.debug("Wait for 120 seconds...")
        time.sleep(120)
        cls.debug("End of 120 seconds wait time....")
        
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(
            cls.api_client,
            zone_name = cls.services["zone_vpn"]["name"])
        
        cls.debug("Use an Existing 'Tiny Instance' Service Offering on the Setup")
        list_service_offerings = []
        list_service_offerings = list_service_offering(
            cls.api_client,
            keyword="Tiny Instance",
        )
        
        cls._cleanup = []
            
        if list_service_offerings is not None:
            cls.debug("Found an Existing 'Tiny Instance' Service Offering on the Setup")
            cls.service_offering = list_service_offerings[0]
            
        else:
            cls.debug("Create a service offering which will be used for VM deployments in this test")
            cls.service_offering = ServiceOffering.create(
                cls.api_client,
                cls.services["service_offering"]
            )
            
            cls.debug("Add the created service offering to the _cleanup queue")
            cls._cleanup.append(cls.service_offering)
        
        try:
            cls.debug("Create or Use Existing Account to own the VPN Clients, which is used to test Remote VPN Access to VPC")
            cls.api_client_vpn_client_reg_user = cloudstackTestClient.getUserApiClient(
                UserName="******",
                DomainName="ROOT"
            )

            list_vpn_client_regular_user = User.list(
                cls.api_client,
                username="******"
            )
            
            cls.debug("Procure the Account Name and DomainID Information of the Regular Account")
            cls.vpn_client_reg_acct_name = list_vpn_client_regular_user[0].account
            cls.vpn_client_reg_domain_id = list_vpn_client_regular_user[0].domainid
            
            list_vpn_client_regular_user_acct = Account.list(
                cls.api_client,
                name = cls.vpn_client_reg_acct_name,
                listall = True
            )
            
            cls._cleanup.append(Account(list_vpn_client_regular_user_acct[0].__dict__))
            
            # Register a Template that already has VPN client installed on it. The template registered here
            # has extra scripts to facilitate automated operations to execute Test Cases.
            # Template has pre-configured configuration files required for the VPN Client operations.
            # The following files are present on the registered template. The location of the files are locations
            # on a VM deployed from this template
            #            1. "/tmp/ipsec.conf"
            #            2. "/tmp/ipsec.secrets"
            #            3. "/tmp/options.xl2tpd.client"
            #            4. "/tmp/xl2tpd.conf"
            #            5  "/tmp/vpnclient_services.sh"
            #            6. "/tmp/firstconn_expectscript.exp"
            #            7. "/tmp/secondconn_expectscript.exp"
            
            cls.debug("Use an Existing VPN Client Template on the Setup")
            list_vpn_client_templates = list_templates(
                cls.api_client_vpn_client_reg_user,
                keyword="VPNClient",
                templatefilter="featured",
                zoneid = cls.zone.id
            )
            
            if list_vpn_client_templates is not None:
                cls.debug("Found an Existing VPN Client Template on the Setup")
                cls.template = list_vpn_client_templates[0]
            
            else:
                cls.debug("Register a Template that already has VPN client installed on it")
                cls.template = Template.register(
                    cls.api_client, 
                    cls.services["vpn_template"], 
                    zoneid=cls.zone.id,
                    hypervisor='XenServer' 
                )

                cls._cleanup.append(cls.template)

                cls.debug("Sleep for {0} seconds specified in the dictionary before checking for Template's Availability".format(cls.services["sleep"]))
                time.sleep(cls.services["sleep"])
                
            cls.debug("Procure Timeout Value from the dictionary")
            timeout = cls.services["timeout"]
            
            while True:
                list_template_response = list_templates(
                    cls.api_client_vpn_client_reg_user,
                    templatefilter='featured',
                    id=cls.template.id,
                )
            
                if isinstance(list_template_response, list):
                    break
                elif timeout == 0:
                    raise Exception("List template failed!")

                time.sleep(5)
                timeout = timeout - 1
            
            cls.debug("Verify template response to check whether template is present")
            
            if list_template_response is None: 
                raise Exception("Check whether the VPN Client Template is available")
            template_response = list_template_response[0]
            if template_response.isready == False: 
                raise Exception("Template state is not ready, it is %r" % template_response.isready)
            
            # Queue that holds all the VPN Client VMs Information
            cls.vpnclientvms = []
            
            cls.debug("Deploy {0} VPN Clients in the account".format(int(cls.services["vpnclient_count"])))
            
            for vm in xrange(0,int(cls.services["vpnclient_count"])):
                
                cls.debug("Deploy a new VM {0} in first account. This VM which will be configured as VPN Client".format(int(vm)))
                new_vpnclient_vm = VirtualMachine.create(
                    cls.api_client_vpn_client_reg_user,
                    cls.services["virtual_machine"],
                    zoneid=cls.zone.id,
                    serviceofferingid=cls.service_offering.id,
                    templateid=cls.template.id,
                )
                
                cls.debug("Add new VM {0} to the vpnclientvms Queue".format(int(vm)))
                cls.vpnclientvms.append(new_vpnclient_vm)                

                cls.debug("Allow SSH Access to the new VPN Client VM {0}".format(int(vm)))
                new_vpnclient_vm.access_ssh_over_nat(
                    cls.api_client_vpn_client_reg_user, 
                    cls.services, 
                    new_vpnclient_vm, 
                    allow_egress=True
                )
                cls.debug("VM for VPNClient Access Got Created with Public IP Address %s" % new_vpnclient_vm.public_ip)
            
            cls.debug("Create or Use existing Account in which we deploy VPCs and test remote access to them from the First Account's VMs present on isolated Network")          
            cls.api_client_vpn_server_reg_user = cloudstackTestClient.getUserApiClient(
                UserName="******",
                DomainName="ROOT"
            )

            list_vpn_server_regular_user = User.list(
                cls.api_client,
                username="******"
            )
            
            cls.debug("Procure the Account Name and DomainID Information of the Regular Account")
            cls.vpn_server_reg_acct_name = list_vpn_server_regular_user[0].account
            cls.vpn_server_reg_domain_id = list_vpn_server_regular_user[0].domainid
        
            list_vpn_server_regular_user_acct = Account.list(
                cls.api_client,
                name = cls.vpn_server_reg_acct_name,
                listall = True
            )
            
            cls._cleanup.append(Account(list_vpn_server_regular_user_acct[0].__dict__))        
        
            cls.debug("Use an Existing 'VPC off-' Service Offering on the Setup")
            list_available_vpc_offerings = list_vpc_offerings(
                cls.api_client,
                keyword="VPC off-",
            )
            
            if list_available_vpc_offerings is not None:
                cls.debug("Found an Existing 'VPC off-' Service Offering on the Setup")
                cls.vpc_offering = VpcOffering(list_available_vpc_offerings[0].__dict__)
            
            else:
                cls.debug("Creating a VPC offering..")
                cls.vpc_offering = VpcOffering.create(
                    cls.api_client,
                    cls.services["vpc_offering"]
                )

                # Add the created VPC Offering to __cleanup queue
                cls._cleanup.append(cls.vpc_offering)

            # Enable to created VPC Offering inorder to deploy VPCs with it       
            cls.debug("Enabling the VPC offering created")
            cls.vpc_offering.update(cls.api_client, state='Enabled')
            cls.debug("Enabled the VPC Offering")

            # Create a VPC for the second account
            cls.debug("Creating a VPC in the account: %s" % cls.vpn_server_reg_acct_name)
            cls.firstvpc = VPC.create(
                cls.api_client_vpn_server_reg_user,
                cls.services["vpc_remote_vpn"],
                vpcofferingid=cls.vpc_offering.id,
                zoneid=cls.zone.id
            )        
        
            cls.debug("Use an Existing 'NET_OFF-RemoteAccessVPNTest-' Network Offering on the Setup")
            list_available_network_offerings = list_network_offerings(
                cls.api_client,
                keyword="NET_OFF-RemoteAccessVPNTest-",
            )
            
            if list_available_network_offerings is not None:
                cls.debug("Found an Existing 'NET_OFF-RemoteAccessVPNTest-' Network Offering on the Setup")
                cls.network_off = NetworkOffering(list_available_network_offerings[0].__dict__)
            
            else:
                cls.debug('Create NetworkOffering for Networks in VPC')
                cls.services["vpc_network_offering"]["name"] = "NET_OFF-RemoteAccessVPNTest-"+ random_gen()
                cls.network_off = NetworkOffering.create(
                    cls.api_client,
                    cls.services["vpc_network_offering"],
                    conservemode=False
                )

                # Add the created Network Offering to __cleanup queue
                cls._cleanup.append(cls.network_off)
        
            # Enable Network offering
            cls.network_off.update(cls.api_client, state='Enabled')
                    
            cls.debug('Created and Enabled NetworkOffering')
            cls.services["network"]["name"] = "NETWORK-" + random_gen()
            
            # Create First Network Tier in the First VPC created for second account using the network offering created above.    
            cls.debug('Adding Network=%s' % cls.services["network"])
            cls.firstnetworktier = Network.create(
                cls.api_client_vpn_server_reg_user,
                cls.services["network"],
                networkofferingid=cls.network_off.id,
                zoneid=cls.zone.id,
                gateway=cls.services["firstnetwork_tier"]["gateway"],
                netmask=cls.services["firstnetwork_tier"]["netmask"],
                vpcid=cls.firstvpc.id 
            )
        
            cls.debug("Created network with ID: %s" % cls.firstnetworktier.id)
        
            # Create Ingress and Egress NetworkACL rules for First Network Tier in the First VPC created for second account.
            cls.debug("Adding NetworkACL rules to make Network accessible for all Protocols and all CIDRs ")
            NetworkACL.create(
                cls.api_client_vpn_server_reg_user,
                cls.services["all_rule"],
                networkid=cls.firstnetworktier.id,
                traffictype='Ingress'
            )
        
            NetworkACL.create(
                cls.api_client_vpn_server_reg_user,
                cls.services["all_rule"],
                networkid=cls.firstnetworktier.id,
                traffictype='Egress'
            )
         
            listFirstVPC = VPC.list(
                cls.api_client_vpn_server_reg_user,
                id=cls.firstvpc.id
            )
            
            cls.debug("Information about the VPC: {0}".format(str(listFirstVPC)))
        
            cls.debug("Obtain the source nat IP Address of the first VPC.")
            cls.listFirstVPCPublicIpAddress = list_publicIP(
                cls.api_client_vpn_server_reg_user,
                issourcenat="true",
                vpcid=listFirstVPC[0].id,
                listall="true"
            )
            cls.debug("Information about the VPC's Source NAT IP Address: {0}".format(str(cls.listFirstVPCPublicIpAddress)))
        
            cls.debug("Enable Remote Access VPN on the source nat Public IP Address of the first VPC")
            cls.FirstVPNonFirstVPC = Vpn.create(
                cls.api_client_vpn_server_reg_user,
                cls.listFirstVPCPublicIpAddress[0].id
            )

            cls.debug("Successfully Created First VPN on VPC with preshared key:"+ cls.FirstVPNonFirstVPC.presharedkey)
            cls.listfirstNetworkTier = list_networks(
                cls.api_client_vpn_server_reg_user,
                id=cls.firstnetworktier.id,
                listall=True
            )


            cls.debug("Create a VM using the default template on the First Network Tier in the First VPC of the Second Account")
            cls.vm1 = VirtualMachine.create(
                cls.api_client_vpn_server_reg_user,
                cls.services["virtual_machine"],
                zoneid=cls.zone.id,
                serviceofferingid=cls.service_offering.id,
                templateid=cls.template.id,
                networkids=[str(cls.firstnetworktier.id)]
            )
        
            cls.debug("First VM deployed in the first Network Tier")
        
        except Exception as e:
            cleanup_resources(cls.api_client, cls._cleanup)
            printex = traceback.format_exc()
            cls.debug("Exception Occurred : {0}".format(printex))
            raise Exception("Warning: Exception during Setting Up the Test Suite Configuration : %s" % e)
        
        return