Exemplo n.º 1
0
    def test_log_ip_ns_debug_enabled(self):
        self.useFixture(mockpatch.PatchObject(test.CONF.debug,
                                              'enable', True))

        self.ip_ns_list_mock.return_value = [1, 2]

        debug.log_ip_ns()
        self.ip_addr_raw_mock.assert_called_with()
        self.assertTrue(self.log_mock.info.called)
        self.ip_route_raw_mock.assert_called_with()
        self.assertEqual(len(debug.TABLES), self.iptables_raw_mock.call_count)
        for table in debug.TABLES:
            self.assertIn(mock.call(table),
                          self.iptables_raw_mock.call_args_list)

        self.ip_ns_list_mock.assert_called_with()
        self.assertEqual(len(self.ip_ns_list_mock.return_value),
                         self.ip_ns_addr_mock.call_count)
        self.assertEqual(len(self.ip_ns_list_mock.return_value),
                         self.ip_ns_route_mock.call_count)
        for ns in self.ip_ns_list_mock.return_value:
            self.assertIn(mock.call(ns),
                          self.ip_ns_addr_mock.call_args_list)
            self.assertIn(mock.call(ns),
                          self.ip_ns_route_mock.call_args_list)

        self.assertEqual(len(debug.TABLES) *
                         len(self.ip_ns_list_mock.return_value),
                         self.iptables_ns_mock.call_count)
        for ns in self.ip_ns_list_mock.return_value:
            for table in debug.TABLES:
                self.assertIn(mock.call(ns, table),
                              self.iptables_ns_mock.call_args_list)
Exemplo n.º 2
0
 def _check_public_network_connectivity(self,
                                        should_connect=True,
                                        msg=None):
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     ssh_login = CONF.compute.image_ssh_user
     LOG.debug('checking network connections')
     try:
         for floating_ip, server in self.floating_ips.iteritems():
             ip_address = floating_ip.floating_ip_address
             private_key = None
             if should_connect:
                 private_key = self.servers[server].private_key
             self._check_vm_connectivity(ip_address,
                                         ssh_login,
                                         private_key,
                                         should_connect=should_connect)
     except Exception:
         ex_msg = 'Public network connectivity check failed'
         if msg:
             ex_msg += ": " + msg
         LOG.exception(ex_msg)
         self._log_console_output(servers=self.servers.keys())
         debug.log_ip_ns()
         raise
Exemplo n.º 3
0
 def ssh_to_server(self):
     try:
         self.linux_client = self.get_remote_client(self.floating_ip.ip)
         self.linux_client.validate_authentication()
     except Exception:
         LOG.exception("ssh to server failed")
         self._log_console_output()
         debug.log_ip_ns()
         raise
Exemplo n.º 4
0
 def ssh_to_server(self):
     try:
         self.linux_client = self.get_remote_client(self.floating_ip.ip)
         self.linux_client.validate_authentication()
     except Exception:
         LOG.exception('ssh to server failed')
         self._log_console_output()
         debug.log_ip_ns()
         raise
Exemplo n.º 5
0
 def _do_test_vm_connectivity_admin_state_up(self):
     must_fail = False
     try:
         self._check_public_network_connectivity()
     except Exception as exc:
         must_fail = True
         LOG.exception(exc)
         debug.log_ip_ns()
     finally:
         self.assertEqual(must_fail, True, "No connection to VM")
 def _check_connectivity(self, access_point, ip, should_succeed=True):
     if should_succeed:
         msg = "Timed out waiting for %s to become reachable" % ip
     else:
         # todo(yfried): remove this line when bug 1252620 is fixed
         return True
         msg = "%s is reachable" % ip
     try:
         self.assertTrue(self._test_remote_connectivity(access_point, ip, should_succeed), msg)
     except Exception:
         debug.log_ip_ns()
         raise
Exemplo n.º 7
0
 def _check_public_network_connectivity(self):
     ssh_login = self.config.compute.image_ssh_user
     private_key = self.keypairs[self.tenant_id].private_key
     try:
         for server, floating_ips in self.floating_ips.iteritems():
             for floating_ip in floating_ips:
                 ip_address = floating_ip.floating_ip_address
                 self._check_vm_connectivity(ip_address, ssh_login, private_key)
     except Exception as exc:
         LOG.exception(exc)
         debug.log_ip_ns()
         raise exc
 def _check_public_network_connectivity(self, floating_ip,
                                        username,
                                        private_key,
                                        should_connect=True):
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     try:
         self._check_vm_connectivity(floating_ip, username, private_key,
                                     should_connect=should_connect)
     except Exception:
         LOG.exception("Public network connectivity check failed")
         debug.log_ip_ns()
         raise
 def _check_public_network_connectivity(self, floating_ip,
                                        username,
                                        private_key,
                                        should_connect=True):
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     try:
         self._check_vm_connectivity(floating_ip, username, private_key,
                                     should_connect=should_connect)
     except Exception:
         LOG.exception("Public network connectivity check failed")
         debug.log_ip_ns()
         raise
 def _check_connectivity(self, access_point, ip, should_succeed=True):
     if should_succeed:
         msg = "Timed out waiting for %s to become reachable" % ip
     else:
         # todo(yfried): remove this line when bug 1252620 is fixed
         return True
         msg = "%s is reachable" % ip
     try:
         self.assertTrue(
             self._test_remote_connectivity(access_point, ip,
                                            should_succeed), msg)
     except Exception:
         debug.log_ip_ns()
         raise
Exemplo n.º 11
0
 def _check_public_network_connectivity(self):
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     ssh_login = self.config.compute.image_ssh_user
     private_key = self.keypairs[self.tenant_id].private_key
     try:
         for server, floating_ips in self.floating_ips.iteritems():
             for floating_ip in floating_ips:
                 ip_address = floating_ip.floating_ip_address
                 self._check_vm_connectivity(ip_address, ssh_login,
                                             private_key)
     except Exception as exc:
         LOG.exception(exc)
         debug.log_ip_ns()
         raise exc
 def _check_public_network_connectivity(self):
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     ssh_login = self.config.compute.image_ssh_user
     private_key = self.keypairs[self.tenant_id].private_key
     try:
         for server, floating_ips in self.floating_ips.iteritems():
             for floating_ip in floating_ips:
                 ip_address = floating_ip.floating_ip_address
                 self._check_vm_connectivity(ip_address,
                                             ssh_login,
                                             private_key)
     except Exception as exc:
         LOG.exception(exc)
         debug.log_ip_ns()
         raise exc
Exemplo n.º 13
0
    def _check_server_connectivity(self, floating_ip, address_list):
        ip_address = floating_ip.floating_ip_address
        private_key = self.servers[self.floating_ip_tuple.server].private_key
        ssh_source = self._ssh_to_server(ip_address, private_key)

        for remote_ip in address_list:
            try:
                self.assertTrue(self._check_remote_connectivity(ssh_source,
                                                                remote_ip),
                                "Timed out waiting for %s to become "
                                "reachable" % remote_ip)
            except Exception:
                LOG.exception("Unable to access {dest} via ssh to "
                              "floating-ip {src}".format(dest=remote_ip,
                                                         src=floating_ip))
                debug.log_ip_ns()
                raise
Exemplo n.º 14
0
    def _check_server_connectivity(self, floating_ip, address_list):
        ip_address = floating_ip.floating_ip_address
        private_key = self._get_server_key(self.floating_ip_tuple.server)
        ssh_source = self._ssh_to_server(ip_address, private_key)

        for remote_ip in address_list:
            try:
                self.assertTrue(
                    self._check_remote_connectivity(ssh_source, remote_ip),
                    "Timed out waiting for %s to become "
                    "reachable" % remote_ip)
            except Exception:
                LOG.exception("Unable to access {dest} via ssh to "
                              "floating-ip {src}".format(dest=remote_ip,
                                                         src=floating_ip))
                debug.log_ip_ns()
                raise
Exemplo n.º 15
0
 def _check_tenant_network_connectivity(self):
     if not self.config.network.tenant_networks_reachable:
         msg = 'Tenant networks not configured to be reachable.'
         LOG.info(msg)
         return
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     ssh_login = self.config.compute.image_ssh_user
     try:
         for server, key in self.servers.items():
             for net_name, ip_addresses in server.networks.iteritems():
                 for ip_address in ip_addresses:
                     self._check_vm_connectivity(ip_address, ssh_login,
                                                 key.private_key)
     except Exception as exc:
         LOG.exception(exc)
         debug.log_ip_ns()
         raise exc
Exemplo n.º 16
0
 def _check_public_network_connectivity(self, should_connect=True):
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     ssh_login = self.config.compute.image_ssh_user
     try:
         for floating_ip, server in self.floating_ips.iteritems():
             ip_address = floating_ip.floating_ip_address
             private_key = None
             if should_connect:
                 private_key = self.servers[server].private_key
             self._check_vm_connectivity(ip_address,
                                         ssh_login,
                                         private_key,
                                         should_connect=should_connect)
     except Exception as exc:
         LOG.exception(exc)
         debug.log_ip_ns()
         raise exc
Exemplo n.º 17
0
 def _check_tenant_network_connectivity(self):
     if not CONF.network.tenant_networks_reachable:
         msg = 'Tenant networks not configured to be reachable.'
         LOG.info(msg)
         return
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     ssh_login = CONF.compute.image_ssh_user
     try:
         for server, key in self.servers.iteritems():
             for net_name, ip_addresses in server.networks.iteritems():
                 for ip_address in ip_addresses:
                     self._check_vm_connectivity(ip_address, ssh_login,
                                                 key.private_key)
     except Exception:
         LOG.exception('Tenant connectivity check failed')
         self._log_console_output(servers=self.servers.keys())
         debug.log_ip_ns()
         raise
Exemplo n.º 18
0
 def _check_public_network_connectivity(self, should_connect=True):
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     ssh_login = CONF.compute.image_ssh_user
     LOG.debug('checking network connections')
     try:
         for floating_ip, server in self.floating_ips.iteritems():
             ip_address = floating_ip.floating_ip_address
             private_key = None
             if should_connect:
                 private_key = self.servers[server].private_key
             self._check_vm_connectivity(ip_address,
                                         ssh_login,
                                         private_key,
                                         should_connect=should_connect)
     except Exception:
         LOG.exception('Public network connectivity check failed')
         self._log_console_output(servers=self.servers.keys())
         debug.log_ip_ns()
         raise
 def _check_tenant_network_connectivity(self, server,
                                        username,
                                        private_key,
                                        should_connect=True):
     if not CONF.network.tenant_networks_reachable:
         msg = 'Tenant networks not configured to be reachable.'
         LOG.info(msg)
         return
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     try:
         for net_name, ip_addresses in server.networks.iteritems():
             for ip_address in ip_addresses:
                 self._check_vm_connectivity(ip_address,
                                             username,
                                             private_key,
                                             should_connect=should_connect)
     except Exception:
         LOG.exception('Tenant network connectivity check failed')
         self._log_console_output(servers=[server])
         debug.log_ip_ns()
         raise
 def _check_tenant_network_connectivity(self, server,
                                        username,
                                        private_key,
                                        should_connect=True):
     if not CONF.network.tenant_networks_reachable:
         msg = 'Tenant networks not configured to be reachable.'
         LOG.info(msg)
         return
     # The target login is assumed to have been configured for
     # key-based authentication by cloud-init.
     try:
         for net_name, ip_addresses in server.networks.iteritems():
             for ip_address in ip_addresses:
                 self._check_vm_connectivity(ip_address,
                                             username,
                                             private_key,
                                             should_connect=should_connect)
     except Exception:
         LOG.exception('Tenant network connectivity check failed')
         self._log_console_output(servers=[server])
         debug.log_ip_ns()
         raise
Exemplo n.º 21
0
 def test_log_ip_ns_debug_disabled(self):
     self.useFixture(mockpatch.PatchObject(test.CONF.debug,
                                           'enable', False))
     debug.log_ip_ns()
     self.assertFalse(self.ip_addr_raw_mock.called)
     self.assertFalse(self.log_mock.info.called)