Ejemplo n.º 1
0
 def config_initialize():
     # Use the 'dell' backend for these tests
     cfg.add_section('general')
     cfg.set('general', 'driver', 'simple_vlan')
     cfg.add_section('vlan')
     cfg.set('vlan', 'vlans', vlan_list)
     cfg.add_section('driver simple_vlan')
     cfg.set('driver simple_vlan', 'switch',
             '{"name":"1", "switch":"test"}')
     cfg.set('driver simple_vlan', 'trunk_port', 'unused')
Ejemplo n.º 2
0
 def config_initialize():
     # Use the 'dell' backend for these tests
     cfg.add_section('general')
     cfg.set('general', 'driver', 'simple_vlan')
     cfg.add_section('vlan')
     cfg.set('vlan', 'vlans', vlan_list)
     cfg.add_section('driver simple_vlan')
     cfg.set('driver simple_vlan', 'switch',
             '{"name":"1", "switch":"test"}')
     cfg.set('driver simple_vlan', 'trunk_port', 'unused')
Ejemplo n.º 3
0
 def config_initialize():
     # Use the complex vlan driver for these tests
     cfg.add_section('general')
     cfg.set('general', 'driver', 'complex_vlan')
     cfg.add_section('vlan')
     cfg.set('vlan', 'vlans', vlan_list)
     cfg.add_section('driver complex_vlan')
     cfg.set('driver complex_vlan', 'switch', '[' \
                 '{"name":"0", "switch":"test"}, ' \
                 '{"name":"1", "switch":"test"}, ' \
                 '{"name":"2", "switch":"test"}]')
     cfg.set('driver complex_vlan', 'trunk_ports', '[]')
Ejemplo n.º 4
0
 def config_initialize():
     # Use the 'null' backend for these tests
     cfg.add_section('general')
     cfg.set('general', 'driver', 'null')
     cfg.add_section('devel')
     cfg.set('devel', 'dry_run', True)
     cfg.add_section('headnode')
     cfg.set('headnode', 'base_imgs', 'base-headnode, img1, img2, img3, img4')
Ejemplo n.º 5
0
 def config_initialize():
     # Use the complex vlan driver for these tests
     cfg.add_section("general")
     cfg.set("general", "driver", "complex_vlan")
     cfg.add_section("vlan")
     cfg.set("vlan", "vlans", vlan_list)
     cfg.add_section("driver complex_vlan")
     cfg.set(
         "driver complex_vlan",
         "switch",
         "["
         '{"name":"0", "switch":"test"}, '
         '{"name":"1", "switch":"test"}, '
         '{"name":"2", "switch":"test"}]',
     )
     cfg.set("driver complex_vlan", "trunk_ports", "[]")
Ejemplo n.º 6
0
 def config_initialize():
     # Use the 'null' backend for these tests
     cfg.add_section('general')
     cfg.set('general', 'driver', 'null')
     cfg.add_section('devel')
     cfg.set('devel', 'dry_run', True)
     cfg.add_section('headnode')
     cfg.set('headnode', 'base_imgs',
             'base-headnode, img1, img2, img3, img4')
Ejemplo n.º 7
0
def config_merge(config_dict):
    """Modify the configuration according to ``config_dict``.

    ``config_dict`` should be a dictionary mapping section names (strings)
    to dictionaries mapping option names within a section (again, strings)
    to their values. If the value of a section, or option is None, that
    section or option is removed. Otherwise, the section is created if it
    does not exist, and any options are set to the specified values.
    """
    for section in config_dict.keys():
        if config_dict[section] is None:
            print('remove section: %r' % section)
            cfg.remove_section(section)
        else:
            if not cfg.has_section(section):
                print('add section: %r' % section)
                cfg.add_section(section)
            for option in config_dict[section].keys():
                if config_dict[section][option] is None:
                    print('remove option: %r' % option)
                    cfg.remove_option(section, option)
                else:
                    print('set option: %r' % option)
                    cfg.set(section, option, config_dict[section][option])
Ejemplo n.º 8
0
def config_merge(config_dict):
    """Modify the configuration according to ``config_dict``.

    ``config_dict`` should be a dictionary mapping section names (strings)
    to dictionaries mapping option names within a section (again, strings)
    to their values. If the value of a section, or option is None, that
    section or option is removed. Otherwise, the section is created if it
    does not exist, and any options are set to the specified values.
    """
    for section in config_dict.keys():
        if config_dict[section] is None:
            print('remove section: %r' % section)
            cfg.remove_section(section)
        else:
            if not cfg.has_section(section):
                print('add section: %r' % section)
                cfg.add_section(section)
            for option in config_dict[section].keys():
                if config_dict[section][option] is None:
                    print('remove option: %r' % option)
                    cfg.remove_option(section, option)
                else:
                    print('set option: %r' % option)
                    cfg.set(section, option, config_dict[section][option])
Ejemplo n.º 9
0
def _dry(func):
    cfg.add_section('devel')
    cfg.set('devel', 'dry_run', True)
    func()
Ejemplo n.º 10
0
def _dry(func):
    cfg.add_section('devel')
    cfg.set('devel', 'dry_run', True)
    func()
Ejemplo n.º 11
0
 def config_initialize():
     # Use the 'dell' backend for these tests
     cfg.add_section('general')
     cfg.set('general', 'driver', 'null_vlan')
     cfg.add_section('vlan')
     cfg.set('vlan', 'vlans', vlan_list)