- client.scp(script_abs_path, script_name)
- cmd = 'sudo python %s' % script_name
- ret, output = client.ssh(cmd)
- if ret:
- raise Exception('Do the command in controller'
- ' node failed, ret=%s, cmd=%s, output=%s'
- % (ret, cmd, output))
- client.ssh(restart_cmd)
+ ret, output = client.ssh(command, raise_enabled=False)
+ self.log.info('return %s' % ret)
+ if ret == 0:
+ ret = True
+ else:
+ ret = False
+ return ret
+
+ @utils.run_async
+ def _run_apply_patches(self, client, restart_cmd, script_names,
+ python='python3'):
+ installer_dir = os.path.dirname(os.path.realpath(__file__))
+ if isinstance(script_names, list):
+ for script_name in script_names:
+ script_abs_path = '{0}/{1}/{2}'.format(installer_dir,
+ 'common', script_name)
+ if self.conf.installer.type == "devstack":
+ script_name = "/opt/stack/%s" % script_name
+ try:
+ client.scp(script_abs_path, script_name)
+ except Exception:
+ client.scp(script_abs_path, script_name)
+ try:
+ if ".py" in script_name:
+ cmd = 'sudo %s %s' % (python, script_name)
+ else:
+ cmd = 'sudo chmod 700 %s;sudo ./%s' % (script_name,
+ script_name)
+ ret, output = client.ssh(cmd)
+ self.log.info('Command %s output %s' % (cmd, output))
+ except Exception:
+ ret, output = client.ssh(cmd)
+ self.log.info('Command %s output %s' % (cmd, output))
+ if ret:
+ raise Exception('Do the command in remote'
+ ' node failed, ret=%s, cmd=%s, output=%s'
+ % (ret, cmd, output))
+ if 'nova' in restart_cmd or 'devstack@n-' in restart_cmd:
+ # Make sure scheduler has proper cpu_allocation_ratio
+ time.sleep(5)
+ client.ssh(restart_cmd)