9d638cbb19a3eece5773cbb039b4d91bc391afbb
3 self
, spec
=None, constraints
=None, disks
=None, series
=None,
5 """Start a new, empty machine and optionally a container, or add a
6 container to a machine.
8 :param str spec: Machine specification
11 (None) - starts a new machine
12 'lxc' - starts a new machine with on lxc container
13 'lxc:4' - starts a new lxc container on machine 4
14 'ssh:user@10.10.0.3' - manually provisions a machine with ssh
15 'zone=us-east-1a' - starts a machine in zone us-east-1s on AWS
16 'maas2.name' - acquire machine maas2.name on MAAS
17 :param constraints: Machine constraints
18 :type constraints: :class:`juju.Constraints`
19 :param list disks: List of disk :class:`constraints <juju.Constraints>`
20 :param str series: Series
21 :param int count: Number of machines to deploy
23 Supported container types are: lxc, lxd, kvm
25 When deploying a container to an existing machine, constraints cannot
30 add_machines
= add_machine
32 def add_relation(self
, relation1
, relation2
):
33 """Add a relation between two services.
35 :param str relation1: '<service>[:<relation_name>]'
36 :param str relation2: '<service>[:<relation_name>]'
41 def add_space(self
, name
, *cidrs
):
42 """Add a new network space.
44 Adds a new space with the given name and associates the given
45 (optional) list of existing subnet CIDRs with it.
47 :param str name: Name of the space
48 :param \*cidrs: Optional list of existing subnet CIDRs
53 def add_ssh_key(self
, key
):
54 """Add a public SSH key to this model.
56 :param str key: The public ssh key
60 add_ssh_keys
= add_ssh_key
62 def add_subnet(self
, cidr_or_id
, space
, *zones
):
63 """Add an existing subnet to this model.
65 :param str cidr_or_id: CIDR or provider ID of the existing subnet
66 :param str space: Network space with which to associate
67 :param str \*zones: Zone(s) in which the subnet resides
72 def get_backups(self
):
73 """Retrieve metadata for backups in this model.
78 def block(self
, *commands
):
79 """Add a new block to this model.
81 :param str \*commands: The commands to block. Valid values are
82 'all-changes', 'destroy-model', 'remove-object'
88 """List blocks for this model.
93 def get_cached_images(self
, arch
=None, kind
=None, series
=None):
94 """Return a list of cached OS images.
96 :param str arch: Filter by image architecture
97 :param str kind: Filter by image kind, e.g. 'lxd'
98 :param str series: Filter by image series, e.g. 'xenial'
103 def create_backup(self
, note
=None, no_download
=False):
104 """Create a backup of this model.
106 :param str note: A note to store with the backup
107 :param bool no_download: Do not download the backup archive
108 :return str: Path to downloaded archive
113 def create_storage_pool(self
, name
, provider_type
, **pool_config
):
114 """Create or define a storage pool.
116 :param str name: Name to give the storage pool
117 :param str provider_type: Pool provider type
118 :param \*\*pool_config: key/value pool configuration pairs
124 self
, no_tail
=False, exclude_module
=None, include_module
=None,
125 include
=None, level
=None, limit
=0, lines
=10, replay
=False,
127 """Get log messages for this model.
129 :param bool no_tail: Stop after returning existing log messages
130 :param list exclude_module: Do not show log messages for these logging
132 :param list include_module: Only show log messages for these logging
134 :param list include: Only show log messages for these entities
135 :param str level: Log level to show, valid options are 'TRACE',
136 'DEBUG', 'INFO', 'WARNING', 'ERROR,
137 :param int limit: Return this many of the most recent (possibly
138 filtered) lines are shown
139 :param int lines: Yield this many of the most recent lines, and keep
141 :param bool replay: Yield the entire log, and keep yielding
142 :param list exclude: Do not show log messages for these entities
148 self
, entity_url
, service_name
=None, bind
=None, budget
=None,
149 channel
=None, config
=None, constraints
=None, force
=False,
150 num_units
=1, plan
=None, resource
=None, series
=None, storage
=None,
152 """Deploy a new service or bundle.
154 :param str entity_url: Charm or bundle url
155 :param str service_name: Name to give the service
156 :param dict bind: <charm endpoint>:<network space> pairs
157 :param dict budget: <budget name>:<limit> pairs
158 :param str channel: Charm store channel from which to retrieve
159 the charm or bundle, e.g. 'development'
160 :param dict config: Charm configuration dictionary
161 :param constraints: Service constraints
162 :type constraints: :class:`juju.Constraints`
163 :param bool force: Allow charm to be deployed to a machine running
164 an unsupported series
165 :param int num_units: Number of units to deploy
166 :param str plan: Plan under which to deploy charm
167 :param dict resource: <resource name>:<file path> pairs
168 :param str series: Series on which to deploy
169 :param dict storage: Storage constraints TODO how do these look?
170 :param str to: Placement directive, e.g.::
173 'lxc:7' - new lxc container on machine 7
174 '24/lxc/3' - lxc container 3 or machine 24
176 If None, a new machine is provisioned.
182 """Terminate all machines and resources for this model.
187 def get_backup(self
, archive_id
):
188 """Download a backup archive file.
190 :param str archive_id: The id of the archive to download
191 :return str: Path to the archive file
197 self
, num_controllers
=0, constraints
=None, series
=None, to
=None):
198 """Ensure sufficient controllers exist to provide redundancy.
200 :param int num_controllers: Number of controllers to make available
201 :param constraints: Constraints to apply to the controller machines
202 :type constraints: :class:`juju.Constraints`
203 :param str series: Series of the controller machines
204 :param list to: Placement directives for controller machines, e.g.::
207 'lxc:7' - new lxc container on machine 7
208 '24/lxc/3' - lxc container 3 or machine 24
210 If None, a new machine is provisioned.
215 def get_config(self
):
216 """Return the configuration settings for this model.
221 def get_constraints(self
):
222 """Return the machine constraints for this model.
227 def grant(self
, username
, acl
='read'):
228 """Grant a user access to this model.
230 :param str username: Username
231 :param str acl: Access control ('read' or 'write')
236 def import_ssh_key(self
, identity
):
237 """Add a public SSH key from a trusted indentity source to this model.
239 :param str identity: User identity in the form <lp|gh>:<username>
243 import_ssh_keys
= import_ssh_key
245 def get_machines(self
, machine
, utc
=False):
246 """Return list of machines in this model.
248 :param str machine: Machine id, e.g. '0'
249 :param bool utc: Display time as UTC in RFC3339 format
254 def get_shares(self
):
255 """Return list of all users with access to this model.
260 def get_spaces(self
):
261 """Return list of all known spaces, including associated subnets.
266 def get_ssh_key(self
):
267 """Return known SSH keys for this model.
271 get_ssh_keys
= get_ssh_key
273 def get_storage(self
, filesystem
=False, volume
=False):
274 """Return details of storage instances.
276 :param bool filesystem: Include filesystem storage
277 :param bool volume: Include volume storage
282 def get_storage_pools(self
, names
=None, providers
=None):
283 """Return list of storage pools.
285 :param list names: Only include pools with these names
286 :param list providers: Only include pools for these providers
291 def get_subnets(self
, space
=None, zone
=None):
292 """Return list of known subnets.
294 :param str space: Only include subnets in this space
295 :param str zone: Only include subnets in this zone
300 def remove_blocks(self
):
301 """Remove all blocks from this model.
306 def remove_backup(self
, backup_id
):
309 :param str backup_id: The id of the backup to remove
314 def remove_cached_images(self
, arch
=None, kind
=None, series
=None):
315 """Remove cached OS images.
317 :param str arch: Architecture of the images to remove
318 :param str kind: Image kind to remove, e.g. 'lxd'
319 :param str series: Image series to remove, e.g. 'xenial'
324 def remove_machine(self
, *machine_ids
):
325 """Remove a machine from this model.
327 :param str \*machine_ids: Ids of the machines to remove
331 remove_machines
= remove_machine
333 def remove_ssh_key(self
, *keys
):
334 """Remove a public SSH key(s) from this model.
336 :param str \*keys: Keys to remove
340 remove_ssh_keys
= remove_ssh_key
343 self
, bootstrap
=False, constraints
=None, archive
=None,
344 backup_id
=None, upload_tools
=False):
345 """Restore a backup archive to a new controller.
347 :param bool bootstrap: Bootstrap a new state machine
348 :param constraints: Model constraints
349 :type constraints: :class:`juju.Constraints`
350 :param str archive: Path to backup archive to restore
351 :param str backup_id: Id of backup to restore
352 :param bool upload_tools: Upload tools if bootstrapping a new machine
357 def retry_provisioning(self
):
358 """Retry provisioning for failed machines.
363 def revoke(self
, username
, acl
='read'):
364 """Revoke a user's access to this model.
366 :param str username: Username to revoke
367 :param str acl: Access control ('read' or 'write')
372 def run(self
, command
, timeout
=None):
373 """Run command on all machines in this model.
375 :param str command: The command to run
376 :param int timeout: Time to wait before command is considered failed
381 def set_config(self
, **config
):
382 """Set configuration keys on this model.
384 :param \*\*config: Config key/values
389 def set_constraints(self
, constraints
):
390 """Set machine constraints on this model.
392 :param :class:`juju.Constraints` constraints: Machine constraints
397 def get_action_output(self
, action_uuid
, wait
=-1):
398 """Get the results of an action by ID.
400 :param str action_uuid: Id of the action
401 :param int wait: Time in seconds to wait for action to complete
406 def get_action_status(self
, uuid_or_prefix
=None, name
=None):
407 """Get the status of all actions, filtered by ID, ID prefix, or action name.
409 :param str uuid_or_prefix: Filter by action uuid or prefix
410 :param str name: Filter by action name
415 def get_budget(self
, budget_name
):
416 """Get budget usage info.
418 :param str budget_name: Name of budget
423 def get_status(self
, filter_
=None, utc
=False):
424 """Return the status of the model.
426 :param str filter_: Service or unit name or wildcard ('*')
427 :param bool utc: Display time as UTC in RFC3339 format
434 self
, all_
=False, destination
=None, dry_run
=False, public
=False,
435 source
=None, stream
=None, version
=None):
436 """Copy Juju tools into this model.
438 :param bool all_: Copy all versions, not just the latest
439 :param str destination: Path to local destination directory
440 :param bool dry_run: Don't do the actual copy
441 :param bool public: Tools are for a public cloud, so generate mirrors
443 :param str source: Path to local source directory
444 :param str stream: Simplestreams stream for which to sync metadata
445 :param str version: Copy a specific major.minor version
450 def unblock(self
, *commands
):
451 """Unblock an operation that would alter this model.
453 :param str \*commands: The commands to unblock. Valid values are
454 'all-changes', 'destroy-model', 'remove-object'
459 def unset_config(self
, *keys
):
460 """Unset configuration on this model.
462 :param str \*keys: The keys to unset
467 def upgrade_gui(self
):
468 """Upgrade the Juju GUI for this model.
474 self
, dry_run
=False, reset_previous_upgrade
=False,
475 upload_tools
=False, version
=None):
476 """Upgrade Juju on all machines in a model.
478 :param bool dry_run: Don't do the actual upgrade
479 :param bool reset_previous_upgrade: Clear the previous (incomplete)
481 :param bool upload_tools: Upload local version of tools
482 :param str version: Upgrade to a specific version
487 def upload_backup(self
, archive_path
):
488 """Store a backup archive remotely in Juju.
490 :param str archive_path: Path to local archive