def _notification(self, context, method, payload, network_id): """Notify all the agents that are hosting the network""" plugin = manager.QuantumManager.get_plugin() if (method != 'network_delete_end' and utils.is_extension_supported( plugin, constants.AGENT_SCHEDULER_EXT_ALIAS)): if method == 'port_create_end': # we don't schedule when we create network # because we want to give admin a chance to # schedule network manually by API adminContext = (context if context.is_admin else context.elevated()) network = plugin.get_network(adminContext, network_id) chosen_agent = plugin.schedule_network(adminContext, network) if chosen_agent: self._notification_host(context, 'network_create_end', {'network': { 'id': network_id }}, chosen_agent['host']) for (host, topic) in self._get_dhcp_agents(context, network_id): self.cast(context, self.make_msg(method, payload=payload), topic='%s.%s' % (topic, host)) else: # besides the non-agentscheduler plugin, # There is no way to query who is hosting the network # when the network is deleted, so we need to fanout self._notification_fanout(context, method, payload)
def _notification(self, context, method, payload, network_id): """Notify all the agents that are hosting the network""" plugin = manager.QuantumManager.get_plugin() if (method != 'network_delete_end' and utils.is_extension_supported( plugin, constants.AGENT_SCHEDULER_EXT_ALIAS)): if method == 'port_create_end': # we don't schedule when we create network # because we want to give admin a chance to # schedule network manually by API adminContext = (context if context.is_admin else context.elevated()) network = plugin.get_network(adminContext, network_id) chosen_agent = plugin.schedule_network(adminContext, network) if chosen_agent: self._notification_host( context, 'network_create_end', {'network': {'id': network_id}}, chosen_agent['host']) for (host, topic) in self._get_dhcp_agents(context, network_id): self.cast( context, self.make_msg(method, payload=payload), topic='%s.%s' % (topic, host)) else: # besides the non-agentscheduler plugin, # There is no way to query who is hosting the network # when the network is deleted, so we need to fanout self._notification_fanout(context, method, payload)
def _notification(self, context, method, routers, operation, data): """Notify all the agents that are hosting the routers.""" plugin = manager.QuantumManager.get_plugin() if utils.is_extension_supported(plugin, constants.AGENT_SCHEDULER_EXT_ALIAS): adminContext = context.is_admin and context or context.elevated() plugin.schedule_routers(adminContext, routers) self._agent_notification(context, method, routers, operation, data) else: self.fanout_cast(context, self.make_msg(method, routers=routers), topic=topics.L3_AGENT)
def _notification(self, context, method, routers, operation, data): """Notify all the agents that are hosting the routers""" plugin = manager.QuantumManager.get_plugin() if utils.is_extension_supported(plugin, constants.AGENT_SCHEDULER_EXT_ALIAS): adminContext = (context.is_admin and context or context.elevated()) plugin.schedule_routers(adminContext, routers) self._agent_notification(context, method, routers, operation, data) else: self.fanout_cast(context, self.make_msg(method, routers=routers), topic=topics.L3_AGENT)
def get_active_networks(self, context, **kwargs): """Retrieve and return a list of the active network ids.""" host = kwargs.get('host') LOG.debug(_('Network list requested from %s'), host) plugin = manager.QuantumManager.get_plugin() if utils.is_extension_supported( plugin, constants.AGENT_SCHEDULER_EXT_ALIAS): if cfg.CONF.network_auto_schedule: plugin.auto_schedule_networks(context, host) nets = plugin.list_active_networks_on_active_dhcp_agent( context, host) else: filters = dict(admin_state_up=[True]) nets = plugin.get_networks(context, filters=filters) return [net['id'] for net in nets]
def _notification(self, context, method, payload, network_id): """Notify all the agents that are hosting the network""" plugin = manager.QuantumManager.get_plugin() if (method != 'network_delete_end' and utils.is_extension_supported( plugin, constants.AGENT_SCHEDULER_EXT_ALIAS)): for (host, topic) in self._get_dhcp_agents(context, network_id): self.cast( context, self.make_msg(method, payload=payload), topic='%s.%s' % (topic, host)) else: # besides the non-agentscheduler plugin, # There is no way to query who is hosting the network # when the network is deleted, so we need to fanout self._notification_fanout(context, method, payload)
def get_active_networks(self, context, **kwargs): """Retrieve and return a list of the active network ids.""" host = kwargs.get('host') LOG.debug(_('Network list requested from %s'), host) plugin = manager.QuantumManager.get_plugin() if utils.is_extension_supported(plugin, constants.AGENT_SCHEDULER_EXT_ALIAS): if cfg.CONF.network_auto_schedule: plugin.auto_schedule_networks(context, host) nets = plugin.list_active_networks_on_active_dhcp_agent( context, host) else: filters = dict(admin_state_up=[True]) nets = plugin.get_networks(context, filters=filters) return [net['id'] for net in nets]
def sync_routers(self, context, **kwargs): """Sync routers according to filters to a specific agent. @param context: contain user information @param kwargs: host, or router_id @return: a list of routers with their interfaces and floating_ips """ router_id = kwargs.get('router_id') host = kwargs.get('host') context = quantum_context.get_admin_context() plugin = manager.QuantumManager.get_plugin() if utils.is_extension_supported( plugin, constants.AGENT_SCHEDULER_EXT_ALIAS): if cfg.CONF.router_auto_schedule: plugin.auto_schedule_routers(context, host, router_id) routers = plugin.list_active_sync_routers_on_active_l3_agent( context, host, router_id) else: routers = plugin.get_sync_data(context, router_id) LOG.debug(_("Routers returned to l3 agent:\n %s"), jsonutils.dumps(routers, indent=5)) return routers
def sync_routers(self, context, **kwargs): """Sync routers according to filters to a specific agent. @param context: contain user information @param kwargs: host, or router_id @return: a list of routers with their interfaces and floating_ips """ router_id = kwargs.get('router_id') host = kwargs.get('host') context = quantum_context.get_admin_context() plugin = manager.QuantumManager.get_plugin() if utils.is_extension_supported(plugin, constants.AGENT_SCHEDULER_EXT_ALIAS): if cfg.CONF.router_auto_schedule: plugin.auto_schedule_routers(context, host, router_id) routers = plugin.list_active_sync_routers_on_active_l3_agent( context, host, router_id) else: routers = plugin.get_sync_data(context, router_id) LOG.debug(_("Routers returned to l3 agent:\n %s"), jsonutils.dumps(routers, indent=5)) return routers