def test_001_check_default_master_node_credential_usage(self): """Check usage of default credentials on master node Target component: Configuration Scenario: 1. Check user can not ssh on master node with default credentials. Duration: 20 s. Available since release: 2014.2-6.1 """ ssh_client = SSHClient('localhost', self.config.master.master_node_ssh_user, self.config.master.master_node_ssh_password, timeout=self.config.master.ssh_timeout) cmd = "date" output = [] try: output = ssh_client.exec_command(cmd) LOG.debug(output) except exceptions.SSHExecCommandFailed: self.verify_response_true( len(output) == 0, 'Step 1 failed: Default credentials for ' 'ssh on master node were not changed') except exceptions.TimeoutException: self.verify_response_true( len(output) == 0, 'Step 1 failed: Default credentials for ' 'ssh on master node were not changed') except exc.SSHException: self.verify_response_true( len(output) == 0, 'Step 1 failed: Default credentials for ' 'ssh on master node were not changed') self.verify_response_true( len(output) == 0, 'Step 1 failed: Default credentials for ' 'ssh on master node were not changed')
def test_001_check_default_master_node_credential_usage(self): """Check usage of default credentials on master node Target component: Configuration Scenario: 1. Check user can not ssh on master node with default credentials. Duration: 20 s. Available since release: 2014.2-6.1 """ ssh_client = SSHClient('localhost', self.usr, self.pwd, timeout=self.timeout) cmd = "date" output = [] try: output = ssh_client.exec_command(cmd) LOG.debug(output) except exceptions.SSHExecCommandFailed: self.verify_response_true(len(output) == 0, 'Step 1 failed: Default credentials for ' 'ssh on master node were not changed') except exceptions.TimeoutException: self.verify_response_true(len(output) == 0, 'Step 1 failed: Default credentials for ' 'ssh on master node were not changed') except exc.SSHException: self.verify_response_true(len(output) == 0, 'Step 1 failed: Default credentials for ' 'ssh on master node were not changed') self.verify_response_true(len(output) == 0, 'Step 1 failed: Default credentials for ' 'ssh on master node were not changed')
def _run_ssh_cmd_with_exit_code(self, host, cmd): """Open SSH session with host and and execute command. Fail if exit code != 0 """ try: sshclient = SSHClient(host, self.usr, self.pwd, key_filename=self.key, timeout=self.timeout) return sshclient.exec_command(cmd) except Exception: LOG.debug(traceback.format_exc()) self.fail("%s command failed." % cmd)
def get_database_nodes(cls, controller_ip, username, key): # retrieve data from controller ssh_client = SSHClient(controller_ip, username, key_filename=key, timeout=100) hiera_cmd = 'ruby -e \'require "hiera"; ' 'puts Hiera.new().lookup("database_nodes", {}, {}).keys\'' database_nodes = ssh_client.exec_command(hiera_cmd) database_nodes = database_nodes.splitlines() # get online nodes databases = [] for node in cls.config.compute.nodes: hostname = node["hostname"] if hostname in database_nodes and node["online"]: databases.append(hostname) return databases
def get_database_nodes(cls, controller_ip, username, key): # retrieve data from controller ssh_client = SSHClient(controller_ip, username, key_filename=key, timeout=100) hiera_cmd = 'ruby -e \'require "hiera"; ' \ 'puts Hiera.new().lookup("database_nodes", {}, {}).keys\'' database_nodes = ssh_client.exec_command(hiera_cmd) database_nodes = database_nodes.splitlines() # get online nodes databases = [] for node in cls.config.compute.nodes: hostname = node['hostname'] if hostname in database_nodes and node['online']: databases.append(hostname) return databases
def get_database_nodes(cls, controller_ip, username, key): if version.StrictVersion(cls.release_version)\ < version.StrictVersion('7.0'): return cls.config.compute.online_controllers # retrieve data from controller ssh_client = SSHClient(controller_ip, username, key_filename=key, timeout=100) hiera_cmd = ('ruby -e \'require "hiera";' 'db = Hiera.new().lookup("database_nodes", {}, {}).keys;' 'if db != [] then puts db else puts "None" end\'') database_nodes = ssh_client.exec_command(hiera_cmd) # get online nodes database_nodes = database_nodes.splitlines() databases = [] for node in cls.config.compute.nodes: hostname = node['hostname'] if hostname in database_nodes and node['online']: databases.append(hostname) return databases