Replace xdsh restapi to new execcmdonvm

Shoud work with related xcat patch.

Change-Id: I8823409c849ba7e250344742c561682cd5f8887b
This commit is contained in:
songqianxia 2016-11-10 19:10:43 +08:00 committed by jichenjc
parent b1a4ba8ba3
commit e4065be35a
2 changed files with 20 additions and 1 deletions

View File

@ -1835,7 +1835,11 @@ class ZVMDriver(driver.ComputeDriver):
def _set_admin_password(self, inst_name, password):
command = "echo %s|passwd --stdin root" % password
try:
zvmutils.xdsh(inst_name, command)
if zvmutils.xcat_support_iucv(self._xcat_version):
# After support IUCV, will use execcmdonvm to replace xdsh.
zvmutils.execcmdonvm(inst_name, command)
else:
zvmutils.xdsh(inst_name, command)
except exception.ZVMXCATXdshFailed as err:
LOG.error(_("Setting root password for instance %(instance)s "
"failed with reason: %(err)s"),

View File

@ -80,6 +80,7 @@ class XCATUrl(object):
self.PUUID = '&objectid='
self.DIAGLOGS = '/logs/diagnostics'
self.PNODERANGE = '&nodeRange='
self.EXECCMDONVM = '/execcmdonvm'
def _nodes(self, arg=''):
return self.PREFIX + self.NODES + arg + self.SUFFIX
@ -221,6 +222,10 @@ class XCATUrl(object):
"""Run shell command."""
return self.PREFIX + self.NODES + arg + self.XDSH + self.SUFFIX
def execcmdonvm(self, arg=''):
"""Run shell command after support IUCV."""
return self.PREFIX + self.NODES + arg + self.EXECCMDONVM + self.SUFFIX
def network(self, arg='', addp=None):
rurl = self.PREFIX + self.NETWORK + arg + self.SUFFIX
if addp is not None:
@ -662,6 +667,16 @@ def xdsh(node, commands):
return res_dict
def execcmdonvm(node, commands):
""""Run command on VM."""
LOG.debug('Run command %(cmd)s on VM %(node)s',
{'cmd': commands, 'node': node})
body = [commands]
url = get_xcat_url().execcmdonvm('/' + node)
return xcat_request("PUT", url, body)
def punch_file(node, fn, fclass, remote_host=None, del_src=True):
"""punch file to reader. """
if remote_host: