From 6cc8bc12a2e5e71131614a7a89ad4bba7a373d17 Mon Sep 17 00:00:00 2001 From: nafei yang Date: Wed, 18 Jan 2017 13:43:14 +0800 Subject: [PATCH] Modify to use one same command to change password Previously, we use different commands to set admin password for different linux distros. However, we found this can be done by chpasswd command on all distros, so change to use it. Change-Id: I0cbbb4644e12fe8fb773fefbfe112b7bc2b0444d --- nova/virt/zvm/dist.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/nova/virt/zvm/dist.py b/nova/virt/zvm/dist.py index 440bf91..f50bbef 100644 --- a/nova/virt/zvm/dist.py +++ b/nova/virt/zvm/dist.py @@ -116,13 +116,12 @@ class LinuxDist(object): """Get network file configuration path.""" pass - @abc.abstractmethod def get_change_passwd_command(self, admin_password): """construct change password command :admin_password: the password to be changed to """ - pass + return "echo 'root:%s' | chpasswd" % admin_password @abc.abstractmethod def _get_cfg_str(self, device, broadcast_v4, gateway_v4, ip_v4, @@ -187,9 +186,6 @@ class rhel(LinuxDist): def _get_network_file_path(self): return '/etc/sysconfig/network-scripts/' - def get_change_passwd_command(self, admin_password): - return 'echo %s|passwd --stdin root' % admin_password - def _get_cfg_str(self, device, broadcast_v4, gateway_v4, ip_v4, netmask_v4, address_read, subchannels): cfg_str = 'DEVICE=\"' + device + '\"\n' @@ -400,9 +396,6 @@ class sles11(sles): 'service network restart', 'cio_ignore -u')) - def get_change_passwd_command(self, admin_password): - return 'echo %s|passwd --stdin root' % admin_password - class sles12(sles): def get_znetconfig_contents(self): @@ -417,9 +410,6 @@ class sles12(sles): 'znetconf -A', 'cio_ignore -u')) - def get_change_passwd_command(self, admin_password): - return "echo 'root:%s' | chpasswd" % admin_password - def get_scp_string(self, root, fcp, wwpn, lun): return ("=root=%(root)s zfcp.allow_lun_scan=0 " "zfcp.device=0.0.%(fcp)s,0x%(wwpn)s,0x%(lun)s") % { @@ -556,9 +546,7 @@ class ubuntu(LinuxDist): class ubuntu16(ubuntu): - - def get_change_passwd_command(self, admin_password): - return "echo 'root:%s' | chpasswd" % admin_password + pass class ListDistManager(object):