def _data_wrapper(self, context, tenant_id, name, reason, nf, **kwargs):
        nfp_context = {}
        description = ast.literal_eval((nf['description'].split('\n'))[1])
        description.update({'tenant_id': tenant_id})
        context_resource_data = df.get_network_function_info(
            description, const.LOADBALANCERV2)
        # REVISIT(dpak): We need to avoid resource description
        # dependency in OTC and instead use neutron context description.
        if name.lower() == 'loadbalancer':
            lb_id = kwargs['loadbalancer']['id']
            kwargs['loadbalancer'].update({'description': str(description)})
            nfp_context = {'network_function_id': nf['id'],
                           'loadbalancer_id': kwargs['loadbalancer']['id']}
        elif name.lower() == 'listener':
            lb_id = kwargs['listener'].get('loadbalancer_id')
            kwargs['listener']['description'] = str(description)
        elif name.lower() == 'pool':
            lb_id = kwargs['pool'].get('loadbalancer_id')
            kwargs['pool']['description'] = str(description)
        elif name.lower() == 'member':
            pool = kwargs['member'].get('pool')
            if pool:
                lb_id = pool.get('loadbalancer_id')
            kwargs['member']['description'] = str(description)
        elif name.lower() == 'healthmonitor':
            pool = kwargs['healthmonitor'].get('pool')
            if pool:
                lb_id = pool.get('loadbalancer_id')
            kwargs['healthmonitor']['description'] = str(description)
        else:
            kwargs[name.lower()].update({'description': str(description)})
            lb_id = kwargs[name.lower()].get('loadbalancer_id')

        args = {'tenant_id': tenant_id,
                'lb_id': lb_id,
                'context': context,
                'description': str(description),
                'context_resource_data': context_resource_data}

        ctx_dict, rsrc_ctx_dict = self._prepare_resource_context_dicts(**args)
        service_vm_context = utils.get_service_vm_context(
                                                description['service_vendor'])
        nfp_context.update({'neutron_context': ctx_dict,
                            'requester': 'nas_service',
                            'logging_context':
                                module_context.get()['log_context'],
                            'service_vm_context': service_vm_context})
        resource_type = 'loadbalancerv2'
        resource = name
        resource_data = {'neutron_context': rsrc_ctx_dict}
        resource_data.update(**kwargs)
        body = common.prepare_request_data(nfp_context, resource,
                                           resource_type, resource_data,
                                           description['service_vendor'])
        return body
    def get_network_function_device_config(self, device_data,
                                           resource_type, is_delete=False,
                                           network_handler=None,
                                           devices_data=None):
        """ Get the configuration information for NFD

        :returns: dict

        """

        if is_delete:
            device_data = self.get_delete_device_data(
                                device_data, network_handler=network_handler,
                                devices_data=devices_data)
            if not device_data:
                return None

        return df.get_network_function_info(
            device_data, resource_type)
    def get_network_function_device_config(self,
                                           device_data,
                                           resource_type,
                                           is_delete=False,
                                           network_handler=None,
                                           devices_data=None):
        """ Get the configuration information for NFD

        :returns: dict

        """

        if is_delete:
            device_data = self.get_delete_device_data(
                device_data,
                network_handler=network_handler,
                devices_data=devices_data)
            if not device_data:
                return None

        return df.get_network_function_info(device_data, resource_type)
    def _data_wrapper(self, context, tenant_id, name, reason, nf, **kwargs):
        nfp_context = {}
        description = ast.literal_eval((nf['description'].split('\n'))[1])
        description.update({'tenant_id': tenant_id})
        context_resource_data = df.get_network_function_info(
            description, const.LOADBALANCERV2)
        # REVISIT(dpak): We need to avoid resource description
        # dependency in OTC and instead use neutron context description.
        if name.lower() == 'loadbalancer':
            lb_id = kwargs['loadbalancer']['id']
            kwargs['loadbalancer'].update({'description': str(description)})
            nfp_context = {
                'network_function_id': nf['id'],
                'loadbalancer_id': kwargs['loadbalancer']['id']
            }
        elif name.lower() == 'listener':
            lb_id = kwargs['listener'].get('loadbalancer_id')
            kwargs['listener']['description'] = str(description)
        elif name.lower() == 'pool':
            lb_id = kwargs['pool'].get('loadbalancer_id')
            kwargs['pool']['description'] = str(description)
        elif name.lower() == 'member':
            pool = kwargs['member'].get('pool')
            if pool:
                lb_id = pool.get('loadbalancer_id')
            kwargs['member']['description'] = str(description)
        elif name.lower() == 'healthmonitor':
            pool = kwargs['healthmonitor'].get('pool')
            if pool:
                lb_id = pool.get('loadbalancer_id')
            kwargs['healthmonitor']['description'] = str(description)
        else:
            kwargs[name.lower()].update({'description': str(description)})
            lb_id = kwargs[name.lower()].get('loadbalancer_id')

        args = {
            'tenant_id': tenant_id,
            'lb_id': lb_id,
            'context': context,
            'description': str(description),
            'context_resource_data': context_resource_data
        }

        ctx_dict, rsrc_ctx_dict = self._prepare_resource_context_dicts(**args)
        service_vm_context = utils.get_service_vm_context(
            description['service_vendor'])
        nfp_context.update({
            'neutron_context':
            ctx_dict,
            'requester':
            'nas_service',
            'logging_context':
            module_context.get()['log_context'],
            'service_vm_context':
            service_vm_context
        })
        resource_type = 'loadbalancerv2'
        resource = name
        resource_data = {'neutron_context': rsrc_ctx_dict}
        resource_data.update(**kwargs)
        body = common.prepare_request_data(nfp_context, resource,
                                           resource_type, resource_data,
                                           description['service_vendor'])
        return body
Exemple #5
0
 def _get_resource_data(self, description, resource_type):
     resource_data = df.get_network_function_info(description,
                                                  resource_type)
     return resource_data
Exemple #6
0
 def _get_resource_data(self, description, resource_type):
     resource_data = df.get_network_function_info(description,
                                                  resource_type)
     return resource_data