juju.controller
Summary
Reference
- class juju.controller.ConnectedController(connection, max_frame_size=None, bakery_client=None, jujudata=None)[source]
Bases:
Controller
- class juju.controller.Controller(max_frame_size=None, bakery_client=None, jujudata=None)[source]
Bases:
object
- coroutine add_cloud(name, cloud)[source]
Add a cloud to this controller.
- Parameters:
name (str) – Name to give the new cloud.
cloud (Cloud) – Cloud configuration.
- Return Cloud:
Cloud that was created.
- coroutine add_credential(name=None, credential=None, cloud=None, owner=None, force=False)[source]
Add or update a credential to the controller.
- Parameters:
name (str) – Name of new credential. If None, the default local credential is used. Name must be provided if a credential is given.
credential (CloudCredential) – Credential to add. If not given, it will attempt to read from local data, if available.
cloud (str) – Name of cloud to associate the credential with. Defaults to the same cloud as the controller.
owner (str) – Username that will own the credential. Defaults to the current user.
force (bool) – Force indicates whether the update should be forced. It’s only supported for facade v3 or later. Defaults to false.
- Returns:
Name of credential that was uploaded.
- coroutine add_model(model_name, cloud_name=None, credential_name=None, owner=None, config=None, region=None)[source]
Add a model to this controller.
- Parameters:
model_name (str) – Name to give the new model.
cloud_name (str) – Name of the cloud in which to create the model, e.g. ‘aws’. Defaults to same cloud as controller.
credential_name (str) – Name of the credential to use when creating the model. If not given, it will attempt to find a default credential.
owner (str) – Username that will own the model. Defaults to the current user.
config (dict) – Model configuration.
region (str) – Region in which to create the model.
- Return Model:
A connection to the newly created model.
- coroutine add_secret_backends(id, name, backend_type, config)[source]
Add a new secret backend.
Parameters
- idstring
id for the backend
- namestring
name of the backend
backend-type : string config : dict
dictionary with the backend configuration values
Returns
- list
a list of errors if any
- coroutine add_user(username, password=None, display_name=None)[source]
Add a user to this controller.
- Parameters:
username (str) – Username
password (str) – Password
display_name (str) – Display name
- Returns:
A
User
instance
- property api_endpoints
Get API endpoints
- Return list string:
List of API Endpoints
- coroutine change_user_password(username, password)[source]
Change the password for a user in this controller.
- Parameters:
username (str) – Username
password (str) – New password
- coroutine cloud(name=None)[source]
Get Cloud
- Parameters:
name (str) – Cloud name. If not specified, the cloud where the controller lives on is returned.
- Returns:
-> ~CloudResult
- coroutine connect(*args, **kwargs)[source]
Connect to a Juju controller.
This supports two calling conventions:
The controller and (optionally) authentication information can be taken from the data files created by the Juju CLI. This convention will be used if a
controller_name
is specified, or if theendpoint
is not.Otherwise, both the
endpoint
and authentication information (username
andpassword
, orbakery_client
and/ormacaroons
) are required.If a single positional argument is given, it will be assumed to be the
controller_name
. Otherwise, the first positional argument, if any, must be theendpoint
.Available parameters are:
- Parameters:
controller_name (str) – Name of controller registered with the Juju CLI.
endpoint (str) – The hostname:port of the controller to connect to.
username (str) – The username for controller-local users (or None to use macaroon-based login.)
password (str) – The password for controller-local users.
cacert (str) – The CA certificate of the controller (PEM formatted).
bakery_client (httpbakery.Client) – The macaroon bakery client to to use when performing macaroon-based login. Macaroon tokens acquired when logging will be saved to bakery_client.cookies. If this is None, a default bakery_client will be used.
macaroons (list) – List of macaroons to load into the
bakery_client
.max_frame_size (int) – The maximum websocket frame size to allow.
specified_facades – Overwrite the facades with a series of specified facades.
- coroutine connect_controller(controller_name)[source]
Deprecated since version 0.7.3: Use
connect(controller_name)()
instead.
- connection()[source]
Return the current Connection object. It raises an exception if the Controller is disconnected
- property controller_name
- property controller_uuid
- coroutine create_offer(model_uuid, endpoint, offer_name=None, application_name=None)[source]
Offer a deployed application using a series of endpoints for use by consumers.
@param endpoint: holds the application and endpoint you want to offer @param offer_name: override the offer name to help the consumer @param application_name: overrides the application name in the endpoint
- coroutine destroy(destroy_all_models=False, destroy_storage=False)[source]
Destroy this controller.
- Parameters:
destroy_all_models (bool) – Destroy all hosted models in the controller.
destroy_storage (bool) – Destory all hosted storage in the controller.
- coroutine destroy_model(*models, destroy_storage=False, force=False, max_wait=None)
Destroy one or more models.
- Parameters:
*models (str) –
Names or UUIDs of models to destroy
destroy_storage (bool) – Whether or not to destroy storage when destroying the models. Defaults to false.
force (bool) – Whether or not to force when destroying the models. Defaults to false.
:param int max_wait : Max time in seconds to wait when destroying the models.
- coroutine destroy_models(*models, destroy_storage=False, force=False, max_wait=None)[source]
Destroy one or more models.
- Parameters:
*models (str) –
Names or UUIDs of models to destroy
destroy_storage (bool) – Whether or not to destroy storage when destroying the models. Defaults to false.
force (bool) – Whether or not to force when destroying the models. Defaults to false.
:param int max_wait : Max time in seconds to wait when destroying the models.
- coroutine get_consume_details(endpoint)[source]
get_consume_details returns the details necessary to pass to another model to consume the specified offers represented by the urls.
- coroutine get_current_user(secret_key=None)[source]
Returns the user object associated with the current connection. :param str secret_key: Issued by juju when add or reset user
password
- Returns:
A
User
instance
- get_current_username()[source]
Returns the username associated with the current connection.
- Returns:
- str:
username of the connected user
- coroutine get_model(model)[source]
Get a model by name or UUID.
- Parameters:
model (str) – Model name or UUID
- Returns Model:
Connected Model instance.
- coroutine get_model_info(model_name=None, model_uuid=None)[source]
Return a client.ModelInfo object for a given Model.
Retrieves latest info for this Model from the api server. The return value is cached on the Model.info attribute so that the valued may be accessed again without another api call, if desired.
This method is called automatically when the Model is connected, resulting in Model.info being initialized without requiring an explicit call to this method.
- coroutine get_models(all=False, username=None)[source]
Deprecated since version 0.7.0: Use
list_models()
instead.
- coroutine get_user(username, secret_key=None)[source]
Get a user by name.
- Parameters:
username (str) – Username
secret_key (str) – Issued by juju when add or reset user password
- Returns:
A
User
instance
- coroutine get_users(include_disabled=False)[source]
Return list of users that can connect to this controller.
- Parameters:
include_disabled (bool) – Include disabled users
- Returns:
A list of
User
instances
- coroutine grant(username, acl='login')[source]
Grant access level of the given user on the controller. Note that if the user already has higher permissions than the provided ACL, this will do nothing (see revoke for a way to remove permissions). :param str username: Username :param str acl: Access control (‘login’, ‘add-model’ or ‘superuser’) :returns: True if new access was granted, False if user already had
requested access or greater. Raises JujuError if failed.
- coroutine grant_model(username, model_uuid, acl='read')[source]
Grant a user access to a model. Note that if the user already has higher permissions than the provided ACL, this will do nothing (see revoke_model for a way to remove permissions).
- Parameters:
username (str) – Username
model_uuid (str) – The UUID of the model to change.
acl (str) – Access control (‘read, ‘write’ or ‘admin’)
- coroutine list_models(username=None, all=False)[source]
Return list of names of the available models on this controller.
Equivalent to
sorted((await self.model_uuids()).keys())
- coroutine list_offers(model_name)[source]
Offers list information about applications’ endpoints that have been shared and who is connected.
- coroutine list_secret_backends(reveal=False)[source]
Return the list of secret backends
Parameters
- revealboolean
include sensitive backend config content if true
Returns
- list
a list of available secret backends
- coroutine model_uuids(username=None, all=False)[source]
Return a mapping of model names to UUIDs the given user can access.
- Parameters:
username (str) – Optional username argument, defaults to
current connected user.
- Parameters:
all (bool) – Flag to list all models, regardless of
user accessibility (administrative users only)
- Returns:
{str name : str UUID}
- coroutine remove_cloud(name)[source]
Remove a cloud from this controller.
- Parameters:
name (str) – Name of the cloud to remove.
- coroutine remove_offer(model_uuid, offer, force=False)[source]
Remove offer for an application.
Offers will also remove relations to those offers, use force to do so, without an error.
- coroutine remove_secret_backends(name, force=False)[source]
Remove a secrets backend.
Parameters
name : name of the backend force : true if the operation is foced
Returns
error if any
- coroutine reset_user_password(username)[source]
Reset user password.
- Parameters:
username (str) – Username
- Returns:
A
User
instance
- coroutine revoke(username, acl='login')[source]
Removes some or all access of a user to from a controller If ‘login’ access is revoked, the user will no longer have any permissions on the controller. Revoking a higher privilege from a user without that privilege will have no effect.
- Parameters:
username (str) – username
acl (str) – Access to remove (‘login’, ‘add-model’ or ‘superuser’)
- coroutine revoke_model(username, model_uuid, acl='read')[source]
Revoke some or all of a user’s access to a model. If ‘read’ access is revoked, the user will no longer have any permissions on the model. Revoking a higher privilege from a user without that privilege will have no effect.
- Parameters:
username (str) – Username to revoke
model_uuid (str) – The UUID of the model to change.
acl (str) – Access control (‘read, ‘write’ or ‘admin’)
- coroutine update_secret_backends(name, config=None, force=False, name_change=None, token_rotate_interval=None)[source]
Update a backend.
Parameters
- namestring
the backend name
- configdict
key value dict with configuration parameters
- forceboolean
true to force the upate process
- name_changestring
new name for the backend
- token_rotate_intervalint
token rotation interval