コード例 #1
0
ファイル: common.py プロジェクト: rafaelthedevops/cloudstack
def add_netscaler(apiclient, zoneid, NSservice):
    """ Adds Netscaler device and enables NS provider"""

    cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
    cmd.zoneid = zoneid
    physical_networks = apiclient.listPhysicalNetworks(cmd)
    if isinstance(physical_networks, list):
        physical_network = physical_networks[0]

    cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
    cmd.name = "Netscaler"
    cmd.physicalnetworkid = physical_network.id
    nw_service_providers = apiclient.listNetworkServiceProviders(cmd)

    if isinstance(nw_service_providers, list):
        netscaler_provider = nw_service_providers[0]
    else:
        cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd()
        cmd1.name = "Netscaler"
        cmd1.physicalnetworkid = physical_network.id
        netscaler_provider = apiclient.addNetworkServiceProvider(cmd1)

    netscaler = NetScaler.add(apiclient, NSservice, physicalnetworkid=physical_network.id)
    if netscaler_provider.state != "Enabled":
        cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
        cmd.id = netscaler_provider.id
        cmd.state = "Enabled"
        apiclient.updateNetworkServiceProvider(cmd)

    return netscaler
コード例 #2
0
ファイル: test_nuage_vsp.py プロジェクト: K0zka/cloudstack
    def setUpClass(cls):
        cls._cleanup = []
        cls.testClient = super(TestNuageVsp, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.services["ostype"]
        )
        # nuage vsp device brings the Nuage virtual service platform into play
        cls.nuage_services = cls.services["nuage_vsp_device"]
        try:

            resp = listPhysicalNetworks.listPhysicalNetworksCmd()
            resp.zoneid = cls.zone.id
            physical_networks = cls.api_client.listPhysicalNetworks(resp)
            if isinstance(physical_networks, list):
                physical_network = physical_networks[0]
            resp = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
            resp.name = 'NuageVsp'
            resp.physicalnetworkid = physical_network.id
            nw_service_providers = cls.api_client.listNetworkServiceProviders(
                resp)
            if not isinstance(nw_service_providers, list):
                # create network service provider and add nuage vsp device
                resp_add_nsp =\
                    addNetworkServiceProvider.addNetworkServiceProviderCmd()
                resp_add_nsp.name = 'NuageVsp'
                resp_add_nsp.physicalnetworkid = physical_network.id
                cls.api_client.addNetworkServiceProvider(resp_add_nsp)
                resp_add_device = addNuageVspDevice.addNuageVspDeviceCmd()
                resp_add_device.physicalnetworkid = physical_network.id
                resp_add_device.username = cls.nuage_services["username"]
                resp_add_device.password = cls.nuage_services["password"]
                resp_add_device.hostname = cls.nuage_services["hostname"]
                resp_add_device.apiversion = cls.nuage_services[
                   "apiversion"]
                resp_add_device.retrycount = cls.nuage_services[
                    "retrycount"]
                resp_add_device.retryinterval = cls.nuage_services[
                    "retryinterval"]
                cls.nuage = cls.api_client.addNuageVspDevice(
                    resp_add_device)

            cls.network_offering = NetworkOffering.create(
                cls.api_client,
                cls.services["network_offering"],
                conservemode=True
            )
            cls._cleanup.append(cls.network_offering)

            cls.network_offering.update(cls.api_client, state='Enabled')
            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
            cls.services["virtual_machine"]["template"] = cls.template.id
            cls.service_offering = ServiceOffering.create(
                cls.api_client,
                cls.services["service_offering"]
            )
            cls._cleanup.append(cls.service_offering)
        except Exception as e:
            cls.tearDownClass()
            raise Exception("Warning: Exception in setUpClass: %s" % e)
        return
コード例 #3
0
    def setUpClass(cls):
        print "In setup class"
        cls._cleanup = []
        cls.testClient = super(TestNuageVsp, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.services["ostype"]
        )
        # nuage vsp device brings the Nuage virtual service platform into play
        cls.nuage_services = cls.services["nuage_vsp_device"]
        try:

            resp = listPhysicalNetworks.listPhysicalNetworksCmd()
            print "in cls.setupClass- resp: %s" % resp
            resp.zoneid = cls.zone.id
            physical_networks = cls.api_client.listPhysicalNetworks(resp)
            for pn in physical_networks:
                if pn.isolationmethods=='VSP':
                    physical_network = pn
            #if isinstance(physical_networks, list):
            #    physical_network = physical_networks[1]
            resp = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
            resp.name = 'NuageVsp'
            resp.physicalnetworkid = physical_network.id
            nw_service_providers = cls.api_client.listNetworkServiceProviders(
                resp)
            if not isinstance(nw_service_providers, list):
                # create network service provider and add nuage vsp device
                resp_add_nsp =\
                    addNetworkServiceProvider.addNetworkServiceProviderCmd()
                resp_add_nsp.name = 'NuageVsp'
                resp_add_nsp.physicalnetworkid = physical_network.id
                cls.api_client.addNetworkServiceProvider(resp_add_nsp)
                #Get NSP ID
                nw_service_providers = cls.api_client.listNetworkServiceProviders(
                    resp)
                cls.debug("NuageVsp NSP ID: %s" % nw_service_providers[0].id)

                resp_add_device = addNuageVspDevice.addNuageVspDeviceCmd()
                resp_add_device.physicalnetworkid = physical_network.id
                resp_add_device.username = cls.nuage_services["username"]
                resp_add_device.password = cls.nuage_services["password"]
                resp_add_device.hostname = cls.nuage_services["hostname"]
                resp_add_device.port = cls.nuage_services["port"]
                resp_add_device.apiversion = cls.nuage_services[
                   "apiversion"]
                resp_add_device.retrycount = cls.nuage_services[
                    "retrycount"]
                resp_add_device.retryinterval = cls.nuage_services[
                    "retryinterval"]
                cls.nuage = cls.api_client.addNuageVspDevice(
                    resp_add_device)
                #Enable NuageVsp NSP 
                cls.debug("NuageVsp NSP ID : %s" % nw_service_providers[0].id)
                resp_up_nsp = \
                    updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
                resp_up_nsp.id = nw_service_providers[0].id
                resp_up_nsp.state = 'Enabled'
                cls.api_client.updateNetworkServiceProvider(resp_up_nsp)

            cls.network_offering = NetworkOffering.create(
                cls.api_client,
                cls.services["network_offering"],
                conservemode=True
            )
            cls._cleanup.append(cls.network_offering)

            cls.network_offering.update(cls.api_client, state='Enabled')
            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
            cls.services["virtual_machine"]["template"] = cls.template.id
            cls.service_offering = ServiceOffering.create(
                cls.api_client,
                cls.services["service_offering"]
            )
            cls._cleanup.append(cls.service_offering)
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Unable to add VSP device")
        return
コード例 #4
0
    def setUpClass(cls):
        cls._cleanup = []
        cls.testClient = super(TestBrocadeVcs, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.template = get_template(
                            cls.api_client,
                            cls.zone.id,
                            cls.services["ostype"]
                           )
        try:
            cls.brocadeDeviceData = cls.config.__dict__["brocadeDeviceData"].__dict__
            assert cls.brocadeDeviceData["ipaddress"], "ipaddress of brocade device\
                    not present in config file"
            assert cls.brocadeDeviceData["username"], "username of brocade device\
                    not present in config file"
        except Exception as e:
            raise unittest.SkipTest("Exception occured while reading\
                    brocade device data from config file: %s" % e)
        try:

           """ Adds Brocade device and enables NS provider"""
           cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
           cmd.zoneid = cls.zone.id
           physical_networks = cls.api_client.listPhysicalNetworks(cmd)
           if isinstance(physical_networks, list):
               physical_network = physical_networks[0]
           cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
           cmd.name = 'BrocadeVcs'
           cmd.physicalnetworkid = physical_network.id
           nw_service_providers = cls.api_client.listNetworkServiceProviders(cmd)

           if isinstance(nw_service_providers, list):
               brocade_provider = nw_service_providers[0]
           else:
               cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd()
               cmd1.name = 'BrocadeVcs'
               cmd1.physicalnetworkid = physical_network.id
               brocade_provider = cls.api_client.addNetworkServiceProvider(cmd1)

           cmd2 = addBrocadeVcsDevice.addBrocadeVcsDeviceCmd()
           cmd2.physicalnetworkid = physical_network.id
           cmd2.username = cls.brocadeDeviceData["username"]
           cmd2.password = cls.brocadeDeviceData["password"]
           cmd2.hostname = cls.brocadeDeviceData["ipaddress"]
           cls.brocade = cls.api_client.addBrocadeVcsDevice(cmd2)

           if brocade_provider.state != 'Enabled':
               cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
               cmd.id = brocade_provider.id
               cmd.state = 'Enabled'
               cls.api_client.updateNetworkServiceProvider(cmd)


           cls.network_offering = NetworkOffering.create(
                                            cls.api_client,
                                            cls.services["network_offering"],
                                            conservemode=True
                                            )
           cls._cleanup.append(cls.network_offering)

           # Enable Network offering
           cls.network_offering.update(cls.api_client, state='Enabled')
           cls.services["virtual_machine"]["zoneid"] = cls.zone.id
           cls.services["virtual_machine"]["template"] = cls.template.id
           cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.services["service_offering"]
                                            )
           cls._cleanup.append(cls.service_offering)
        except Exception as e:
           cls.tearDownClass()
           raise Exception ("Warning: Exception in setUpClass: %s" % e)
        return