예제 #1
0
    def configureVSDSessions(cls):
        # VSD is a programmable policy and analytics engine of Nuage VSP SDN
        # platform; vspk is a Python SDK for Nuage VSP's VSD; libVSD is a
        # library that wraps vspk package
        try:
            vspk_module = "vspk." + cls.nuage_vsp_device.apiversion
            cls.vsdk = importlib.import_module(vspk_module)
        except ImportError as e:
            try:
                vspk_module = "vspk.vsdk." + cls.nuage_vsp_device.apiversion
                cls.vsdk = importlib.import_module(vspk_module)
            except ImportError:
                cls.tearDownClass()
                raise unittest.SkipTest("Warning: vspk import failure"
                                        " - %s" % e)

        try:
            from libVSD import ApiClient, VSDHelpers
        except ImportError as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Warning: libVSD package import failure "
                                    "- %s" % e)

        # Configure VSD session
        cls._session = cls.vsdk.NUVSDSession(
            username=cls.nuage_vsp_device.username,
            password=cls.nuage_vsp_device.password,
            enterprise="csp",
            api_url="https://%s:%d" % (cls.nuage_vsp_device.hostname,
                                       cls.nuage_vsp_device.port)
            )
        cls._session.start()

        # Configure libVSD session
        root = logging.getLogger()
        log_handler = logging.StreamHandler(sys.stdout)
        formatter = logging.Formatter('%(asctime)s - %(name)s - '
                                      '%(levelname)s - %(message)s')
        log_handler.setFormatter(formatter)
        root.addHandler(log_handler)
        vsd_info = cls.nuage_vsp_device.__dict__
        cls.debug("Nuage VSP device (VSD) details - %s" % vsd_info)
        vsd_api_client = ApiClient(
            address=vsd_info["hostname"],
            user=vsd_info["username"],
            password=vsd_info["password"],
            version=vsd_info["apiversion"][1] + "." + vsd_info["apiversion"][3]
        )
        vsd_api_client.new_session()
        cls.vsd = VSDHelpers(vsd_api_client)
        return
예제 #2
0
    def setUpClass(cls, zone=None):
        cls.debug("setUpClass nuageTestCase")

        # We want to fail quicker, if it's a failure
        socket.setdefaulttimeout(60)

        test_client = super(nuageTestCase, cls).getClsTestClient()
        cls.api_client = test_client.getApiClient()
        cls.db_client = test_client.getDbConnection()
        cls.test_data = test_client.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.zone = get_zone(cls.api_client,
                            zone_name=zone.name if zone else None,
                            zone_id=zone.id if zone else None)
        cls.domain = get_domain(cls.api_client)
        cls.template = get_template(cls.api_client, cls.zone.id,
                                    cls.test_data["ostype"])
        cls.test_data["virtual_machine"]["zoneid"] = cls.zone.id
        cls.test_data["virtual_machine"]["template"] = cls.template.id

        # Create service offering
        cls.service_offering = ServiceOffering.create(
            cls.api_client, cls.test_data["service_offering"])
        cls._cleanup = [cls.service_offering]

        # Check if the host hypervisor type is simulator
        cls.isSimulator = Hypervisor.list(
            cls.api_client, zoneid=cls.zone.id)[0].name == "Simulator"

        # Get configured Nuage VSP device details
        try:
            physical_networks = PhysicalNetwork.list(cls.api_client,
                                                     zoneid=cls.zone.id)
            for pn in physical_networks:
                if pn.isolationmethods == "VSP":
                    cls.vsp_physical_network = pn
                    break
            cls.nuage_vsp_device = Nuage.list(
                cls.api_client,
                physicalnetworkid=cls.vsp_physical_network.id)[0]
            pns = cls.config.zones[0].physical_networks
            providers = filter(
                lambda physical_network: "VSP" in physical_network.
                isolationmethods, pns)[0].providers
            devices = filter(lambda provider: provider.name == "NuageVsp",
                             providers)[0].devices
            cls.nuage_vsp_device.username = devices[0].username
            cls.nuage_vsp_device.password = devices[0].password
            cls.cms_id = cls.nuage_vsp_device.cmsid
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest(
                "Warning: Could not get configured Nuage VSP device details - %s"
                % e)

        # VSD is a programmable policy and analytics engine of Nuage VSP SDN platform
        # vspk is a Python SDK for Nuage VSP's VSD
        # libVSD is a library that wraps vspk package
        try:
            vspk_module = "vspk." + cls.nuage_vsp_device.apiversion if int(cls.nuage_vsp_device.apiversion[1]) >= 4 \
                else "vspk.vsdk." + cls.nuage_vsp_device.apiversion
            cls.vsdk = importlib.import_module(vspk_module)
            from libVSD import ApiClient, VSDHelpers
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest(
                "Warning: vspk (and/or) libVSD package import failure - %s" %
                e)

        # Configure VSD session
        cls._session = cls.vsdk.NUVSDSession(
            username=cls.nuage_vsp_device.username,
            password=cls.nuage_vsp_device.password,
            enterprise="csp",
            api_url="https://%s:%d" %
            (cls.nuage_vsp_device.hostname, cls.nuage_vsp_device.port))
        cls._session.start()

        # Configure libVSD session
        root = logging.getLogger()
        log_handler = logging.StreamHandler(sys.stdout)
        formatter = logging.Formatter(
            '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        log_handler.setFormatter(formatter)
        root.addHandler(log_handler)
        vsd_info = cls.nuage_vsp_device.__dict__
        cls.debug("Nuage VSP device (VSD) details - %s" % vsd_info)
        vsd_api_client = ApiClient(address=vsd_info["hostname"],
                                   user=vsd_info["username"],
                                   password=vsd_info["password"],
                                   version=vsd_info["apiversion"][1] + "." +
                                   vsd_info["apiversion"][3])
        vsd_api_client.new_session()
        cls.vsd = VSDHelpers(vsd_api_client)

        cls.debug("setUpClass nuageTestCase [DONE]")
예제 #3
0
    def setUpClass(cls, zone=None):
        cls.debug("setUpClass nuageTestCase")

        # We want to fail quicker, if it's a failure
        socket.setdefaulttimeout(60)

        test_client = super(nuageTestCase, cls).getClsTestClient()
        cls.api_client = test_client.getApiClient()
        cls.db_client = test_client.getDbConnection()
        cls.test_data = test_client.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.zone = get_zone(cls.api_client,
                            zone_name=zone.name if zone else None,
                            zone_id=zone.id if zone else None
                            )
        cls.domain = get_domain(cls.api_client)
        cls.template = get_template(cls.api_client,
                                    cls.zone.id,
                                    cls.test_data["ostype"]
                                    )
        cls.test_data["virtual_machine"]["zoneid"] = cls.zone.id
        cls.test_data["virtual_machine"]["template"] = cls.template.id

        # Create service offering
        cls.service_offering = ServiceOffering.create(cls.api_client,
                                                      cls.test_data["service_offering"]
                                                      )
        cls._cleanup = [cls.service_offering]

        # Check if the host hypervisor type is simulator
        cls.isSimulator = Hypervisor.list(cls.api_client, zoneid=cls.zone.id)[0].name == "Simulator"

        # Get configured Nuage VSP device details
        try:
            physical_networks = PhysicalNetwork.list(cls.api_client, zoneid=cls.zone.id)
            for pn in physical_networks:
                if pn.isolationmethods == "VSP":
                    cls.vsp_physical_network = pn
                    break
            cls.nuage_vsp_device = Nuage.list(cls.api_client,
                                              physicalnetworkid=cls.vsp_physical_network.id
                                              )[0]
            pns = cls.config.zones[0].physical_networks
            providers = filter(lambda physical_network: "VSP" in physical_network.isolationmethods, pns)[0].providers
            devices = filter(lambda provider: provider.name == "NuageVsp", providers)[0].devices
            cls.nuage_vsp_device.username = devices[0].username
            cls.nuage_vsp_device.password = devices[0].password
            cls.cms_id = cls.nuage_vsp_device.cmsid
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Warning: Could not get configured Nuage VSP device details - %s" % e)

        # VSD is a programmable policy and analytics engine of Nuage VSP SDN platform
        # vspk is a Python SDK for Nuage VSP's VSD
        # libVSD is a library that wraps vspk package
        try:
            vspk_module = "vspk." + cls.nuage_vsp_device.apiversion if int(cls.nuage_vsp_device.apiversion[1]) >= 4 \
                else "vspk.vsdk." + cls.nuage_vsp_device.apiversion
            cls.vsdk = importlib.import_module(vspk_module)
            from libVSD import ApiClient, VSDHelpers
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Warning: vspk (and/or) libVSD package import failure - %s" % e)

        # Configure VSD session
        cls._session = cls.vsdk.NUVSDSession(username=cls.nuage_vsp_device.username,
                                             password=cls.nuage_vsp_device.password,
                                             enterprise="csp",
                                             api_url="https://%s:%d" % (cls.nuage_vsp_device.hostname,
                                                                        cls.nuage_vsp_device.port)
                                             )
        cls._session.start()

        # Configure libVSD session
        root = logging.getLogger()
        log_handler = logging.StreamHandler(sys.stdout)
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        log_handler.setFormatter(formatter)
        root.addHandler(log_handler)
        vsd_info = cls.nuage_vsp_device.__dict__
        cls.debug("Nuage VSP device (VSD) details - %s" % vsd_info)
        vsd_api_client = ApiClient(address=vsd_info["hostname"],
                                   user=vsd_info["username"],
                                   password=vsd_info["password"],
                                   version=vsd_info["apiversion"][1] + "." + vsd_info["apiversion"][3]
                                   )
        vsd_api_client.new_session()
        cls.vsd = VSDHelpers(vsd_api_client)

        cls.debug("setUpClass nuageTestCase [DONE]")