63
63
# Load the bundle file.
64
64
bundle_file = os.path.abspath(os.path.expanduser(bundle))
65
if os.path.isdir(bundle_file):
66
bundle_file = os.path.join(bundle_file, 'bundles.yaml')
66
68
bundle_yaml = open(bundle_file).read()
67
69
except IOError as err:
133
135
- admin_secret: the password to use to access the Juju API;
134
136
- env_file: the absolute path of the Juju environments.yaml file;
135
137
- env_name: the name of the Juju environment to use;
136
- env_type: the provider type of the selected Juju environment.
138
- env_type: the provider type of the selected Juju environment;
139
- charm_url: the Juju GUI charm URL or None if not specified;
140
- open_browser: whether the GUI browser must be opened.
142
The following attributes will also be included in the namespace if a bundle
143
deployment is requested:
144
- bundle_name: the name of the bundle to be deployed;
145
- bundle_services: a list of service names included in the bundle;
146
- bundle_yaml: the YAML encoded contents of the bundle.
138
148
Exit with an error if the provided arguments are not valid.
146
156
parser = argparse.ArgumentParser(description=quickstart.__doc__)
147
157
parser.add_argument(
148
158
'bundle', default=None, nargs='?',
149
help='The bundle URL or the path to the bundle file to deploy')
159
help='The optional bundle to be deployed. The bundle can be '
160
'1) a path to a YAML/JSON file or '
161
'2) a path to a directory containing a bundles.yaml file or '
162
'3) a URL (starting with http:// or https://) to a YAML/JSON')
150
163
parser.add_argument(
151
164
'-e', '--environment', default=default_env_name, dest='env_name',
153
166
parser.add_argument(
154
167
'-n', '--bundle-name', default=None, dest='bundle_name',
155
168
help='The name of the bundle to use. This must be included in the '
156
'provided bundle file. Specifying the bundle name is not '
157
'required if the bundle file only contains one bundle. This '
169
'provided bundle YAML/JSON. Specifying the bundle name is not '
170
'required if the bundle YAML/JSON only contains one bundle. This '
158
171
'option is ignored if the bundle file is not specified')
159
172
parser.add_argument(
160
173
'--environments-file',
161
174
default=os.path.join(juju_home, 'environments.yaml'), dest='env_file',
162
175
help='The path to the Juju environments YAML file (%(default)s)')
163
176
parser.add_argument(
177
'--gui-charm-url', dest='charm_url',
178
help='The Juju GUI charm URL to deploy in the environment. If not '
179
'provided, the last release of the GUI will be deployed')
181
'--no-browser', action='store_false', dest='open_browser',
182
help='Avoid opening the browser to the GUI at the end of the process')
164
184
'--version', action='version', version='%(prog)s {}'.format(version))
165
185
parser.add_argument(
166
186
'--debug', action='store_true', help='Turn debug mode on')
190
210
print('connecting to {}'.format(api_url))
191
211
env = app.connect(api_url, options.admin_secret)
192
212
print('requesting Juju GUI deployment')
193
app.deploy_gui(env, 'juju-gui')
213
app.deploy_gui(env, 'juju-gui', charm_url=options.charm_url)
194
214
print('Juju GUI deployment request accepted')
195
215
address = app.watch(env, 'juju-gui')
196
216
url = 'https://{}'.format(address)
208
228
gui_api_url, options.admin_secret,
209
229
options.bundle_yaml, options.bundle_name)
211
# XXX 2013-10-18 frankban:
212
# Add a command line option to decline opening the browser.
231
if options.open_browser: