Esempio n. 1
0
    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)
Esempio n. 2
0
    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
Esempio n. 3
0
def create_p2n_driver():
    graph = py2neo.Graph("bolt://{}:{}@{}:7687".format(
        os.environ.get('neo4juser') or config.get('neo4j', 'user'),
        os.environ.get('neo4jpass') or config.get('neo4j', 'pass'),
        os.environ.get('neo4jhost') or config.get('neo4j', 'host')))
    return graph