def Main(): """Main routine. """ opts = ParseOptions() utils.SetupToolLogging(opts.debug, opts.verbose) try: data = common.LoadData(sys.stdin.read(), _DATA_CHECK) # Check if input data is correct common.VerifyClusterName(data, SshUpdateError, constants.SSHS_CLUSTER_NAME) common.VerifyCertificateSoft(data, SshUpdateError) # Update / Generate SSH files UpdateAuthorizedKeys(data, opts.dry_run) UpdatePubKeyFile(data, opts.dry_run) GenerateRootSshKeys(data, opts.dry_run) logging.info("Setup finished successfully") except Exception, err: # pylint: disable=W0703 logging.debug("Caught unhandled exception", exc_info=True) (retcode, message) = cli.FormatError(err) logging.error(message) return retcode
def Main(): """Main routine. """ opts = ParseOptions() utils.SetupToolLogging(opts.debug, opts.verbose, toolname=os.path.splitext( os.path.basename(__file__))[0]) try: data = common.LoadData(sys.stdin.read(), _DATA_CHECK) # Check if input data is correct common.VerifyClusterName(data, JoinError, constants.SSHS_CLUSTER_NAME) common.VerifyCertificateSoft(data, JoinError) # Update SSH files UpdateSshDaemon(data, opts.dry_run) UpdateSshRoot(data, opts.dry_run) logging.info("Setup finished successfully") except Exception, err: # pylint: disable=W0703 logging.debug("Caught unhandled exception", exc_info=True) (retcode, message) = cli.FormatError(err) logging.error(message) return retcode
def Main(): """Main routine. """ opts = ParseOptions() utils.SetupToolLogging(opts.debug, opts.verbose) try: getent = runtime.GetEnts() data = common.LoadData(sys.stdin.read(), SetupError) cluster_name = common.VerifyClusterName(data, SetupError, constants.NDS_CLUSTER_NAME) cert_pem = common.VerifyCertificateStrong(data, SetupError) ssdata = VerifySsconf(data, cluster_name) logging.info("Writing ssconf files ...") ssconf.WriteSsconfFiles(ssdata, dry_run=opts.dry_run) logging.info("Writing node daemon certificate ...") utils.WriteFile(pathutils.NODED_CERT_FILE, data=cert_pem, mode=pathutils.NODED_CERT_MODE, uid=getent.masterd_uid, gid=getent.masterd_gid, dry_run=opts.dry_run) common.GenerateClientCertificate(data, SetupError) if (data.get(constants.NDS_START_NODE_DAEMON) and # pylint: disable=E1103 not opts.dry_run): logging.info("Restarting node daemon ...") stop_cmd = "%s stop-all" % pathutils.DAEMON_UTIL noded_cmd = "%s start %s" % (pathutils.DAEMON_UTIL, constants.NODED) mond_cmd = "" if constants.ENABLE_MOND: mond_cmd = "%s start %s" % (pathutils.DAEMON_UTIL, constants.MOND) cmd = "; ".join([stop_cmd, noded_cmd, mond_cmd]) result = utils.RunCmd(cmd, interactive=True) if result.failed: raise SetupError( "Could not start the node daemons, command '%s'" " failed: %s" % (result.cmd, result.fail_reason)) logging.info("Node daemon successfully configured") except Exception as err: # pylint: disable=W0703 logging.debug("Caught unhandled exception", exc_info=True) (retcode, message) = cli.FormatError(err) logging.error(message) return retcode else: return constants.EXIT_SUCCESS
def Main(): """Main routine. """ opts = ParseOptions() utils.SetupToolLogging(opts.debug, opts.verbose) try: data = common.LoadData(sys.stdin.read(), _DATA_CHECK) common.VerifyClusterName(data, SslSetupError, constants.NDS_CLUSTER_NAME) # Verifies whether the server certificate of the caller # is the same as on this node. common.VerifyCertificateStrong(data, SslSetupError) action = data.get(constants.NDS_ACTION) if not action: raise SslSetupError("No Action specified.") if action == constants.CRYPTO_ACTION_CREATE: common.GenerateClientCertificate(data, SslSetupError) elif action == constants.CRYPTO_ACTION_DELETE: DeleteClientCertificate() ClearMasterCandidateSsconfList() else: raise SslSetupError("Unsupported action: %s." % action) except Exception as err: # pylint: disable=W0703 logging.debug("Caught unhandled exception", exc_info=True) (retcode, message) = cli.FormatError(err) logging.error(message) return retcode else: return constants.EXIT_SUCCESS