def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('--development', default=False, action='store_true') parser.add_argument('--source-directory', default='klever') parser.add_argument('--deployment-directory', default='klever-inst') args = parser.parse_args() if args.development: install_klever_bridge_development(get_logger(__name__), args.source_directory) else: install_klever_bridge_production(get_logger(__name__), args.source_directory, args.deployment_directory)
def main(sys_args=sys.argv[1:]): args = parse_args(sys_args) logger = get_logger(__name__, args.log_level) check_deployment_configuration_file(logger, args.deployment_configuration_file) try: if args.entity == 'image': getattr(OSKleverBaseImage(args, logger), args.action)() elif args.entity == 'instance' and args.instances == 1: getattr(OSKleverInstance(args, logger), args.action)() elif args.entity == 'instance' and args.instances > 1: getattr(OSKleverInstances(args, logger), args.action)() else: logger.error(f'Entity "{args.entity}" is not supported') sys.exit(errno.ENOSYS) except SystemExit: logger.error( f'Could not execute action "{args.action}" for "{args.entity}" (analyze error messages above for details)' ) raise logger.info('Finish execution of action "{0}" for "{1}"'.format( args.action, args.entity))
def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('--deployment-configuration-file', default='klever.json') parser.add_argument('--deployment-directory', default='klever-inst') parser.add_argument('--non-interactive', default=False, action='store_true') parser.add_argument('--update-packages', default=False, action='store_true') args = parser.parse_args() with open(args.deployment_configuration_file) as fp: deploy_conf = json.load(fp) prev_deploy_info_file = os.path.join(args.deployment_directory, 'klever.json') if os.path.exists(prev_deploy_info_file): with open(prev_deploy_info_file) as fp: prev_deploy_info = json.load(fp) else: prev_deploy_info = {} install_deps(get_logger(__name__), deploy_conf, prev_deploy_info, args.non_interactive, args.update_packages) with open(prev_deploy_info_file, 'w') as fp: json.dump(prev_deploy_info, fp, sort_keys=True, indent=4)
def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('--deployment-directory', default='klever-inst') args = parser.parse_args() prepare_env(get_logger(__name__), args.deployment_directory)
def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('--development', default=False, action='store_true') parser.add_argument('--source-directory', default='klever') parser.add_argument('--deployment-directory', default='klever-inst') args = parser.parse_args() with open(os.path.join(args.deployment_directory, 'klever.json')) as fp: prev_deploy_info = json.load(fp) configure_controller_and_schedulers(get_logger(__name__), args.development, args.source_directory, args.deployment_directory, prev_deploy_info)
def main(): parser = argparse.ArgumentParser() parser.add_argument('action', choices=['install', 'update', 'uninstall'], help='Action to be executed.') parser.add_argument('mode', choices=['development', 'production', 'testing'], help='Mode for which action to be executed.') parser.add_argument( '--non-interactive', default=False, action='store_true', help= 'Install/update packages non-interactively (default: "%(default)s"). ' + 'This option has no effect for mode "testing".') parser.add_argument( '--deployment-configuration-file', default=os.path.join(os.path.dirname(__file__), os.path.pardir, 'conf', 'klever.json'), help= 'Path to Klever deployment configuration file (default: "%(default)s").' ) parser.add_argument( '--source-directory', default=os.getcwd(), help='Path to Klever source directory (default: "%(default)s").') parser.add_argument('--deployment-directory', required=True, help='Path to Klever deployment directory.') parser.add_argument( '--update-packages', default=False, action='store_true', help='Update packages for action "update" (default: "%(default)s"). ' + 'This option has no effect for action "install".') parser.add_argument( '--update-python3-packages', default=False, action='store_true', help= 'Update Python3 packages for action "update" (default: "%(default)s"). ' + 'This option has no effect for action "install".') parser.add_argument( '--allow-symbolic-links', default=False, action='store_true', help= 'Use symbolic links to directories (Klever addons and build bases) rather than copy them' + ' (default: "%(default)s"). Please, use this option very carefully to avoid dangling' + ' symbolic links as well as unexpected changes in their targets. Indeed this option is' + ' intended to update Klever addons and build bases silently without using deployment' + ' scripts.') args = parser.parse_args() logger = get_logger(__name__) check_deployment_configuration_file(logger, args.deployment_configuration_file) if get_cgroup_version() != "v1": logger.error( 'It appears that you are using cgroup v2, which is not supported by Klever' ) logger.error( 'To revert the systemd configuration to use cgroup v1 run the following command and reboot:' ) logger.error( '\tsudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"' ) sys.exit(-1) logger.info('Start execution of action "{0}" for Klever "{1}"'.format( args.action, args.mode)) try: if args.mode == 'development': getattr(KleverDevelopment(args, logger), args.action)() elif args.mode == 'production': getattr(KleverProduction(args, logger), args.action)() elif args.mode == 'testing': getattr(KleverTesting(args, logger), args.action)() else: logger.error('Mode "{0}" is not supported'.format(args.mode)) sys.exit(errno.ENOSYS) except SystemExit: logger.error( 'Could not execute action "{0}" for Klever "{1}" (analyze error messages above for details)' .format(args.action, args.mode)) raise logger.info('Finish execution of action "{0}" for Klever "{1}"'.format( args.action, args.mode))
def get_instance_floating_ip(instance_name): client = OSClient(get_logger(__name__, 'ERROR'), get_os_username()) return client.get_instance_floating_ip(client.get_instance(instance_name))
def main(): parser = argparse.ArgumentParser() parser.add_argument( 'action', choices=['show', 'create', 'update', 'ssh', 'remove', 'share', 'hide'], help='Action to be executed.') parser.add_argument('entity', choices=[ 'Klever base image', 'Klever developer instance', 'Klever experimental instances' ], help='Entity for which action to be executed.') parser.add_argument( '--os-auth-url', default='https://cloud.ispras.ru:5000/v2.0', help= 'OpenStack identity service endpoint for authorization (default: "%(default)s").' ) parser.add_argument( '--os-username', default=getpass.getuser(), help='OpenStack username for authentication (default: "%(default)s").') parser.add_argument('--os-tenant-name', default='computations', help='OpenStack tenant name (default: "%(default)s").') parser.add_argument( '--os-network-type', default='internal', help= 'OpenStack network type. Can be "internal" or "external" (default: "%(default)s").' ) parser.add_argument( '--os-keypair-name', default='ldv', help='OpenStack keypair name (default: "%(default)s").') parser.add_argument( '--ssh-username', default='debian', help='SSH username for authentication (default: "%(default)s").') parser.add_argument( '--ssh-rsa-private-key-file', help='Path to SSH RSA private key file.' 'The appropriate SSH RSA key pair should be stored to OpenStack by name "ldv".' ) parser.add_argument('--name', help='Entity name.') parser.add_argument( '--base-image', default='Debian 9.11.1 64-bit', help= 'Name of base image on which Klever base image will be based on (default: "%(default)s").' ) parser.add_argument( '--klever-base-image', default='Klever Base', help= 'Name of Klever base image on which instances will be based on (default: "%(default)s").' ) parser.add_argument( '--flavor', default='spark.large', help= 'Name of flavor to be used for new instances (default: "%(default)s").' ) parser.add_argument( '--instances', type=int, help='The number of new Klever experimental instances.') parser.add_argument( '--deployment-configuration-file', default=os.path.join(os.path.dirname(__file__), os.path.pardir, 'conf', 'klever.json'), help= 'Path to Klever deployment configuration file (default: "%(default)s").' ) parser.add_argument( '--source-directory', default=os.getcwd(), help='Path to Klever source directory (default: "%(default)s").') parser.add_argument( '--update-packages', default=False, action='store_true', help='Update packages for action "update" (default: "%(default)s"). ' + 'This option has no effect for other actions.') parser.add_argument( '--update-python3-packages', default=False, action='store_true', help= 'Update Python3 packages for action "update" (default: "%(default)s"). ' + 'This option has no effect for other actions.') # TODO: Check the correctness of the provided arguments args = parser.parse_args() logger = get_logger(__name__) check_deployment_configuration_file(logger, args.deployment_configuration_file) logger.info('Start execution of action "{0}" for "{1}"'.format( args.action, args.entity)) try: if args.entity == 'Klever base image': getattr(OSKleverBaseImage(args, logger), args.action)() elif args.entity == 'Klever developer instance': getattr(OSKleverDeveloperInstance(args, logger), args.action)() elif args.entity == 'Klever experimental instances': getattr(OSKleverExperimentalInstances(args, logger), args.action)() else: logger.error('Entity "{0}" is not supported'.format(args.entity)) sys.exit(errno.ENOSYS) except SystemExit: logger.error( 'Could not execute action "{0}" for "{1}" (analyze error messages above for details)' .format(args.action, args.entity)) raise logger.info('Finish execution of action "{0}" for "{1}"'.format( args.action, args.entity))