def editClient(args, fromCLI): """ Edits the various options of a deployment client. THIS WORKS ON THE LOCAL FILESYSTEM. We usually don't want this, so this will only be used for certain options. """ paramsReq = () paramsOpt = tuple(optionMapClient.keys()) comm.validateArgs(paramsReq, paramsOpt, args) returnDict = {} if 0 == len(args): raise cex.ArgError, "No changes have been specified." if not module.deplClientStatus({}, fromCLI)["enabled"]: raise cex.ServerState, ERR_CLIENT_DIS currConf = comm.getMergedConf(module.DEPL_CLI_CONFIG) if not module.DEPL_CLI_STANZA in currConf: raise cex.ParsingError, ERR_CLI_STANZA # assuming that we only support one of each of these tags - replace every tag found, and add if non-existent. for arg, val in args.items(): paramName = optionMapClient[arg] # validate the few types of args we recognize, ignore anything else. try: if arg in (ARG_MCASTURI, ARG_DEPSERVURI): validate.checkIPPortOrHostPort(arg, val) elif arg == ARG_MCASTIP: validate.checkIP(arg, val) elif arg == ARG_POLLFREQ: validate.checkPosInt(arg, val) except cex.ValidationError: if "0" != val: # we use 0 to disable these things, i guess. raise # remove if 0. if "0" == val and paramName in currConf[module.DEPL_CLI_STANZA]: currConf[module.DEPL_CLI_STANZA].pop(paramName) # or add/set. else: currConf[module.DEPL_CLI_STANZA][paramName] = val # if we're at this point, *something* has changed. returnDict["restartRequired"] = True comm.writeConfFile( bundle_paths.make_path(module.DEPL_CLI_CONFIG + ".conf"), currConf) if fromCLI: logger.info("Configuration updated.") return returnDict
def editClient(args, fromCLI): """ Edits the various options of a deployment client. THIS WORKS ON THE LOCAL FILESYSTEM. We usually don't want this, so this will only be used for certain options. """ paramsReq = () paramsOpt = tuple(optionMapClient.keys()) comm.validateArgs(paramsReq, paramsOpt, args) returnDict = {} if 0 == len(args): raise cex.ArgError, "No changes have been specified." if not module.deplClientStatus({}, fromCLI)["enabled"]: raise cex.ServerState, ERR_CLIENT_DIS currConf = comm.getMergedConf(module.DEPL_CLI_CONFIG) if not module.DEPL_CLI_STANZA in currConf: raise cex.ParsingError, ERR_CLI_STANZA # assuming that we only support one of each of these tags - replace every tag found, and add if non-existent. for arg, val in args.items(): paramName = optionMapClient[arg] # validate the few types of args we recognize, ignore anything else. try: if arg in (ARG_MCASTURI, ARG_DEPSERVURI): validate.checkIPPortOrHostPort(arg, val) elif arg == ARG_MCASTIP: validate.checkIP(arg, val) elif arg == ARG_POLLFREQ: validate.checkPosInt(arg, val) except cex.ValidationError: if "0" != val: # we use 0 to disable these things, i guess. raise # remove if 0. if "0" == val and paramName in currConf[module.DEPL_CLI_STANZA]: currConf[module.DEPL_CLI_STANZA].pop(paramName) # or add/set. else: currConf[module.DEPL_CLI_STANZA][paramName] = val # if we're at this point, *something* has changed. returnDict["restartRequired"] = True comm.writeConfFile(bundle_paths.make_path(module.DEPL_CLI_CONFIG + ".conf"), currConf) if fromCLI: logger.info("Configuration updated.") return returnDict
def ensureClientEnabled(fromCLI): if not module.deplClientStatus({}, fromCLI)["enabled"]: # make sure we relay fromCLI here intact. want the messages from this to show up. module.deplClientEnable({}, fromCLI)