Method warm_shutdown_nodes to use sudo
Change-Id: I0a530a93ea4db762bb703a881b1787aec1e0df9c Closes-Bug: #1619019
This commit is contained in:
parent
2ad42ec2a4
commit
424dbce4d1
|
@ -168,7 +168,7 @@ class SSHManager(six.with_metaclass(SingletonMeta, object)):
|
|||
:rtype: SSHClient
|
||||
"""
|
||||
if (ip, port) not in self.connections:
|
||||
logger.debug('SSH_MANAGER:Create new connection for '
|
||||
logger.debug('SSH_MANAGER: Create new connection for '
|
||||
'{ip}:{port}'.format(ip=ip, port=port))
|
||||
|
||||
keys = self._get_keys() if ip != self.admin_ip else []
|
||||
|
@ -200,7 +200,7 @@ class SSHManager(six.with_metaclass(SingletonMeta, object)):
|
|||
)
|
||||
ssh_client.sudo_mode = SSH_SLAVE_CREDENTIALS['sudo']
|
||||
self.connections[(ip, port)] = ssh_client
|
||||
logger.debug('SSH_MANAGER:Return existed connection for '
|
||||
logger.debug('SSH_MANAGER: Return existed connection for '
|
||||
'{ip}:{port}'.format(ip=ip, port=port))
|
||||
logger.debug('SSH_MANAGER: Connections {0}'.format(self.connections))
|
||||
return self._connect(self.connections[(ip, port)])
|
||||
|
@ -217,10 +217,10 @@ class SSHManager(six.with_metaclass(SingletonMeta, object)):
|
|||
:return: None
|
||||
"""
|
||||
if (ip, port) in self.connections:
|
||||
logger.info('SSH_MANAGER:Close connection for {ip}:{port}'.format(
|
||||
logger.info('SSH_MANAGER: Close connection for {ip}:{port}'.format(
|
||||
ip=ip, port=port))
|
||||
self.connections[(ip, port)].clear()
|
||||
logger.info('SSH_MANAGER:Create new connection for '
|
||||
logger.info('SSH_MANAGER: Create new connection for '
|
||||
'{ip}:{port}'.format(ip=ip, port=port))
|
||||
|
||||
self.connections[(ip, port)] = SSHClient(
|
||||
|
@ -234,7 +234,7 @@ class SSHManager(six.with_metaclass(SingletonMeta, object)):
|
|||
def clean_all_connections(self):
|
||||
for (ip, port), connection in self.connections.items():
|
||||
connection.clear()
|
||||
logger.info('SSH_MANAGER:Close connection for {ip}:{port}'.format(
|
||||
logger.info('SSH_MANAGER: Close connection for {ip}:{port}'.format(
|
||||
ip=ip, port=port))
|
||||
|
||||
def execute(self, ip, cmd, port=22, sudo=None):
|
||||
|
|
|
@ -2011,15 +2011,15 @@ class FuelWebClient29(object):
|
|||
return self.get_nailgun_node_online_status(
|
||||
self.get_nailgun_node_by_devops_node(devops_node))
|
||||
|
||||
def warm_shutdown_nodes(self, devops_nodes, timeout=4 * 60):
|
||||
def warm_shutdown_nodes(self, devops_nodes, timeout=10 * 60):
|
||||
logger.info('Shutting down (warm) nodes %s',
|
||||
[n.name for n in devops_nodes])
|
||||
for node in devops_nodes:
|
||||
logger.debug('Shutdown node %s', node.name)
|
||||
nailgun_node = self.get_nailgun_node_by_devops_node(node)
|
||||
self.ssh_manager.execute_on_remote(ip=nailgun_node['ip'],
|
||||
cmd='/sbin/shutdown -Ph now')
|
||||
|
||||
# TODO: LP1620680
|
||||
self.ssh_manager.check_call(ip=nailgun_node['ip'], sudo=True,
|
||||
command='sudo shutdown +1')
|
||||
for node in devops_nodes:
|
||||
self.wait_node_is_offline(node, timeout=timeout)
|
||||
node.destroy()
|
||||
|
|
Loading…
Reference in New Issue