コード例 #1
0
static void
ind_soc_cfg_commit(void)
{
    aim_log_t *lobj;

    if ((lobj = aim_log_find("socketmanager")) == NULL) {
        AIM_DIE("Could not find log module");
    } else {
        lobj->common_flags = staged_config.log_flags;
    }
}
コード例 #2
0
static void
ind_cxn_cfg_commit(void)
{
    aim_log_t *lobj;
    int i;

    if ((lobj = aim_log_find("ofconnectionmanager")) == NULL) {
        AIM_LOG_WARN("Could not find log module");
    } else {
        lobj->common_flags = staged_config.log_flags;
    }

    for (i = 0; i < staged_config.num_controllers; i++) {
        struct controller *c = &staged_config.controllers[i];
        const struct controller *old_controller;
        int rv;
        indigo_cxn_params_tcp_over_ipv4_t *proto = &c->proto.tcp_over_ipv4;
        AIM_LOG_INFO("controller %d: %s:%hu", i,
                     proto->controller_ip, proto->controller_port);

        /* Keep existing connections to the same controller. */
        if ((old_controller = find_controller(&current_config, &c->proto))) {
            c->cxn_id = old_controller->cxn_id;
            /* TODO apply keepalive_period to existing connection. */
            continue;
        }

        rv = indigo_cxn_connection_add(&c->proto, &c->config, &c->cxn_id);
        if (rv != 0) {
            AIM_LOG_ERROR("failed to add controller connection %d: %s:%u",
                          i, proto->controller_ip, proto->controller_port);
        }
    }

    /* Remove connections that don't exist in the new configuration. */
    for (i = 0; i < current_config.num_controllers; i++) {
        const struct controller *c = &current_config.controllers[i];
        if (!find_controller(&staged_config, &c->proto)) {
            (void) indigo_cxn_connection_remove(c->cxn_id);
        }
    }

    /* Save config so we can diff the controllers next time */
    current_config = staged_config;
}
コード例 #3
0
static void
ind_core_cfg_commit(void)
{
    aim_log_t *lobj;

    if ((lobj = aim_log_find("ofstatemanager")) == NULL) {
        AIM_LOG_INTERNAL("Could not find log module");
    } else {
        lobj->common_flags = staged_config.log_flags;
    }

    /* Set whether or not changed */
    (void)ind_core_hw_desc_set(staged_config.hw_desc);
    (void)ind_core_sw_desc_set(staged_config.sw_desc);
    (void)ind_core_dp_desc_set(staged_config.dp_desc);
    (void)ind_core_mfr_desc_set(staged_config.mfr_desc);
    (void)ind_core_serial_num_set(staged_config.serial_num);
    (void)indigo_core_dpid_set(staged_config.dpid);
}
コード例 #4
0
static void
ind_cxn_cfg_commit(void)
{
    aim_log_t *lobj;
    int i, enable;

    if (staged_config.valid != true)
        return;

    /* Commit config only if connection manager is enabled. */
    (void) ind_cxn_enable_get(&enable);
    if (!enable)
        return;

    if ((lobj = aim_log_find("ofconnectionmanager")) == NULL) {
        AIM_LOG_WARN("Could not find log module");
    } else {
        lobj->common_flags = staged_config.log_flags;
    }

    /* configure TLS before parsing controller configs */
    (void) indigo_cxn_config_tls(staged_config.cipher_list,
                                 staged_config.ca_cert,
                                 staged_config.switch_cert,
                                 staged_config.switch_priv_key,
                                 staged_config.exp_controller_suffix);

    for (i = 0; i < staged_config.num_controllers; i++) {
        struct controller *c = &staged_config.controllers[i];
        const struct controller *old_controller;
        int rv;
        char desc[256];

        ind_cxn_proto_ip_string(&c->proto, desc, sizeof(desc));
        AIM_LOG_INFO("controller %d: %s", i, desc);

        /* Keep existing connections to the same controller. */
        if ((old_controller = find_controller(&current_config, &c->proto))) {
            c->controller_id = old_controller->controller_id;
            /* TODO apply keepalive_period to existing connection. */
            continue;
        }

        rv = indigo_controller_add(&c->proto, &c->config, &c->controller_id);
        if (rv != 0) {
            AIM_LOG_ERROR("failed to add controller connection %d: %s",
                          i, desc);
        }
    }

    /* Remove controller's that don't exist in the new configuration. */
    for (i = 0; i < current_config.num_controllers; i++) {
        const struct controller *c = &current_config.controllers[i];
        if (!find_controller(&staged_config, &c->proto)) {
            (void) indigo_controller_remove(c->controller_id);
        }
    }

    /* Save config so we can diff the controllers next time */
    current_config = staged_config;
    staged_config.valid = false;
}