Ejemplo n.º 1
0
 def validate_NetworkServiceProvider(self, provider_name, state=None):
     """Validates the Network Service Provider in the Nuage VSP Physical
     Network"""
     self.debug("Validating the creation and state of Network Service "
                "Provider - %s" % provider_name)
     providers = NetworkServiceProvider.list(
         self.api_client,
         name=provider_name,
         physicalnetworkid=self.vsp_physical_network.id
     )
     self.assertEqual(isinstance(providers, list), True,
                      "List Network Service Provider should return a "
                      "valid list"
                      )
     self.assertEqual(provider_name, providers[0].name,
                      "Name of the Network Service Provider should match "
                      "with the returned list data"
                      )
     if state:
         self.assertEqual(providers[0].state, state,
                          "Network Service Provider state should be '%s'" %
                          state
                          )
     self.debug("Successfully validated the creation and state of Network "
                "Service Provider - %s" % provider_name)
Ejemplo n.º 2
0
    def test_baremetal(self):
        self.debug("Test create baremetal network offering")
        networkoffering = NetworkOffering.create(
            self.apiclient, self.services["network_offering"])
        networkoffering.update(self.apiclient, state="Enabled")
        self.cleanup.append(networkoffering)

        physical_network = PhysicalNetwork.list(self.apiclient,
                                                zoneid=self.zoneid)[0]
        dhcp_provider = NetworkServiceProvider.list(
            self.apiclient,
            name="BaremetalDhcpProvider",
            physical_network_id=physical_network.id)[0]
        NetworkServiceProvider.update(self.apiclient,
                                      id=dhcp_provider.id,
                                      state='Enabled')
        pxe_provider = NetworkServiceProvider.list(
            self.apiclient,
            name="BaremetalPxeProvider",
            physical_network_id=physical_network.id)[0]
        NetworkServiceProvider.update(self.apiclient,
                                      id=pxe_provider.id,
                                      state='Enabled')
        userdata_provider = NetworkServiceProvider.list(
            self.apiclient,
            name="BaremetalUserdataProvider",
            physical_network_id=physical_network.id)[0]
        NetworkServiceProvider.update(self.apiclient,
                                      id=userdata_provider.id,
                                      state='Enabled')

        network = Network.create(self.apiclient,
                                 self.services["network"],
                                 zoneid=self.zoneid,
                                 networkofferingid=networkoffering.id)
        self.cleanup.insert(0, network)

        pod = Pod.list(self.apiclient)[0]
        cmd = createVlanIpRange.createVlanIpRangeCmd()
        cmd.podid = pod.id
        cmd.networkid = network.id
        cmd.gateway = "10.1.1.1"
        cmd.netmask = "255.255.255.0"
        cmd.startip = "10.1.1.20"
        cmd.endip = "10.1.1.40"
        cmd.forVirtualNetwork = "false"
        self.apiclient.createVlanIpRange(cmd)
Ejemplo n.º 3
0
    def setUpClass(cls):
        testClient = super(TestRegionVpcOffering, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = Services().services

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype


        cls.template = get_template(
            cls.apiclient,
            cls.zone.id,
            cls.services["ostype"]
        )
        if cls.template == FAILED:
            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]


        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id

        cls.service_offering = ServiceOffering.create(
                                            cls.apiclient,
                                            cls.services["service_offering"]
                                            )
        cls._cleanup = [cls.service_offering, ]

        try:
            list_physical_networks = PhysicalNetwork.list(
                                                     cls.apiclient,
                                                     zoneid=cls.zone.id
                                                     )
            assert validateList(list_physical_networks)[0] == PASS,\
                "physical networks list validation failed"

            cls.isOvsPluginEnabled = False
            for i in range(0, len(list_physical_networks)):
                list_network_serviceprovider = NetworkServiceProvider.list(
                                                                       cls.apiclient,
                                                                       physicalnetworkid=list_physical_networks[i].id
                                                                       )
                for j in range(0, len(list_network_serviceprovider)):
                    if((str(list_network_serviceprovider[j].name).lower() == 'ovs') and
                        (str(list_network_serviceprovider[j].state).lower() == 'enabled')):
                        cls.isOvsPluginEnabled = True
                        break
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest(e)
        return
Ejemplo n.º 4
0
 def test_baremetal(self):
     self.debug("Test create baremetal network offering")
     networkoffering = NetworkOffering.create(self.apiclient, self.services["network_offering"])
     networkoffering.update(self.apiclient, state="Enabled")
     self.cleanup.append(networkoffering)
     
     physical_network = PhysicalNetwork.list(self.apiclient, zoneid=self.zoneid)[0];
     dhcp_provider = NetworkServiceProvider.list(self.apiclient, name="BaremetalDhcpProvider", physical_network_id=physical_network.id)[0]
     NetworkServiceProvider.update(
                                       self.apiclient,
                                       id=dhcp_provider.id,
                                       state='Enabled'
                                       )
     pxe_provider = NetworkServiceProvider.list(self.apiclient, name="BaremetalPxeProvider", physical_network_id=physical_network.id)[0]
     NetworkServiceProvider.update(
                                       self.apiclient,
                                       id=pxe_provider.id,
                                       state='Enabled'
                                       )
     userdata_provider = NetworkServiceProvider.list(self.apiclient, name="BaremetalUserdataProvider", physical_network_id=physical_network.id)[0]
     NetworkServiceProvider.update(
                                       self.apiclient,
                                       id=userdata_provider.id,
                                       state='Enabled'
                                       )
     
     network = Network.create(self.apiclient, self.services["network"], zoneid=self.zoneid, networkofferingid=networkoffering.id)
     self.cleanup.insert(0, network)
     
     pod = Pod.list(self.apiclient)[0]
     cmd = createVlanIpRange.createVlanIpRangeCmd()
     cmd.podid = pod.id
     cmd.networkid = network.id
     cmd.gateway = "10.1.1.1"
     cmd.netmask = "255.255.255.0"
     cmd.startip = "10.1.1.20"
     cmd.endip = "10.1.1.40"
     cmd.forVirtualNetwork="false"
     self.apiclient.createVlanIpRange(cmd)
    def setUpClass(cls):
        testClient = super(TestVPCDistributedRouterOffering, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = Services().services

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype

        cls.template = get_template(
            cls.apiclient,
            cls.zone.id,
            cls.services["ostype"]
        )
        if cls.template == FAILED:
            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id

        cls.service_offering = ServiceOffering.create(
                                            cls.apiclient,
                                            cls.services["service_offering"]
                                            )
        cls._cleanup = [
                        cls.service_offering,
                        ]
        try:
            list_physical_networks = PhysicalNetwork.list(
                                                     cls.apiclient,
                                                     zoneid=cls.zone.id
                                                     )
            assert validateList(list_physical_networks)[0] == PASS,\
                "physical networks list validation failed"

            cls.isOvsPluginEnabled = False
            for i in range(0, len(list_physical_networks)):
                list_network_serviceprovider = NetworkServiceProvider.list(
                                                                       cls.apiclient,
                                                                       physicalnetworkid=list_physical_networks[i].id
                                                                       )
                for j in range(0, len(list_network_serviceprovider)):
                    if((str(list_network_serviceprovider[j].name).lower() == 'ovs') and
                        (str(list_network_serviceprovider[j].state).lower() == 'enabled')):
                        cls.isOvsPluginEnabled = True
                        break
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest(e)
        return
Ejemplo n.º 6
0
 def validate_NetworkServiceProvider(self, provider_name, state=None):
     """Validates the Network Service Provider in the Nuage VSP Physical Network"""
     self.debug("Check if the Network Service Provider is created successfully ?")
     providers = NetworkServiceProvider.list(self.api_client,
                                             name=provider_name,
                                             physicalnetworkid=self.vsp_physical_network.id)
     self.assertEqual(isinstance(providers, list), True,
                      "List Network Service Provider should return a valid list"
                      )
     self.assertEqual(provider_name, providers[0].name,
                      "Name of the Network Service Provider should match with the returned list data"
                      )
     if state:
         self.assertEqual(providers[0].state, state,
                          "Network Service Provider state should be in state - %s" % state
                          )
     self.debug("Network Service Provider creation successfully validated for %s" % provider_name)
    def setUpClass(cls):
        cls.testClient = super(TestNccIntegrationShared, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()
        cls.services = cls.testClient.getParsedTestDataConfig()
        cls._cleanup = []

        cls.logger = logging.getLogger('TestNccIntegrationShared')
        cls.stream_handler = logging.StreamHandler()
        cls.logger.setLevel(logging.DEBUG)
        cls.logger.addHandler(cls.stream_handler)

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype
        cls.template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.services["ostype"] )
        ncc_ip=cls.services["NCC"]["NCCIP"]
        ns_ip=cls.services["NSShared"]["NSIP"]
        cls.debug("NS IP: Shared: %s" % ns_ip)

        mgmt_srv_ip = cls.config.__dict__["mgtSvr"][0].__dict__["mgtSvrIp"]
        #ncc_ip = "10.102.195.215"
        #ns_ip = "10.102.195.210"
        cls.ns = ncc.NCC(ncc_ip, ns_ip, mgmt_srv_ip, logger=cls.logger)
        cls.ns.registerCCP(cls.api_client)
        cls.ns.registerNS()
        cls.ns.assignNStoCSZone()
        spname = cls.services["servicepackage_shared"]["name"]
        cls.debug("SPname (Shared): %s" % spname)
        #spname="SharedSP9"
        # Create Service package and get device group id, tenant group id and service package id
        # These would be needed later for clean up

        (cls.dv_group_id, cls.tnt_group_id, cls.srv_pkg_id) = cls.ns.createServicePackages(
            spname,
            "NetScalerVPX",
            ns_ip)
        srv_pkg_list = RegisteredServicePackage.list(cls.api_client)
        # Choose the one created
        cls.srv_pkg_uuid = None
        for sp in srv_pkg_list:
            if sp.name == spname:
                cls.srv_pkg_uuid = sp.id
        #srv_pkg_id = srv_pkg_list[0].id

        cls.account = Account.create(
            cls.api_client,
            cls.services["account"]
        )
        cls._cleanup.append(cls.account)

        try:
            cls.services["nw_off_ncc_SharedSP"]["servicepackageuuid"] = cls.srv_pkg_uuid
            cls.services["nw_off_ncc_SharedSP"]["servicepackagedescription"] = "A NetScalerVPX is shared across all networks."
            cls.network_offering = NetworkOffering.create(
                cls.api_client,
                cls.services["nw_off_ncc_SharedSP"])
        except Exception as e:
            raise Exception ("Unable to create network offering with Service package % s due to exception % s"
                             % (cls.srv_pkg_uuid, e))

        # Network offering should be removed so that service package may be deleted later
        cls._cleanup.append(cls.network_offering)

        cls.network_offering.update(cls.api_client, state = "Enabled")
        cls.service_offering_shared = ServiceOffering.create(
                cls.api_client,
                cls.services["service_offering"]
            )
        cls.services["small"]["template"] = cls.template.id

        # Enable Netscaler Service Provider

        cls.phy_nws = PhysicalNetwork.list(cls.api_client,zoneid=cls.zone.id)
        if isinstance(cls.phy_nws, list):
            physical_network = cls.phy_nws[0]

        try:
            cls.ns_service_provider = NetworkServiceProvider.list(cls.api_client,name='Netscaler')
            if isinstance(cls.ns_service_provider, list):
                ns_provider = cls.ns_service_provider[0]
        except:
            raise Exception ("Netscaler service provider not found!!")

        try:
            if ns_provider.state != "Enabled":
                NetworkServiceProvider.update(cls.api_client, id=ns_provider.id, physicalnetworkid=physical_network.id, state="Enabled")
        except:
            raise Exception ("Enabling Netscaler Service provider failed. Unable to proceed")

        return
    def setUpClass(cls):
        cls.testClient = super(TestNccIntegrationDedicated,
                               cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()
        cls.services = cls.testClient.getParsedTestDataConfig()
        cls._cleanup = []

        cls.logger = logging.getLogger('TestNccIntegrationDedicated')
        cls.stream_handler = logging.StreamHandler()
        cls.logger.setLevel(logging.DEBUG)
        cls.logger.addHandler(cls.stream_handler)

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype
        cls.template = get_template(cls.api_client, cls.zone.id,
                                    cls.services["ostype"])
        ncc_ip = cls.services["NCC"]["NCCIP"]
        ns_ip = cls.services["NSDedicated"]["NSIP"]
        cls.debug("NS IP - Dedicated: %s" % ns_ip)

        mgmt_srv_ip = cls.config.__dict__["mgtSvr"][0].__dict__["mgtSvrIp"]
        #ncc_ip = "10.102.195.215"
        #ns_ip = "10.102.195.210"
        cls.ns = ncc.NCC(ncc_ip, ns_ip, mgmt_srv_ip, logger=cls.logger)
        cls.ns.registerCCP(cls.api_client)
        cls.ns.registerNS()
        cls.ns.assignNStoCSZone()
        spname = cls.services["servicepackage_dedicated"]["name"]

        # Create Service package and get device group id, tenant group id and service package id
        # These would be needed later for clean up

        (cls.dv_group_id, cls.tnt_group_id,
         cls.srv_pkg_id) = cls.ns.createServicePackages(
             spname, "NetScalerVPX", ns_ip, isolation_policy="dedicated")
        cls.debug("Created service package in NCC")
        cls.debug("dv_group, tnt_group, srv_pkg_id: %s %s %s" %
                  (cls.dv_group_id, cls.tnt_group_id, cls.srv_pkg_id))

        srv_pkg_list = RegisteredServicePackage.list(cls.api_client)
        # Choose the one created
        cls.srv_pkg_uuid = None
        for sp in srv_pkg_list:
            if sp.name == spname:
                cls.srv_pkg_uuid = sp.id
        #srv_pkg_id = srv_pkg_list[0].id

        cls.account = Account.create(cls.api_client, cls.services["account"])
        cls._cleanup.append(cls.account)

        try:
            cls.services["nw_off_ncc_DedicatedSP"][
                "servicepackageuuid"] = cls.srv_pkg_uuid
            cls.services["nw_off_ncc_DedicatedSP"][
                "servicepackagedescription"] = "A NetScalerVPX is dedicated per network."
            cls.network_offering = NetworkOffering.create(
                cls.api_client, cls.services["nw_off_ncc_DedicatedSP"])
        except Exception as e:
            raise Exception(
                "Unable to create network offering with Service package % s due to exception % s"
                % (cls.srv_pkg_uuid, e))

        # Network offering should be removed so that service package may be deleted later
        cls._cleanup.append(cls.network_offering)

        cls.network_offering.update(cls.api_client, state="Enabled")
        cls.service_offering = ServiceOffering.create(
            cls.api_client, cls.services["service_offering"])
        cls.services["small"]["template"] = cls.template.id

        # Enable Netscaler Service Provider

        cls.phy_nws = PhysicalNetwork.list(cls.api_client, zoneid=cls.zone.id)
        if isinstance(cls.phy_nws, list):
            physical_network = cls.phy_nws[0]

        try:
            cls.ns_service_provider = NetworkServiceProvider.list(
                cls.api_client, name='Netscaler')
            if isinstance(cls.ns_service_provider, list):
                ns_provider = cls.ns_service_provider[0]
        except:
            raise Exception("Netscaler service provider not found!!")

        try:
            if ns_provider.state != "Enabled":
                NetworkServiceProvider.update(
                    cls.api_client,
                    id=ns_provider.id,
                    physicalnetworkid=physical_network.id,
                    state="Enabled")
        except:
            raise Exception(
                "Enabling Netscaler Service provider failed. Unable to proceed"
            )

        return