Beispiel #1
0
    def get_resources(cls):
        special_mappings = {}
        plural_mappings = resource_helper.build_plural_mappings(
            special_mappings, RESOURCE_ATTRIBUTE_MAP)
        attr.PLURALS.update(plural_mappings)

        resources = resource_helper.build_resource_info(
            plural_mappings, RESOURCE_ATTRIBUTE_MAP, constants.NFVO,
            translate_name=True)
        plugin = manager.TackerManager.get_service_plugins()[
            constants.NFVO]
        for collection_name in SUB_RESOURCE_ATTRIBUTE_MAP:
            parent = SUB_RESOURCE_ATTRIBUTE_MAP[collection_name]['parent']

            for resource_name in SUB_RESOURCE_ATTRIBUTE_MAP[
                    collection_name]['members']:
                params = SUB_RESOURCE_ATTRIBUTE_MAP[
                    collection_name]['members'][resource_name]['parameters']

                controller = base.create_resource(collection_name,
                                                  resource_name,
                                                  plugin, params,
                                                  allow_bulk=True,
                                                  parent=parent)

            resource = extensions.ResourceExtension(
                collection_name,
                controller, parent,
                attr_map=params)
            resources.append(resource)
        return resources
Beispiel #2
0
    def get_resources(cls):
        special_mappings = {}
        plural_mappings = resource_helper.build_plural_mappings(
            special_mappings, RESOURCE_ATTRIBUTE_MAP)
        plural_mappings['service_types'] = 'service_type'
        attr.PLURALS.update(plural_mappings)
        resources = resource_helper.build_resource_info(plural_mappings,
                                                        RESOURCE_ATTRIBUTE_MAP,
                                                        constants.VNFM,
                                                        translate_name=True)
        plugin = manager.TackerManager.get_service_plugins()[constants.VNFM]
        for collection_name in SUB_RESOURCE_ATTRIBUTE_MAP:
            parent = SUB_RESOURCE_ATTRIBUTE_MAP[collection_name]['parent']

            for resource_name in SUB_RESOURCE_ATTRIBUTE_MAP[collection_name][
                    'members']:
                params = SUB_RESOURCE_ATTRIBUTE_MAP[collection_name][
                    'members'][resource_name]['parameters']

                controller = base.create_resource(collection_name,
                                                  resource_name,
                                                  plugin,
                                                  params,
                                                  allow_bulk=True,
                                                  parent=parent)

                resource = extensions.ResourceExtension(collection_name,
                                                        controller,
                                                        parent,
                                                        attr_map=params)
                resources.append(resource)
        return resources
Beispiel #3
0
 def get_resources(cls):
     special_mappings = {}
     plural_mappings = resource_helper.build_plural_mappings(
         special_mappings, RESOURCE_ATTRIBUTE_MAP)
     attr.PLURALS.update(plural_mappings)
     return resource_helper.build_resource_info(
         plural_mappings, RESOURCE_ATTRIBUTE_MAP, constants.COMMONSERVICES,
         translate_name=True)
 def get_resources(cls):
     special_mappings = {}
     plural_mappings = resource_helper.build_plural_mappings(
         special_mappings, RESOURCE_ATTRIBUTE_MAP)
     attr.PLURALS.update(plural_mappings)
     return resource_helper.build_resource_info(
         plural_mappings, RESOURCE_ATTRIBUTE_MAP, constants.NFVO,
         translate_name=True)
Beispiel #5
0
 def get_resources(cls):
     special_mappings = {}
     plural_mappings = resource_helper.build_plural_mappings(
         special_mappings, RESOURCE_ATTRIBUTE_MAP)
     plural_mappings['service_types'] = 'service_type'
     attr.PLURALS.update(plural_mappings)
     return resource_helper.build_resource_info(
         plural_mappings, RESOURCE_ATTRIBUTE_MAP, constants.VNFM,
         translate_name=True)
Beispiel #6
0
 def get_resources(cls):
     special_mappings = {}
     #遍历生成'event'
     plural_mappings = resource_helper.build_plural_mappings(
         special_mappings, RESOURCE_ATTRIBUTE_MAP)
     #添加到attr.PLURALS中
     attr.PLURALS.update(plural_mappings)
     #返回本扩展对应的资源
     return resource_helper.build_resource_info(
         plural_mappings, RESOURCE_ATTRIBUTE_MAP, constants.COMMONSERVICES,
         translate_name=True)
Beispiel #7
0
    def test_build_resource_info(self, mock_get_service_plugins):
        mock_get_service_plugins.return_value = {"DUMMY": ""}
        plural_mappings = {'test_vnffgs': 'test_vnffg', 'policies': 'policy'}
        resource_map = {
            'policies': {
                'id': {
                    'allow_post': False,
                }
            },
            'test_vnffgs': {
                'id': {
                    'allow_post': False,
                },
            }
        }
        action_map = {'policy': ['do', 'undo']}

        result = build_resource_info(plural_mappings, resource_map, "DUMMY")
        self.assertEqual(2, len(result))
        self.assertEqual("/dummy_svc", result[0].path_prefix)
        self.assertEqual("/dummy_svc", result[1].path_prefix)
        self.assertEqual({'id': {'allow_post': False}}, result[0].attr_map)
        self.assertEqual({'id': {'allow_post': False}}, result[1].attr_map)

        result = build_resource_info(plural_mappings,
                                     resource_map,
                                     "DUMMY",
                                     action_map=action_map)
        for i in range(len(result)):
            a = result[i].member_actions in ({}, ['do', 'undo'])
            self.assertEqual(a, True)

        result = build_resource_info(plural_mappings,
                                     resource_map,
                                     "DUMMY",
                                     action_map=action_map,
                                     translate_name=True)
        for i in range(len(result)):
            a = result[i].collection in ('policies', 'test-vnffgs')
            self.assertEqual(a, True)
Beispiel #8
0
 def get_resources(cls):
     special_mappings = {}
     plural_mappings = resource_helper.build_plural_mappings(
         special_mappings, RESOURCE_ATTRIBUTE_MAP)
     plural_mappings['devices'] = 'device'
     plural_mappings['service_types'] = 'service_type'
     plural_mappings['service_contexts'] = 'service_context'
     plural_mappings['services'] = 'service'
     attr.PLURALS.update(plural_mappings)
     return resource_helper.build_resource_info(plural_mappings,
                                                RESOURCE_ATTRIBUTE_MAP,
                                                constants.SERVICEVM,
                                                translate_name=True)
Beispiel #9
0
 def get_resources(cls):
     special_mappings = {}
     plural_mappings = resource_helper.build_plural_mappings(
         special_mappings, RESOURCE_ATTRIBUTE_MAP)
     plural_mappings['devices'] = 'device'
     plural_mappings['service_types'] = 'service_type'
     plural_mappings['service_contexts'] = 'service_context'
     plural_mappings['services'] = 'service'
     attr.PLURALS.update(plural_mappings)
     action_map = {'device': {'attach_interface': 'PUT',
                              'detach_interface': 'PUT'}}
     return resource_helper.build_resource_info(
         plural_mappings, RESOURCE_ATTRIBUTE_MAP, constants.SERVICEVM,
         translate_name=True, action_map=action_map)
    def test_build_resource_info(self, mock_get_service_plugins):
        mock_get_service_plugins.return_value = {"DUMMY": ""}
        plural_mappings = {'test_vnffgs': 'test_vnffg', 'policies': 'policy'}
        resource_map = {
            'policies': {
                'id': {
                    'allow_post': False,
                }
            },
            'test_vnffgs': {
                'id': {
                    'allow_post': False,
                },
            }
        }
        action_map = {'policy': ['do', 'undo']}

        result = build_resource_info(plural_mappings, resource_map, "DUMMY")
        self.assertEqual(2, len(result))
        self.assertEqual("/dummy_svc", result[0].path_prefix)
        self.assertEqual("/dummy_svc", result[1].path_prefix)
        self.assertEqual({'id': {'allow_post': False}}, result[0].attr_map)
        self.assertEqual({'id': {'allow_post': False}}, result[1].attr_map)

        result = build_resource_info(plural_mappings, resource_map, "DUMMY",
                                     action_map=action_map)
        for i in range(len(result)):
            a = result[i].member_actions in ({}, ['do', 'undo'])
            self.assertEqual(a, True)

        result = build_resource_info(plural_mappings, resource_map, "DUMMY",
                                     action_map=action_map,
                                     translate_name=True)
        for i in range(len(result)):
            a = result[i].collection in ('policies', 'test-vnffgs')
            self.assertEqual(a, True)