- self.log.info('Get SSH keys from Apex installer......')
-
- if self.key_file is not None:
- self.log.info('Already have SSH keys from Apex installer......')
- return self.key_file
-
- ssh_key = '{0}/{1}'.format(self.test_dir, 'instack_key')
- self.client.scp('/home/stack/.ssh/id_rsa', ssh_key, method='get')
- user = getpass.getuser()
- uid = pwd.getpwnam(user).pw_uid
- gid = grp.getgrnam(user).gr_gid
- os.chown(ssh_key, uid, gid)
- os.chmod(ssh_key, stat.S_IREAD)
- self.key_file = ssh_key
- return self.key_file
-
- def get_controller_ips(self):
- self.log.info('Get controller ips from Apex installer......')
-
- command = "source stackrc; " \
- "nova list | grep ' overcloud-controller-[0-9] ' " \
- "| sed -e 's/^.*ctlplane=//' |awk '{print $1}'"
- ret, controllers = self.client.ssh(command)
- if ret:
- raise Exception('Exec command to get controller ips'
- 'in Apex installer failed, ret=%s, output=%s'
- % (ret, controllers))
- self.log.info('Get controller_ips:%s from Apex installer'
- % controllers)
- self.controllers = controllers
+ key_path = '/home/stack/.ssh/id_rsa'
+ return self._get_ssh_key(self.client, key_path)
+
+ def _get_and_set_ips(self):
+ self.log.info('Get controller and compute ips from Apex installer'
+ '......')
+
+ command = "source stackrc; nova list | grep ' overcloud-'"
+ raw_ips_list = self._run_cmd_remote(self.client, command)
+ for line in raw_ips_list:
+ ip = line.split('ctlplane=', 1)[1].split(" ", 1)[0]
+ if 'overcloud-controller-' in line:
+ self.controllers.append(ip)
+ elif 'overcloud-novacompute-' in line:
+ self.computes.append(ip)
+ self.log.info('controller_ips:%s' % self.controllers)
+ self.log.info('compute_ips:%s' % self.computes)