OLD | NEW |
1 # This file is part of the Juju Quickstart Plugin, which lets users set up a | 1 # This file is part of the Juju Quickstart Plugin, which lets users set up a |
2 # Juju environment in very few steps (https://launchpad.net/juju-quickstart). | 2 # Juju environment in very few steps (https://launchpad.net/juju-quickstart). |
3 # Copyright (C) 2013-2014 Canonical Ltd. | 3 # Copyright (C) 2013-2014 Canonical Ltd. |
4 # | 4 # |
5 # This program is free software: you can redistribute it and/or modify it under | 5 # This program is free software: you can redistribute it and/or modify it under |
6 # the terms of the GNU Affero General Public License version 3, as published by | 6 # the terms of the GNU Affero General Public License version 3, as published by |
7 # the Free Software Foundation. | 7 # the Free Software Foundation. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, but WITHOUT | 9 # This program is distributed in the hope that it will be useful, but WITHOUT |
10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | 10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 return parser.error(bytes(err)) | 146 return parser.error(bytes(err)) |
147 if charm.is_local(): | 147 if charm.is_local(): |
148 return parser.error(b'local charms are not allowed: {}'.format(charm)) | 148 return parser.error(b'local charms are not allowed: {}'.format(charm)) |
149 if charm.series not in settings.JUJU_GUI_SUPPORTED_SERIES: | 149 if charm.series not in settings.JUJU_GUI_SUPPORTED_SERIES: |
150 return parser.error( | 150 return parser.error( |
151 'unsupported charm series: {}'.format(charm.series)) | 151 'unsupported charm series: {}'.format(charm.series)) |
152 if ( | 152 if ( |
153 # The user requested a bundle deployment. | 153 # The user requested a bundle deployment. |
154 options.bundle and | 154 options.bundle and |
155 # This is the official Juju GUI charm. | 155 # This is the official Juju GUI charm. |
156 charm.name == settings.JUJU_GUI_CHARM_NAME and | 156 charm.name == settings.JUJU_GUI_CHARM_NAME and not charm.user and |
157 not charm.user and | |
158 # The charm at this revision does not support bundle deployments. | 157 # The charm at this revision does not support bundle deployments. |
159 charm.revision < settings.MINIMUM_CHARM_REVISION_FOR_BUNDLES | 158 charm.revision < settings.MINIMUM_REVISIONS_FOR_BUNDLES[charm.series] |
160 ): | 159 ): |
161 return parser.error( | 160 return parser.error( |
162 'bundle deployments not supported by the requested charm ' | 161 'bundle deployments not supported by the requested charm ' |
163 'revision: {}'.format(charm)) | 162 'revision: {}'.format(charm)) |
164 | 163 |
165 | 164 |
166 def _retrieve_env_db(parser, env_file=None): | 165 def _retrieve_env_db(parser, env_file=None): |
167 """Retrieve the environment database (or create an in-memory empty one).""" | 166 """Retrieve the environment database (or create an in-memory empty one).""" |
168 if env_file is None: | 167 if env_file is None: |
169 return envs.create_empty_env_db() | 168 return envs.create_empty_env_db() |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 options.bundle_name, len(options.bundle_services))) | 441 options.bundle_name, len(options.bundle_services))) |
443 | 442 |
444 logging.debug('ensuring juju and lxc are installed') | 443 logging.debug('ensuring juju and lxc are installed') |
445 juju_version = app.ensure_dependencies(options.distro_only) | 444 juju_version = app.ensure_dependencies(options.distro_only) |
446 | 445 |
447 logging.debug('ensuring SSH keys are available') | 446 logging.debug('ensuring SSH keys are available') |
448 app.ensure_ssh_keys() | 447 app.ensure_ssh_keys() |
449 | 448 |
450 print('bootstrapping the {} environment (type: {})'.format( | 449 print('bootstrapping the {} environment (type: {})'.format( |
451 options.env_name, options.env_type)) | 450 options.env_name, options.env_type)) |
452 is_local = options.env_type == 'local' | |
453 requires_sudo = False | 451 requires_sudo = False |
454 if is_local: | 452 if options.env_type == 'local': |
455 # If this is a local environment, notify the user that "sudo" will be | 453 # If this is a local environment, notify the user that "sudo" will be |
456 # required to bootstrap the application, even in newer Juju versions | 454 # required to bootstrap the application, even in newer Juju versions |
457 # where "sudo" is invoked by juju-core itself. | 455 # where "sudo" is invoked by juju-core itself. |
458 print('sudo privileges will be required to bootstrap the environment') | 456 print('sudo privileges will be required to bootstrap the environment') |
459 # If the Juju version is less than 1.17.2 then use sudo for local envs. | 457 # If the Juju version is less than 1.17.2 then use sudo for local envs. |
460 requires_sudo = juju_version < (1, 17, 2) | 458 requires_sudo = juju_version < (1, 17, 2) |
461 already_bootstrapped, bsn_series = app.bootstrap( | 459 already_bootstrapped, bootstrap_node_series = app.bootstrap( |
462 options.env_name, requires_sudo=requires_sudo, debug=options.debug) | 460 options.env_name, requires_sudo=requires_sudo, debug=options.debug) |
463 | 461 |
464 # Retrieve the admin-secret for the current environment. | 462 # Retrieve the admin-secret for the current environment. |
465 try: | 463 try: |
466 admin_secret = app.get_value_from_jenv( | 464 admin_secret = app.get_value_from_jenv( |
467 options.env_name, settings.JUJU_HOME, 'admin-secret') | 465 options.env_name, settings.JUJU_HOME, 'admin-secret') |
468 except ValueError as err: | 466 except ValueError as err: |
469 admin_secret = options.admin_secret | 467 admin_secret = options.admin_secret |
470 if admin_secret is None: | 468 if admin_secret is None: |
471 # The admin-secret cannot be found in the jenv file and is not | 469 # The admin-secret cannot be found in the jenv file and is not |
472 # explicitly specified in the environments.yaml file. | 470 # explicitly specified in the environments.yaml file. |
473 msg = b'{} or {}'.format(err, options.env_file.encode('utf-8')) | 471 msg = b'{} or {}'.format(err, options.env_file.encode('utf-8')) |
474 raise app.ProgramExit(msg) | 472 raise app.ProgramExit(msg) |
475 | 473 |
476 print('retrieving the Juju API address') | 474 print('retrieving the Juju API address') |
477 api_url = app.get_api_url(options.env_name) | 475 api_url = app.get_api_url(options.env_name) |
478 print('connecting to {}'.format(api_url)) | 476 print('connecting to {}'.format(api_url)) |
479 env = app.connect(api_url, admin_secret) | 477 env = app.connect(api_url, admin_secret) |
480 | 478 |
481 # It is not possible to deploy on the bootstrap node if we are using the | 479 # Inspect the environment and deploy the charm if required. |
482 # local provider, or if the bootstrap node series is not compatible with | 480 charm_url, machine, service_data, unit_data = app.check_environment( |
483 # the Juju GUI charm. | 481 env, settings.JUJU_GUI_SERVICE_NAME, options.charm_url, |
484 machine = '0' | 482 options.env_type, bootstrap_node_series, already_bootstrapped) |
485 if is_local or (bsn_series != settings.JUJU_GUI_PREFERRED_SERIES): | |
486 machine = None | |
487 unit_name = app.deploy_gui( | 483 unit_name = app.deploy_gui( |
488 env, settings.JUJU_GUI_SERVICE_NAME, machine, | 484 env, settings.JUJU_GUI_SERVICE_NAME, charm_url, machine, |
489 charm_url=options.charm_url, check_preexisting=already_bootstrapped) | 485 service_data, unit_data) |
| 486 |
| 487 # Observe the deployment progress. |
490 address = app.watch(env, unit_name) | 488 address = app.watch(env, unit_name) |
491 env.close() | 489 env.close() |
492 url = 'https://{}'.format(address) | 490 url = 'https://{}'.format(address) |
493 print('\nJuju GUI URL: {}\npassword: {}\n'.format(url, admin_secret)) | 491 print('\nJuju GUI URL: {}\npassword: {}\n'.format(url, admin_secret)) |
494 gui_api_url = 'wss://{}:443/ws'.format(address) | 492 gui_api_url = 'wss://{}:443/ws'.format(address) |
495 print('connecting to the Juju GUI server') | 493 print('connecting to the Juju GUI server') |
496 gui_env = app.connect(gui_api_url, admin_secret) | 494 gui_env = app.connect(gui_api_url, admin_secret) |
497 | 495 |
498 # Handle bundle deployment. | 496 # Handle bundle deployment. |
499 if options.bundle is not None: | 497 if options.bundle is not None: |
(...skipping 21 matching lines...) Expand all Loading... |
521 'to reopen and log in to the GUI browser later.\n' | 519 'to reopen and log in to the GUI browser later.\n' |
522 'Run "juju quickstart -i" if you want to manage\n' | 520 'Run "juju quickstart -i" if you want to manage\n' |
523 'or bootstrap your Juju environments using the\n' | 521 'or bootstrap your Juju environments using the\n' |
524 'interactive session.\n' | 522 'interactive session.\n' |
525 'Run "{sudo}juju destroy-environment {eflag}{env_name} [-y]"\n' | 523 'Run "{sudo}juju destroy-environment {eflag}{env_name} [-y]"\n' |
526 'to destroy the environment you just bootstrapped.'.format( | 524 'to destroy the environment you just bootstrapped.'.format( |
527 env_name=options.env_name, | 525 env_name=options.env_name, |
528 sudo='sudo ' if requires_sudo else '', | 526 sudo='sudo ' if requires_sudo else '', |
529 eflag='-e ' if juju_version < (1, 17, 2) else '') | 527 eflag='-e ' if juju_version < (1, 17, 2) else '') |
530 ) | 528 ) |
OLD | NEW |