Conditionally reconfig multipath

In MOS 9.1 /etc/multipath.conf doesn't exist by default. So the reconfiguration
should depend on the existence of /etc/multipath.conf.

Change-Id: I2784642fc49f6ea01f131f63be011ba1fc81acf6
(cherry-picked from commit 	bccc176701)
This commit is contained in:
John Hua 2016-11-02 17:21:33 +08:00 committed by Bob Ball
parent 8632696558
commit b21c892db6
2 changed files with 9 additions and 2 deletions

View File

@ -321,8 +321,14 @@ def reconfig_multipath():
Change devnode rule from "^hd[a-z]" to "^(hd|xvd)[a-z]"
"""
utils.execute('sed', '-i', r's/"\^hd\[a-z\]"/"^(hd|xvd)[a-z]"/',
'/etc/multipath.conf')
multipath_conf = '/etc/multipath.conf'
if os.path.exists(multipath_conf):
utils.execute('sed', '-i', r's/"\^hd\[a-z\]"/"^(hd|xvd)[a-z]"/',
multipath_conf)
else:
with open(multipath_conf, "w") as f:
f.write('# Generated by %s:\n' % utils.PLUGIN_NAME)
f.write('blacklist {\ndevnode "^(hd|xvd)[a-z]"\n}')
utils.execute('service', 'multipath-tools', 'restart')

View File

@ -9,6 +9,7 @@ import yaml
XS_RSA = '/root/.ssh/xs_rsa'
ASTUTE_PATH = '/etc/astute.yaml'
ASTUTE_SECTION = '@PLUGIN_NAME@'
PLUGIN_NAME = '@PLUGIN_NAME@'
LOG_ROOT = '/var/log/@PLUGIN_NAME@'
HIMN_IP = '169.254.0.1'