A Python library for Juju
Source code: https://github.com/juju/python-libjuju
Bug reports: https://github.com/juju/python-libjuju/issues
Documentation: https://pythonlibjuju.readthedocs.io/en/latest/
Design Notes
Asynchronous - Uses asyncio and async/await features of Python
Websocket-level bindings are programmatically generated (indirectly) from the Juju golang code, ensuring full api coverage
Provides an OO layer which encapsulates much of the websocket api and provides familiar nouns and verbs (e.g. Model.deploy(), Application.add_unit(), etc.)
Installation
pip3 install juju
Quickstart
Here’s a simple example that shows basic usage of the library. The example connects to the currently active Juju model, deploys a single unit of the ubuntu charm, then exits:
Note : Pylibjuju requires an already bootstrapped Juju controller to connect to.
#!/usr/bin/python3
import asyncio
import logging
import sys
from juju.model import Model
async def deploy():
# Create a Model instance. We need to connect our Model to a Juju api
# server before we can use it.
model = Model()
# Connect to the currently active Juju model
await model.connect()
try:
# Deploy a single unit of the ubuntu charm, using the latest revision
# from the stable channel of the Charm Store.
ubuntu_app = await model.deploy(
'ubuntu',
application_name='my-ubuntu',
)
if '--wait' in sys.argv:
# optionally block until the application is ready
await model.wait_for_idle(status='active')
finally:
# Disconnect from the api server and cleanup.
await model.disconnect()
def main():
logging.basicConfig(level=logging.INFO)
# If you want to see everything sent over the wire, set this to DEBUG.
ws_logger = logging.getLogger('websockets.protocol')
ws_logger.setLevel(logging.INFO)
# Run the deploy coroutine in an asyncio event loop, using a helper
# that abstracts loop creation and teardown.
asyncio.run(deploy())
if __name__ == '__main__':
main()
More examples can be found in the docs, as well as in the examples/
directory of the source tree which can be run using tox
. For
example, to run examples/connect_current_model.py
, use:
tox -e example -- examples/connect_current_model.py
REPL
To experiment with the library in a REPL, launch python in asyncio mode
$ python3 -m asyncio
and then, to connect to the current model and fetch status:
>>> from juju.model import Model
>>> model = Model()
>>> await model.connect_current()
>>> status = await model.get_status()
Versioning
The current Pylibjuju release policy tracks the Juju release cadence. In particular, whenever Juju makes a latest/stable release, pylibjuju pushes out a release with the same version in the following week. Newly generated schemas will be updated per Juju releases.
Table of Contents
- Public APIs
- juju.action
- juju.annotation
- juju.application
- juju.constraints
- juju.controller
- juju.delta
- juju.errors
AbstractMethodError
JujuAPIError
JujuAgentError
JujuAppError
JujuApplicationConfigError
JujuAuthError
JujuBackupError
JujuConfigError
JujuConnectionError
JujuControllerNotFoundError
JujuEntityNotFoundError
JujuError
JujuMachineError
JujuModelConfigError
JujuModelError
JujuNotSupportedError
JujuNotValid
JujuPermissionError
JujuRedirectException
JujuUnitError
JujuUnknownVersion
PylibjujuError
PylibjujuProgrammingError
- juju.exceptions
- juju.juju
- juju.loop
- juju.machine
- juju.model
- juju.placement
- juju.relation
- juju.tag
- juju.unit
- juju.user
- juju.utils
Addrs
IdQueue
RegistrationInfo
base_channel_from_series()
base_channel_to_series()
block_until()
block_until_with_coroutine()
execute_process()
generate_user_controller_access_token()
get_base_from_origin_or_channel()
get_local_charm_base()
get_local_charm_charmcraft_yaml()
get_local_charm_data()
get_local_charm_manifest()
get_local_charm_metadata()
get_os_from_series()
get_series_version()
get_version_series()
juju_config_dir()
juju_ssh_key_paths()
parse_base_arg()
read_ssh_key()
run_with_interrupt()
series_for_charm()
series_selector()
should_upgrade_resource()
user_requested()
wait_for_bundle()
- Internal APIs
- juju.client.client module
- juju.client._definitions module
AccessInfo
Action
ActionMessage
ActionResult
ActionResults
ActionSpec
Actions
AddApplicationOffer
AddApplicationOffers
AddApplicationUnits
AddApplicationUnitsResults
AddCharmWithOrigin
AddCloudArgs
AddMachineParams
AddMachines
AddMachinesResult
AddMachinesResults
AddPendingResourcesArgsV2
AddPendingResourcesResult
AddRelation
AddRelationResults
AddSecretBackendArg
AddSecretBackendArgs
AddStorageDetails
AddStorageResult
AddStorageResults
AddUser
AddUserResult
AddUserResults
AddUsers
Address
AllWatcherId
AllWatcherNextResults
AnnotationsGetResult
AnnotationsGetResults
AnnotationsSet
ApplicationCharmActionsResult
ApplicationCharmPlacement
ApplicationCharmPlacements
ApplicationCharmRelations
ApplicationCharmRelationsResults
ApplicationConfigUnsetArgs
ApplicationConstraint
ApplicationDeploy
ApplicationExpose
ApplicationGet
ApplicationGetArgs
ApplicationGetConfigResults
ApplicationGetConstraintsResults
ApplicationGetResults
ApplicationInfoResult
ApplicationInfoResults
ApplicationMergeBindings
ApplicationMergeBindingsArgs
ApplicationMetricCredential
ApplicationMetricCredentials
ApplicationOfferAdminDetails
ApplicationOfferAdminDetailsV5
ApplicationOfferDetails
ApplicationOfferDetailsV5
ApplicationOfferResult
ApplicationOfferStatus
ApplicationOffersResults
ApplicationResult
ApplicationSetCharm
ApplicationStatus
ApplicationUnexpose
ApplicationUnset
ApplicationsCharmActionsResults
ApplicationsDeploy
AuthUserInfo
BackupsCreateArgs
BackupsMetadataResult
Base
Block
BlockResult
BlockResults
BlockSwitchParams
BoolResult
BranchArg
BranchInfoArgs
BranchResults
BranchStatus
BranchTrackArg
BulkImportStorageParams
BundleChange
BundleChangesMapArgs
BundleChangesMapArgsResults
BundleChangesParams
BundleChangesResults
CIDRParams
ChangeModelCredentialParams
ChangeModelCredentialsParams
Charm
CharmActionSpec
CharmActions
CharmBase
CharmContainer
CharmDeployment
CharmDevice
CharmLXDProfile
CharmManifest
CharmMeta
CharmMetric
CharmMetrics
CharmMount
CharmOption
CharmOrigin
CharmOriginResult
CharmPayloadClass
CharmPlan
CharmRelation
CharmResource
CharmResourceMeta
CharmResourceResult
CharmResourcesResults
CharmStorage
CharmURL
CharmURLAndOrigin
CharmURLAndOrigins
CharmURLOriginResult
CharmsList
CharmsListResult
Cloud
CloudCredential
CloudCredentialArg
CloudCredentialArgs
CloudCredentialResult
CloudCredentialResults
CloudDetails
CloudImageMetadata
CloudImageMetadataList
CloudInfo
CloudInfoResult
CloudInfoResults
CloudInstanceTypesConstraint
CloudInstanceTypesConstraints
CloudRegion
CloudResult
CloudResults
CloudSpec
CloudSpecResult
CloudSpecResults
CloudUserInfo
CloudsResult
ConfigResult
ConfigSet
ConfigSetArgs
Constraints
ConsumeApplicationArg
ConsumeApplicationArgV5
ConsumeApplicationArgs
ConsumeApplicationArgsV5
ConsumeOfferDetails
ConsumeOfferDetailsArg
ConsumeOfferDetailsResult
ConsumeOfferDetailsResults
ControllerAPIInfoResult
ControllerAPIInfoResults
ControllerConfigResult
ControllerConfigSet
ControllerCredentialInfo
ControllerVersionResults
ControllersChangeResult
ControllersChangeResults
ControllersChanges
ControllersSpec
ControllersSpecs
CreateSecretArg
CreateSecretArgs
CreateSpaceParams
CreateSpacesParams
CredentialContent
CredentialContentResult
CredentialContentResults
DashboardConnectionInfo
DashboardConnectionSSHTunnel
DeleteSecretArg
DeleteSecretArgs
DeployFromRepositoryArg
DeployFromRepositoryArgs
DeployFromRepositoryInfo
DeployFromRepositoryResult
DeployFromRepositoryResults
DestroyApplicationInfo
DestroyApplicationOffers
DestroyApplicationParams
DestroyApplicationResult
DestroyApplicationResults
DestroyApplicationsParams
DestroyConsumedApplicationParams
DestroyConsumedApplicationsParams
DestroyControllerArgs
DestroyMachineInfo
DestroyMachineResult
DestroyMachineResults
DestroyMachinesParams
DestroyModelParams
DestroyModelsParams
DestroyRelation
DestroyUnitInfo
DestroyUnitParams
DestroyUnitResult
DestroyUnitResults
DestroyUnitsParams
DetailedStatus
DownloadInfoResult
DownloadInfoResults
DumpModelRequest
EndpointFilterAttributes
EndpointRelationData
EndpointStatus
EnqueuedActions
Entities
Entity
EntityAnnotations
EntityMetrics
EntityPassword
EntityPasswords
EntityStatus
Error
ErrorResult
ErrorResults
ExportBundleParams
ExposedEndpoint
ExpressionTree
ExternalControllerInfo
FilesystemAttachmentDetails
FilesystemAttachmentInfo
FilesystemDetails
FilesystemDetailsListResult
FilesystemDetailsListResults
FilesystemFilter
FilesystemFilters
FilesystemInfo
FindToolsParams
FindToolsResult
FirewallRule
FirewallRuleArgs
FullStatus
Generation
GenerationApplication
GenerationId
GenerationResult
GetConstraintsResults
GrantRevokeUserSecretArg
HardwareCharacteristics
History
HostPort
HostedModelConfig
HostedModelConfigsResults
ImageMetadataFilter
ImportStorageDetails
ImportStorageParams
ImportStorageResult
ImportStorageResults
InitiateMigrationArgs
InitiateMigrationResult
InitiateMigrationResults
InstanceType
InstanceTypesResult
InstanceTypesResults
IntResult
InvalidateCredentialArg
IsMeteredResult
LXDProfile
ListCloudImageMetadataResult
ListCloudInfo
ListCloudInfoResult
ListCloudInfoResults
ListCloudsRequest
ListFirewallRulesResults
ListResourcesArgs
ListSSHKeys
ListSecretBackendsArgs
ListSecretBackendsResults
ListSecretResult
ListSecretResults
ListSecretsArgs
ListSpacesResults
ListSubnetsResults
LoginRequest
LoginResult
Macaroon
MachineHardware
MachineStatus
MapResult
MapResults
MetadataImageIds
MetadataSaveParams
MeterStatus
MeterStatusParam
MeterStatusParams
MetricResult
MetricResults
MigrationSpec
MigrationTargetInfo
Model
ModelAccess
ModelApplicationInfo
ModelBlockInfo
ModelBlockInfoList
ModelConfigResults
ModelCreateArgs
ModelDefaultValues
ModelDefaults
ModelDefaultsResult
ModelDefaultsResults
ModelEntityCount
ModelFilesystemInfo
ModelInfo
ModelInfoResult
ModelInfoResults
ModelInstanceTypesConstraint
ModelInstanceTypesConstraints
ModelMachineInfo
ModelMigrationStatus
ModelParam
ModelSLA
ModelSLAInfo
ModelSequencesResult
ModelSet
ModelStatus
ModelStatusInfo
ModelStatusResults
ModelSummariesRequest
ModelSummary
ModelSummaryResult
ModelSummaryResults
ModelTag
ModelUnset
ModelUnsetKeys
ModelUserInfo
ModelUserInfoResult
ModelUserInfoResults
ModelVolumeInfo
ModifyCloudAccess
ModifyCloudAccessRequest
ModifyControllerAccess
ModifyControllerAccessRequest
ModifyModelAccess
ModifyModelAccessRequest
ModifyOfferAccess
ModifyOfferAccessRequest
ModifyUserSSHKeys
MoveSubnetsParam
MoveSubnetsParams
MoveSubnetsResult
MoveSubnetsResults
MovedSubnet
NetworkInterface
NotifyWatchResult
NotifyWatchResults
OfferConnection
OfferFilter
OfferFilters
OfferURLs
OfferUserDetails
OperationQueryArgs
OperationResult
OperationResults
Payload
PayloadListArgs
PayloadListResults
PendingResourceUpload
Placement
ProvisioningScriptParams
ProvisioningScriptResult
Proxy
QueryApplicationOffersResults
QueryApplicationOffersResultsV5
RedirectInfoResult
RegionDefaults
RelationData
RelationStatus
RelationSuspendedArg
RelationSuspendedArgs
RemoteApplicationInfo
RemoteApplicationInfoResult
RemoteApplicationInfoResults
RemoteApplicationStatus
RemoteEndpoint
RemoteSpace
RemoveBlocksArgs
RemoveSecretBackendArg
RemoveSecretBackendArgs
RemoveSpaceParam
RemoveSpaceParams
RemoveSpaceResult
RemoveSpaceResults
RemoveStorage
RemoveStorageInstance
RenameSpaceParams
RenameSpacesParams
ResolveCharmWithChannel
ResolveCharmWithChannelResult
ResolveCharmWithChannelResults
ResolveCharmsWithChannel
ResourcesResult
ResourcesResults
RetryProvisioningArgs
RevokeCredentialArg
RevokeCredentialArgs
RunParams
SSHAddressResult
SSHAddressResults
SSHAddressesResult
SSHAddressesResults
SSHProxyResult
SSHPublicKeysResult
SSHPublicKeysResults
ScaleApplicationInfo
ScaleApplicationParams
ScaleApplicationResult
ScaleApplicationResults
ScaleApplicationsParams
SecretBackend
SecretBackendResult
SecretContentParams
SecretRevision
SecretValueRef
SecretValueResult
SecretsFilter
SetConstraints
SetModelDefaults
ShowSpaceResult
ShowSpaceResults
Space
StatusHistoryFilter
StatusHistoryRequest
StatusHistoryRequests
StatusHistoryResult
StatusHistoryResults
StatusParams
StorageAddParams
StorageAttachmentDetails
StorageAttachmentId
StorageAttachmentIds
StorageConstraints
StorageDetachmentParams
StorageDetails
StorageDetailsListResult
StorageDetailsListResults
StorageDetailsResult
StorageDetailsResults
StorageFilter
StorageFilters
StoragePool
StoragePoolArgs
StoragePoolDeleteArg
StoragePoolDeleteArgs
StoragePoolFilter
StoragePoolFilters
StoragePoolsResult
StoragePoolsResults
StoragesAddParams
StringResult
StringResults
StringsResult
StringsResults
StringsWatchResult
StringsWatchResults
Subnet
SubnetV2
SubnetsFilters
SubnetsResult
SubnetsResults
SummaryWatcherID
SupportedFeature
TaggedCredential
TaggedCredentials
Tools
UnitInfoResult
UnitInfoResults
UnitResources
UnitResult
UnitStatus
UnitsResolved
UnsetModelDefaults
UpdateChannelArg
UpdateChannelArgs
UpdateCloudArgs
UpdateCredentialArgs
UpdateCredentialModelResult
UpdateCredentialResult
UpdateCredentialResults
UpdateSecretBackendArg
UpdateSecretBackendArgs
UpdateUserSecretArg
UpdateUserSecretArgs
UpgradeModelParams
UpgradeModelResult
UpgradeSeriesNotificationParam
UpgradeSeriesNotificationParams
UpgradeSeriesUnitsResult
UpgradeSeriesUnitsResults
UpsertSecretArg
UserAccess
UserAccessResult
UserAccessResults
UserCloud
UserClouds
UserInfo
UserInfoRequest
UserInfoResult
UserInfoResults
UserModel
UserModelList
Value
VolumeAttachmentDetails
VolumeAttachmentInfo
VolumeAttachmentPlanInfo
VolumeDetails
VolumeDetailsListResult
VolumeDetailsListResults
VolumeFilter
VolumeFilters
VolumeInfo
ZoneResult
ZoneResults
- juju.client._client module
ActionFacade
AdminFacade
AllModelWatcherFacade
AllWatcherFacade
AnnotationsFacade
ApplicationFacade
ApplicationOffersFacade
BackupsFacade
BlockFacade
BundleFacade
CharmsFacade
ClientFacade
CloudFacade
ControllerFacade
CredentialManagerFacade
FacadeVersions
FirewallRulesFacade
HighAvailabilityFacade
ImageMetadataManagerFacade
KeyManagerFacade
MachineManagerFacade
MetricsDebugFacade
ModelConfigFacade
ModelGenerationFacade
ModelManagerFacade
ModelUpgraderFacade
PayloadsFacade
PingerFacade
ResourcesFacade
SSHClientFacade
SecretBackendsFacade
SecretsFacade
SpacesFacade
StorageFacade
SubnetsFacade
TypeFactory
UserManagerFacade
lookup_facade()
- juju.client._client1 module
- juju.client._client2 module
- juju.client._client3 module
- juju.client._client4 module
- juju.client._client5 module
- juju.client.codegen module
- juju.client.connection module
- juju.client.facade module
Args
KindRegistry
ReturnMapping()
Schema
Type
TypeEncoder
TypeRegistry
booler()
build_facade()
build_methods()
build_types()
build_validation()
build_watcher_methods()
generate_definitions()
generate_facades()
kind_to_py()
load_schemas()
main()
make_factory()
make_func()
make_rpc_func()
name_to_py()
retspec()
setup()
strcast()
var_type_to_py()
write_client()
write_definitions()
write_facades()
- juju.client.overrides module
- juju.client.runner module
- Module contents
- Syncing Upstream Updates
- Changelog
- 3.6.0.0
- 3.5.2.0
- 3.5.0.0
- 3.4.0.0
- 3.3.1.1
- 3.3.1.0
- 3.3.0.0
- 3.2.3.0
- 3.2.2.0
- 3.2.0.1
- 3.2.0.0
- 3.1.2.0
- 3.1.0.1
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.9.11
- 2.9.10
- 2.9.9
- 2.9.8
- 2.9.7
- 2.9.6
- 2.9.5
- 2.9.4
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.6
- 2.8.5
- 2.8.4
- 2.8.3
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.1
- 2.7.0
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6.0
- 0.11.7
- 0.11.6
- 0.11.5
- 0.11.4
- 0.11.3
- 0.11.2
- 0.11.1
- 0.11.0
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.1
- 0.9.0
- 0.8.0
- 0.7.5
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.1
- 0.6.0
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.2
- 0.1.1
- 0.1.0