本文整理汇总了Python中fuelweb_test.helpers.ssh_manager.SSHManager.execute_on_remote方法的典型用法代码示例。如果您正苦于以下问题:Python SSHManager.execute_on_remote方法的具体用法?Python SSHManager.execute_on_remote怎么用?Python SSHManager.execute_on_remote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fuelweb_test.helpers.ssh_manager.SSHManager
的用法示例。
在下文中一共展示了SSHManager.execute_on_remote方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _turnoff_executable_ruby
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def _turnoff_executable_ruby(node):
"""Set mode -x for /usr/bin/ruby
:param node: dict, node attributes
"""
ssh = SSHManager()
cmd = 'chmod -x /usr/bin/ruby'
ssh.execute_on_remote(node['ip'], cmd)
示例2: _turnon_executable_ruby
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def _turnon_executable_ruby(node):
"""Set mode +x for /usr/bin/ruby
:param node: dict, node attributes
"""
ssh = SSHManager()
cmd = "chmod +x /usr/bin/ruby"
ssh.execute_on_remote(node["ip"], cmd)
示例3: generate_facts
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def generate_facts(ip):
ssh_manager = SSHManager()
facter_dir = '/var/lib/puppet/lib/facter'
exluded_facts = ['naily.rb']
if not ssh_manager.isdir_on_remote(ip, facter_dir):
ssh_manager.mkdir_on_remote(ip, facter_dir)
logger.debug('Directory {0} was created'.format(facter_dir))
ssh_manager.execute_on_remote(ip, 'rm -f {0}/*.rb'.format(facter_dir))
logger.debug('rb files were removed from {0}'.format(facter_dir))
facts_files = ssh_manager.execute_on_remote(
ip,
'find /etc/puppet/modules/ -wholename "*/lib/facter/*.rb"')['stdout']
facts_files = [i.strip() for i in facts_files]
logger.debug('The following facts {0} will'
' be copied to {1}'.format(facts_files, facter_dir))
for fact in facts_files:
if not fact or re.sub(r'.*/', '', fact) in exluded_facts:
continue
ssh_manager.execute_on_remote(ip,
'cp {0} {1}/'.format(fact, facter_dir))
logger.debug('Facts were copied')
ssh_manager.execute_on_remote(ip, 'facter -p -y > /tmp/facts.yaml')
logger.info('Facts yaml was created')
ssh_manager.execute_on_remote(ip, 'rm -f {0}/*.rb'.format(facter_dir))
logger.debug('rb files were removed from {0}'.format(facter_dir))
示例4: delete_astute_log
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def delete_astute_log():
"""Delete astute.log file(s) on master node.
This is to ensure that no unwanted tasks are used by tests (e.g. from
previous deployments).
:return: None
"""
ssh = SSHManager()
ssh.execute_on_remote(ssh.admin_ip, "rm /var/log/astute/astute*")
ssh.execute_on_remote(ssh.admin_ip, "systemctl restart astute.service")
示例5: inject_nailgun_agent_ubuntu_bootstrap
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def inject_nailgun_agent_ubuntu_bootstrap(environment):
"""Inject nailgun agent packet from review into ubuntu bootsrap
environment - Environment Model object - self.env
"""
logger.info("Update nailgun-agent code and assemble new ubuntu bootstrap")
ssh = SSHManager()
if not settings.UPDATE_FUEL:
raise Exception("{} variable don't exist"
.format(settings.UPDATE_FUEL))
pack_path = '/var/www/nailgun/nailgun-agent-review/'
# Step 1 - install squashfs-tools
cmd = "yum install -y squashfs-tools"
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
# Step 2 - unpack bootstrap
bootstrap = "/var/www/nailgun/bootstraps/active_bootstrap"
bootstrap_var = "/var/root.squashfs"
cmd = "unsquashfs -d /var/root.squashfs {}/root.squashfs".format(
bootstrap)
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
# Step 3 - replace nailgun-agent code in unpacked bootstrap
agent_path = "/usr/bin/nailgun-agent"
bootstrap_file = bootstrap + "/root.squashfs"
logger.info('bootsrap file {0}{1}'.format(bootstrap_var, agent_path))
old_sum = get_sha_sum('{0}{1}'.format(bootstrap_var, agent_path))
logger.info('Old sum is {0}'.format(old_sum))
cmd_etc_sync = ('rsync -r {1}etc/* {0}/etc/'.format(
bootstrap_var, pack_path))
ssh.execute_on_remote(ssh.admin_ip, cmd=cmd_etc_sync)
cmd = ("rsync -r {1}usr/* {0}/usr/;" "mv {2} "
"/var/root.squashfs.old;"
"").format(bootstrap_var, pack_path, bootstrap_file)
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
new_sum = get_sha_sum('{0}{1}'.format(bootstrap_var, agent_path))
logger.info('new sum is {0}'.format(new_sum))
assert_equal(new_sum != old_sum, True)
# Step 4 - assemble new bootstrap
compression = "-comp xz"
no_progress_bar = "-no-progress"
no_append = "-noappend"
image_rebuild = "mksquashfs {0} {1} {2} {3} {4}".format(
bootstrap_var,
bootstrap_file,
compression,
no_progress_bar,
no_append)
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=image_rebuild)
checkers.check_file_exists(ssh.admin_ip, bootstrap_file)
示例6: centos_setup_fuel
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def centos_setup_fuel(self, hostname):
with TimeStat("bootstrap_centos_node", is_uniq=True):
admin = list(self.env.d_env.get_nodes(role__contains='master'))[0]
self.env.d_env.start([admin])
logger.info("Waiting for Centos node to start up")
wait(lambda: admin.driver.node_active(admin), 60,
timeout_msg='Centos node failed to start')
logger.info("Waiting for Centos node ssh ready")
self.env.wait_for_provisioning()
ssh = SSHManager()
logger.debug("Update host information")
cmd = "echo HOSTNAME={} >> /etc/sysconfig/network".format(hostname)
ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)
cmd = "echo {0} {1} {2} >> /etc/hosts".format(
ssh.admin_ip,
hostname,
settings.FUEL_MASTER_HOSTNAME)
ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)
cmd = "hostname {}".format(hostname)
ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)
cmd = "yum install -y screen"
ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)
install_mos_repos()
logger.info("Install Fuel services")
cmd = "screen -dm bash -c 'showmenu=no wait_for_external_config=yes " \
"bootstrap_admin_node.sh'"
ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)
self.env.wait_for_external_config()
self.env.admin_actions.modify_configs(self.env.d_env.router())
if CUSTOM_FUEL_SETTING_YAML:
self.env.admin_actions.update_fuel_setting_yaml(
CUSTOM_FUEL_SETTING_YAML)
self.env.kill_wait_for_external_config()
self.env.wait_bootstrap()
logger.debug("Check Fuel services")
self.env.admin_actions.wait_for_fuel_ready()
logger.debug("post-installation configuration of Fuel services")
self.fuel_post_install_actions()
示例7: upload_nailgun_agent_rpm
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def upload_nailgun_agent_rpm():
"""Upload nailgun_agent.rpm on master node
"""
ssh = SSHManager()
logger.info("Upload nailgun-agent")
if not settings.UPDATE_FUEL:
raise exceptions.FuelQAVariableNotSet('UPDATE_FUEL', 'True')
pack_path = '/var/www/nailgun/nailgun-agent-review/'
ssh.upload_to_remote(
ip=ssh.admin_ip,
source=settings.UPDATE_FUEL_PATH.rstrip('/'),
target=pack_path)
# Extract rpm context
cmd = 'cd {0}; rpm2cpio {1} | cpio -idmv'.format(
pack_path, 'nailgun-agent-*.noarch.rpm ')
ssh.execute_on_remote(ssh.admin_ip, cmd)
示例8: get_nodes_tasks
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def get_nodes_tasks(node_id):
"""
:param node_id: an integer number of node id
:return: a set of deployment tasks for corresponding node
"""
tasks = set()
ssh = SSHManager()
result = ssh.execute_on_remote(ssh.admin_ip, "ls /var/log/astute")
filenames = [filename.strip() for filename in result['stdout']]
for filename in filenames:
ssh.download_from_remote(
ssh.admin_ip,
destination="/var/log/astute/{0}".format(filename),
target="/tmp/{0}".format(filename))
data = fileinput.FileInput(
files=["/tmp/{0}".format(filename) for filename in filenames],
openhook=fileinput.hook_compressed)
for line in data:
if "Task time summary" in line \
and "node {}".format(node_id) in line:
# FIXME: define an exact search of task
task_name = line.split("Task time summary: ")[1].split()[0]
check = any([excluded_task in task_name
for excluded_task in TASKS_BLACKLIST])
if check:
continue
tasks.add(task_name)
return tasks
示例9: check_service
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def check_service(ip, commands):
"""Check that required nova services are running on controller.
:param ip: ip address of node
:param commands: type list, nova commands to execute on controller,
example of commands:
['nova-manage service list | grep vcenter-vmcluster1'
"""
ssh_manager = SSHManager()
ssh_manager.execute_on_remote(ip=ip, cmd='source openrc')
for cmd in commands:
wait(
lambda:
':-)' in ssh_manager.execute_on_remote(ip=ip,
cmd=cmd)['stdout'][-1],
timeout=200)
示例10: patch_centos_bootstrap
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def patch_centos_bootstrap():
"""Replaced initramfs.img in /var/www/nailgun/
with newly_builded from review
environment - Environment Model object - self.env
"""
logger.info("Update fuel-agent code and assemble new bootstrap")
ssh = SSHManager()
if not settings.UPDATE_FUEL:
raise Exception("{} variable don't exist"
.format(settings.UPDATE_FUEL))
try:
pack_path = '/var/www/nailgun/fuel-agent-review/'
ssh.upload_to_remote(
ip=ssh.admin_ip,
source=settings.FUEL_AGENT_REPO_PATH.rstrip('/'),
target=pack_path)
# Step 1 - unpack bootstrap
bootstrap_var = "/var/initramfs"
bootstrap = "/var/www/nailgun/bootstrap"
cmd = ("mkdir {0}; cp /{1}/initramfs.img {0}/; cd {0}; "
"cat initramfs.img | gunzip | cpio -imudv;").format(
bootstrap_var, bootstrap)
result = ssh.execute_on_remote(
ip=ssh.admin_ip, cmd=cmd)['stdout_str']
logger.debug("Patching bootsrap finishes with {0}".format(result))
# Step 2 - replace fuel-agent code in unpacked bootstrap
agent_path = "/usr/lib/python2.7/site-packages/fuel_agent"
image_rebuild = "{} | {} | {}".format(
"find . -xdev",
"cpio --create --format='newc'",
"gzip -9 > /var/initramfs.img.updated")
cmd = ("rm -rf {0}/initramfs.img; "
"rsync -r {2}fuel_agent/* {0}{1}/;"
"cd {0}/;"
"{3};").format(bootstrap_var, agent_path, pack_path,
image_rebuild)
result = ssh.execute_on_remote(
ip=ssh.admin_ip, cmd=cmd)['stdout_str']
logger.debug("Failed to rebuild image with {0}".format(result))
except Exception as e:
logger.error("Could not upload package {e}".format(e=e))
raise
示例11: install_mos_repos
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def install_mos_repos():
"""
Upload and install fuel-release packet with mos-repo description
and install necessary packets for packetary Fuel installation
:return: nothing
"""
logger.info("upload fuel-release packet")
if not settings.FUEL_RELEASE_PATH:
raise exceptions.FuelQAVariableNotSet('FUEL_RELEASE_PATH', '/path')
try:
ssh = SSHManager()
pack_path = '/tmp/'
full_pack_path = os.path.join(pack_path,
'fuel-release*.noarch.rpm')
ssh.upload_to_remote(
ip=ssh.admin_ip,
source=settings.FUEL_RELEASE_PATH.rstrip('/'),
target=pack_path)
if settings.RPM_REPOS_YAML:
with ssh.open_on_remote(
ip=ssh.admin_ip,
path='/etc/yum.repos.d/custom.repo',
mode="w") as f:
f.write(generate_yum_repos_config(settings.RPM_REPOS_YAML))
if settings.DEB_REPOS_YAML:
ssh = SSHManager()
pack_path = "/root/default_deb_repos.yaml"
ssh.upload_to_remote(
ip=ssh.admin_ip,
source=settings.DEB_REPOS_YAML,
target=pack_path)
except Exception:
logger.exception("Could not upload package")
raise
logger.debug("setup MOS repositories")
cmd = "rpm -ivh {}".format(full_pack_path)
ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)
cmd = "yum install -y fuel-setup"
ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)
示例12: patch_and_assemble_ubuntu_bootstrap
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def patch_and_assemble_ubuntu_bootstrap(environment):
"""Replaced initramfs.img in /var/www/nailgun/
with newly_builded from review
environment - Environment Model object - self.env
"""
logger.info("Update fuel-agent code and assemble new ubuntu bootstrap")
ssh = SSHManager()
if not settings.UPDATE_FUEL:
raise Exception("{} variable don't exist"
.format(settings.UPDATE_FUEL))
try:
pack_path = '/var/www/nailgun/fuel-agent-review/'
ssh.upload_to_remote(
ip=ssh.admin_ip,
source=settings.FUEL_AGENT_REPO_PATH.rstrip('/'),
target=pack_path)
# renew code in bootstrap
# Step 1 - install squashfs-tools
cmd = "yum install -y squashfs-tools"
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
# Step 2 - unpack bootstrap
bootstrap = "/var/www/nailgun/bootstraps/active_bootstrap"
bootstrap_var = "/var/root.squashfs"
cmd = "unsquashfs -d /var/root.squashfs {}/root.squashfs".format(
bootstrap)
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
# Step 3 - replace fuel-agent code in unpacked bootstrap
agent_path = "/usr/lib/python2.7/dist-packages/fuel_agent"
bootstrap_file = bootstrap + "/root.squashfs"
cmd = ("rsync -r {2}fuel_agent/* {0}{1}/;"
"mv {3} /var/root.squashfs.old;"
).format(bootstrap_var, agent_path, pack_path, bootstrap_file)
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
# Step 4 - assemble new bootstrap
compression = "-comp xz"
no_progress_bar = "-no-progress"
no_append = "-noappend"
image_rebuild = "mksquashfs {0} {1} {2} {3} {4}".format(
bootstrap_var,
bootstrap_file,
compression,
no_progress_bar,
no_append)
ssh.execute_on_remote(ip=ssh.admin_ip, cmd=image_rebuild)
with environment.d_env.get_admin_remote() as remote:
checkers.check_file_exists(remote, '{0}'.format(bootstrap_file))
except Exception as e:
logger.error("Could not upload package {e}".format(e=e))
raise
示例13: BaseActions
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
class BaseActions(object):
"""BaseActions.""" # TODO documentation
def __init__(self):
self.ssh_manager = SSHManager()
self.admin_ip = self.ssh_manager.admin_ip
def __repr__(self):
klass, obj_id = type(self), hex(id(self))
return "[{klass}({obj_id})]".format(
klass=klass,
obj_id=obj_id)
def restart_service(self, service):
self.ssh_manager.execute_on_remote(
ip=self.admin_ip,
cmd="systemctl restart {0}".format(service),
err_msg="Failed to restart service {!r}, please inspect logs for "
"details".format(service))
示例14: replace_fuel_agent_rpm
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def replace_fuel_agent_rpm():
"""Replaced fuel_agent.rpm on master node with fuel_agent.rpm
from review
"""
ssh = SSHManager()
logger.info("Patching fuel-agent")
if not settings.UPDATE_FUEL:
raise exceptions.FuelQAVariableNotSet('UPDATE_FUEL', 'True')
try:
pack_path = '/var/www/nailgun/fuel-agent/'
full_pack_path = os.path.join(pack_path, 'fuel-agent*.noarch.rpm')
ssh.upload_to_remote(
ip=ssh.admin_ip,
source=settings.UPDATE_FUEL_PATH.rstrip('/'),
target=pack_path)
# Update fuel-agent on master node
cmd = "rpm -q fuel-agent"
old_package = ssh.execute_on_remote(ssh.admin_ip, cmd)['stdout_str']
cmd = "rpm -qp {0}".format(full_pack_path)
new_package = ssh.execute_on_remote(ssh.admin_ip, cmd)['stdout_str']
logger.info("Updating package {0} with {1}"
.format(old_package, new_package))
if old_package != new_package:
logger.info("Updating fuel-agent package on master node")
logger.info('Try to install package {0}'.format(
new_package))
cmd = "rpm -Uvh --oldpackage {0}".format(full_pack_path)
ssh.execute_on_remote(ssh.admin_ip, cmd)
cmd = "rpm -q fuel-agent"
installed_package = ssh.execute_on_remote(
ssh.admin_ip, cmd)['stdout_str']
assert_equal(installed_package, new_package,
"The new package {0} was not installed".
format(new_package))
except Exception as e:
logger.error("Could not upload package {e}".format(e=e))
raise
示例15: hiera_json_out
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import execute_on_remote [as 别名]
def hiera_json_out(node_ip, parameter):
hiera_cmd = "ruby -rhiera -rjson -e \"h = Hiera.new(); " \
"Hiera.logger = 'noop'; " \
"puts JSON.dump(h.lookup(\'{0}\', " \
"[], {{}}, nil, nil))\"".format(parameter)
ssh_manager = SSHManager()
config = ssh_manager.execute_on_remote(
ip=node_ip,
cmd=hiera_cmd,
jsonify=True,
err_msg='Cannot get floating ranges')['stdout_json']
return config