Exemplo n.º 1
0
def _configure(nets, bonds, running_config, save_init_config=True):
    initial_config = deepcopy(running_config)

    commands = prepare_ovs(nets, bonds, running_config)
    libvirt_create, libvirt_remove = prepare_libvirt(nets, running_config)

    if save_init_config:
        log('Saving initial configuration for optional rollback: %s' %
            initial_config)
        _save_init_config(initial_config)

    remove_libvirt_nets(libvirt_remove)
    configure_ovs(commands, running_config)
    configure_mtu(running_config)
    configure_ip(nets, initial_config.networks, bonds, initial_config.bonds)
    _set_devices_up(nets, bonds)

    log('Saving running configuration: %s %s' % (running_config.networks,
                                                 running_config.bonds))
    running_config.save()

    # we have to create libvirt nets last. when an exception occurs, rollback
    # will find created libvirt networks in running config and will be able to
    # remove them
    create_libvirt_nets(libvirt_create)
Exemplo n.º 2
0
def _configure(nets, bonds, running_config, save_init_config=True):
    initial_config = deepcopy(running_config)

    commands = prepare_ovs(nets, bonds, running_config)
    libvirt_create, libvirt_remove = prepare_libvirt(nets, running_config)

    if save_init_config:
        log('Saving initial configuration for optional rollback: %s' %
            initial_config)
        _save_init_config(initial_config)

    remove_libvirt_nets(libvirt_remove)
    configure_ovs(commands, running_config)
    configure_mtu(running_config)
    configure_ip(nets, initial_config.networks, bonds, initial_config.bonds)
    _set_devices_up(nets, bonds)

    log('Saving running configuration: %s %s' %
        (running_config.networks, running_config.bonds))
    running_config.save()

    # we have to create libvirt nets last. when an exception occurs, rollback
    # will find created libvirt networks in running config and will be able to
    # remove them
    create_libvirt_nets(libvirt_create)
Exemplo n.º 3
0
def configure(nets, bonds, running_config, in_rollback):
    initial_config = deepcopy(running_config)

    commands, libvirt_create, libvirt_remove = prepare_ovs(
        nets, bonds, running_config)
    with _rollback(running_config, initial_config, in_rollback):
        configure_ovs(commands, libvirt_create, libvirt_remove, running_config)
        configure_mtu(running_config)
        configure_ip(nets, initial_config.networks)

    hooking.log('Saving running configuration: %s %s' %
                (running_config.networks, running_config.bonds))
    running_config.save()