Пример #1
0
    def test_instantiate_multi_vm_vnf_nsr(self, logger, nsd_proxy, nsr_proxy,
                                          rwnsr_proxy, base_proxy,
                                          cloud_account_name):
        def verify_input_parameters(running_config, config_param):
            """
            Verify the configured parameter set against the running configuration
            """
            for run_input_param in running_config.input_parameter:
                if (input_param.xpath == config_param.xpath
                        and input_param.value == config_param.value):
                    return True

            assert False, (
                "Verification of configured input parameters: { xpath:%s, value:%s} "
                "is unsuccessful.\nRunning configuration: %s" %
                (config_param.xpath, config_param.value,
                 running_nsr_config.input_parameter))

        catalog = nsd_proxy.get_config(
            '/rw-project:project[rw-project:name="default"]/nsd-catalog')
        nsd = catalog.nsd[0]

        input_parameters = []
        descr_xpath = "/rw-project:project/project-nsd:nsd-catalog/project-nsd:nsd[project-nsd:id=%s]/project-nsd:description" % quoted_key(
            nsd.id)
        descr_value = "New NSD Description"
        in_param_id = str(uuid.uuid4())

        input_param_1 = NsrYang.YangData_RwProject_Project_NsInstanceConfig_Nsr_InputParameter(
            xpath=descr_xpath, value=descr_value)

        input_parameters.append(input_param_1)

        nsr = create_nsr(nsd.id, input_parameters, cloud_account_name)

        logger.info("Instantiating the Network Service")
        rwnsr_proxy.create_config(
            '/rw-project:project[rw-project:name="default"]/ns-instance-config/nsr',
            nsr)

        nsr_opdata = rwnsr_proxy.get(
            '/rw-project:project[rw-project:name="default"]/ns-instance-opdata'
        )
        nsrs = nsr_opdata.nsr

        # Verify the input parameter configuration
        running_config = rwnsr_proxy.get_config(
            "/rw-project:project[rw-project:name='default']/ns-instance-config/nsr[id=%s]"
            % quoted_key(nsr.id))
        for input_param in input_parameters:
            verify_input_parameters(running_config, input_param)

        assert len(nsrs) == 1
        assert nsrs[0].ns_instance_config_ref == nsr.id

        xpath = "/rw-project:project[rw-project:name='default']/ns-instance-opdata/nsr[ns-instance-config-ref={}]/operational-status".format(
            quoted_key(nsr.id))
        rwnsr_proxy.wait_for(xpath, "running", fail_on=['failed'], timeout=360)
Пример #2
0
    def test_substitution(self):
        """
        Test that substitution of input parameters occurs as expected.

        """
        # Define the original NSD
        nsd = ProjectNsdYang.YangData_RwProject_Project_NsdCatalog_Nsd()
        # nsd.name = "robert"
        # nsd.short_name = "bob"

        # Define which parameters may be modified
        nsd.input_parameter_xpath.extend([
                ProjectNsdYang.YangData_RwProject_Project_NsdCatalog_Nsd_InputParameterXpath(
                    xpath="/nsd:nsd-catalog/nsd:nsd/nsd:name",
                    label="NSD Name",
                    ),
                ProjectNsdYang.YangData_RwProject_Project_NsdCatalog_Nsd_InputParameterXpath(
                    xpath="/nsd:nsd-catalog/nsd:nsd/nsd:short-name",
                    label="NSD Short Name",
                    ),
                ])

        # Define the input parameters that are intended to be modified
        nsr_config = NsrYang.YangData_RwProject_Project_NsInstanceConfig_Nsr()
        nsr_config.input_parameter.extend([
            NsrYang.YangData_RwProject_Project_NsInstanceConfig_Nsr_InputParameter(
                xpath="/nsd:nsd-catalog/nsd:nsd/nsd:name",
                value="robert",
                ),
            NsrYang.YangData_RwProject_Project_NsInstanceConfig_Nsr_InputParameter(
                xpath="/nsd:nsd-catalog/nsd:nsd/nsd:short-name",
                value="bob",
                ),
            ])

        self.substitute_input_parameters(nsd, nsr_config)

        # Verify that both the 'name' and 'short-name' fields are correctly
        # replaced.
        self.assertEqual("robert", nsd.name)
        self.assertEqual("bob", nsd.short_name)
Пример #3
0
    def test_instantiate_nsr(self, logger, nsd_proxy, rwnsr_proxy, base_proxy,
                             cloud_account_name):
        def verify_input_parameters(running_config, config_param):
            """
            Verify the configured parameter set against the running configuration
            """
            for run_input_param in running_config.input_parameter:
                if (run_input_param.xpath == config_param.xpath
                        and run_input_param.value == config_param.value):
                    return True

            assert False, (
                "Verification of configured input parameters: { xpath:%s, value:%s} "
                "is unsuccessful.\nRunning configuration: %s" %
                (config_param.xpath, config_param.value,
                 running_config.input_parameter))

        catalog = nsd_proxy.get_config(
            '/rw-project:project[rw-project:name="default"]/nsd-catalog')
        nsd = catalog.nsd[0]

        input_parameters = []
        descr_xpath = "/nsd:nsd-catalog/nsd:nsd/nsd:vendor"
        descr_value = "New Vendor"
        in_param_id = str(uuid.uuid4())

        input_param_1 = NsrYang.YangData_RwProject_Project_NsInstanceConfig_Nsr_InputParameter(
            xpath=descr_xpath, value=descr_value)

        input_parameters.append(input_param_1)

        nsr = rift.auto.descriptor.create_nsr(
            cloud_account_name,
            nsd.name,
            nsd,
            input_param_list=input_parameters)

        logger.info("Instantiating the Network Service")
        rwnsr_proxy.create_config(
            '/rw-project:project[rw-project:name="default"]/ns-instance-config/nsr',
            nsr)

        nsr_opdata = rwnsr_proxy.get(
            '/rw-project:project[rw-project:name="default"]/ns-instance-opdata/nsr[ns-instance-config-ref={}]'
            .format(quoted_key(nsr.id)))
        assert nsr_opdata is not None

        # Verify the input parameter configuration
        running_config = rwnsr_proxy.get_config(
            "/rw-project:project[rw-project:name='default']/ns-instance-config/nsr[id=%s]"
            % quoted_key(nsr.id))
        for input_param in input_parameters:
            verify_input_parameters(running_config, input_param)
Пример #4
0
    def test_illegal_input_parameter(self):
        """
        In the NSD there is a list of the parameters that are allowed to be
        sbustituted by input parameters. This test checks that when an input
        parameter is provided in the NSR config that is not in the NSD, it is
        not applied.

        """
        # Define the original NSD
        nsd = ProjectNsdYang.YangData_RwProject_Project_NsdCatalog_Nsd()
        nsd.name = "robert"
        nsd.short_name = "bob"

        # Define which parameters may be modified
        nsd.input_parameter_xpath.append(
                ProjectNsdYang.YangData_RwProject_Project_NsdCatalog_Nsd_InputParameterXpath(
                    xpath="/nsd:nsd-catalog/nsd:nsd/nsd:name",
                    label="NSD Name",
                    )
                )

        # Define the input parameters that are intended to be modified
        nsr_config = NsrYang.YangData_RwProject_Project_NsInstanceConfig_Nsr()
        nsr_config.input_parameter.extend([
            NsrYang.YangData_RwProject_Project_NsInstanceConfig_Nsr_InputParameter(
                xpath="/nsd:nsd-catalog/nsd:nsd/nsd:name",
                value="alice",
                ),
            NsrYang.YangData_RwProject_Project_NsInstanceConfig_Nsr_InputParameter(
                xpath="/nsd:nsd-catalog/nsd:nsd/nsd:short-name",
                value="alice",
                ),
            ])

        self.substitute_input_parameters(nsd, nsr_config)

        # Verify that only the parameter in the input_parameter_xpath list is
        # modified after the input parameters have been applied.
        self.assertEqual("alice", nsd.name)
        self.assertEqual("bob", nsd.short_name)
Пример #5
0
def create_nsr_from_nsd_id(nsd_id):
    nsr = RwNsrYang.YangData_RwProject_Project_NsInstanceConfig_Nsr()
    nsr.id = str(uuid.uuid4())
    nsr.name = "pingpong_{}".format(
        datetime.datetime.now().strftime("%Y%m%d_%H%M%S"))
    nsr.short_name = "nsr_short_name"
    nsr.description = "This is a description"
    nsr.nsd_ref = nsd_id
    nsr.admin_status = "ENABLED"
    nsr.cloud_account = "openstack"

    param = NsrYang.YangData_RwProject_Project_NsInstanceConfig_Nsr_InputParameter(
    )
    param.xpath = '/rw-project:project/project-nsd:nsd-catalog/project-nsd:nsd/project-nsd:vendor'
    param.value = "rift-o-matic"

    nsr.input_parameter.append(param)

    return nsr