igw: Add check for mismatch ceph-iscsi and iscsigws.yml settings

If the user has manually installed ceph-iscsi but is trying to setup a
iscsi object in iscsigws.yml you will just a python crash. This patch
adds a check and more user friendly error message for the case.

Signed-off-by: Mike Christie <mchristi@redhat.com>
(cherry picked from commit 2e1a4328a8)
pull/4199/head
Mike Christie 2019-05-13 12:59:27 -05:00 committed by mergify[bot]
parent db65b82a42
commit dd4d12662b
1 changed files with 10 additions and 0 deletions

View File

@ -63,6 +63,7 @@ from logging.handlers import RotatingFileHandler # noqa E402
from ansible.module_utils.basic import * # noqa E402 from ansible.module_utils.basic import * # noqa E402
import ceph_iscsi_config.settings as settings # noqa E402 import ceph_iscsi_config.settings as settings # noqa E402
from ceph_iscsi_config.common import Config # noqa E402
from ceph_iscsi_config.gateway import GWTarget # noqa E402 from ceph_iscsi_config.gateway import GWTarget # noqa E402
from ceph_iscsi_config.utils import valid_ip # noqa E402 from ceph_iscsi_config.utils import valid_ip # noqa E402
@ -85,6 +86,15 @@ def ansible_main():
module = AnsibleModule(argument_spec=fields, # noqa F405 module = AnsibleModule(argument_spec=fields, # noqa F405
supports_check_mode=False) supports_check_mode=False)
cfg = Config(logger)
if cfg.config['version'] > 3:
module.fail_json(msg="Unsupported iscsigws.yml/iscsi-gws.yml setting "
"detected. Remove depreciated iSCSI target, LUN, "
"client, and gateway settings from "
"iscsigws.yml/iscsi-gws.yml. See "
"iscsigws.yml.sample for list of supported "
"settings")
gateway_iqn = module.params['gateway_iqn'] gateway_iqn = module.params['gateway_iqn']
gateway_ip_list = module.params['gateway_ip_list'].split(',') gateway_ip_list = module.params['gateway_ip_list'].split(',')
mode = module.params['mode'] mode = module.params['mode']