示例#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
示例#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
示例#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)
示例#5
0
文件: vnfm.py 项目: Urban123/tacker
 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)
示例#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)
示例#7
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)
示例#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)
     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)
示例#9
0
    def test_build_plural_mappings_with_suffix_y(self):
        special_mappings = {}
        resource_map = {
            'policies': {
                'id': {
                    'allow_post': False,
                }
            },
            'vnffgs': {
                'id': {
                    'allow_post': False,
                    'allow_put': False,
                }
            },
        }

        expected_res = {'vnffgs': 'vnffg', 'policies': 'policy'}
        result = build_plural_mappings(special_mappings, resource_map)
        self.assertEqual(expected_res, result)
示例#10
0
    def test_build_plural_mappings_with_suffix_y(self):
        special_mappings = {}
        resource_map = {
            'policies': {
                'id': {
                    'allow_post': False,
                }
            },
            'vnffgs': {
                'id': {
                    'allow_post': False,
                    'allow_put': False,
                }
            },
        }

        expected_res = {'vnffgs': 'vnffg', 'policies': 'policy'}
        result = build_plural_mappings(special_mappings, resource_map)
        self.assertEqual(expected_res, result)