cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [5/7] git commit: updated refs/heads/master to 3638965
Date Wed, 16 Nov 2016 05:35:54 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a97d54f3/test/integration/plugins/nuagevsp/test_nuage_internal_dns.py
----------------------------------------------------------------------
diff --git a/test/integration/plugins/nuagevsp/test_nuage_internal_dns.py b/test/integration/plugins/nuagevsp/test_nuage_internal_dns.py
new file mode 100644
index 0000000..9e03ba0
--- /dev/null
+++ b/test/integration/plugins/nuagevsp/test_nuage_internal_dns.py
@@ -0,0 +1,523 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Component tests for Internal DNS functionality with Nuage VSP SDN plugin
+"""
+# Import Local Modules
+from nuageTestCase import nuageTestCase
+from marvin.cloudstackAPI import updateZone
+from marvin.lib.base import Account, Network
+# Import System Modules
+from nose.plugins.attrib import attr
+
+
+class TestNuageInternalDns(nuageTestCase):
+    DNS = "06"
+    HOSTNAME = "0c"
+    DOMAINNAME = "0f"
+
+    @classmethod
+    def setUpClass(cls):
+        super(TestNuageInternalDns, cls).setUpClass()
+        cls.dnsdata = cls.test_data["nuagevsp"]
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.account = Account.create(
+            self.apiclient,
+            self.test_data["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
+        self.test_data["virtual_machine"]["displayname"] = "vm1"
+        self.test_data["virtual_machine"]["name"] = "vm1"
+
+        self.cleanup = [self.account]
+        return
+
+    # Creates and verifies the firewall rule
+    def create_and_verify_fw(self, vm, public_ip, network):
+        self.debug("Create and verify firewall rule")
+        self.create_StaticNatRule_For_VM(vm, public_ip, network)
+
+        # VSD verification
+        self.verify_vsd_floating_ip(network, vm, public_ip.ipaddress)
+
+        fw_rule = self.create_FirewallRule(
+            public_ip, self.test_data["ingress_rule"])
+        self.verify_vsd_firewall_rule(fw_rule)
+
+    def verify_vsd_dhcp_option(self, dhcp_type, value, subnet_or_vm_interface,
+                               is_vm_interface=False):
+        self.debug("Verifying the creation and value of DHCP option type - %s "
+                   "in VSD" % dhcp_type)
+        found_dhcp_type = False
+        if is_vm_interface:
+            dhcp_options = self.vsd.get_vm_interface_dhcpoptions(
+                filter=self.get_externalID_filter(subnet_or_vm_interface.id))
+        else:
+            dhcp_options = self.vsd.get_subnet_dhcpoptions(
+                filter=self.get_externalID_filter(subnet_or_vm_interface.id))
+        for dhcp_option in dhcp_options:
+            self.debug("dhcptype option is %s:" % dhcp_option.actual_type)
+            self.debug("dhcptype expected value is option is %s:" % dhcp_type)
+            if dhcp_option.type == dhcp_type:
+                found_dhcp_type = True
+                if isinstance(dhcp_option.actual_values, list):
+                    self.debug("dhcptype actual value is %s:" %
+                               dhcp_option.actual_values)
+                    if value in dhcp_option.actual_values:
+                        self.debug("Excepted DHCP option value found in VSD")
+                    else:
+                        self.fail("Excepted DHCP option value not found in "
+                                  "VSD")
+                else:
+                    self.assertEqual(dhcp_options.actual_values, value,
+                                     "Expected DHCP option value is not same "
+                                     "in both CloudStack and VSD"
+                                     )
+        if not found_dhcp_type:
+            self.fail("Expected DHCP option type and value not found in the "
+                      "VSD")
+        self.debug("Successfully verified the creation and value of DHCP "
+                   "option type - %s in VSD" % dhcp_type)
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="false")
+    def test_01_Isolated_Network_with_zone(self):
+        """ Verify InternalDns on Isolated Network
+        """
+
+        # Validate the following
+        # 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS
+        #    network offering.
+        # 2. Deploy vm1 in network1.
+        # 3. Verify dhcp option 06 and 0f for subnet
+        # 4. Verify dhcp option 06,15 and 0f for vm Interface.
+
+        # update Network Domain at zone level
+        cmd = updateZone.updateZoneCmd()
+        cmd.id = self.zone.id
+        cmd.domain = "isolated.com"
+        self.apiclient.updateZone(cmd)
+        self.debug("Creating and enabling Nuage Vsp Isolated Network "
+                   "offering...")
+        network_offering = self.create_NetworkOffering(
+            self.dnsdata["isolated_network_offering"])
+        self.validate_NetworkOffering(network_offering, state="Enabled")
+
+        network_1 = self.create_Network(network_offering)
+        vm_1 = self.create_VM(network_1)
+
+        # VSD verification
+        self.verify_vsd_network(self.domain.id, network_1)
+        self.verify_vsd_vm(vm_1)
+
+        # Internal DNS check point on VSD
+        self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
+        self.verify_vsd_dhcp_option(self.DOMAINNAME, "isolated.com", network_1)
+        for nic in vm_1.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(
+                self.DOMAINNAME, "isolated.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="true")
+    def test_02_Isolated_Network(self):
+        """ Verify InternalDns on Isolated Network with ping by hostname
+        """
+
+        # Validate the following
+        # 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS
+        #    network offering.
+        # 2. Deploy vm1 in network1.
+        # 3. Verify dhcp option 06 and 0f for subnet
+        # 4. Verify dhcp option 06,15 and 0f for vm Interface.
+        # 5. Deploy VM2 in network1.
+        # 6. Verify end to end by pinging with hostname
+
+        cmd = updateZone.updateZoneCmd()
+        cmd.id = self.zone.id
+        cmd.domain = "isolated.com"
+        self.apiclient.updateZone(cmd)
+
+        self.debug("Creating and enabling Nuage Vsp Isolated Network "
+                   "offering...")
+        network_offering = self.create_NetworkOffering(
+            self.dnsdata["isolated_network_offering"])
+        self.validate_NetworkOffering(network_offering, state="Enabled")
+
+        network_1 = self.create_Network(network_offering)
+        vm_1 = self.create_VM(network_1)
+
+        # VSD verification
+        self.verify_vsd_network(self.domain.id, network_1)
+        self.verify_vsd_vm(vm_1)
+
+        # Internal DNS check point on VSD
+        self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
+        self.verify_vsd_dhcp_option(self.DOMAINNAME, "isolated.com", network_1)
+        for nic in vm_1.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(
+                self.DOMAINNAME, "isolated.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
+
+        self.test_data["virtual_machine"]["displayname"] = "vm2"
+        self.test_data["virtual_machine"]["name"] = "vm2"
+        vm_2 = self.create_VM(network_1)
+        self.test_data["virtual_machine"]["displayname"] = "vm1"
+        self.test_data["virtual_machine"]["name"] = "vm1"
+        self.verify_vsd_vm(vm_2)
+        for nic in vm_2.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(
+                self.DOMAINNAME, "isolated.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True)
+
+        public_ip_1 = self.acquire_PublicIPAddress(network_1)
+        self.create_and_verify_fw(vm_1, public_ip_1, network_1)
+
+        vm_public_ip = public_ip_1.ipaddress.ipaddress
+
+        try:
+            vm_1.ssh_ip = vm_public_ip
+            vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"]
+            vm_1.username = self.test_data["virtual_machine"]["username"]
+            vm_1.password = self.test_data["virtual_machine"]["password"]
+            self.debug("SSHing into VM: %s with %s" %
+                       (vm_1.ssh_ip, vm_1.password))
+
+            ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip)
+
+        except Exception as e:
+            self.fail("SSH into VM failed with exception %s" % e)
+
+        cmd = 'ping -c 2 vm2'
+        self.debug("ping vm2 by hostname with command: " + cmd)
+        outputlist = ssh.execute(cmd)
+        self.debug("command is executed properly " + cmd)
+        completeoutput = str(outputlist).strip('[]')
+        self.debug("complete output is " + completeoutput)
+        expectedlist = ['2 received', 'vm2.isolated.com', vm_2.ipaddress]
+        for item in expectedlist:
+            if item in completeoutput:
+                self.debug("excepted value found in vm: " + item)
+            else:
+                self.fail("excepted value not found in vm: " + item)
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="false")
+    def test_03_Update_Network_with_Domain(self):
+        """ Verify update NetworkDomain for InternalDns on Isolated Network
+        """
+
+        # Validate the following
+        # 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS
+        #    network offering.
+        # 2. Deploy vm1 in network1.
+        # 3. Verify dhcp option 06 and 0f for subnet
+        # 4. Verify dhcp option 06,15 and 0f for vm Interface.
+        # 5. Update Network domain and verify it is properly updated
+
+        # update Network Domain at zone level
+        cmd = updateZone.updateZoneCmd()
+        cmd.id = self.zone.id
+        cmd.domain = "isolated.com"
+        self.apiclient.updateZone(cmd)
+
+        self.debug("Creating and enabling Nuage Vsp Isolated Network "
+                   "offering...")
+        network_offering = self.create_NetworkOffering(
+            self.dnsdata["isolated_network_offering"])
+        self.validate_NetworkOffering(network_offering, state="Enabled")
+
+        network_1 = self.create_Network(network_offering)
+        vm_1 = self.create_VM(network_1)
+
+        # VSD verification
+        self.verify_vsd_network(self.domain.id, network_1)
+        self.verify_vsd_vm(vm_1)
+
+        # Internal DNS check point on VSD
+        self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
+        self.verify_vsd_dhcp_option(self.DOMAINNAME, "isolated.com", network_1)
+        for nic in vm_1.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(
+                self.DOMAINNAME, "isolated.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
+
+        update_response = Network.update(
+            network_1, self.apiclient, id=network_1.id,
+            networkdomain="update.com", changecidr=False)
+        completeoutput = str(update_response).strip('[]')
+        self.debug("network update response is " + completeoutput)
+        self.assertEqual("update.com", update_response.networkdomain,
+                         "Network Domain is not updated as expected"
+                         )
+        self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
+        self.verify_vsd_dhcp_option(self.DOMAINNAME, "update.com", network_1)
+        for nic in vm_1.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(
+                self.DOMAINNAME, "update.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="true")
+    def test_04_Update_Network_with_Domain(self):
+        """ Verify update NetworkDomain for InternalDns on Isolated Network
+        with ping VM
+        """
+
+        # Validate the following
+        # 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS
+        #    network offering.
+        # 2. Deploy vm1 in network1.
+        # 3. Verify dhcp option 06 and 0f for subnet
+        # 4. Verify dhcp option 06,15 and 0f for vm Interface.
+        # 5. Update Network domain and verify it is properly updated
+
+        # update Network Domain at zone level
+        cmd = updateZone.updateZoneCmd()
+        cmd.id = self.zone.id
+        cmd.domain = "isolated.com"
+        self.apiclient.updateZone(cmd)
+
+        self.debug("Creating and enabling Nuage Vsp Isolated Network "
+                   "offering...")
+        network_offering = self.create_NetworkOffering(
+            self.dnsdata["isolated_network_offering"])
+        self.validate_NetworkOffering(network_offering, state="Enabled")
+
+        network_1 = self.create_Network(network_offering)
+        vm_1 = self.create_VM(network_1)
+
+        # VSD verification
+        self.verify_vsd_network(self.domain.id, network_1)
+        self.verify_vsd_vm(vm_1)
+
+        # Internal DNS check point on VSD
+        self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
+        self.verify_vsd_dhcp_option(
+            self.DOMAINNAME, "isolated.com", network_1)
+        for nic in vm_1.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(
+                self.DOMAINNAME, "isolated.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
+
+        update_response = Network.update(
+            network_1, self.apiclient, id=network_1.id,
+            networkdomain="update.com", changecidr=False)
+        completeoutput = str(update_response).strip('[]')
+        self.debug("network update response is " + completeoutput)
+        self.assertEqual("update.com", update_response.networkdomain,
+                         "Network Domain is not updated as expected"
+                         )
+        self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
+        self.verify_vsd_dhcp_option(self.DOMAINNAME, "update.com", network_1)
+        for nic in vm_1.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(
+                self.DOMAINNAME, "update.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
+
+        # stop and start VM to get new DHCP option
+        try:
+            vm_1.stop(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to stop the virtual instances, %s" % e)
+
+        try:
+            vm_1.start(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to start the virtual instances, %s" % e)
+
+        self.test_data["virtual_machine"]["displayname"] = "vm2"
+        self.test_data["virtual_machine"]["name"] = "vm2"
+        vm_2 = self.create_VM(network_1)
+        self.test_data["virtual_machine"]["displayname"] = "vm1"
+        self.test_data["virtual_machine"]["name"] = "vm1"
+        self.verify_vsd_vm(vm_2)
+        for nic in vm_2.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(
+                self.DOMAINNAME, "update.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True)
+
+        public_ip_1 = self.acquire_PublicIPAddress(network_1)
+        self.create_and_verify_fw(vm_1, public_ip_1, network_1)
+
+        vm_public_ip = public_ip_1.ipaddress.ipaddress
+
+        try:
+            vm_1.ssh_ip = vm_public_ip
+            vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"]
+            vm_1.username = self.test_data["virtual_machine"]["username"]
+            vm_1.password = self.test_data["virtual_machine"]["password"]
+            self.debug("SSHing into VM: %s with %s" %
+                       (vm_1.ssh_ip, vm_1.password))
+
+            ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip)
+
+        except Exception as e:
+            self.fail("SSH into VM failed with exception: %s " % e)
+
+        cmd = 'ping -c 2 vm2'
+        self.debug("ping vm2 by hostname with command: " + cmd)
+        outputlist = ssh.execute(cmd)
+        self.debug("command is executed properly " + cmd)
+        completeoutput = str(outputlist).strip('[]')
+        self.debug("complete output is " + completeoutput)
+        expectedlist = ['2 received', 'vm2.update.com', vm_2.ipaddress]
+        for item in expectedlist:
+            if item in completeoutput:
+                self.debug("excepted value found in vm: " + item)
+            else:
+                self.fail("excepted value not found in vm: " + item)
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="false")
+    def test_05_VPC_Network_With_InternalDns(self):
+        """ Verify InternalDns on VPC Network
+        """
+
+        # Validate the following
+        # 1. Create a VPC and tier network by using DNS network offering.
+        # 2. Deploy vm1 in tier network.
+        # 3. Verify dhcp option 06 and 0f for subnet
+        # 4. Verify dhcp option 06,15 and 0f for vm Interface.
+
+        cmd = updateZone.updateZoneCmd()
+        cmd.id = self.zone.id
+        cmd.domain = "vpc.com"
+        self.apiclient.updateZone(cmd)
+        vpc_off = self.create_VpcOffering(self.dnsdata["vpc_offering"])
+        self.validate_VpcOffering(vpc_off, state="Enabled")
+
+        vpc = self.create_Vpc(vpc_off, cidr='10.1.0.0/16', cleanup=False)
+
+        self.debug("Creating Nuage Vsp VPC Network offering...")
+        network_offering = self.create_NetworkOffering(
+            self.dnsdata["vpc_network_offering"])
+        self.validate_NetworkOffering(network_offering, state="Enabled")
+        network_1 = self.create_Network(
+            network_offering, gateway='10.1.1.1', vpc=vpc)
+
+        vm_1 = self.create_VM(network_1)
+
+        # VSD verification
+        self.verify_vsd_network(self.domain.id, network_1, vpc)
+        self.verify_vsd_vm(vm_1)
+
+        # Internal DNS check point on VSD
+        self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
+        self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", network_1)
+        for nic in vm_1.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
+
+    @attr(tags=["advanced", "nuagevsp"], required_hardware="true")
+    def test_06_VPC_Network_With_InternalDns(self):
+        """ Verify InternalDns on VPC Network by ping with hostname
+        """
+
+        # Validate the following
+        # 1. Create a VPC and Tier network by using DNS network offering.
+        # 2. Deploy vm1 in Tier network network1.
+        # 3. Verify dhcp option 06 and 0f for subnet
+        # 4. Verify dhcp option 06,15 and 0f for vm Interface.
+        # 5. Deploy Vm2.
+        # 6. Verify end to end by pinging with hostname
+
+        cmd = updateZone.updateZoneCmd()
+        cmd.id = self.zone.id
+        cmd.domain = "vpc.com"
+        self.apiclient.updateZone(cmd)
+
+        vpc_off = self.create_VpcOffering(self.dnsdata["vpc_offering"])
+        self.validate_VpcOffering(vpc_off, state="Enabled")
+        vpc = self.create_Vpc(vpc_off, cidr='10.1.0.0/16', cleanup=False)
+
+        self.debug("Creating Nuage Vsp VPC Network offering...")
+        network_offering = self.create_NetworkOffering(
+            self.dnsdata["vpc_network_offering"])
+        self.validate_NetworkOffering(network_offering, state="Enabled")
+        network_1 = self.create_Network(
+            network_offering, gateway='10.1.1.1', vpc=vpc)
+
+        vm_1 = self.create_VM(network_1)
+
+        # VSD verification
+        self.verify_vsd_network(self.domain.id, network_1, vpc)
+        self.verify_vsd_vm(vm_1)
+        # Internal DNS check point on VSD
+        self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
+        self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", network_1)
+        for nic in vm_1.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
+
+        self.test_data["virtual_machine"]["displayname"] = "vm2"
+        self.test_data["virtual_machine"]["name"] = "vm2"
+        vm_2 = self.create_VM(network_1)
+        self.test_data["virtual_machine"]["displayname"] = "vm1"
+        self.test_data["virtual_machine"]["name"] = "vm1"
+        self.verify_vsd_vm(vm_2)
+        for nic in vm_2.nic:
+            self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
+            self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", nic, True)
+            self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True)
+
+        public_ip_1 = self.acquire_PublicIPAddress(network_1, vpc)
+        self.create_StaticNatRule_For_VM(vm_1, public_ip_1, network_1)
+        # Adding Network ACL rule in the Public tier
+        self.debug("Adding Network ACL rule to make the created NAT rule "
+                   "(SSH) accessible...")
+        public_ssh_rule = self.create_NetworkAclRule(
+            self.test_data["ingress_rule"], network=network_1)
+
+        # VSD verification
+        self.verify_vsd_firewall_rule(public_ssh_rule)
+        vm_public_ip = public_ip_1.ipaddress.ipaddress
+
+        try:
+            vm_1.ssh_ip = vm_public_ip
+            vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"]
+            vm_1.username = self.test_data["virtual_machine"]["username"]
+            vm_1.password = self.test_data["virtual_machine"]["password"]
+            self.debug("SSHing into VM: %s with %s" %
+                       (vm_1.ssh_ip, vm_1.password))
+
+            ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip)
+
+        except Exception as e:
+            self.fail("SSH into VM failed with exception %s" % e)
+
+        cmd = 'ping -c 2 vm2'
+        self.debug("ping vm2 by hostname with command: " + cmd)
+        outputlist = ssh.execute(cmd)
+        self.debug("command is executed properly " + cmd)
+        completeoutput = str(outputlist).strip('[]')
+        self.debug("complete output is " + completeoutput)
+        expectedlist = ['2 received', 'vm2.vpc.com', vm_2.ipaddress]
+        for item in expectedlist:
+            if item in completeoutput:
+                self.debug("excepted value found in vm: " + item)
+            else:
+                self.fail("excepted value not found in vm: " + item)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a97d54f3/test/integration/plugins/nuagevsp/test_nuage_password_reset.py
----------------------------------------------------------------------
diff --git a/test/integration/plugins/nuagevsp/test_nuage_password_reset.py b/test/integration/plugins/nuagevsp/test_nuage_password_reset.py
index bd8bba6..1ab6d57 100644
--- a/test/integration/plugins/nuagevsp/test_nuage_password_reset.py
+++ b/test/integration/plugins/nuagevsp/test_nuage_password_reset.py
@@ -15,7 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-""" Component tests for user data and password reset functionality with Nuage VSP SDN plugin
+""" Component tests for user data and password reset functionality with
+Nuage VSP SDN plugin
 """
 # Import Local Modules
 from nuageTestCase import nuageTestCase
@@ -31,7 +32,8 @@ import base64
 
 
 class TestNuagePasswordReset(nuageTestCase):
-    """Test user data and password reset functionality with Nuage VSP SDN plugin
+    """Test user data and password reset functionality with
+    Nuage VSP SDN plugin
     """
 
     @classmethod
@@ -60,22 +62,26 @@ class TestNuagePasswordReset(nuageTestCase):
         if isinstance(list_volume, list):
             self.volume = list_volume[0]
         else:
-            raise Exception("Exception: Unable to find root volume for VM with ID - %s" %
vm.id)
-        self.pw_enabled_template = Template.create(self.api_client,
-                                                   self.test_data["template"],
-                                                   self.volume.id,
-                                                   account=self.account.name,
-                                                   domainid=self.account.domainid
-                                                   )
+            raise Exception("Exception: Unable to find root volume for VM "
+                            "with ID - %s" % vm.id)
+        self.pw_enabled_template = Template.create(
+            self.api_client,
+            self.test_data["template"],
+            self.volume.id,
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         self.assertEqual(self.pw_enabled_template.passwordenabled, True,
-                         "template is not passwordenabled"
+                         "Template is not password enabled"
                          )
         self.cleanup.append(self.pw_enabled_template)
         self.debug("Created guest VM template")
 
-    # updateTemplate - Updates value of the guest VM template's password enabled setting
+    # updateTemplate - Updates value of the guest VM template's password
+    # enabled setting
     def updateTemplate(self, value):
-        self.debug("Updating value of guest VM template's password enabled setting")
+        self.debug("Updating value of guest VM template's password enabled "
+                   "setting")
         cmd = updateTemplate.updateTemplateCmd()
         cmd.id = self.template.id
         cmd.passwordenabled = value
@@ -96,7 +102,8 @@ class TestNuagePasswordReset(nuageTestCase):
         user_data_url = 'curl "http://' + gateway + ':80/latest/user-data"'
         return user_data_url
 
-    # create_and_verify_fw - Creates and verifies (Ingress) firewall rule with a Static NAT
rule enabled public IP
+    # create_and_verify_fw - Creates and verifies (Ingress) firewall rule with
+    # a Static NAT rule enabled public IP
     def create_and_verify_fw(self, vm, public_ip, network):
         self.debug("Creating and verifying firewall rule")
         self.create_StaticNatRule_For_VM(vm, public_ip, network)
@@ -104,7 +111,8 @@ class TestNuagePasswordReset(nuageTestCase):
         # VSD verification
         self.verify_vsd_floating_ip(network, vm, public_ip.ipaddress)
 
-        fw_rule = self.create_FirewallRule(public_ip, self.test_data["ingress_rule"])
+        fw_rule = self.create_FirewallRule(
+            public_ip, self.test_data["ingress_rule"])
 
         # VSD verification
         self.verify_vsd_firewall_rule(fw_rule)
@@ -122,14 +130,17 @@ class TestNuagePasswordReset(nuageTestCase):
             if vm.state != 'Stopped':
                 raise Exception("Failed to stop VM (ID: %s) " % self.vm.id)
         else:
-            raise Exception("Invalid response from list_virtual_machines VM (ID: %s) " %
self.vm.id)
+            raise Exception("Invalid response from list_virtual_machines VM "
+                            "(ID: %s) " % self.vm.id)
         self.debug("Stopped VM")
 
-    # install_cloud_set_guest_password_script - Installs the cloud-set-guest-password script
from people.apache.org in
-    # the given VM (SSH client)
+    # install_cloud_set_guest_password_script - Installs the
+    # cloud-set-guest-password script from people.apache.org in the given VM
+    # (SSH client)
     def install_cloud_set_guest_password_script(self, ssh_client):
         self.debug("Installing cloud-set-guest-password script")
-        cmd = "cd /etc/init.d;wget http://people.apache.org/~tsp/cloud-set-guest-password"
+        cmd = "cd /etc/init.d;wget http://people.apache.org/~tsp/" \
+              "cloud-set-guest-password"
         result = self.execute_cmd(ssh_client, cmd)
         self.debug("wget file cloud-set-guest-password: " + result)
         if "200 OK" not in result:
@@ -145,53 +156,71 @@ class TestNuagePasswordReset(nuageTestCase):
 
     @attr(tags=["advanced", "nuagevsp"], required_hardware="true")
     def test_nuage_UserDataPasswordReset(self):
-        """Test user data and password reset functionality with Nuage VSP SDN plugin
+        """Test user data and password reset functionality with
+        Nuage VSP SDN plugin
         """
 
-        # 1. Create an Isolated Network with Nuage VSP Isolated Network offering, check if
it is successfully created
-        #    and is in the "Allocated" state.
+        # 1. Create an Isolated Network with Nuage VSP Isolated Network
+        #    offering, check if it is successfully created and is in the
+        #    "Allocated" state.
         # 2. Set password enabled to false in the guest VM template.
-        # 3. Deploy a VM in the created Isolated network with user data, check if the Isolated
network state is changed
-        #    to "Implemented", and both the VM & VR are successfully deployed and are
in the "Running" state.
-        # 4. Verify that the guest VM template is not password enabled by checking the deployed
VM's password
-        #    (password == "password").
-        # 5. SSH into the deployed VM and verify its user data (expected user data == actual
user data).
-        # 6. Check for cloud-set-guest-password script in the deployed VM for testing password
reset functionality.
-        # 7. if cloud-set-guest-password script does not exist in the deployed VM:
-        #       7.1  Install the cloud-set-guest-password script from people.apache.org in
the deployed VM.
-        #       7.2  Stop the deployed VM, and create a new password enabled guest VM template
with it.
-        #       7.3  Deploy a new VM in the created Isolated network with the newly created
guest VM template,
-        #            check if the VM is successfully deployed and is in the "Running" state.
-        #       7.4  Verify that the new guest VM template is password enabled by checking
the newly deployed VM's
-        #            password (password != "password").
+        # 3. Deploy a VM in the created Isolated network with user data, check
+        #    if the Isolated network state is changed to "Implemented", and
+        #    both the VM & VR are successfully deployed and are in the
+        #    "Running" state.
+        # 4. Verify that the guest VM template is not password enabled by
+        #    checking the deployed VM's password (password == "password").
+        # 5. SSH into the deployed VM and verify its user data
+        #    (expected user data == actual user data).
+        # 6. Check for cloud-set-guest-password script in the deployed VM for
+        #    testing password reset functionality.
+        # 7. if cloud-set-guest-password script does not exist in the deployed
+        #    VM:
+        #       7.1  Install the cloud-set-guest-password script from
+        #            people.apache.org in the deployed VM.
+        #       7.2  Stop the deployed VM, and create a new password enabled
+        #            guest VM template with it.
+        #       7.3  Deploy a new VM in the created Isolated network with the
+        #            newly created guest VM template, check if the VM is
+        #            successfully deployed and is in the "Running" state.
+        #       7.4  Verify that the new guest VM template is password enabled
+        #            by checking the newly deployed VM's password
+        #            (password != "password").
         #       7.5  SSH into the newly deployed VM for verifying its password.
         # 8. else cloud-set-guest-password script exists in the deployed VM:
         #       8.1  Change password enabled to true in the guest VM template.
         #       8.2  Verify that the guest VM template is password enabled.
         # 9. Reset VM password, and start the VM.
-        # 10. Verify that the new guest VM template is password enabled by checking the VM's
password
-        #     (password != "password").
-        # 11. SSH into the VM for verifying its new password after its password reset.
-        # 12. Set password enabled to the default value in the guest VM template.
+        # 10. Verify that the new guest VM template is password enabled by
+        #     checking the VM's password (password != "password").
+        # 11. SSH into the VM for verifying its new password after its password
+        #     reset.
+        # 12. Set password enabled to the default value in the guest VM
+        #     template.
         # 13. Delete all the created objects (cleanup).
 
-        self.debug("Testing user data & password reset functionality in an Isolated network...")
+        self.debug("Testing user data & password reset functionality in an "
+                   "Isolated network...")
 
         self.debug("Creating an Isolated network...")
-        net_off = self.create_NetworkOffering(self.test_data["nuagevsp"]["isolated_network_offering"])
+        net_off = self.create_NetworkOffering(
+            self.test_data["nuagevsp"]["isolated_network_offering"])
         self.network = self.create_Network(net_off)
         self.validate_Network(self.network, state="Allocated")
 
-        self.debug("Setting password enabled to false in the guest VM template...")
+        self.debug("Setting password enabled to false in the guest VM "
+                   "template...")
         self.defaultTemplateVal = self.template.passwordenabled
         if self.template.passwordenabled:
             self.updateTemplate(False)
 
-        self.debug("Deploying a VM in the created Isolated network with user data...")
+        self.debug("Deploying a VM in the created Isolated network with user "
+                   "data...")
         expected_user_data = "hello world vm1"
         user_data = base64.b64encode(expected_user_data)
         self.test_data["virtual_machine_userdata"]["userdata"] = user_data
-        self.vm_1 = self.create_VM(self.network, testdata=self.test_data["virtual_machine_userdata"])
+        self.vm_1 = self.create_VM(
+            self.network, testdata=self.test_data["virtual_machine_userdata"])
         self.validate_Network(self.network, state="Implemented")
         vr = self.get_Router(self.network)
         self.check_Router_state(vr, state="Running")
@@ -202,11 +231,15 @@ class TestNuagePasswordReset(nuageTestCase):
         self.verify_vsd_router(vr)
         self.verify_vsd_vm(self.vm_1)
 
-        self.debug("verifying that the guest VM template is not password enabled...")
-        self.debug("VM - %s password - %s !" % (self.vm_1.name, self.vm_1.password))
-        self.assertEqual(self.vm_1.password, self.test_data["virtual_machine_userdata"]["password"],
-                         "Password is enabled for the VM (vm_1)"
-                         )
+        self.debug("verifying that the guest VM template is not password "
+                   "enabled...")
+        self.debug("VM - %s password - %s !" %
+                   (self.vm_1.name, self.vm_1.password))
+        self.assertEqual(
+            self.vm_1.password,
+            self.test_data["virtual_machine_userdata"]["password"],
+            "Password is enabled for the VM (vm_1)"
+        )
 
         self.debug("SSHing into the VM for verifying its user data...")
         public_ip_1 = self.acquire_PublicIPAddress(self.network)
@@ -214,27 +247,35 @@ class TestNuagePasswordReset(nuageTestCase):
         ssh = self.ssh_into_VM(self.vm_1, public_ip_1)
         user_data_cmd = self.get_userdata_url(self.vm_1)
         self.debug("Getting user data with command: " + user_data_cmd)
-        actual_user_data = base64.b64decode(self.execute_cmd(ssh, user_data_cmd))
-        self.debug("Actual user data - " + actual_user_data + ", Expected user data - " +
expected_user_data)
+        actual_user_data = base64.b64decode(self.execute_cmd
+                                            (ssh, user_data_cmd))
+        self.debug("Actual user data - " + actual_user_data +
+                   ", Expected user data - " + expected_user_data)
         self.assertEqual(actual_user_data, expected_user_data,
                          "Un-expected VM (VM_1) user data"
                          )
 
-        self.debug("Checking for cloud-set-guest-password script in the VM for testing password
reset functionality...")
+        self.debug("Checking for cloud-set-guest-password script in the VM "
+                   "for testing password reset functionality...")
         ls_cmd = "ls /etc/init.d/cloud-set-guest-password"
         ls_result = self.execute_cmd(ssh, ls_cmd)
         ls_result = ls_result.lower()
         self.debug("Response from ls_cmd: " + ls_result)
         if "no such file" in ls_result:
             self.debug("No cloud-set-guest-password script in the VM")
-            self.debug("Installing the cloud-set-guest-password script from people.apache.org
in the VM...")
+            self.debug("Installing the cloud-set-guest-password script from "
+                       "people.apache.org in the VM...")
             self.install_cloud_set_guest_password_script(ssh)
-            self.debug("Stopping the VM, and creating a new password enabled guest VM template
with it...")
+            self.debug("Stopping the VM, and creating a new password enabled "
+                       "guest VM template with it...")
             self.stop_vm(self.vm_1)
             self.create_template(self.vm_1)
 
-            self.debug("Deploying a new VM in the created Isolated network with the newly
created guest VM template...")
-            self.vm_2 = self.create_VM(self.network, testdata=self.test_data["virtual_machine_userdata"])
+            self.debug("Deploying a new VM in the created Isolated network "
+                       "with the newly created guest VM template...")
+            self.vm_2 = self.create_VM(
+                self.network,
+                testdata=self.test_data["virtual_machine_userdata"])
             self.debug("Starting the VM...")
             vm_2a = self.vm_2.start(self.api_client)
             self.vm_2.password = vm_2a.password.strip()
@@ -243,11 +284,15 @@ class TestNuagePasswordReset(nuageTestCase):
             # VSD verification
             self.verify_vsd_vm(self.vm_2)
 
-            self.debug("verifying that the guest VM template is password enabled...")
-            self.debug("VM - %s password - %s !" % (self.vm_2.name, self.vm_2.password))
-            self.assertNotEqual(self.vm_2.password, self.test_data["virtual_machine_userdata"]["password"],
-                                "Password is not enabled for the VM"
-                                )
+            self.debug("verifying that the guest VM template is password "
+                       "enabled...")
+            self.debug("VM - %s password - %s !" %
+                       (self.vm_2.name, self.vm_2.password))
+            self.assertNotEqual(
+                self.vm_2.password,
+                self.test_data["virtual_machine_userdata"]["password"],
+                "Password is not enabled for the VM"
+            )
 
             self.debug("SSHing into the VM for verifying its password...")
             public_ip_2 = self.acquire_PublicIPAddress(self.network)
@@ -272,14 +317,20 @@ class TestNuagePasswordReset(nuageTestCase):
         self.debug("Starting the VM")
         vm_test.start(self.api_client)
 
-        self.debug("verifying that the guest VM template is password enabled...")
-        self.debug("VM - %s password - %s !" % (vm_test.name, vm_test.password))
-        self.assertNotEqual(vm_test.password, self.test_data["virtual_machine_userdata"]["password"],
-                            "Password is not enabled for the VM"
-                            )
-
-        self.debug("SSHing into the VM for verifying its new password after its password
reset...")
+        self.debug("verifying that the guest VM template is password "
+                   "enabled...")
+        self.debug("VM - %s password - %s !" %
+                   (vm_test.name, vm_test.password))
+        self.assertNotEqual(
+            vm_test.password,
+            self.test_data["virtual_machine_userdata"]["password"],
+            "Password is not enabled for the VM"
+        )
+
+        self.debug("SSHing into the VM for verifying its new password after "
+                   "its password reset...")
         self.ssh_into_VM(vm_test, vm_test_public_ip)
 
-        self.debug("Setting password enabled to the default value in the guest VM template...")
+        self.debug("Setting password enabled to the default value in the "
+                   "guest VM template...")
         self.updateTemplate(self.defaultTemplateVal)


Mime
View raw message