Exemplo n.º 1
0
//!
//! Responsible for flushing any networking artifacts implemented by this
//! network driver.
//!
//! @param[in] pGni a pointer to the Global Network Information structure
//!
//! @return 0 on success or 1 if any failure occurred.
//!
//! @see
//!
//! @pre
//!     The driver must be initialized already
//!
//! @post
//!     On success, all networking mode artifacts will be flushed from the system. If any
//!     failure occurred. The system is left in a non-deterministic state and a subsequent
//!     call to this API may resolve the remaining issues.
//!
static int network_driver_system_flush(globalNetworkInfo *pGni)
{
    int rc = 0;
    int ret = 0;

    LOGINFO("Flushing '%s' network driver artifacts.\n", DRIVER_NAME());

    // Is our driver initialized?
    if (!IS_INITIALIZED()) {
        LOGERROR("Failed to flush the networking artifacts for '%s' network driver. Driver not initialized.\n", DRIVER_NAME());
        return (1);
    }

    //    if (PEER_IS_NC(eucanetdPeer)) {
        if (pMidoConfig) {
            if ((rc = do_midonet_teardown(pMidoConfig)) != 0) {
                ret = 1;
            } else {
                EUCA_FREE(pMidoConfig);
                pMidoConfig = NULL;
                gInitialized = FALSE;
            }
        }
        //    }

    return (0);
}
Exemplo n.º 2
0
//!
//! Responsible for flushing any networking artifacts implemented by this
//! network driver.
//!
//! @param[in] pGni a pointer to the Global Network Information structure
//!
//! @return 0 on success or 1 if any failure occurred.
//!
//! @see
//!
//! @pre
//!     The driver must be initialized already
//!
//! @post
//!     On success, all networking mode artifacts will be flushed from the system. If any
//!     failure occurred, the system is left in a non-deterministic state and a subsequent
//!     call to this API may resolve the remaining issues.
//!
static int network_driver_system_flush(globalNetworkInfo *pGni)
{
    int rc = 0;
    int ret = 0;

    // Is our driver initialized?
    if (!IS_INITIALIZED()) {
        LOGERROR("Failed to flush the networking artifacts for '%s' network driver. Driver not initialized.\n", DRIVER_NAME());
        return (1);
    }

    if (pMidoConfig->config->flushmode) {
        switch(pMidoConfig->config->flushmode) {
            case FLUSH_MIDO_DYNAMIC:
                LOGINFO("Flushing objects in MidoNet (keep the core intact)\n");
                rc = do_midonet_teardown(pMidoConfig);
                if (rc) {
                    ret = 1;
                }
                break;
            case FLUSH_MIDO_ALL:
                LOGINFO("Flush all objects in MidoNet\n");
                rc = do_midonet_teardown(pMidoConfig);
                if (rc) {
                    ret = 1;
                }
                break;
            case FLUSH_MIDO_CHECKDUPS:
                LOGINFO("Check for duplicate objects in MidoNet\n");
                rc = do_midonet_delete_dups(pMidoConfig, TRUE);
                if (rc) {
                    ret = 1;
                }
                break;
            case FLUSH_MIDO_DUPS:
                LOGINFO("Flush duplicate objects in MidoNet\n");
                rc = do_midonet_delete_dups(pMidoConfig, FALSE);
                if (rc) {
                    ret = 1;
                }
                break;
            case FLUSH_MIDO_CHECKUNCONNECTED:
                LOGINFO("Check for unconnected objects in MidoNet\n");
                rc = do_midonet_delete_vpc_object(pMidoConfig, "unconnected", TRUE);
                if (rc) {
                    ret = 1;
                }
                break;
            case FLUSH_MIDO_UNCONNECTED:
                LOGINFO("Flush unconnected objects in MidoNet\n");
                rc = do_midonet_delete_vpc_object(pMidoConfig, "unconnected", FALSE);
                if (rc) {
                    ret = 1;
                }
                break;
            case FLUSH_MIDO_CHECKVPC:
                LOGINFO("Check %s health in MidoNet\n", pMidoConfig->config->flushmodearg);
                rc = do_midonet_delete_vpc_object(pMidoConfig, pMidoConfig->config->flushmodearg, TRUE);
                if (rc) {
                    ret = 1;
                }
                break;
            case FLUSH_MIDO_VPC:
                rc = do_midonet_delete_vpc_object(pMidoConfig, pMidoConfig->config->flushmodearg, FALSE);
                if (rc) {
                    ret = 1;
                }
                break;
            case FLUSH_MIDO_LISTVPC:
                rc = do_midonet_delete_vpc_object(pMidoConfig, "list", TRUE);
                if (rc) {
                    ret = 1;
                }
                break;
            case FLUSH_MIDO_TEST:
                do_midonet_delete_vpc_object(pMidoConfig, "test", TRUE);
                break;
            case FLUSH_NONE:
            default:
                LOGERROR("check for eucanetd bug: should never reach this point.\n");
                break;                
        }
        free_mido_config(pMidoConfig);
        EUCA_FREE(pMidoConfig);
        pMidoConfig = NULL;
        gInitialized = FALSE;
    }

    return (ret);
}