Example #1
0
 def update_device_up(self, rpc_context, **kwargs):
     """Device is up on agent."""
     agent_id = kwargs.get("agent_id")
     device = kwargs.get("device")
     LOG.debug(_("Device %(device)s up %(agent_id)s"), {"device": device, "agent_id": agent_id})
     port = self.get_port_from_device(device)
     if port:
         if port["status"] != q_const.PORT_STATUS_ACTIVE:
             # Set port status to ACTIVE
             db.set_port_status(port["id"], q_const.PORT_STATUS_ACTIVE)
     else:
         LOG.debug(_("%s can not be found in database"), device)
Example #2
0
 def update_device_up(self, rpc_context, **kwargs):
     """Device is up on agent."""
     agent_id = kwargs.get('agent_id')
     device = kwargs.get('device')
     LOG.debug(_("Device %(device)s up %(agent_id)s"),
               {'device': device, 'agent_id': agent_id})
     port = self.get_port_from_device(device)
     if port:
         if port['status'] != q_const.PORT_STATUS_ACTIVE:
             # Set port status to ACTIVE
             db.set_port_status(port['id'], q_const.PORT_STATUS_ACTIVE)
     else:
         LOG.debug(_("%s can not be found in database"), device)
 def update_device_down(self, rpc_context, **kwargs):
     """Device no longer exists on agent"""
     agent_id = kwargs.get("agent_id")
     device = kwargs.get("device")
     LOG.debug("Device %s no longer exists on %s", device, agent_id)
     port = db.get_port_from_device(device)
     if port:
         entry = {"device": device, "exists": True}
         # Set port status to DOWN
         db.set_port_status(port["id"], q_const.PORT_STATUS_DOWN)
     else:
         entry = {"device": device, "exists": False}
         LOG.debug("%s can not be found in database", device)
     return entry
Example #4
0
 def update_device_down(self, rpc_context, **kwargs):
     """Device no longer exists on agent."""
     agent_id = kwargs.get('agent_id')
     device = kwargs.get('device')
     LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
               {'device': device, 'agent_id': agent_id})
     port = db.get_port_from_device(device)
     if port:
         entry = {'device': device,
                  'exists': True}
         # Set port status to DOWN
         db.set_port_status(port['id'], q_const.PORT_STATUS_DOWN)
     else:
         entry = {'device': device,
                  'exists': False}
         LOG.debug(_("%s can not be found in database"), device)
     return entry
Example #5
0
 def get_device_details(self, rpc_context, **kwargs):
     """Agent requests device details."""
     agent_id = kwargs.get('agent_id')
     device = kwargs.get('device')
     LOG.debug("Device %s details requested from %s", device, agent_id)
     port = self.get_port_from_device(device)
     if port:
         binding = db.get_network_binding(db_api.get_session(),
                                          port['network_id'])
         entry = {'device': device,
                  'physical_network': binding.physical_network,
                  'network_type': binding.network_type,
                  'vlan_id': binding.segmentation_id,
                  'network_id': port['network_id'],
                  'port_mac': port['mac_address'],
                  'port_id': port['id'],
                  'admin_state_up': port['admin_state_up']}
         # Set the port status to UP
         db.set_port_status(port['id'], q_const.PORT_STATUS_ACTIVE)
     else:
         entry = {'device': device}
         LOG.debug("%s can not be found in database", device)
     return entry
 def get_device_details(self, rpc_context, **kwargs):
     """Agent requests device details"""
     agent_id = kwargs.get("agent_id")
     device = kwargs.get("device")
     LOG.debug("Device %s details requested from %s", device, agent_id)
     port = self.get_port_from_device(device)
     if port:
         binding = db.get_network_binding(db_api.get_session(), port["network_id"])
         entry = {
             "device": device,
             "physical_network": binding.physical_network,
             "network_type": "vlan",
             "vlan_id": binding.segmentation_id,
             "network_id": port["network_id"],
             "port_mac": port["mac_address"],
             "port_id": port["id"],
             "admin_state_up": port["admin_state_up"],
         }
         # Set the port status to UP
         db.set_port_status(port["id"], q_const.PORT_STATUS_ACTIVE)
     else:
         entry = {"device": device}
         LOG.debug("%s can not be found in database", device)
     return entry