def isl_discovery_failed(self): """ :return: Ideally, this should return true IFF discovery is deleted or deactivated. """ path = self.payload['path'] switch_id = path[0]['switch_id'] port = int(path[0]['port_no']) effective_policy = config.get("isl_failover_policy", "effective_policy") logger.info('Isl failure: %s_%d -- apply policy %s: timestamp=%s', switch_id, port, effective_policy, self.timestamp) is_moved = self.payload['state'] == 'MOVED' try: with graph.begin() as tx: updated = isl_utils.disable_by_endpoint( tx, model.NetworkEndpoint(switch_id, port), is_moved) updated.sort(key=lambda x: (x.source, x.dest)) for isl in updated: # we can get multiple records for one port # but will use lifecycle data from first one life_cycle = isl_utils.get_life_cycle_fields(tx, isl) self.update_payload_lifecycle(life_cycle) break except exc.DBRecordNotFound: logger.error('There is no ISL on %s_%s', switch_id, port)
def isl_discovery_failed(self): """ :return: Ideally, this should return true IFF discovery is deleted or deactivated. """ path = self.payload['path'] switch_id = path[0]['switch_id'] port = int(path[0]['port_no']) effective_policy = config.get("isl_failover_policy", "effective_policy") logger.info('Isl failure: %s_%d -- apply policy %s: timestamp=%s', switch_id, port, effective_policy, self.timestamp) is_moved = self.payload['state'] == 'MOVED' try: with graph.begin() as tx: isl_utils.disable_by_endpoint( tx, model.NetworkEndpoint(switch_id, port), is_moved) except exc.DBRecordNotFound: logger.error('There is no ISL on %s_%s', switch_id, port) return True
def port_down(self): switch_id = self.payload['switch_id'] port_id = int(self.payload['port_no']) logger.info('Port %s_%d deletion request: timestamp=%s', switch_id, port_id, self.timestamp) try: with graph.begin() as tx: for isl in isl_utils.disable_by_endpoint( tx, model.NetworkEndpoint(switch_id, port_id)): # TODO(crimi): should be policy / toggle based isl_utils.set_cost(tx, isl, config.ISL_COST_WHEN_PORT_DOWN) isl_utils.set_cost(tx, isl.reversed(), config.ISL_COST_WHEN_PORT_DOWN) except exc.DBRecordNotFound: logger.info("There is no ISL on %s_%s", switch_id, port_id)