def create_dhcp_port(self, port): """Make a remote process call to create the dhcp port.""" cctxt = self.client.prepare(version='1.1') port = cctxt.call(self.context, 'create_dhcp_port', port=port, host=self.host) if port: return dhcp.DictModel(port)
def get_dhcp_port(self, network_id, device_id): """Make a remote process call to get the dhcp port.""" cctxt = self.client.prepare() port = cctxt.call(self.context, 'get_dhcp_port', network_id=network_id, device_id=device_id, host=self.host) if port: return dhcp.DictModel(port)
def port_update_end(self, req=None, **kwargs): try: payload = json.loads(req.body) updated_port = dhcp.DictModel(payload) LOG.debug("updated_port:%s", updated_port) if updated_port: #self.pool.spawn(self._port_update, updated_port) self._port_update(updated_port) else: LOG.debug("updated_port is NULL") return 200, "SUCCESS" except Exception as err: LOG.error(err) raise Exception('Err: %s' % err)
def port_update_end(self, context, payload): """Handle the port.update.end notification event.""" updated_port = dhcp.DictModel(payload['port']) network = self.cache.get_network_by_id(updated_port.network_id) if network: driver_action = 'reload_allocations' if self._is_port_on_this_agent(updated_port): orig = self.cache.get_port_by_id(updated_port['id']) # assume IP change if not in cache old_ips = {i['ip_address'] for i in orig['fixed_ips'] or []} new_ips = {i['ip_address'] for i in updated_port['fixed_ips']} if old_ips != new_ips: driver_action = 'restart' self.cache.put_port(updated_port) self.call_driver(driver_action, network)