Beispiel #1
0
 def setup_class(cls):
     ConnectionPluginRegister.deregister_all()
     ConnectionPluginRegister.register("dummy", DummyConnectionPlugin)
     ConnectionPluginRegister.register("dummy2", DummyConnectionPlugin)
     ConnectionPluginRegister.register("dummy_no_overrides",
                                       DummyConnectionPlugin)
     ConnectionPluginRegister.register(FailedConnectionPlugin.name,
                                       FailedConnectionPlugin)
Beispiel #2
0
def default_nr_init(pytester):
    """Create initial Nornir files and expose the location
    as nornir_config_file fixture."""
    hosts_path = pytester.path / f"hosts{YAML_EXTENSION}"
    config = f"""inventory:
                          plugin: SimpleInventory
                          options:
                              host_file: {hosts_path}"""
    arguments = {
        "nr-config": config,
        "hosts": """
            R1:
              hostname: 1.1.1.1
            R2:
              hostname: 2.2.2.2
            R3:
              hostname: 3.3.3.3
            L1:
              hostname: 11.11.11.11
            L2:
              hostname: 22.22.22.22
            S1:
              hostname: 111.111.111.111
            S2:
              hostname: 222.222.222.222""",
    }
    pytester.makefile(YAML_EXTENSION, **arguments)

    # We need to have the test tmpdir in sys.path, so NUTS can import the test
    # modules (e.g. basic_task.py).
    pytester.syspathinsert()

    yield

    # Cleanup Nornir's PluginRegisters.
    # This is necessary as InitNornir is initiated for every test case, but the
    # PluginRegisters are (somehow) shared. This results in a
    # PluginAlreadyRegistered Exception as the plugins are registered multiple
    # times.
    ConnectionPluginRegister.deregister_all()
    InventoryPluginRegister.deregister_all()
    RunnersPluginRegister.deregister_all()
Beispiel #3
0
 def test_deregister_all(self):
     ConnectionPluginRegister.deregister_all()
     assert ConnectionPluginRegister.available == {}
Beispiel #4
0
 def teardown_method(self, method):
     ConnectionPluginRegister.deregister_all()
     ConnectionPluginRegister.auto_register()
Beispiel #5
0
 def setup_method(self, method):
     ConnectionPluginRegister.deregister_all()
     ConnectionPluginRegister.register("dummy", DummyConnectionPlugin)
     ConnectionPluginRegister.register("another_dummy",
                                       AnotherDummyConnectionPlugin)