Esempio n. 1
0
 def test_explicit_ssh_transport(self):
     """Assert it is possible to explicitly ask for a "ssh" transport."""
     system = cli.System(hostname=utils.uuid4(), transport="ssh")
     with mock.patch(
             "camayoc.cli.plumbum.machines.SshMachine") as SshMachine:
         machine = mock.Mock()
         SshMachine.return_value = machine
         self.assertIs(cli.Client(system).machine, machine)
Esempio n. 2
0
def wait_until_live(servers, timeout=360):
    """Wait for servers to be live.

    For each server in the "servers" list, verify if it is reachable.
    Keep trying until a connection is made for all servers or the timeout
    limit is reached.

    If the timeout limit is reached, we exit even if there are unreached hosts.
    This means tests could fail with "No auths valid for this profile" if every
    host in the profile is unreachable. Otherwise, if there is at least one
    valid host, the scan will go on and only facts about reached hosts will be
    tested.

    `See rho issue #302 <https://github.com/quipucords/rho/issues/302>`_
    """
    system = cli.System(hostname="localhost", transport="local")
    client = cli.Client(system)

    unreached = servers
    while unreached and timeout > 0:
        unreached = [host for host in unreached if not is_live(client, host)]
        time.sleep(10)
        timeout -= 10
Esempio n. 3
0
 def test_implicit_local_transport(self):
     """Assert it is possible to implicitly ask for a "local" transport."""
     system = cli.System(hostname=socket.getfqdn(), transport=None)
     self.assertIsInstance(cli.Client(system).machine, LocalMachine)
Esempio n. 4
0
 def test_explicit_local_transport(self):
     """Assert it is possible to explicitly ask for a "local" transport."""
     system = cli.System(hostname=utils.uuid4(), transport="local")
     self.assertIsInstance(cli.Client(system).machine, LocalMachine)
Esempio n. 5
0
 def test_explicit_response_handler(self):
     """Assert it is possible to explicitly set a response handler."""
     system = cli.System(hostname=utils.uuid4(), transport="local")
     handler = mock.Mock()
     self.assertIs(cli.Client(system, handler).response_handler, handler)
Esempio n. 6
0
 def test_default_response_handler(self):
     """Assert the default response handler checks return codes."""
     system = cli.System(hostname=utils.uuid4(), transport="local")
     self.assertIs(cli.Client(system).response_handler, cli.code_handler)