Aravinda VK has uploaded a new change for review. Change subject: packaging: Application Mode option in installer ......................................................................
packaging: Application Mode option in installer Application Mode option added to engine-setup, Engine can be configured as gluster only, virtualization only or both. This new prompt can be disabled by setting USE_DEFAULT_APPLICATION_MODE_WITHOUT_PROMPT to True in basedef.py Also introduced a Constant(CONST_DEFAULT_APPLICATION_MODE) in basedef.py to set the default application mode. Now USE_DEFAULT option can be dynamic, so function name can be specified instead of value. Initially USE_DEFAULT contains True or False, now function name can be given instead of Boolean which helps to decide usage depending on the other questions answered. Modified NFS options override in plugins/all_in_one_100.py since those options can be managed by setting USE_DEFAULT dynamically. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=901443 Change-Id: I2c958205727905d00f6e407779ee64f5c5eb5a1a Signed-off-by: Aravinda VK <[email protected]> --- M backend/manager/dbscripts/inst_sp.sql M packaging/fedora/setup/basedefs.py M packaging/fedora/setup/common_utils.py M packaging/fedora/setup/engine-setup.py M packaging/fedora/setup/output_messages.py M packaging/fedora/setup/plugins/all_in_one_100.py 6 files changed, 117 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/01/11801/1 diff --git a/backend/manager/dbscripts/inst_sp.sql b/backend/manager/dbscripts/inst_sp.sql index f25d49d..82e8502 100644 --- a/backend/manager/dbscripts/inst_sp.sql +++ b/backend/manager/dbscripts/inst_sp.sql @@ -38,3 +38,13 @@ END; $procedure$ LANGUAGE plpgsql; +-- Updates service types(gluster and virt) in vds_groups table +create or replace FUNCTION inst_update_service_type(v_cluster_id uuid, v_virt_service boolean, + v_gluster_service boolean) +returns void +AS $procedure$ +begin + update vds_groups set virt_service = v_virt_service, gluster_service = v_gluster_service + where vds_group_id = v_cluster_id; +END; $procedure$ +LANGUAGE plpgsql; diff --git a/packaging/fedora/setup/basedefs.py b/packaging/fedora/setup/basedefs.py index f8b03a2..fc4cd67 100644 --- a/packaging/fedora/setup/basedefs.py +++ b/packaging/fedora/setup/basedefs.py @@ -180,6 +180,14 @@ CONST_INSTALL_SIZE_MB=500 CONST_DOWNLOAD_SIZE_MB=500 CONST_DB_SIZE=500 +CONST_DEFAULT_CLUSTER_ID="99408929-82CF-4DC7-A532-9D998063FA95" +CONST_DEFAULT_APPLICATION_MODE="both" + +# If following option is True then ApplicationMode set option will not be +# shown/prompted to the user at the time of engine-setup. Default value will be +# CONST_DEFAULT_APPLICATION_MODE. If this definition is False then Installer +# prompts the user to select Application Mode option. +USE_DEFAULT_APPLICATION_MODE_WITHOUT_PROMPT=False # This is needed for avoiding error in create_ca when supporting max cn length of 64. # please DONT increase this size, any value over 55 will fail the setup. diff --git a/packaging/fedora/setup/common_utils.py b/packaging/fedora/setup/common_utils.py index e5c1e06..05eb0c2 100755 --- a/packaging/fedora/setup/common_utils.py +++ b/packaging/fedora/setup/common_utils.py @@ -1589,3 +1589,10 @@ return int(re.match("\d*", s).group(0)) version_num = version_string.split('.') return 1000*_prefixNum(version_num[0]) + _prefixNum(version_num[1]) + + +def isApplicationModeGluster(conf): + if "APPLICATION_MODE" in conf and conf["APPLICATION_MODE"] == "gluster": + return True + + return False diff --git a/packaging/fedora/setup/engine-setup.py b/packaging/fedora/setup/engine-setup.py index 12178e4..8b35e7a 100755 --- a/packaging/fedora/setup/engine-setup.py +++ b/packaging/fedora/setup/engine-setup.py @@ -130,7 +130,7 @@ 'steps' : [ { 'title' : output_messages.INFO_SET_DB_SECURITY, 'functions' : [_encryptDBPass, _configEncryptedPass] }, { 'title' : output_messages.INFO_UPGRADE_DB, - 'functions' : [stopRhevmDbRelatedServices, _upgradeDB, startRhevmDbRelatedServices]} ] + 'functions' : [stopRhevmDbRelatedServices, _upgradeDB, _setApplicationMode, startRhevmDbRelatedServices]} ] }, { 'description' : 'Create DB', 'condition' : [_isDbAlreadyInstalled], @@ -138,7 +138,7 @@ 'steps' : [ { 'title' : output_messages.INFO_SET_DB_SECURITY, 'functions' : [_encryptDBPass, _configEncryptedPass]}, { 'title' : output_messages.INFO_CREATE_DB, - 'functions' : [_createDB, _updateVDCOptions]}, + 'functions' : [_createDB, _updateVDCOptions, _setApplicationMode]}, { 'title' : output_messages.INFO_UPD_DC_TYPE, 'functions' : [_updateDefaultDCType]} ] }, @@ -178,6 +178,23 @@ for item in sequences_conf: controller.addSequence(item['description'], item['condition'], item['condition_match'], item['steps']) + + +def _useDefaultDcType(conf): + return utils.isApplicationModeGluster(conf) + + +def _useDefaultConfigNfs(conf): + # When gluster mode is selected then don't ask the questions related + # to NFS setup, so update default value for CONFIG_NFS as "no" if gluster + # is selected in application mode prompt(NFS_MP and ISO_DOMAIN_NAME). + if utils.isApplicationModeGluster(conf): + controller.getParamByName("CONFIG_NFS").setKey("DEFAULT_VALUE", "no") + return True + else: + controller.getParamByName("CONFIG_NFS").setKey("DEFAULT_VALUE", "yes") + return False + def initConfig(): """ @@ -320,6 +337,19 @@ "NEED_CONFIRM" : False, "CONDITION" : False}, + { "CMD_OPTION" : "application-mode", + "USAGE" : output_messages.INFO_CONF_PARAMS_APPLICATION_MODE_USAGE, + "PROMPT" : output_messages.INFO_CONF_PARAMS_APPLICATION_MODE_PROMPT, + "OPTION_LIST" : ["virt","gluster", "both"], + "VALIDATION_FUNC" : validate.validateOptions, + "DEFAULT_VALUE" : basedefs.CONST_DEFAULT_APPLICATION_MODE, + "MASK_INPUT" : False, + "LOOSE_VALIDATION": False, + "CONF_NAME" : "APPLICATION_MODE", + "USE_DEFAULT" : basedefs.USE_DEFAULT_APPLICATION_MODE_WITHOUT_PROMPT, + "NEED_CONFIRM" : False, + "CONDITION" : False}, + { "CMD_OPTION" :"default-dc-type", "USAGE" :output_messages.INFO_CONF_PARAMS_DC_TYPE_USAGE, "PROMPT" :output_messages.INFO_CONF_PARAMS_DC_TYPE_PROMPT, @@ -329,7 +359,7 @@ "MASK_INPUT" : False, "LOOSE_VALIDATION": False, "CONF_NAME" : "DC_TYPE", - "USE_DEFAULT" : False, + "USE_DEFAULT" : _useDefaultDcType, "NEED_CONFIRM" : False, "CONDITION" : False}, @@ -463,7 +493,7 @@ "MASK_INPUT" : False, "LOOSE_VALIDATION": False, "CONF_NAME" : "CONFIG_NFS", - "USE_DEFAULT" : False, + "USE_DEFAULT" : _useDefaultConfigNfs, "NEED_CONFIRM" : False, "CONDITION" : True} ] } @@ -520,6 +550,7 @@ #data center types enum controller.CONF["DC_TYPE_ENUM"] = utils.Enum(NFS=1, FC=2, ISCSI=3, POSIXFS=6) +controller.CONF["APPLICATION_MODE_ENUM"] = utils.Enum(VIRT=1, GLUSTER=2, BOTH=255) def _getColoredText (text, color): ''' gets text string and color @@ -540,7 +571,7 @@ userInput = None try: - if param.getKey("USE_DEFAULT"): + if _getConditionValue(param.getKey("USE_DEFAULT")): logging.debug("setting default value (%s) for key (%s)" % (mask(param.getKey("DEFAULT_VALUE")), param.getKey("CONF_NAME"))) controller.CONF[param.getKey("CONF_NAME")] = param.getKey("DEFAULT_VALUE") else: @@ -1031,6 +1062,40 @@ except: logging.error(traceback.format_exc()) raise Exception(output_messages.ERR_EXP_FAILED_CFG_IPTABLES) + +def _setApplicationMode(): + virtService = 'true' + glusterService = 'true' + + if controller.CONF["APPLICATION_MODE"].upper() == "GLUSTER": + virtService = 'false' + elif controller.CONF["APPLICATION_MODE"].upper() == "VIRT": + glusterService = 'false' + + # Update default cluster group service types, since default value of gluster_service + # column is false. + # Ref: dbscripts/upgrade/03_01_0620_add_service_columns_to_vds_groups.sql + sqlQuery = "select inst_update_service_type('%s', %s, %s)" % (basedefs.CONST_DEFAULT_CLUSTER_ID, virtService, glusterService) + utils.execRemoteSqlCommand(getDbUser(), \ + getDbHostName(), \ + getDbPort(), \ + basedefs.DB_NAME, \ + sqlQuery, False, \ + output_messages.ERR_DB_SET_SERVICE_TYPE) + + # No change with respect to default application mode, No DB update required + if controller.CONF["APPLICATION_MODE"].upper() == "BOTH": + return + + applicationMode = controller.CONF["APPLICATION_MODE_ENUM"].parse(str.upper(controller.CONF["APPLICATION_MODE"])) + + sqlQuery = "select fn_db_update_config_value('ApplicationMode', '%s', 'general')" % applicationMode + utils.execRemoteSqlCommand(getDbUser(), \ + getDbHostName(), \ + getDbPort(), \ + basedefs.DB_NAME, \ + sqlQuery, False, \ + output_messages.ERR_DB_SET_APPLICATION_MODE) def _createDB(): """ @@ -1590,7 +1655,9 @@ def _getConditionValue(matchMember): returnValue = False - if type(matchMember) == types.FunctionType: + if type(matchMember) == types.BooleanType: + returnValue = matchMember + elif type(matchMember) == types.FunctionType: returnValue = matchMember(controller.CONF) elif type(matchMember) == types.StringType: #we assume that if we get a string as a member it is the name @@ -1611,7 +1678,7 @@ logging.info("*** User input summary ***") for group in controller.getAllGroups(): for param in group.getAllParams(): - if not param.getKey("USE_DEFAULT") and controller.CONF.has_key(param.getKey("CONF_NAME")): + if not _getConditionValue(param.getKey("USE_DEFAULT")) and controller.CONF.has_key(param.getKey("CONF_NAME")): cmdOption = param.getKey("CMD_OPTION") l = 30 - len(cmdOption) maskParam = param.getKey("MASK_INPUT") @@ -2156,7 +2223,7 @@ cmdOption = param.getKey("CMD_OPTION") paramUsage = param.getKey("USAGE") optionsList = param.getKey("OPTION_LIST") - useDefault = param.getKey("USE_DEFAULT") + useDefault = _getConditionValue(param.getKey("USE_DEFAULT")) if not useDefault: if optionsList: groupParser.add_option("--%s" % cmdOption, metavar=optionsList, help=paramUsage, choices=optionsList) diff --git a/packaging/fedora/setup/output_messages.py b/packaging/fedora/setup/output_messages.py index 7bbd8f6..cd66e57 100644 --- a/packaging/fedora/setup/output_messages.py +++ b/packaging/fedora/setup/output_messages.py @@ -144,6 +144,8 @@ INFO_CONF_PARAMS_DB_PASSWD_USAGE="Password for the local database administrator" INFO_CONF_PARAMS_DB_PASSWD_PROMPT="Enter a password for a local %s DB admin user (%s)" % (basedefs.APP_NAME, basedefs.DB_USER) INFO_CONF_PARAMS_PASSWD_CONFIRM_PROMPT="Confirm password" +INFO_CONF_PARAMS_APPLICATION_MODE_USAGE="Application Mode" +INFO_CONF_PARAMS_APPLICATION_MODE_PROMPT="The engine can be configured to present the UI in three different application modes. virt [Manage virtualization only], gluster [Manage gluster storage only], and both [Manage virtualization as well as gluster storage]" #Remote DB interaction INFO_CONF_PARAMS_REMOTE_DB_USAGE="Select local or remote DB server" @@ -246,6 +248,8 @@ ERR_DB_UUID = "Error: uuid-ossp extension is not loaded into the DB.\n\ Verify with the DB admin that uuid-ossp extension is loaded into newly created databases and \ rerun the setup." +ERR_DB_SET_APPLICATION_MODE = "Error: failed to update Application Mode in DB" +ERR_DB_SET_SERVICE_TYPE = "Error: failed to update Service type in DB" #_updateVdcOptions ERR_CANT_FIND_VDC_OPTION_FILE="Unexpected error, Cannot find %s" diff --git a/packaging/fedora/setup/plugins/all_in_one_100.py b/packaging/fedora/setup/plugins/all_in_one_100.py index 8ff0c3d..3323a78 100644 --- a/packaging/fedora/setup/plugins/all_in_one_100.py +++ b/packaging/fedora/setup/plugins/all_in_one_100.py @@ -76,6 +76,17 @@ logging.debug("plugin %s loaded", __name__) +def _useDefaultConfigNfs(conf): + # When gluster mode is selected then don't ask the questions related + # to NFS setup, so update default value for CONFIG_NFS as "no" if gluster + # is selected in application mode prompt(NFS_MP and ISO_DOMAIN_NAME). + if utils.isApplicationModeGluster(conf): + controller.getParamByName("CONFIG_NFS").setKey("DEFAULT_VALUE", "no") + else: + controller.getParamByName("CONFIG_NFS").setKey("DEFAULT_VALUE", "yes") + return True + + def initConfig(controllerObject): global controller controller = controllerObject @@ -132,9 +143,9 @@ # Hack: # We disable the question regarding the NFS configuration (ISO domain) because we always want # it in All In One installation. - controller.getParamByName("CONFIG_NFS").setKey("USE_DEFAULT", True) + controller.getParamByName("CONFIG_NFS").setKey("USE_DEFAULT", _useDefaultConfigNfs) controller.getParamByName("CONFIG_NFS").setKey("CONDITION", False) - controller.getGroupByName("NFS").setKey("PRE_CONDITION", returnYes) + def initSequences(controller): logging.debug("Setting the Sequences for VDSM all in one installation") @@ -205,9 +216,6 @@ '#migration', '-A INPUT -p tcp -m state --state NEW -m multiport --dports 49152:49216 -j ACCEPT' ] - -def returnYes(controller): - return "yes" def waitForJbossUp(): """ -- To view, visit http://gerrit.ovirt.org/11801 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2c958205727905d00f6e407779ee64f5c5eb5a1a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: engine_3.2 Gerrit-Owner: Aravinda VK <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
