summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjianghua wang <jianghua.wang@citrix.com>2017-04-15 17:27:46 +0100
committerJianghua Wang <jianghua.wang@citrix.com>2017-04-18 09:27:49 +0000
commit1153ae44dbbb2cc59a568a609964687a59755775 (patch)
tree5d3d7d8efba0f6133c2cac17ba6b47740986b933
parent8d9642a3632d8ffdbe150d43f7f157bacda708a6 (diff)
Fix error for patching9.0
If MOS picked some fix from upstream, the patches may be not needed any more. We need avoid error for this case. The fix is to make it to skip patching fix which has already existed. Change-Id: I2b2a2cf1a01d24701b94fd00e2e815869f078cdd Closes-Bug: #1683288
Notes
Notes (review): Verified+1: Citrix XenServer CI 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: Tue, 18 Apr 2017 11:41:11 +0000 Reviewed-on: https://review.openstack.org/457540 Project: openstack/fuel-plugin-xenserver Branch: refs/heads/9.0
-rw-r--r--plugin_source/deployment_scripts/utils.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/plugin_source/deployment_scripts/utils.py b/plugin_source/deployment_scripts/utils.py
index fe511c9..a75c3a7 100644
--- a/plugin_source/deployment_scripts/utils.py
+++ b/plugin_source/deployment_scripts/utils.py
@@ -90,12 +90,27 @@ def patch(directory, patch_file, level):
90 patched = (patch_file) in patches 90 patched = (patch_file) in patches
91 91
92 if not patched: 92 if not patched:
93 execute('patch', '-d', directory, '-p%s' % level, '-i', 93 # use '--forward' to ignore patches that seem to be reversed or
94 os.path.join(patchset_dir, patch_file)) 94 # already applied.
95 ret_code, out, err = detailed_execute(
96 'patch', '--forward', '-d', directory, '-p%s' % level,
97 '-i', os.path.join(patchset_dir, patch_file),
98 allowed_return_codes=[0, 1])
99
100 if ret_code == 1:
101 skip_reason = 'Reversed (or previously applied) patch detected!'
102 if skip_reason in out or skip_reason in err:
103 LOG.info('Skipping patching %s: not needed anymore.'
104 % patch_file)
105 else:
106 raise ExecutionError('Failed patching %s' % patch_file)
107 else:
108 LOG.info('%s is applied successfully.' % patch_file)
109
95 with open(patches_applied, "a") as f: 110 with open(patches_applied, "a") as f:
96 f.write(patch_file + "\n") 111 f.write(patch_file + "\n")
97 else: 112 else:
98 logging.info(patch_file + " is already applied - skipping") 113 LOG.info("%s is already applied - skipping" % patch_file)
99 114
100 115
101def ssh(host, username, *cmd, **kwargs): 116def ssh(host, username, *cmd, **kwargs):