def find_public_gateway(self):
        networks = list_networks(self.apiclient,
                                 zoneid=self.zone.id,
                                 listall=True,
                                 issystem=True,
                                 traffictype="Public")
        self.logger.debug('::: Public Networks ::: ==> %s' % networks)

        self.assertTrue(
            len(networks) == 1,
            "Test expects only 1 Public network but found -> '%s'" %
            len(networks))

        ip_ranges = list_vlan_ipranges(self.apiclient,
                                       zoneid=self.zone.id,
                                       networkid=networks[0].id)
        self.logger.debug('::: IP Ranges ::: ==> %s' % ip_ranges)

        self.assertTrue(
            len(ip_ranges) == 1,
            "Test expects only 1 VLAN IP Range network but found -> '%s'" %
            len(ip_ranges))
        self.assertIsNotNone(
            ip_ranges[0].gateway,
            "The network with id -> '%s' returned an IP Range with a None gateway. Please check your Datacenter settings."
            % networks[0].id)

        return ip_ranges[0].gateway
Esempio n. 2
0
    def test_06_router_advanced(self):
        """Test router advanced setup
        """

        # Validate the following
        # 1. verify that listRouters returned a 'Running' router
        # 2. router will have dns and gateway as in listZones, listVlanIpRanges
        # 3. router will have guest,public and linklocal IPs

        list_router_response = list_routers(self.apiclient,
                                            account=self.account.name,
                                            domainid=self.account.domainid)
        self.assertEqual(isinstance(list_router_response, list), True,
                         "Check list response returns a valid list")
        self.assertNotEqual(len(list_router_response), 0,
                            "Check list router response")
        for router in list_router_response:
            self.assertEqual(router.state, 'Running',
                             "Check list router response for router state")

            zones = list_zones(self.apiclient, id=router.zoneid)
            self.assertEqual(isinstance(zones, list), True,
                             "Check list response returns a valid list")
            zone = zones[0]

            self.assertEqual(router.dns1, zone.dns1,
                             "Compare DNS1 of router and zone")
            self.assertEqual(router.dns2, zone.dns2,
                             "Compare DNS2 of router and zone")
            self.assertEqual(hasattr(router, 'guestipaddress'), True,
                             "Check whether router has guest IP field")

            self.assertEqual(hasattr(router, 'linklocalip'), True,
                             "Check whether router has link local IP field")

            # Fetch corresponding ip ranges information from listVlanIpRanges
            ipranges_response = list_vlan_ipranges(self.apiclient,
                                                   zoneid=router.zoneid)
            self.assertEqual(isinstance(ipranges_response, list), True,
                             "Check list response returns a valid list")
            iprange = ipranges_response[0]
            self.assertEqual(
                router.gateway, iprange.gateway,
                "Check gateway with that of corresponding IP range")
        return
    def find_public_gateway(self):
        networks = list_networks(self.apiclient,
                                  zoneid = self.zone.id,
                                  listall = True,
                                  issystem = True,
                                  traffictype = "Public")
        self.logger.debug('::: Public Networks ::: ==> %s' % networks)

        self.assertTrue(len(networks) == 1, "Test expects only 1 Public network but found -> '%s'" % len(networks))
        
        ip_ranges = list_vlan_ipranges(self.apiclient,
                                       zoneid = self.zone.id,
                                       networkid = networks[0].id)
        self.logger.debug('::: IP Ranges ::: ==> %s' % ip_ranges)

        self.assertTrue(len(ip_ranges) == 1, "Test expects only 1 VLAN IP Range network but found -> '%s'" % len(ip_ranges))
        self.assertIsNotNone(ip_ranges[0].gateway, "The network with id -> '%s' returned an IP Range with a None gateway. Please check your Datacenter settings." % networks[0].id)

        return ip_ranges[0].gateway
Esempio n. 4
0
    def test_01_list_sec_storage_vm(self):
        """Test List secondary storage VMs
        """

        # Validate the following:
        # 1. listSystemVM (systemvmtype=secondarystoragevm)
        #    should return only ONE SSVM per zone
        # 2. The returned SSVM should be in Running state
        # 3. listSystemVM for secondarystoragevm should list publicip,
        #    privateip and link-localip
        # 4. The gateway programmed on the ssvm by listSystemVm should be
        #    the same as the gateway returned by listVlanIpRanges
        # 5. DNS entries must match those given for the zone

        list_ssvm_response = list_ssvms(
            self.apiclient,
            systemvmtype='secondarystoragevm',
            state='Running',
        )
        self.assertEqual(
            isinstance(list_ssvm_response, list),
            True,
            "Check list response returns a valid list"
        )
        # Verify SSVM response
        self.assertNotEqual(
            len(list_ssvm_response),
            0,
            "Check list System VMs response"
        )

        list_zones_response = list_zones(self.apiclient)

        self.assertEqual(
            isinstance(list_zones_response, list),
            True,
            "Check list response returns a valid list"
        )

        self.debug("Number of zones: %s" % len(list_zones_response))
        self.debug("Number of SSVMs: %s" % len(list_ssvm_response))
        # Number of Sec storage VMs = No of Zones
        self.assertEqual(
            len(list_ssvm_response),
            len(list_zones_response),
            "Check number of SSVMs with number of zones"
        )
        # For each secondary storage VM check private IP,
        # public IP, link local IP and DNS
        for ssvm in list_ssvm_response:

            self.debug("SSVM state: %s" % ssvm.state)
            self.assertEqual(
                ssvm.state,
                'Running',
                "Check whether state of SSVM is running"
            )

            self.assertEqual(
                hasattr(ssvm, 'privateip'),
                True,
                "Check whether SSVM has private IP field"
            )

            self.assertEqual(
                hasattr(ssvm, 'linklocalip'),
                True,
                "Check whether SSVM has link local IP field"
            )

            self.assertEqual(
                hasattr(ssvm, 'publicip'),
                True,
                "Check whether SSVM has public IP field"
            )

            # Fetch corresponding ip ranges information from listVlanIpRanges
            ipranges_response = list_vlan_ipranges(
                self.apiclient,
                zoneid=ssvm.zoneid
            )
            self.assertEqual(
                isinstance(ipranges_response, list),
                True,
                "Check list response returns a valid list"
            )
            iprange = ipranges_response[0]

            # Fetch corresponding Physical Network of SSVM's Zone
            listphyntwk = PhysicalNetwork.list(
                self.apiclient,
                zoneid=ssvm.zoneid
            )

            # Execute the following assertion in all zones except EIP-ELB Zones
            if not (
                self.zone.networktype.lower() == 'basic' and isinstance(
                    NetScaler.list(
                        self.apiclient,
                        physicalnetworkid=listphyntwk[0].id),
                    list) is True):
                self.assertEqual(
                    ssvm.gateway,
                    iprange.gateway,
                    "Check gateway with that of corresponding ip range"
                )

            # Fetch corresponding zone information from listZones
            zone_response = list_zones(
                self.apiclient,
                id=ssvm.zoneid
            )
            self.assertEqual(
                isinstance(zone_response, list),
                True,
                "Check list response returns a valid list"
            )
            self.assertEqual(
                ssvm.dns1,
                zone_response[0].dns1,
                "Check DNS1 with that of corresponding zone"
            )

            self.assertEqual(
                ssvm.dns2,
                zone_response[0].dns2,
                "Check DNS2 with that of corresponding zone"
            )
        return
Esempio n. 5
0
    def test_01_list_sec_storage_vm(self):
        """Test List secondary storage VMs
        """

        # Validate the following:
        # 1. listSystemVM (systemvmtype=secondarystoragevm)
        #    should return only ONE SSVM per zone
        # 2. The returned SSVM should be in Running state
        # 3. listSystemVM for secondarystoragevm should list publicip,
        #    privateip and link-localip
        # 4. The gateway programmed on the ssvm by listSystemVm should be
        #    the same as the gateway returned by listVlanIpRanges
        # 5. DNS entries must match those given for the zone

        list_ssvm_response = list_ssvms(
            self.apiclient,
            systemvmtype='secondarystoragevm',
            state='Running',
        )
        self.assertEqual(isinstance(list_ssvm_response, list), True,
                         "Check list response returns a valid list")
        # Verify SSVM response
        self.assertNotEqual(len(list_ssvm_response), 0,
                            "Check list System VMs response")

        list_zones_response = list_zones(self.apiclient)

        self.assertEqual(isinstance(list_zones_response, list), True,
                         "Check list response returns a valid list")

        self.debug("Number of zones: %s" % len(list_zones_response))
        self.debug("Number of SSVMs: %s" % len(list_ssvm_response))
        # Number of Sec storage VMs = No of Zones
        self.assertEqual(len(list_ssvm_response), len(list_zones_response),
                         "Check number of SSVMs with number of zones")
        # For each secondary storage VM check private IP,
        # public IP, link local IP and DNS
        for ssvm in list_ssvm_response:

            self.debug("SSVM state: %s" % ssvm.state)
            self.assertEqual(ssvm.state, 'Running',
                             "Check whether state of SSVM is running")

            self.assertEqual(hasattr(ssvm, 'privateip'), True,
                             "Check whether SSVM has private IP field")

            self.assertEqual(hasattr(ssvm, 'linklocalip'), True,
                             "Check whether SSVM has link local IP field")

            self.assertEqual(hasattr(ssvm, 'publicip'), True,
                             "Check whether SSVM has public IP field")

            # Fetch corresponding ip ranges information from listVlanIpRanges
            ipranges_response = list_vlan_ipranges(self.apiclient,
                                                   zoneid=ssvm.zoneid)
            self.assertEqual(isinstance(ipranges_response, list), True,
                             "Check list response returns a valid list")
            iprange = ipranges_response[0]

            # Fetch corresponding Physical Network of SSVM's Zone
            listphyntwk = PhysicalNetwork.list(self.apiclient,
                                               zoneid=ssvm.zoneid)

            # Execute the following assertion in all zones except EIP-ELB Zones
            if not (self.zone.networktype.lower() == 'basic' and isinstance(
                    NetScaler.list(self.apiclient,
                                   physicalnetworkid=listphyntwk[0].id), list)
                    is True):
                self.assertEqual(
                    ssvm.gateway, iprange.gateway,
                    "Check gateway with that of corresponding ip range")

            # Fetch corresponding zone information from listZones
            zone_response = list_zones(self.apiclient, id=ssvm.zoneid)
            self.assertEqual(isinstance(zone_response, list), True,
                             "Check list response returns a valid list")
            self.assertEqual(ssvm.dns1, zone_response[0].dns1,
                             "Check DNS1 with that of corresponding zone")

            self.assertEqual(ssvm.dns2, zone_response[0].dns2,
                             "Check DNS2 with that of corresponding zone")
        return
Esempio n. 6
0
    def test_02_list_cpvm_vm(self):
        """Test List console proxy VMs
        """

        # Validate the following:
        # 1. listSystemVM (systemvmtype=consoleproxy) should return
        #    at least ONE CPVM per zone
        # 2. The returned ConsoleProxyVM should be in Running state
        # 3. listSystemVM for console proxy should list publicip, privateip
        #    and link-localip
        # 4. The gateway programmed on the console proxy should be the same
        #    as the gateway returned by listZones
        # 5. DNS entries must match those given for the zone

        list_cpvm_response = list_ssvms(
            self.apiclient,
            systemvmtype='consoleproxy',
            state='Running',
        )
        self.assertEqual(isinstance(list_cpvm_response, list), True,
                         "Check list response returns a valid list")
        # Verify CPVM response
        self.assertNotEqual(len(list_cpvm_response), 0,
                            "Check list System VMs response")
        list_zones_response = list_zones(self.apiclient)
        # Number of Console Proxy VMs = No of Zones

        self.assertEqual(isinstance(list_zones_response, list), True,
                         "Check list response returns a valid list")

        self.debug("Number of zones: %s" % len(list_zones_response))
        self.debug("Number of CPVMs: %s" % len(list_cpvm_response))

        self.assertEqual(len(list_cpvm_response), len(list_zones_response),
                         "Check number of CPVMs with number of zones")
        # For each CPVM check private IP, public IP, link local IP and DNS
        for cpvm in list_cpvm_response:

            self.debug("CPVM state: %s" % cpvm.state)
            self.assertEqual(cpvm.state, 'Running',
                             "Check whether state of CPVM is running")

            self.assertEqual(hasattr(cpvm, 'privateip'), True,
                             "Check whether CPVM has private IP field")

            self.assertEqual(hasattr(cpvm, 'linklocalip'), True,
                             "Check whether CPVM has link local IP field")

            self.assertEqual(hasattr(cpvm, 'publicip'), True,
                             "Check whether CPVM has public IP field")
            # Fetch corresponding ip ranges information from listVlanIpRanges
            ipranges_response = list_vlan_ipranges(self.apiclient,
                                                   zoneid=cpvm.zoneid)
            self.assertEqual(isinstance(ipranges_response, list), True,
                             "Check list response returns a valid list")

            # Fetch corresponding Physical Network of SSVM's Zone
            listphyntwk = PhysicalNetwork.list(self.apiclient,
                                               zoneid=cpvm.zoneid)

            # Execute the following assertion in all zones except EIP-ELB Zones
            if not (self.zone.networktype.lower() == 'basic' and isinstance(
                    NetScaler.list(self.apiclient,
                                   physicalnetworkid=listphyntwk[0].id), list)
                    is True):
                gatewayFound = False
                for iprange in ipranges_response:
                    if iprange.gateway == cpvm.gateway:
                        gatewayFound = True
                        break
                self.assertTrue(
                    gatewayFound,
                    "Check gateway with that of corresponding ip range")

            # Fetch corresponding zone information from listZones
            zone_response = list_zones(self.apiclient, id=cpvm.zoneid)

            self.assertEqual(cpvm.dns1, zone_response[0].dns1,
                             "Check DNS1 with that of corresponding zone")

            self.assertEqual(cpvm.dns2, zone_response[0].dns2,
                             "Check DNS2 with that of corresponding zone")
Esempio n. 7
0
    def test_06_router_advanced(self):
        """Test router advanced setup
        """

        # Validate the following
        # 1. verify that listRouters returned a 'Running' router
        # 2. router will have dns and gateway as in listZones, listVlanIpRanges
        # 3. router will have guest,public and linklocal IPs

        list_router_response = list_routers(
            self.apiclient,
            account=self.account.name,
            domainid=self.account.domainid
        )
        self.assertEqual(
            isinstance(list_router_response, list),
            True,
            "Check list response returns a valid list"
        )
        self.assertNotEqual(
            len(list_router_response),
            0,
            "Check list router response"
        )
        for router in list_router_response:
            self.assertEqual(
                router.state,
                'Running',
                "Check list router response for router state"
            )

            zones = list_zones(
                self.apiclient,
                id=router.zoneid
            )
            self.assertEqual(
                isinstance(zones, list),
                True,
                "Check list response returns a valid list"
            )
            zone = zones[0]

            self.assertEqual(
                router.dns1,
                zone.dns1,
                "Compare DNS1 of router and zone"
            )
            self.assertEqual(
                router.dns2,
                zone.dns2,
                "Compare DNS2 of router and zone"
            )
            self.assertEqual(
                hasattr(router, 'guestipaddress'),
                True,
                "Check whether router has guest IP field"
            )

            self.assertEqual(
                hasattr(router, 'linklocalip'),
                True,
                "Check whether router has link local IP field"
            )

            # Fetch corresponding ip ranges information from listVlanIpRanges
            ipranges_response = list_vlan_ipranges(
                self.apiclient,
                zoneid=router.zoneid
            )
            self.assertEqual(
                isinstance(ipranges_response, list),
                True,
                "Check list response returns a valid list"
            )
            iprange = ipranges_response[0]
            self.assertEqual(
                router.gateway,
                iprange.gateway,
                "Check gateway with that of corresponding IP range"
            )
        return
Esempio n. 8
0
    def test_02_list_cpvm_vm(self):
        """Test List console proxy VMs
        """

        # Validate the following:
        # 1. listSystemVM (systemvmtype=consoleproxy) should return
        #    at least ONE CPVM per zone
        # 2. The returned ConsoleProxyVM should be in Running state
        # 3. listSystemVM for console proxy should list publicip, privateip
        #    and link-localip
        # 4. The gateway programmed on the console proxy should be the same
        #    as the gateway returned by listZones
        # 5. DNS entries must match those given for the zone

        list_cpvm_response = list_ssvms(
            self.apiclient,
            systemvmtype='consoleproxy',
            state='Running',
        )
        self.assertEqual(
            isinstance(list_cpvm_response, list),
            True,
            "Check list response returns a valid list"
        )
        # Verify CPVM response
        self.assertNotEqual(
            len(list_cpvm_response),
            0,
            "Check list System VMs response"
        )
        list_zones_response = list_zones(self.apiclient)
        # Number of Console Proxy VMs = No of Zones

        self.assertEqual(
            isinstance(list_zones_response, list),
            True,
            "Check list response returns a valid list"
        )

        self.debug("Number of zones: %s" % len(list_zones_response))
        self.debug("Number of CPVMs: %s" % len(list_cpvm_response))

        self.assertEqual(
            len(list_cpvm_response),
            len(list_zones_response),
            "Check number of CPVMs with number of zones"
        )
        # For each CPVM check private IP, public IP, link local IP and DNS
        for cpvm in list_cpvm_response:

            self.debug("CPVM state: %s" % cpvm.state)
            self.assertEqual(
                cpvm.state,
                'Running',
                "Check whether state of CPVM is running"
            )

            self.assertEqual(
                hasattr(cpvm, 'privateip'),
                True,
                "Check whether CPVM has private IP field"
            )

            self.assertEqual(
                hasattr(cpvm, 'linklocalip'),
                True,
                "Check whether CPVM has link local IP field"
            )

            self.assertEqual(
                hasattr(cpvm, 'publicip'),
                True,
                "Check whether CPVM has public IP field"
            )
            # Fetch corresponding ip ranges information from listVlanIpRanges
            ipranges_response = list_vlan_ipranges(
                self.apiclient,
                zoneid=cpvm.zoneid
            )
            self.assertEqual(
                isinstance(ipranges_response, list),
                True,
                "Check list response returns a valid list"
            )

            # Fetch corresponding Physical Network of SSVM's Zone
            listphyntwk = PhysicalNetwork.list(
                self.apiclient,
                zoneid=cpvm.zoneid
            )

            # Execute the following assertion in all zones except EIP-ELB Zones
            if not (
                self.zone.networktype.lower() == 'basic' and isinstance(
                    NetScaler.list(
                        self.apiclient,
                        physicalnetworkid=listphyntwk[0].id),
                    list) is True):
                gatewayFound = False
                for iprange in ipranges_response:
                    if iprange.gateway == cpvm.gateway:
                        gatewayFound = True
                        break
                self.assertTrue(
                    gatewayFound,
                    "Check gateway with that of corresponding ip range"
                )

            # Fetch corresponding zone information from listZones
            zone_response = list_zones(
                self.apiclient,
                id=cpvm.zoneid
            )

            self.assertEqual(
                cpvm.dns1,
                zone_response[0].dns1,
                "Check DNS1 with that of corresponding zone"
            )

            self.assertEqual(
                cpvm.dns2,
                zone_response[0].dns2,
                "Check DNS2 with that of corresponding zone"
            )