def test_delete_network_function_without_nfi(self, mock_rpc,
                                                 mock_get_service_profile,
                                                 mock_get_admin_token,
                                                 mock_get_admin_tenant_id):
        network_function = self.create_network_function()
        nfp_context.init()
        mock_get_admin_token.return_value = 'admin_token'
        mock_get_admin_tenant_id.return_value = 'admin_tenant_id'
        transport.parse_service_flavor_string = mock.MagicMock(
            return_value={'device_type': 'VM',
                          'service_vendor': 'vyos'})
        self.service_orchestrator._create_event = mock.MagicMock(
            return_value='')

        delete_network_function_data = {
            'service_chain_instance': {},
            'provider': {},
            'consumer': {}}
        self.service_orchestrator.delete_network_function(
            self.context, network_function['id'], delete_network_function_data)
        self.assertRaises(nfp_exc.NetworkFunctionNotFound,
                          self.nfp_db.get_network_function,
                          self.session, network_function['id'])
        self.assertFalse(self.controller.event.called)
        self.assertFalse(self.controller.rpc_event.called)
 def test_delete_network_function(self, mock_rpc, mock_get_service_profile,
                                  mock_get_admin_token, mock_create_event,
                                  mock_get_admin_tenant_id):
     nfi = self.create_network_function_instance()
     network_function = self.nfp_db.get_network_function(
         self.session, nfi['network_function_id'])
     transport.parse_service_flavor_string = mock.MagicMock(
         return_value={
             'device_type': 'VM',
             'service_vendor': 'vyos'
         })
     self.assertEqual([nfi['id']],
                      network_function['network_function_instances'])
     mock_get_admin_token.return_value = 'admin_token'
     mock_get_admin_tenant_id.return_value = 'admin_tenant_id'
     nfp_context.init()
     (self.service_orchestrator.db_handler.
      update_node_instance_network_function_map) = mock.MagicMock(
          return_value=None)
     delete_network_function_data = {
         'service_chain_instance': {},
         'provider': {},
         'consumer': {}
     }
     self.service_orchestrator.delete_network_function(
         self.context, network_function['id'], delete_network_function_data)
     db_nf = self.nfp_db.get_network_function(self.session,
                                              network_function['id'])
     self.assertEqual('PENDING_DELETE', db_nf['status'])
Пример #3
0
 def update_network_function_config(self, context, body):
     """Method of rpc handler for delete_network_function_config.
     Return: Http Response.
     """
     module_context.init()
     transport.send_request_to_configurator(self._conf, context, body,
                                            "UPDATE")
 def test_delete_network_function(self, mock_rpc, mock_get_service_profile,
                                  mock_get_admin_token,
                                  mock_create_event,
                                  mock_get_admin_tenant_id):
     nfi = self.create_network_function_instance()
     network_function = self.nfp_db.get_network_function(
         self.session, nfi['network_function_id'])
     transport.parse_service_flavor_string = mock.MagicMock(
         return_value={'device_type': 'VM',
                       'service_vendor': 'vyos'})
     self.assertEqual([nfi['id']],
                      network_function['network_function_instances'])
     mock_get_admin_token.return_value = 'admin_token'
     mock_get_admin_tenant_id.return_value = 'admin_tenant_id'
     nfp_context.init()
     (self.service_orchestrator.db_handler.
         update_node_instance_network_function_map) = mock.MagicMock(
             return_value=None)
     delete_network_function_data = {
         'service_chain_instance': {},
         'provider': {},
         'consumer': {}}
     self.service_orchestrator.delete_network_function(
         self.context, network_function['id'], delete_network_function_data)
     db_nf = self.nfp_db.get_network_function(
         self.session, network_function['id'])
     self.assertEqual('PENDING_DELETE', db_nf['status'])
    def test_delete_network_function_without_nfi(self, mock_rpc,
                                                 mock_get_service_profile,
                                                 mock_get_admin_token,
                                                 mock_get_admin_tenant_id):
        network_function = self.create_network_function()
        nfp_context.init()
        mock_get_admin_token.return_value = 'admin_token'
        mock_get_admin_tenant_id.return_value = 'admin_tenant_id'
        transport.parse_service_flavor_string = mock.MagicMock(
            return_value={
                'device_type': 'VM',
                'service_vendor': 'vyos'
            })
        self.service_orchestrator._create_event = mock.MagicMock(
            return_value='')

        delete_network_function_data = {
            'service_chain_instance': {},
            'provider': {},
            'consumer': {}
        }
        self.service_orchestrator.delete_network_function(
            self.context, network_function['id'], delete_network_function_data)
        self.assertRaises(nfp_exc.NetworkFunctionNotFound,
                          self.nfp_db.get_network_function, self.session,
                          network_function['id'])
        self.assertFalse(self.controller.event.called)
        self.assertFalse(self.controller.rpc_event.called)
Пример #6
0
 def update_network_function_config(self, context, body):
     """Method of rpc handler for delete_network_function_config.
     Return: Http Response.
     """
     module_context.init()
     transport.send_request_to_configurator(self._conf,
                                            context, body,
                                            "UPDATE")
Пример #7
0
 def create_network_function_device_config(self, context, body):
     """Method of rpc handler for create_network_function_device_config.
     Return: Http Response.
     """
     module_context.init()
     transport.send_request_to_configurator(self._conf,
                                            context, body,
                                            "CREATE",
                                            device_config=True)
Пример #8
0
 def create_network_function_device_config(self, context, body):
     """Method of rpc handler for create_network_function_device_config.
     Return: Http Response.
     """
     module_context.init()
     transport.send_request_to_configurator(self._conf,
                                            context,
                                            body,
                                            "CREATE",
                                            device_config=True)
Пример #9
0
 def _dispatch(self, handler, event, *args, **kwargs):
     event.context['log_context']['namespace'] = event.desc.target
     context.init(event.context)
     try:
         handler(event, *args)
     except greenlet.GreenletExit:
         self.controller.event_complete(event, result='FAILED')
     except Exception as exc:
         # How to log traceback propery ??
         message = "Exception - %r" % (exc)
         LOG.error(message)
         self.dispatch_exception(kwargs.get('eh'), event, exc)
         self.controller.event_complete(event, result="FAILED")
     finally:
         self._send_event_ack(event)
Пример #10
0
 def _dispatch(self, handler, event, *args, **kwargs):
     event.context['log_context']['namespace'] = event.desc.target
     context.init(event.context)
     try:
         handler(event, *args)
     except greenlet.GreenletExit:
         self.controller.event_complete(event, result='FAILED')
     except Exception as exc:
         # How to log traceback propery ??
         message = "Exception - %r" % (exc)
         LOG.error(message)
         self.dispatch_exception(kwargs.get('eh'), event, exc)
         self.controller.event_complete(event, result="FAILED")
     finally:
         self._send_event_ack(event)
Пример #11
0
    def update_network_function_config(self, context, request_data):
        """RPC method to update of configuration in a network service.

        Updates configuration of a network service. This RPC method is
        invoked by the configurator REST server. It updates configuration
        of a network service based on the configuration request specified
        in the request_data argument.

        :param context: RPC context instance
        :param request_data: RPC data

        Returns: None

        """

        try:
            nfp_context = module_context.init()
            log_info = request_data.get('info')
            logging_context = log_info['context'].get('logging_context', {})
            nfp_context['log_context'] = logging_context
            LOG.info("Received RPC UPDATE NETWORK FUNCTION CONFIG "
                     "for %(service_type)s ",
                     {'service_type': request_data['info']['service_type']})

            self._invoke_service_agent('update', request_data)
        except Exception as err:
            msg = ("Failed to update network service configuration. %s" %
                   str(err).capitalize())
            LOG.error(msg)
Пример #12
0
    def set_firewall_status(self, context, notification_data):
        nfp_context = module_context.init()
        notification = notification_data['notification'][0]

        request_info = notification_data.get('info')
        request_context = request_info.get('context')
        logging_context = request_context.get('logging_context', {})
        nfp_context['log_context'] = logging_context

        resource_data = notification['data']
        firewall_id = resource_data['firewall_id']
        status = resource_data['status']

        LOG.info(
            "Received firewall configuration create complete API, "
            "making an RPC call set firewall status for "
            "firewall:%(firewall)s and status: %(status)s", {
                'firewall': firewall_id,
                'status': status
            })

        # RPC call to plugin to set firewall status
        rpcClient = transport.RPCClient(a_topics.FW_NFP_PLUGIN_TOPIC)
        rpcClient.cctxt.cast(context,
                             'set_firewall_status',
                             host=resource_data['host'],
                             firewall_id=firewall_id,
                             status=status)
Пример #13
0
    def delete_network_function_device_config(self, context, request_data):
        """RPC method to clear configuration of a network service device.

        Clears configuration of a network service VM. This RPC method is
        invoked by the configurator REST server. It clears configuration
        of a network service based on the configuration request specified
        in the request_data argument.

        :param context: RPC context instance
        :param request_data: RPC data

        Returns: None

        """

        try:
            nfp_context = module_context.init()
            log_info = request_data.get('info')
            logging_context = log_info['context'].get('logging_context', {})
            nfp_context['log_context'] = logging_context
            LOG.info("Received RPC DELETE NETWORK FUNCTION DEVICE CONFIG "
                     "for %(service_type)s, NFI: %(nfi)s, "
                     "NF_ID: %(nf_id)s",
                     {'service_type': request_data['info']['service_type'],
                      'nfi': request_data['info']['context']['nfi_id'],
                      'nf_id': request_data['info']['context']['nf_id']})

            self._invoke_service_agent('delete', request_data, True)
        except Exception as err:
            msg = ("Failed to delete network device configuration. %s" %
                   str(err).capitalize())
            LOG.error(msg)
Пример #14
0
    def delete_network_function_device_config(self, context, request_data):
        """RPC method to clear configuration of a network service device.

        Clears configuration of a network service VM. This RPC method is
        invoked by the configurator REST server. It clears configuration
        of a network service based on the configuration request specified
        in the request_data argument.

        :param context: RPC context instance
        :param request_data: RPC data

        Returns: None

        """

        try:
            nfp_context = module_context.init()
            log_info = request_data.get('info')
            logging_context = log_info['context'].get('logging_context', {})
            nfp_context['log_context'] = logging_context
            LOG.info(_LI("Received RPC DELETE NETWORK FUNCTION DEVICE CONFIG "
                         "for %(service_type)s, NFI: %(nfi)s, "
                         "NF_ID: %(nf_id)s"),
                     {'service_type': request_data['info']['service_type'],
                      'nfi': request_data['info']['context']['nfi_id'],
                      'nf_id': request_data['info']['context']['nf_id']})

            self._invoke_service_agent('delete', request_data, True)
        except Exception as err:
            msg = ("Failed to delete network device configuration. %s" %
                   str(err).capitalize())
            LOG.error(msg)
Пример #15
0
    def update_network_function_config(self, context, request_data):
        """RPC method to update of configuration in a network service.

        Updates configuration of a network service. This RPC method is
        invoked by the configurator REST server. It updates configuration
        of a network service based on the configuration request specified
        in the request_data argument.

        :param context: RPC context instance
        :param request_data: RPC data

        Returns: None

        """

        try:
            nfp_context = module_context.init()
            log_info = request_data.get('info')
            logging_context = log_info['context'].get('logging_context', {})
            nfp_context['log_context'] = logging_context
            LOG.info(_LI("Received RPC UPDATE NETWORK FUNCTION CONFIG "
                         "for %(service_type)s "),
                     {'service_type': request_data['info']['service_type']})

            self._invoke_service_agent('update', request_data)
        except Exception as err:
            msg = ("Failed to update network service configuration. %s" %
                   str(err).capitalize())
            LOG.error(msg)
Пример #16
0
    def set_firewall_status(self, context, notification_data):
        nfp_context = module_context.init()
        notification = notification_data['notification'][0]

        request_info = notification_data.get('info')
        request_context = request_info.get('context')
        logging_context = request_context.get('logging_context', {})
        nfp_context['log_context'] = logging_context

        resource_data = notification['data']
        firewall_id = resource_data['firewall_id']
        status = resource_data['status']

        LOG.info("Received firewall configuration create complete API, "
                 "making an RPC call set firewall status for "
                 "firewall:%(firewall)s and status: %(status)s",
                 {'firewall': firewall_id,
                  'status': status})

        # RPC call to plugin to set firewall status
        rpcClient = transport.RPCClient(a_topics.FW_NFP_PLUGIN_TOPIC)
        rpcClient.cctxt.cast(context, 'set_firewall_status',
                             host=resource_data['host'],
                             firewall_id=firewall_id,
                             status=status)
Пример #17
0
    def handle_event(self, event):
        event.context['log_context']['namespace'] = event.desc.target
        nfp_context.init(event.context)

        if event.id == 'TEST_EVENT_ACK_FROM_WORKER':
            self.controller.event_ack_handler_cb_obj.set()

        if event.id == 'TEST_POST_EVENT_FROM_WORKER':
            self.controller.post_event_worker_wait_obj.set()

        if event.id == 'TEST_POLL_EVENT_FROM_WORKER':
            self.controller.poll_event_worker_wait_obj.set()
            self.controller.poll_event(event, spacing=1)

        if event.id == 'TEST_POLL_EVENT_CANCEL_FROM_WORKER':
            self.controller.poll_event_worker_wait_obj.set()
            self.controller.poll_event(event, spacing=1, max_times=2)
Пример #18
0
def main():
    context.init()
    args, module = extract_module(sys.argv[1:])
    conf = nfp_cfg.init(module, args)
    conf.module = module
    load_module_opts(conf)
    nfp_logging.init_logger(oslo_config.CONF.logger_class)
    nfp_common.init()
    nfp_controller = NfpController(conf)
    # Load all nfp modules from path configured
    nfp_modules = load_nfp_modules(conf, nfp_controller)
    # Init the controller, launch required contexts
    controller_init(conf, nfp_controller)
    # post_init of each module
    nfp_modules_post_init(conf, nfp_modules, nfp_controller)
    # Wait for every exec context to complete
    nfp_controller.wait()
Пример #19
0
def main():
    context.init()
    args, module = extract_module(sys.argv[1:])
    conf = nfp_cfg.init(module, args)
    conf.module = module
    load_module_opts(conf)
    nfp_logging.init_logger(oslo_config.CONF.logger_class)
    nfp_common.init()
    nfp_controller = NfpController(conf)
    # Load all nfp modules from path configured
    nfp_modules = load_nfp_modules(conf, nfp_controller)
    # Init the controller, launch required contexts
    controller_init(conf, nfp_controller)
    # post_init of each module
    nfp_modules_post_init(conf, nfp_modules, nfp_controller)
    # Wait for every exec context to complete
    nfp_controller.wait()
Пример #20
0
    def handle_event(self, event):
        event.context['log_context']['namespace'] = event.desc.target
        nfp_context.init(event.context)

        if event.id == 'TEST_EVENT_ACK_FROM_WORKER':
            self.controller.event_ack_handler_cb_obj.set()

        if event.id == 'TEST_POST_EVENT_FROM_WORKER':
            self.controller.post_event_worker_wait_obj.set()

        if event.id == 'TEST_POLL_EVENT_FROM_WORKER':
            self.controller.poll_event_worker_wait_obj.set()
            self.controller.poll_event(event, spacing=1)

        if event.id == 'TEST_POLL_EVENT_CANCEL_FROM_WORKER':
            self.controller.poll_event_worker_wait_obj.set()
            self.controller.poll_event(event, spacing=1, max_times=2)
Пример #21
0
 def network_function_notification(self, context, notification_data):
     module_context.init()
     try:
         LOG.info(
             "Received NETWORK FUNCTION NOTIFICATION:"
             "%(notification)s",
             {'notification': notification_data['notification']})
         if notification_data['info']['service_type'] is not None:
             handler = NaasNotificationHandler(self.conf, self.sc)
             handler.\
                 handle_notification(context, notification_data)
     except Exception as e:
         exc_type, exc_value, exc_traceback = sys.exc_info()
         msg = ("Generic exception (%s) while handling message (%s) : %s" %
                (e, notification_data,
                 traceback.format_exception(exc_type, exc_value,
                                            exc_traceback)))
         LOG.error(msg)
Пример #22
0
 def network_function_notification(self, context, notification_data):
     module_context.init()
     try:
         LOG.info("Received NETWORK FUNCTION NOTIFICATION:"
                  "%(notification)s",
                  {'notification': notification_data['notification']})
         if notification_data['info']['service_type'] is not None:
             handler = NaasNotificationHandler(self.conf, self.sc)
             handler.\
                 handle_notification(context, notification_data)
     except Exception as e:
         exc_type, exc_value, exc_traceback = sys.exc_info()
         msg = ("Generic exception (%s) while handling message (%s) : %s"
                % (e,
                   notification_data,
                   traceback.format_exception(exc_type,
                                              exc_value,
                                              exc_traceback)))
         LOG.error(msg)
Пример #23
0
 def delete_pool(self, context, pool):
     nfp_context = module_context.init()
     LOG.info("Received RPC DELETE POOL for Pool:%(pool)s", {'pool': pool})
     loadbalancer = pool['loadbalancer']
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('pool', pool)
     self._delete(context, pool['tenant_id'], 'pool', nf, pool=pool)
Пример #24
0
 def update_member(self, context, old_member, member):
     nfp_context = module_context.init()
     loadbalancer = member['pool']['loadbalancer']
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('member', member)
     self._put(
         context, member['tenant_id'],
         'member', nf, old_member=old_member, member=member)
Пример #25
0
 def delete_firewall(self, context, firewall, host):
     nfp_context = module_context.init()
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(firewall["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     LOG.info("Received RPC DELETE FIREWALL for "
              "Firewall: %(firewall)s", {'firewall': firewall})
     body = self._data_wrapper(context, firewall, host, nf, 'DELETE')
     transport.send_request_to_configurator(self._conf, context, body,
                                            "DELETE")
Пример #26
0
 def delete_member(self, context, member):
     nfp_context = module_context.init()
     LOG.info(_LI("Received RPC DELETE MEMBER for Member:%(member)s"),
              {'member': member})
     loadbalancer = member['pool']['loadbalancer']
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('member', member)
     self._delete(context, member['tenant_id'], 'member', nf, member=member)
Пример #27
0
    def get_notifications(self, context):
        """RPC method to get all notifications published by configurator.

        Gets all the notifications from the notifications from notification
        queue and sends to configurator agent

        :param context: RPC context instance

        Returns: notification_data

        """
        module_context.init()
        LOG.info(_LI("Received RPC GET NOTIFICATIONS "))
        events = self.sc.get_stashed_events()
        notifications = []
        for event in events:
            notification = event.data
            msg = ("Notification Data: %r" % notification)
            notifications.append(notification)
            LOG.info(msg)
        return notifications
Пример #28
0
    def get_notifications(self, context):
        """RPC method to get all notifications published by configurator.

        Gets all the notifications from the notifications from notification
        queue and sends to configurator agent

        :param context: RPC context instance

        Returns: notification_data

        """
        module_context.init()
        LOG.info("Received RPC GET NOTIFICATIONS ")
        events = self.sc.get_stashed_events()
        notifications = []
        for event in events:
            notification = event.data
            msg = ("Notification Data: %r" % notification)
            notifications.append(notification)
            LOG.info(msg)
        return notifications
Пример #29
0
    def update_status(self, context, notification_data):
        nfp_context = module_context.init()
        notification = notification_data['notification'][0]

        request_info = notification_data.get('info')
        request_context = request_info.get('context')
        logging_context = request_context.get('logging_context', {})
        nfp_context['log_context'] = logging_context

        resource_data = notification['data']
        obj_type = resource_data['obj_type']
        obj_id = resource_data['obj_id']

        rpcClient = transport.RPCClient(a_topics.LBV2_NFP_PLUGIN_TOPIC)
        rpcClient.cctxt = rpcClient.client.prepare(
            version=const.LOADBALANCERV2_RPC_API_VERSION)

        lb_p_status = const.ACTIVE
        lb_o_status = None
        obj_p_status = resource_data['provisioning_status']
        obj_o_status = resource_data['operating_status']

        LOG.info(
            "Received LB's update_status API. Making an "
            "update_status RPC call to plugin for %(obj_type)s:"
            "%(obj_id)s with status: %(status)s", {
                'obj_type': obj_type,
                'obj_id': obj_id,
                'status': obj_p_status
            })

        if obj_type == 'healthmonitor':
            obj_o_status = None

        if obj_type != 'loadbalancer':
            rpcClient.cctxt.cast(context,
                                 'update_status',
                                 obj_type=obj_type,
                                 obj_id=obj_id,
                                 provisioning_status=obj_p_status,
                                 operating_status=obj_o_status)
        else:
            lb_o_status = lbv2_const.ONLINE
            if obj_p_status == const.ERROR:
                lb_p_status = const.ERROR
                lb_o_status = lbv2_const.OFFLINE

        rpcClient.cctxt.cast(context,
                             'update_status',
                             obj_type='loadbalancer',
                             obj_id=resource_data['root_lb_id'],
                             provisioning_status=lb_p_status,
                             operating_status=lb_o_status)
Пример #30
0
 def delete_firewall(self, context, firewall, host):
     nfp_context = module_context.init()
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(firewall["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     LOG.info("Received RPC DELETE FIREWALL for "
              "Firewall: %(firewall)s",
              {'firewall': firewall})
     body = self._data_wrapper(context, firewall, host, nf, 'DELETE')
     transport.send_request_to_configurator(self._conf,
                                            context, body, "DELETE")
    def test_handle_consumer_ptg_added(self, mock_create_rpc,
                                       mock_get_service_profile,
                                       mock_get_admin_token,
                                       mock_create_event):
        (self.service_orchestrator.db_handler.
         update_node_instance_network_function_map) = mock.MagicMock(
             return_value=None)
        nfi = self.create_network_function_instance()
        network_function_id = nfi['network_function_id']
        policy_target_group = mock.Mock()
        transport.parse_service_flavor_string = mock.MagicMock(
            return_value={
                'device_type': 'VM',
                'service_vendor': 'vyos'
            })
        with mock.patch.object(
                self.service_orchestrator.config_driver,
                "handle_consumer_ptg_operations") as\
                mock_handle_consumer_ptg_added:
            mock_handle_consumer_ptg_added.return_value = 'stack_id'
            nfp_context.init()

            self.service_orchestrator.handle_consumer_ptg_added(
                self.context, network_function_id, policy_target_group)
        db_nf = self.nfp_db.get_network_function(self.session,
                                                 nfi['network_function_id'])
        tag_str = 'heat_config'
        self.assertIsNotNone(db_nf['config_policy_id'])
        service_config = db_nf['service_config']
        network_function_details = (
            self.service_orchestrator.get_network_function_details(
                db_nf['id']))
        network_function_details['network_function']['status'] = 'status'
        network_function_data = {
            'service_type': mock.ANY,
            'network_function_details': network_function_details,
            'consumer_ptg': policy_target_group
        }
        mock_create_rpc.assert_called_once_with(network_function_data,
                                                service_config, tag_str)
    def test_handle_consumer_ptg_added(self, mock_create_rpc,
                                       mock_get_service_profile,
                                       mock_get_admin_token,
                                       mock_create_event):
        (self.service_orchestrator.db_handler.
            update_node_instance_network_function_map) = mock.MagicMock(
                return_value=None)
        nfi = self.create_network_function_instance()
        network_function_id = nfi['network_function_id']
        policy_target_group = mock.Mock()
        transport.parse_service_flavor_string = mock.MagicMock(
            return_value={'device_type': 'VM',
                          'service_vendor': 'vyos'})
        with mock.patch.object(
                self.service_orchestrator.config_driver,
                "handle_consumer_ptg_operations") as\
                mock_handle_consumer_ptg_added:
            mock_handle_consumer_ptg_added.return_value = 'stack_id'
            nfp_context.init()

            self.service_orchestrator.handle_consumer_ptg_added(
                self.context, network_function_id, policy_target_group)
        db_nf = self.nfp_db.get_network_function(
            self.session, nfi['network_function_id'])
        tag_str = 'heat_config'
        self.assertIsNotNone(db_nf['config_policy_id'])
        service_config = db_nf['service_config']
        network_function_details = (
            self.service_orchestrator.get_network_function_details(
                db_nf['id']))
        network_function_details['network_function'][
            'status'] = 'status'
        network_function_data = {
            'service_type': mock.ANY,
            'network_function_details': network_function_details,
            'consumer_ptg': policy_target_group
        }
        mock_create_rpc.assert_called_once_with(
            network_function_data, service_config, tag_str
        )
Пример #33
0
 def delete_healthmonitor(self, context, healthmonitor):
     nfp_context = module_context.init()
     LOG.info("Received RPC DELETE HEALTH MONITOR for HM:%(hm)s",
              {'hm': healthmonitor})
     loadbalancer = healthmonitor['pool']['loadbalancer']
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('healthmonitor', healthmonitor)
     self._delete(
         context, healthmonitor['tenant_id'],
         'healthmonitor', nf, healthmonitor=healthmonitor)
Пример #34
0
 def update_loadbalancer(self, context, old_loadbalancer, loadbalancer):
     nfp_context = module_context.init()
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('loadbalancer', loadbalancer)
     self._put(context,
               loadbalancer['tenant_id'],
               'loadbalancer',
               nf,
               old_loadbalancer=old_loadbalancer,
               loadbalancer=loadbalancer)
Пример #35
0
 def delete_member(self, context, member):
     nfp_context = module_context.init()
     LOG.info("Received RPC DELETE MEMBER for Member:%(member)s",
              {'member': member})
     loadbalancer = member['pool']['loadbalancer']
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('member', member)
     self._delete(
         context, member['tenant_id'],
         'member', nf, member=member)
Пример #36
0
 def delete_pool(self, context, pool):
     nfp_context = module_context.init()
     LOG.info("Received RPC DELETE POOL for Pool:%(pool)s",
              {'pool': pool})
     loadbalancer = pool['loadbalancer']
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('pool', pool)
     self._delete(
         context, pool['tenant_id'],
         'pool', nf, pool=pool)
Пример #37
0
 def create_listener(self, context, listener):
     nfp_context = module_context.init()
     LOG.info("Received RPC CREATE LISTENER for Listener:%(listener)s",
              {'listener': listener})
     loadbalancer = listener['loadbalancer']
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('listener', listener)
     self._post(
         context, listener['tenant_id'],
         'listener', nf, listener=listener)
Пример #38
0
 def delete_loadbalancer(self, context, loadbalancer,
                         delete_vip_port=True):
     nfp_context = module_context.init()
     LOG.info("Received RPC DELETE LOADBALANCER for LB:"
              "%(lb)s", {'lb': loadbalancer})
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('loadbalancer', loadbalancer)
     self._delete(
         context, loadbalancer['tenant_id'],
         'loadbalancer', nf, loadbalancer=loadbalancer)
Пример #39
0
 def vpnservice_updated(self, context, **kwargs):
     nfp_context = module_context.init()
     LOG.info(_LI("Received RPC VPN SERVICE UPDATED with data:%(data)s"),
              {'data': kwargs})
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(
         kwargs['resource']['description'])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     reason = kwargs['reason']
     body = self._data_wrapper(context, kwargs['resource']['tenant_id'], nf,
                               **kwargs)
     transport.send_request_to_configurator(self._conf, context, body,
                                            reason)
Пример #40
0
 def delete_loadbalancer(self, context, loadbalancer, delete_vip_port=True):
     nfp_context = module_context.init()
     LOG.info(_LI("Received RPC DELETE LOADBALANCER for LB:"
                  "%(lb)s"), {'lb': loadbalancer})
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('loadbalancer', loadbalancer)
     self._delete(context,
                  loadbalancer['tenant_id'],
                  'loadbalancer',
                  nf,
                  loadbalancer=loadbalancer)
Пример #41
0
    def update_status(self, context, notification_data):
        nfp_context = module_context.init()
        notification = notification_data['notification'][0]

        request_info = notification_data.get('info')
        request_context = request_info.get('context')
        logging_context = request_context.get('logging_context', {})
        nfp_context['log_context'] = logging_context

        resource_data = notification['data']
        obj_type = resource_data['obj_type']
        obj_id = resource_data['obj_id']

        rpcClient = transport.RPCClient(a_topics.LBV2_NFP_PLUGIN_TOPIC)
        rpcClient.cctxt = rpcClient.client.prepare(
            version=const.LOADBALANCERV2_RPC_API_VERSION)

        lb_p_status = const.ACTIVE
        lb_o_status = None
        obj_p_status = resource_data['provisioning_status']
        obj_o_status = resource_data['operating_status']

        LOG.info("Received LB's update_status API. Making an "
                 "update_status RPC call to plugin for %(obj_type)s:"
                 "%(obj_id)s with status: %(status)s",
                 {'obj_type': obj_type,
                  'obj_id': obj_id,
                  'status': obj_p_status})

        if obj_type == 'healthmonitor':
            obj_o_status = None

        if obj_type != 'loadbalancer':
            rpcClient.cctxt.cast(context, 'update_status',
                                 obj_type=obj_type,
                                 obj_id=obj_id,
                                 provisioning_status=obj_p_status,
                                 operating_status=obj_o_status)
        else:
            lb_o_status = lbv2_const.ONLINE
            if obj_p_status == const.ERROR:
                lb_p_status = const.ERROR
                lb_o_status = lbv2_const.OFFLINE

        rpcClient.cctxt.cast(context, 'update_status',
                             obj_type='loadbalancer',
                             obj_id=resource_data['root_lb_id'],
                             provisioning_status=lb_p_status,
                             operating_status=lb_o_status)
Пример #42
0
 def vpnservice_updated(self, context, **kwargs):
     nfp_context = module_context.init()
     LOG.info("Received RPC VPN SERVICE UPDATED with data:%(data)s",
              {'data': kwargs})
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(kwargs[
         'resource']['description'])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     reason = kwargs['reason']
     body = self._data_wrapper(context, kwargs[
         'resource']['tenant_id'], nf, **kwargs)
     transport.send_request_to_configurator(self._conf,
                                            context, body,
                                            reason)
Пример #43
0
 def delete_healthmonitor(self, context, healthmonitor):
     nfp_context = module_context.init()
     LOG.info(_LI("Received RPC DELETE HEALTH MONITOR for HM:%(hm)s"),
              {'hm': healthmonitor})
     loadbalancer = healthmonitor['pool']['loadbalancer']
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('healthmonitor', healthmonitor)
     self._delete(context,
                  healthmonitor['tenant_id'],
                  'healthmonitor',
                  nf,
                  healthmonitor=healthmonitor)
Пример #44
0
 def create_listener(self, context, listener):
     nfp_context = module_context.init()
     LOG.info(_LI("Received RPC CREATE LISTENER for Listener:%(listener)s"),
              {'listener': listener})
     loadbalancer = listener['loadbalancer']
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('listener', listener)
     self._post(context,
                listener['tenant_id'],
                'listener',
                nf,
                listener=listener)
Пример #45
0
    def update_status(self, context, notification_data):
        nfp_context = module_context.init()
        resource_data = notification_data['notification'][0]['data']

        request_info = notification_data.get('info')
        request_context = request_info.get('context')
        logging_context = request_context.get('logging_context', {})
        nfp_context['log_context'] = logging_context

        status = resource_data['status']
        LOG.info(
            "Received VPN's update_status API. "
            "Making an update_status RPC cast to plugin for object"
            "with status: %(status)s", {'status': status})
        rpcClient = transport.RPCClient(a_topics.VPN_NFP_PLUGIN_TOPIC)
        rpcClient.cctxt.cast(context, 'update_status', status=status)
Пример #46
0
    def update_status(self, context, notification_data):
        nfp_context = module_context.init()
        resource_data = notification_data['notification'][0]['data']

        request_info = notification_data.get('info')
        request_context = request_info.get('context')
        logging_context = request_context.get('logging_context', {})
        nfp_context['log_context'] = logging_context

        status = resource_data['status']
        LOG.info("Received VPN's update_status API. "
                 "Making an update_status RPC cast to plugin for object"
                 "with status: %(status)s",
                 {'status': status})
        rpcClient = transport.RPCClient(a_topics.VPN_NFP_PLUGIN_TOPIC)
        rpcClient.cctxt.cast(context, 'update_status',
                             status=status)
Пример #47
0
 def create_loadbalancer(self,
                         context,
                         loadbalancer,
                         driver_name,
                         allocate_vip=True):
     nfp_context = module_context.init()
     LOG.info("Received RPC CREATE LOADBALANCER for LB:%(lb)s",
              {'lb': loadbalancer})
     # Fetch nf_id from description of the resource
     nf_id = self._fetch_nf_from_resource_desc(loadbalancer["description"])
     nfp_context['log_context']['meta_id'] = nf_id
     nf = common.get_network_function_details(context, nf_id)
     self._update_tls_cert('loadbalancer', loadbalancer)
     self._post(context,
                loadbalancer['tenant_id'],
                'loadbalancer',
                nf,
                loadbalancer=loadbalancer,
                driver_name=driver_name)
Пример #48
0
    def firewall_deleted(self, context, notification_data):
        nfp_context = module_context.init()
        notification = notification_data['notification'][0]

        request_info = notification_data.get('info')
        request_context = request_info.get('context')
        logging_context = request_context.get('logging_context', {})
        nfp_context['log_context'] = logging_context

        resource_data = notification['data']
        firewall_id = resource_data['firewall_id']

        LOG.info("Received firewall_configuration_delete_complete API, "
                 "making an RPC call firewall_deleted  for firewall:"
                 "%(firewall)s ",
                 {'firewall': firewall_id})

        # RPC call to plugin to update firewall deleted
        rpcClient = transport.RPCClient(a_topics.FW_NFP_PLUGIN_TOPIC)
        rpcClient.cctxt.cast(context, 'firewall_deleted',
                             host=resource_data['host'],
                             firewall_id=firewall_id)
Пример #49
0
    def firewall_deleted(self, context, notification_data):
        nfp_context = module_context.init()
        notification = notification_data['notification'][0]

        request_info = notification_data.get('info')
        request_context = request_info.get('context')
        logging_context = request_context.get('logging_context', {})
        nfp_context['log_context'] = logging_context

        resource_data = notification['data']
        firewall_id = resource_data['firewall_id']

        LOG.info(
            "Received firewall_configuration_delete_complete API, "
            "making an RPC call firewall_deleted  for firewall:"
            "%(firewall)s ", {'firewall': firewall_id})

        # RPC call to plugin to update firewall deleted
        rpcClient = transport.RPCClient(a_topics.FW_NFP_PLUGIN_TOPIC)
        rpcClient.cctxt.cast(context,
                             'firewall_deleted',
                             host=resource_data['host'],
                             firewall_id=firewall_id)
Пример #50
0
 def dispatch(self, job):
     context.init()
     return job['method'](*job['args'], **job['kwargs'])
Пример #51
0
 def dispatch(self, job):
     context.init()
     return job['method'](*job['args'], **job['kwargs'])
 def setUp(self):
     nfp_context.init()