summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuan Xie <huan.xie@citrix.com>2017-03-08 23:28:20 -0800
committerHuan Xie <huan.xie@citrix.com>2017-03-09 18:24:12 -0800
commit3009f637e288a9449634ebcee5f48b89a77c64b7 (patch)
tree12ea2877bf136e7b9f30d5831dd53a24afd7f517
parentfdf87958447b02d95f0e0d9502a9d64788a74f85 (diff)
Support install suppack multi times
When add a new VM to current MOS environment, our plugins script compute_post_deployment.py will be triggered and it will try to install the supplemental packages and got the exception like: "This update has already been applied", this patch is to add the acceptable return code 1 when execute xe-install-supplemental-pack Change-Id: Ie4e4328ed85938a6f98b272858ce3a39f9d564d4
Notes
Notes (review): Verified+1: Citrix XenServer CI Code-Review+2: Jianghua Wang <jianghua.wang@citrix.com> Code-Review+2: Bob Ball <bob.ball@citrix.com> Workflow+1: Bob Ball <bob.ball@citrix.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 13 Mar 2017 09:59:58 +0000 Reviewed-on: https://review.openstack.org/443451 Project: openstack/fuel-plugin-xenserver Branch: refs/heads/master
-rwxr-xr-xplugin_source/deployment_scripts/compute_post_deployment.py35
-rw-r--r--plugin_source/deployment_scripts/utils.py11
2 files changed, 42 insertions, 4 deletions
diff --git a/plugin_source/deployment_scripts/compute_post_deployment.py b/plugin_source/deployment_scripts/compute_post_deployment.py
index 92f4125..e71b49f 100755
--- a/plugin_source/deployment_scripts/compute_post_deployment.py
+++ b/plugin_source/deployment_scripts/compute_post_deployment.py
@@ -129,6 +129,15 @@ def route_to_compute(endpoints, himn_xs, himn_local, username):
129 '> /etc/udev/rules.d/90-reroute.rules')) 129 '> /etc/udev/rules.d/90-reroute.rules'))
130 130
131 131
132def parse_uuid(output):
133 uuid = None
134 index = output.strip().find('uuid:')
135 if index >= 0:
136 start = index + len('uuid:')
137 uuid = output[start:].strip()
138 return uuid
139
140
132def install_suppack(himn, username, package, xcp_version): 141def install_suppack(himn, username, package, xcp_version):
133 """Install xapi driver supplemental pack. """ 142 """Install xapi driver supplemental pack. """
134 tmp = utils.ssh(himn, username, 'mktemp', '-d') 143 tmp = utils.ssh(himn, username, 'mktemp', '-d')
@@ -136,8 +145,30 @@ def install_suppack(himn, username, package, xcp_version):
136 if not os.path.exists(real_pack): 145 if not os.path.exists(real_pack):
137 utils.reportError('Package folder %s not exist' % real_pack) 146 utils.reportError('Package folder %s not exist' % real_pack)
138 utils.scp(himn, username, tmp, real_pack) 147 utils.scp(himn, username, tmp, real_pack)
139 utils.ssh(himn, username, 'xe-install-supplemental-pack', 148 if LooseVersion(xcp_version) < LooseVersion('2.2.0'):
140 tmp + '/' + package, prompt='Y\n') 149 utils.ssh(himn, username, 'xe-install-supplemental-pack',
150 tmp + '/' + package, prompt='Y\n')
151 else:
152 errcode, uuid, errmsg = \
153 utils.ssh_detailed(himn, username, 'xe', 'update-upload',
154 'file-name=' + tmp + '/' + package,
155 allowed_return_codes=[0, 1])
156 if errcode == 0:
157 utils.ssh(himn, username, 'xe', 'update-apply',
158 'uuid=' + uuid.strip())
159 else:
160 LOG.debug("Install supplemental pack failed, err: %s", errmsg)
161 if "The uploaded update already exists" in errmsg:
162 uuid = parse_uuid(errmsg)
163 if uuid is None:
164 raise utils.ExecutionError(errmsg)
165 # Check current update is applied already
166 out = utils.ssh(himn, username, 'xe', 'update-list',
167 'uuid=' + uuid, '--minimal')
168 # Apply this update if cannot find it with uuid
169 if not out:
170 utils.ssh(himn, username, 'xe', 'update-apply',
171 'uuid=' + uuid)
141 utils.ssh(himn, username, 'rm', tmp, '-rf') 172 utils.ssh(himn, username, 'rm', tmp, '-rf')
142 173
143 174
diff --git a/plugin_source/deployment_scripts/utils.py b/plugin_source/deployment_scripts/utils.py
index 073eaaf..fe511c9 100644
--- a/plugin_source/deployment_scripts/utils.py
+++ b/plugin_source/deployment_scripts/utils.py
@@ -103,8 +103,15 @@ def ssh(host, username, *cmd, **kwargs):
103 103
104 return execute('ssh', '-i', XS_RSA, 104 return execute('ssh', '-i', XS_RSA,
105 '-o', 'StrictHostKeyChecking=no', 105 '-o', 'StrictHostKeyChecking=no',
106 '%s@%s' % (username, host), *cmd, 106 '%s@%s' % (username, host), *cmd, **kwargs)
107 prompt=kwargs.get('prompt')) 107
108
109def ssh_detailed(host, username, *cmd, **kwargs):
110 cmd = map(str, cmd)
111
112 return detailed_execute('ssh', '-i', XS_RSA,
113 '-o', 'StrictHostKeyChecking=no',
114 '%s@%s' % (username, host), *cmd, **kwargs)
108 115
109 116
110def scp(host, username, target_path, filename): 117def scp(host, username, target_path, filename):