Beispiel #1
0
    def test_tcp_ping_(self, sock):
        s = mock.Mock()
        settimeout = mock.Mock()
        connect = mock.Mock()
        close = mock.Mock()
        s.configure_mock(settimeout=settimeout, connect=connect, close=close)
        sock.return_value = s

        host = '127.0.0.1'
        port = 65535
        timeout = 1

        helpers.tcp_ping_(host, port)
        sock.assert_called_once()
        settimeout.assert_not_called()
        connect.assert_called_once_with((str(host), int(port)))
        close.assert_called_once()

        sock.reset_mock()
        s.reset_mock()
        settimeout.reset_mock()
        close.reset_mock()
        connect.reset_mock()

        helpers.tcp_ping_(host, port, timeout)
        sock.assert_called_once()
        settimeout.assert_called_once_with(timeout)
        connect.assert_called_once_with((str(host), int(port)))
        close.assert_called_once()
Beispiel #2
0
    def test_tcp_ping_(self, sock):
        s = mock.Mock()
        settimeout = mock.Mock()
        connect = mock.Mock()
        close = mock.Mock()
        s.configure_mock(
            settimeout=settimeout, connect=connect, close=close)
        sock.return_value = s

        host = '127.0.0.1'
        port = 65535
        timeout = 1

        helpers.tcp_ping_(host, port)
        sock.assert_called_once()
        settimeout.assert_not_called()
        connect.assert_called_once_with((str(host), int(port)))
        close.assert_called_once()

        sock.reset_mock()
        s.reset_mock()
        settimeout.reset_mock()
        close.reset_mock()
        connect.reset_mock()

        helpers.tcp_ping_(host, port, timeout)
        sock.assert_called_once()
        settimeout.assert_called_once_with(timeout)
        connect.assert_called_once_with((str(host), int(port)))
        close.assert_called_once()
 def check_ssh_connection():
     """Try to close fuelmenu and check ssh connection"""
     try:
         tcp_ping_(self.d_env.nodes().admin.get_ip_address_by_network_name(self.d_env.admin_net), 22)
     except Exception:
         #  send F8 trying to exit fuelmenu
         self.d_env.nodes().admin.send_keys("<F8>\n")
         return False
     return True
Beispiel #4
0
 def check_ssh_connection():
     """Try to close fuelmenu and check ssh connection"""
     try:
         tcp_ping_(
             self.d_env.nodes().admin.get_ip_address_by_network_name(
                 'admin'), 22)
     except Exception:
         #  send F8 trying to exit fuelmenu
         self.d_env.nodes().admin.send_keys("<F8>\n")
         return False
     return True
Beispiel #5
0
 def wait_for_provisioning(self,
                           timeout=settings.WAIT_FOR_PROVISIONING_TIMEOUT):
     # TODO(astudenov): add timeout_msg
     wait_pass(lambda: tcp_ping_(
         self.d_env.nodes(
         ).admin.get_ip_address_by_network_name
         ('admin'), 22), timeout=timeout)
 def wait_for_provisioning(self,
                           timeout=settings.WAIT_FOR_PROVISIONING_TIMEOUT):
     # TODO(astudenov): add timeout_msg
     wait_pass(lambda: tcp_ping_(
         self.d_env.nodes(
         ).admin.get_ip_address_by_network_name
         ('admin'), 22), timeout=timeout)
Beispiel #7
0
        interface = self.get_interface_by_nailgun_network_name(name)
        return interface.address_set.first().ip_address

    def remote(self, network_name, login, password=None, private_keys=None):
        """Create SSH-connection to the network

        :rtype : SSHClient
        """
        return SSHClient(
            self.get_ip_address_by_network_name(network_name),
            username=login,
            password=password, private_keys=private_keys)

    def await(self, network_name, timeout=120, by_port=22):
        wait_pass(
            lambda: tcp_ping_(
                self.get_ip_address_by_network_name(network_name), by_port),
            timeout=timeout)

    # NEW
    def add_interfaces(self, interfaces):
        for interface in interfaces:
            label = interface['label']
            l2_network_device_name = interface.get('l2_network_device')
            interface_model = interface.get('interface_model')
            self.add_interface(
                label=label,
                l2_network_device_name=l2_network_device_name,
                interface_model=interface_model)

    # NEW
    def add_interface(self, label, l2_network_device_name, interface_model):
Beispiel #8
0
 def await (self, network_name, timeout=120, by_port=22):
     wait_pass(lambda: tcp_ping_(
         self.get_ip_address_by_network_name(network_name), by_port),
               timeout=timeout)