本文整理汇总了Python中fuelweb_test.helpers.ssh_manager.SSHManager.update_connection方法的典型用法代码示例。如果您正苦于以下问题:Python SSHManager.update_connection方法的具体用法?Python SSHManager.update_connection怎么用?Python SSHManager.update_connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fuelweb_test.helpers.ssh_manager.SSHManager
的用法示例。
在下文中一共展示了SSHManager.update_connection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EnvironmentModel
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import update_connection [as 别名]
#.........这里部分代码省略.........
return True
def set_admin_ssh_password(self):
new_login = settings.SSH_FUEL_CREDENTIALS['login']
new_password = settings.SSH_FUEL_CREDENTIALS['password']
try:
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd='date'
)
logger.debug('Accessing admin node using SSH: SUCCESS')
except Exception:
logger.debug('Accessing admin node using SSH credentials:'
' FAIL, trying to change password from default')
self.ssh_manager.initialize(
admin_ip=self.ssh_manager.admin_ip,
admin_login='root',
admin_password='r00tme',
slave_login=settings.SSH_SLAVE_CREDENTIALS['login'],
slave_password=settings.SSH_SLAVE_CREDENTIALS['password']
)
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd='echo -e "{1}\\n{1}" | passwd {0}'.format(new_login,
new_password)
)
self.ssh_manager.initialize(
admin_ip=self.ssh_manager.admin_ip,
admin_login=new_login,
admin_password=new_password,
slave_login=settings.SSH_SLAVE_CREDENTIALS['login'],
slave_password=settings.SSH_SLAVE_CREDENTIALS['password']
)
self.ssh_manager.update_connection(
ip=self.ssh_manager.admin_ip,
login=new_login,
password=new_password
)
logger.debug("Admin node password has changed.")
logger.info("Admin node login name: '{0}' , password: '{1}'".
format(new_login, new_password))
def set_admin_keystone_password(self):
try:
self.fuel_web.client.get_releases()
# TODO(akostrikov) CENTOS7 except exceptions.Unauthorized:
except:
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd='fuel user --newpass {0} --change-password'.format(
settings.KEYSTONE_CREDS['password'])
)
logger.info(
'New Fuel UI (keystone) username: "{0}", password: "{1}"'
.format(settings.KEYSTONE_CREDS['username'],
settings.KEYSTONE_CREDS['password']))
def insert_cdrom_tray(self):
# This is very rude implementation and it SHOULD be changes after
# implementation this feature in fuel-devops
name = "{}_{}".format(settings.ENV_NAME, self.d_env.nodes().admin.name)
name_size = 80
if len(name) > name_size:
hash_str = str(hash(name))
name = (hash_str + name)[:name_size]
示例2: EnvironmentModel
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import update_connection [as 别名]
#.........这里部分代码省略.........
self.d_env.revert(name)
logger.info("Resuming the snapshot '{0}' ....".format(name))
self.resume_environment()
if not skip_timesync:
nailgun_nodes = [self.fuel_web.get_nailgun_node_by_name(node.name)
for node in self.d_env.nodes().slaves
if node.driver.node_active(node)]
self.sync_time(nailgun_nodes)
try:
_wait(self.fuel_web.client.get_releases,
expected=EnvironmentError, timeout=300)
except exceptions.Unauthorized:
self.set_admin_keystone_password()
self.fuel_web.get_nailgun_version()
_wait(lambda: self.check_slaves_are_ready(), timeout=60 * 6)
return True
def set_admin_ssh_password(self):
new_login = settings.SSH_CREDENTIALS['login']
new_password = settings.SSH_CREDENTIALS['password']
try:
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd='date'
)
logger.debug('Accessing admin node using SSH: SUCCESS')
except Exception:
logger.debug('Accessing admin node using SSH credentials:'
' FAIL, trying to change password from default')
self.ssh_manager.update_connection(
ip=self.ssh_manager.admin_ip,
login='root',
password='r00tme'
)
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd='echo -e "{1}\\n{1}" | passwd {0}'.format(new_login,
new_password)
)
self.ssh_manager.update_connection(
ip=self.ssh_manager.admin_ip,
login=new_login,
password=new_password
)
logger.debug("Admin node password has changed.")
logger.info("Admin node login name: '{0}' , password: '{1}'".
format(new_login, new_password))
def set_admin_keystone_password(self):
try:
self.fuel_web.client.get_releases()
# TODO(akostrikov) CENTOS7 except exceptions.Unauthorized:
except:
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd='fuel user --newpass {0} --change-password'.format(
settings.KEYSTONE_CREDS['password'])
)
logger.info(
'New Fuel UI (keystone) username: "{0}", password: "{1}"'
.format(settings.KEYSTONE_CREDS['username'],
settings.KEYSTONE_CREDS['password']))
示例3: EnvironmentModel
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import update_connection [as 别名]
#.........这里部分代码省略.........
logger.info("We have snapshot with such name: %s" % name)
logger.info("Reverting the snapshot '{0}' ....".format(name))
self.d_env.revert(name)
logger.info("Resuming the snapshot '{0}' ....".format(name))
self.resume_environment()
if not skip_timesync:
self.sync_time()
try:
_wait(self.fuel_web.client.get_releases, expected=EnvironmentError, timeout=300)
except exceptions.Unauthorized:
self.set_admin_keystone_password()
self.fuel_web.get_nailgun_version()
_wait(lambda: self.check_slaves_are_ready(), timeout=60 * 6)
return True
def set_admin_ssh_password(self):
new_login = settings.SSH_CREDENTIALS["login"]
new_password = settings.SSH_CREDENTIALS["password"]
try:
self.ssh_manager.execute_on_remote(ip=self.ssh_manager.admin_ip, cmd="date")
logger.debug("Accessing admin node using SSH: SUCCESS")
except Exception:
logger.debug("Accessing admin node using SSH credentials:" " FAIL, trying to change password from default")
self.ssh_manager.initialize(admin_ip=self.ssh_manager.admin_ip, login="root", password="r00tme")
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip, cmd='echo -e "{1}\\n{1}" | passwd {0}'.format(new_login, new_password)
)
self.ssh_manager.initialize(admin_ip=self.ssh_manager.admin_ip, login=new_login, password=new_password)
self.ssh_manager.update_connection(ip=self.ssh_manager.admin_ip, login=new_login, password=new_password)
logger.debug("Admin node password has changed.")
logger.info("Admin node login name: '{0}' , password: '{1}'".format(new_login, new_password))
def set_admin_keystone_password(self):
try:
self.fuel_web.client.get_releases()
# TODO(akostrikov) CENTOS7 except exceptions.Unauthorized:
except:
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd="fuel user --newpass {0} --change-password".format(settings.KEYSTONE_CREDS["password"]),
)
logger.info(
'New Fuel UI (keystone) username: "{0}", password: "{1}"'.format(
settings.KEYSTONE_CREDS["username"], settings.KEYSTONE_CREDS["password"]
)
)
def insert_cdrom_tray(self):
# This is very rude implementation and it SHOULD be changes after
# implementation this feature in fuel-devops
name = "{}_{}".format(settings.ENV_NAME, self.d_env.nodes().admin.name)
NAME_SIZE = 80
if len(name) > NAME_SIZE:
hash_str = str(hash(name))
name = (hash_str + name)[:NAME_SIZE]
cmd = """EDITOR="sed -i s/tray=\\'open\\'//" virsh edit {}""".format(name)
subprocess.check_call(cmd, shell=True)
def reinstall_master_node(self):
"""Erase boot sector and run setup_environment"""
示例4: EnvironmentModel
# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import update_connection [as 别名]
#.........这里部分代码省略.........
self.set_admin_keystone_password()
self.fuel_web.get_nailgun_version()
if not skip_slaves_check:
# TODO(astudenov): add timeout_msg
wait_pass(lambda: self.check_slaves_are_ready(), timeout=60 * 6)
return True
def set_admin_ssh_password(self):
new_login = settings.SSH_FUEL_CREDENTIALS["login"]
new_password = settings.SSH_FUEL_CREDENTIALS["password"]
try:
self.ssh_manager.execute_on_remote(ip=self.ssh_manager.admin_ip, cmd="date")
logger.debug("Accessing admin node using SSH: SUCCESS")
except Exception:
logger.debug("Accessing admin node using SSH credentials:" " FAIL, trying to change password from default")
self.ssh_manager.initialize(
admin_ip=self.ssh_manager.admin_ip,
admin_login="root",
admin_password="r00tme",
slave_login=settings.SSH_SLAVE_CREDENTIALS["login"],
slave_password=settings.SSH_SLAVE_CREDENTIALS["password"],
)
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip, cmd='echo -e "{1}\\n{1}" | passwd {0}'.format(new_login, new_password)
)
self.ssh_manager.initialize(
admin_ip=self.ssh_manager.admin_ip,
admin_login=new_login,
admin_password=new_password,
slave_login=settings.SSH_SLAVE_CREDENTIALS["login"],
slave_password=settings.SSH_SLAVE_CREDENTIALS["password"],
)
self.ssh_manager.update_connection(ip=self.ssh_manager.admin_ip, login=new_login, password=new_password)
logger.debug("Admin node password has changed.")
logger.info("Admin node login name: '{0}' , password: '{1}'".format(new_login, new_password))
def set_admin_keystone_password(self):
try:
self.fuel_web.client.get_releases()
# TODO(akostrikov) CENTOS7 except exceptions.Unauthorized:
except:
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd="fuel user --newpass {0} --change-password".format(settings.KEYSTONE_CREDS["password"]),
)
config_file = self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip, cmd="ls -1 $HOME/.config/fuel/fuel_client.yaml"
)["stdout_str"]
with YamlEditor(config_file, ip=self.admin_node_ip) as editor:
editor.content["OS_USERNAME"] = settings.KEYSTONE_CREDS["username"]
editor.content["OS_PASSWORD"] = settings.KEYSTONE_CREDS["password"]
with YamlEditor(settings.FUEL_SETTINGS_YAML, ip=self.admin_node_ip) as editor:
editor.content["FUEL_ACCESS"]["user"] = settings.KEYSTONE_CREDS["username"]
editor.content["FUEL_ACCESS"]["password"] = settings.KEYSTONE_CREDS["password"]
logger.info(
'New Fuel UI (keystone) username: "{0}", password: "{1}"'.format(
settings.KEYSTONE_CREDS["username"], settings.KEYSTONE_CREDS["password"]
)
)
def setup_environment(
self,