Ejemplo n.º 1
0
 def add_network_to_dhcp_agent(self, context, id, network_id):
     self._get_network(context, network_id)
     with db_api.CONTEXT_WRITER.using(context):
         agent_db = self._get_agent(context, id)
         if (agent_db['agent_type'] != constants.AGENT_TYPE_DHCP or
                 not services_available(agent_db['admin_state_up'])):
             raise das_exc.InvalidDHCPAgent(id=id)
         dhcp_agents = self.get_dhcp_agents_hosting_networks(
             context, [network_id])
         for dhcp_agent in dhcp_agents:
             if id == dhcp_agent.id:
                 raise das_exc.NetworkHostedByDHCPAgent(
                     network_id=network_id, agent_id=id)
         self.network_scheduler.resource_filter.bind(
             context, [agent_db], network_id, force_scheduling=True)
     dhcp_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_DHCP)
     if dhcp_notifier:
         dhcp_notifier.network_added_to_agent(
             context, network_id, agent_db.host)
Ejemplo n.º 2
0
 def add_network_to_dhcp_agent(self, context, id, network_id):
     self._get_network(context, network_id)
     with context.session.begin(subtransactions=True):
         agent_db = self._get_agent(context, id)
         if (agent_db['agent_type'] != constants.AGENT_TYPE_DHCP
                 or not services_available(agent_db['admin_state_up'])):
             raise das_exc.InvalidDHCPAgent(id=id)
         dhcp_agents = self.get_dhcp_agents_hosting_networks(
             context, [network_id])
         for dhcp_agent in dhcp_agents:
             if id == dhcp_agent.id:
                 raise das_exc.NetworkHostedByDHCPAgent(
                     network_id=network_id, agent_id=id)
         network.NetworkDhcpAgentBinding(context,
                                         dhcp_agent_id=id,
                                         network_id=network_id).create()
     dhcp_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_DHCP)
     if dhcp_notifier:
         dhcp_notifier.network_added_to_agent(context, network_id,
                                              agent_db.host)