def install(args) -> None: if "--help" in args or "-h" in args: _show_install_help() return parser = argparse.ArgumentParser("microk8s install") parser.add_argument("--cpu", default=definitions.DEFAULT_CORES, type=int) parser.add_argument("--mem", default=definitions.DEFAULT_MEMORY, type=int) parser.add_argument("--disk", default=definitions.DEFAULT_DISK, type=int) parser.add_argument("--channel", default=definitions.DEFAULT_CHANNEL, type=str) parser.add_argument("-y", "--assume-yes", action="store_true", default=definitions.DEFAULT_ASSUME) args = parser.parse_args(args) echo = Echo() if platform == "win32": aux = Windows(args) if not aux.is_enough_space(): echo.warning("VM disk size requested exceeds free space on host.") if platform == "darwin": aux = MacOS(args) if not aux.is_enough_space(): echo.warning("VM disk size requested exceeds free space on host.") vm_provider_name: str = "multipass" vm_provider_class = get_provider_for(vm_provider_name) try: vm_provider_class.ensure_provider() except ProviderNotFound as provider_error: if provider_error.prompt_installable: if args.assume_yes or (echo.is_tty_connected() and echo.confirm( "Support for {!r} needs to be set up. " "Would you like to do that it now?".format( provider_error.provider))): vm_provider_class.setup_provider(echoer=echo) else: raise provider_error else: raise provider_error instance = vm_provider_class(echoer=echo) instance.launch_instance(vars(args)) echo.info( "MicroK8s is up and running. See the available commands with `microk8s --help`." )
def install(args) -> None: if "--help" in args: _show_install_help() return parser = argparse.ArgumentParser("microk8s install") parser.add_argument('--cpu', default=definitions.DEFAULT_CORES, type=int) parser.add_argument('--mem', default=definitions.DEFAULT_MEMORY, type=int) parser.add_argument('--disk', default=definitions.DEFAULT_DISK, type=int) parser.add_argument('--channel', default=definitions.DEFAULT_CHANNEL, type=str) parser.add_argument('-y', '--assume-yes', action='store_true', default=definitions.DEFAULT_ASSUME) args = parser.parse_args(args) echo = Echo() if platform == 'win32': if not Windows().check_admin(): echo.error( '`microk8s install` must be ran as adminstrator in order to check Hyper-V status.' ) input('Press return key to exit...') exit(1) if not Windows().is_enough_space(): echo.error( 'There is not enough disk space to continue. You need at least 50GB.' ) input('Press return key to exit...') exit(1) if not Windows().check_hyperv(): if args.assume_yes or (echo.is_tty_connected() and echo.confirm( "Hyper-V needs to be enabled. " "Would you like to do that now?")): echo.info('Hyper-V will now be enabled.') Windows().enable_hyperv() echo.info('Hyper-V has been enabled.') echo.info( 'This host must be restarted. After restart, run `microk8s install` again to complete setup.' ) input('Press return key to exit...') exit(0) else: echo.error('Cannot continue without enabling Hyper-V') exit(1) vm_provider_name: str = 'multipass' vm_provider_class = get_provider_for(vm_provider_name) try: vm_provider_class.ensure_provider() except ProviderNotFound as provider_error: if provider_error.prompt_installable: if args.assume_yes or (echo.is_tty_connected() and echo.confirm( "Support for {!r} needs to be set up. " "Would you like to do that it now?".format( provider_error.provider))): vm_provider_class.setup_provider(echoer=echo) else: raise provider_error else: raise provider_error instance = vm_provider_class(echoer=echo) instance.launch_instance(vars(args)) echo.info( "MicroK8s is up and running. See the available commands with 'microk8s --help'." )
def install(args) -> None: if "--help" in args or "-h" in args: _show_install_help() return parser = argparse.ArgumentParser("microk8s install") parser.add_argument("--cpu", default=definitions.DEFAULT_CORES, type=int) parser.add_argument("--mem", default=definitions.DEFAULT_MEMORY, type=int) parser.add_argument("--disk", default=definitions.DEFAULT_DISK, type=int) parser.add_argument("--channel", default=definitions.DEFAULT_CHANNEL, type=str) parser.add_argument("-y", "--assume-yes", action="store_true", default=definitions.DEFAULT_ASSUME) args = parser.parse_args(args) echo = Echo() if platform == "win32": aux = Windows(args) if not aux.check_admin(): echo.error("`microk8s install` must be ran as adminstrator in order to check Hyper-V status.") input("Press return key to exit...") exit(1) if not aux.is_enough_space(): echo.warning("VM disk size requested exceeds free space on host.") if not aux.check_hyperv(): if args.assume_yes or (echo.is_tty_connected() and echo.confirm( "Hyper-V needs to be enabled. " "Would you like to do that now?" )): echo.info("Hyper-V will now be enabled.") aux.enable_hyperv() echo.info("Hyper-V has been enabled.") echo.info("This host must be restarted. After restart, run `microk8s install` again to complete setup.") input("Press return key to exit...") exit(0) else: echo.error("Cannot continue without enabling Hyper-V") exit(1) if platform == "darwin": aux = MacOS(args) if not aux.is_enough_space(): echo.warning("VM disk size requested exceeds free space on host.") vm_provider_name: str = "multipass" vm_provider_class = get_provider_for(vm_provider_name) try: vm_provider_class.ensure_provider() except ProviderNotFound as provider_error: if provider_error.prompt_installable: if args.assume_yes or (echo.is_tty_connected() and echo.confirm( "Support for {!r} needs to be set up. " "Would you like to do that it now?".format(provider_error.provider) )): vm_provider_class.setup_provider(echoer=echo) else: raise provider_error else: raise provider_error instance = vm_provider_class(echoer=echo) instance.launch_instance(vars(args)) echo.info("MicroK8s is up and running. See the available commands with `microk8s --help`.")