Пример #1
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)
Пример #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)
    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