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/
Supported Python versions: 3.8 through 3.13 Supported Juju versions: 3.1 through 3.6
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
How-to guides
- How-to guides
- Manage python-libjuju
- Manage clouds
- Manage credentials
- Manage controllers
- Manage users
- Manage SSH keys
- Manage models
- Manage charms
- Manage applications
- Deploy an application
- View details about an application
- Trust an application with a credential
- Run an application action
- Configure an application
- Scale an application
- Make an application highly available
- Integrate an application with another application
- Manage an application’s public availability over the network
- Manage constraints for an application
- Change space bindings for an application
- Upgrade an application
- Remove an application
- Manage resources (charms)
- Manage actions
- Manage relations
- Manage offers
- Manage units
- Manage secrets
- Manage secret backends
- Manage machines
- Manage storage
- Manage storage pools
- Manage spaces
Overview
API Documentation
- Public APIs
- juju.action
- juju.annotation
- juju.application
- juju.constraints
- juju.controller
- juju.delta
- juju.errors
AbstractMethodErrorJujuAPIErrorJujuAgentErrorJujuAppErrorJujuApplicationConfigErrorJujuAuthErrorJujuBackupErrorJujuConfigErrorJujuConnectionErrorJujuControllerNotFoundErrorJujuEntityNotFoundErrorJujuErrorJujuMachineErrorJujuModelConfigErrorJujuModelErrorJujuNotSupportedErrorJujuNotValidJujuPermissionErrorJujuRedirectExceptionJujuUnitErrorJujuUnknownVersionPylibjujuErrorPylibjujuProgrammingError
- juju.exceptions
- juju.juju
- juju.machine
- juju.model
- juju.placement
- juju.relation
- juju.tag
- juju.unit
- juju.user
- juju.utils
AddrsIdQueueRegistrationInfobase_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
AccessInfoActionActionMessageActionResultActionResultsActionSpecActionsAddApplicationOfferAddApplicationOffersAddApplicationUnitsAddApplicationUnitsResultsAddCharmWithOriginAddCloudArgsAddMachineParamsAddMachinesAddMachinesResultAddMachinesResultsAddPendingResourcesArgsV2AddPendingResourcesResultAddRelationAddRelationResultsAddSecretBackendArgAddSecretBackendArgsAddStorageDetailsAddStorageResultAddStorageResultsAddUserAddUserResultAddUserResultsAddUsersAddressAllWatcherIdAllWatcherNextResultsAnnotationsGetResultAnnotationsGetResultsAnnotationsSetApplicationCharmActionsResultApplicationCharmPlacementApplicationCharmPlacementsApplicationCharmRelationsApplicationCharmRelationsResultsApplicationConfigUnsetArgsApplicationConstraintApplicationDeployApplicationExposeApplicationGetApplicationGetArgsApplicationGetConfigResultsApplicationGetConstraintsResultsApplicationGetResultsApplicationInfoResultApplicationInfoResultsApplicationMergeBindingsApplicationMergeBindingsArgsApplicationMetricCredentialApplicationMetricCredentialsApplicationOfferAdminDetailsApplicationOfferAdminDetailsV5ApplicationOfferDetailsApplicationOfferDetailsV5ApplicationOfferResultApplicationOfferStatusApplicationOffersResultsApplicationResultApplicationSetCharmApplicationStatusApplicationUnexposeApplicationUnsetApplicationsCharmActionsResultsApplicationsDeployAuthUserInfoBackupsCreateArgsBackupsMetadataResultBaseBlockBlockResultBlockResultsBlockSwitchParamsBoolResultBranchArgBranchInfoArgsBranchResultsBranchStatusBranchTrackArgBulkImportStorageParamsBundleChangeBundleChangesMapArgsBundleChangesMapArgsResultsBundleChangesParamsBundleChangesResultsCIDRParamsChangeModelCredentialParamsChangeModelCredentialsParamsCharmCharmActionSpecCharmActionsCharmBaseCharmContainerCharmDeploymentCharmDeviceCharmLXDProfileCharmManifestCharmMetaCharmMetricCharmMetricsCharmMountCharmOptionCharmOriginCharmOriginResultCharmPayloadClassCharmPlanCharmRelationCharmResourceCharmResourceMetaCharmResourceResultCharmResourcesResultsCharmStorageCharmURLCharmURLAndOriginCharmURLAndOriginsCharmURLOriginResultCharmsListCharmsListResultCloudCloudCredentialCloudCredentialArgCloudCredentialArgsCloudCredentialResultCloudCredentialResultsCloudDetailsCloudImageMetadataCloudImageMetadataListCloudInfoCloudInfoResultCloudInfoResultsCloudInstanceTypesConstraintCloudInstanceTypesConstraintsCloudRegionCloudResultCloudResultsCloudSpecCloudSpecResultCloudSpecResultsCloudUserInfoCloudsResultConfigResultConfigSetConfigSetArgsConstraintsConsumeApplicationArgConsumeApplicationArgV5ConsumeApplicationArgsConsumeApplicationArgsV5ConsumeOfferDetailsConsumeOfferDetailsArgConsumeOfferDetailsResultConsumeOfferDetailsResultsControllerAPIInfoResultControllerAPIInfoResultsControllerConfigResultControllerConfigSetControllerCredentialInfoControllerVersionResultsControllersChangeResultControllersChangeResultsControllersChangesControllersSpecControllersSpecsCreateSecretArgCreateSecretArgsCreateSpaceParamsCreateSpacesParamsCredentialContentCredentialContentResultCredentialContentResultsDashboardConnectionInfoDashboardConnectionSSHTunnelDeleteSecretArgDeleteSecretArgsDeployFromRepositoryArgDeployFromRepositoryArgsDeployFromRepositoryInfoDeployFromRepositoryResultDeployFromRepositoryResultsDestroyApplicationInfoDestroyApplicationOffersDestroyApplicationParamsDestroyApplicationResultDestroyApplicationResultsDestroyApplicationsParamsDestroyConsumedApplicationParamsDestroyConsumedApplicationsParamsDestroyControllerArgsDestroyMachineInfoDestroyMachineResultDestroyMachineResultsDestroyMachinesParamsDestroyModelParamsDestroyModelsParamsDestroyRelationDestroyUnitInfoDestroyUnitParamsDestroyUnitResultDestroyUnitResultsDestroyUnitsParamsDetailedStatusDownloadInfoResultDownloadInfoResultsDumpModelRequestEndpointFilterAttributesEndpointRelationDataEndpointStatusEnqueuedActionsEntitiesEntityEntityAnnotationsEntityMetricsEntityPasswordEntityPasswordsEntityStatusErrorErrorResultErrorResultsExportBundleParamsExposedEndpointExpressionTreeExternalControllerInfoFilesystemAttachmentDetailsFilesystemAttachmentInfoFilesystemDetailsFilesystemDetailsListResultFilesystemDetailsListResultsFilesystemFilterFilesystemFiltersFilesystemInfoFindToolsParamsFindToolsResultFirewallRuleFirewallRuleArgsFullStatusGenerationGenerationApplicationGenerationIdGenerationResultGetConstraintsResultsGrantRevokeUserSecretArgHardwareCharacteristicsHistoryHostPortHostedModelConfigHostedModelConfigsResultsImageMetadataFilterImportStorageDetailsImportStorageParamsImportStorageResultImportStorageResultsInitiateMigrationArgsInitiateMigrationResultInitiateMigrationResultsInstanceTypeInstanceTypesResultInstanceTypesResultsIntResultInvalidateCredentialArgIsMeteredResultLXDProfileListCloudImageMetadataResultListCloudInfoListCloudInfoResultListCloudInfoResultsListCloudsRequestListFirewallRulesResultsListResourcesArgsListSSHKeysListSecretBackendsArgsListSecretBackendsResultsListSecretResultListSecretResultsListSecretsArgsListSpacesResultsListSubnetsResultsLoginRequestLoginResultMacaroonMachineHardwareMachineStatusMapResultMapResultsMetadataImageIdsMetadataSaveParamsMeterStatusMeterStatusParamMeterStatusParamsMetricResultMetricResultsMigrationSpecMigrationTargetInfoModelModelAccessModelApplicationInfoModelBlockInfoModelBlockInfoListModelConfigResultsModelCreateArgsModelDefaultValuesModelDefaultsModelDefaultsResultModelDefaultsResultsModelEntityCountModelFilesystemInfoModelInfoModelInfoResultModelInfoResultsModelInstanceTypesConstraintModelInstanceTypesConstraintsModelMachineInfoModelMigrationStatusModelParamModelSLAModelSLAInfoModelSequencesResultModelSetModelStatusModelStatusInfoModelStatusResultsModelSummariesRequestModelSummaryModelSummaryResultModelSummaryResultsModelTagModelUnsetModelUnsetKeysModelUserInfoModelUserInfoResultModelUserInfoResultsModelVolumeInfoModifyCloudAccessModifyCloudAccessRequestModifyControllerAccessModifyControllerAccessRequestModifyModelAccessModifyModelAccessRequestModifyOfferAccessModifyOfferAccessRequestModifyUserSSHKeysMoveSubnetsParamMoveSubnetsParamsMoveSubnetsResultMoveSubnetsResultsMovedSubnetNetworkInterfaceNotifyWatchResultNotifyWatchResultsOfferConnectionOfferFilterOfferFiltersOfferURLsOfferUserDetailsOperationQueryArgsOperationResultOperationResultsPayloadPayloadListArgsPayloadListResultsPendingResourceUploadPlacementProvisioningScriptParamsProvisioningScriptResultProxyQueryApplicationOffersResultsQueryApplicationOffersResultsV5RedirectInfoResultRegionDefaultsRelationDataRelationStatusRelationSuspendedArgRelationSuspendedArgsRemoteApplicationInfoRemoteApplicationInfoResultRemoteApplicationInfoResultsRemoteApplicationStatusRemoteEndpointRemoteSpaceRemoveBlocksArgsRemoveSecretBackendArgRemoveSecretBackendArgsRemoveSpaceParamRemoveSpaceParamsRemoveSpaceResultRemoveSpaceResultsRemoveStorageRemoveStorageInstanceRenameSpaceParamsRenameSpacesParamsResolveCharmWithChannelResolveCharmWithChannelResultResolveCharmWithChannelResultsResolveCharmsWithChannelResourcesResultResourcesResultsRetryProvisioningArgsRevokeCredentialArgRevokeCredentialArgsRunParamsSSHAddressResultSSHAddressResultsSSHAddressesResultSSHAddressesResultsSSHProxyResultSSHPublicKeysResultSSHPublicKeysResultsScaleApplicationInfoScaleApplicationParamsScaleApplicationResultScaleApplicationResultsScaleApplicationsParamsSecretBackendSecretBackendResultSecretContentParamsSecretRevisionSecretValueRefSecretValueResultSecretsFilterSetConstraintsSetModelDefaultsShowSpaceResultShowSpaceResultsSpaceStatusHistoryFilterStatusHistoryRequestStatusHistoryRequestsStatusHistoryResultStatusHistoryResultsStatusParamsStorageAddParamsStorageAttachmentDetailsStorageAttachmentIdStorageAttachmentIdsStorageConstraintsStorageDetachmentParamsStorageDetailsStorageDetailsListResultStorageDetailsListResultsStorageDetailsResultStorageDetailsResultsStorageFilterStorageFiltersStoragePoolStoragePoolArgsStoragePoolDeleteArgStoragePoolDeleteArgsStoragePoolFilterStoragePoolFiltersStoragePoolsResultStoragePoolsResultsStoragesAddParamsStringResultStringResultsStringsResultStringsResultsStringsWatchResultStringsWatchResultsSubnetSubnetV2SubnetsFiltersSubnetsResultSubnetsResultsSummaryWatcherIDSupportedFeatureTaggedCredentialTaggedCredentialsToolsUnitInfoResultUnitInfoResultsUnitResourcesUnitResultUnitStatusUnitsResolvedUnsetModelDefaultsUpdateChannelArgUpdateChannelArgsUpdateCloudArgsUpdateCredentialArgsUpdateCredentialModelResultUpdateCredentialResultUpdateCredentialResultsUpdateSecretBackendArgUpdateSecretBackendArgsUpdateUserSecretArgUpdateUserSecretArgsUpgradeModelParamsUpgradeModelResultUpgradeSeriesNotificationParamUpgradeSeriesNotificationParamsUpgradeSeriesUnitsResultUpgradeSeriesUnitsResultsUpsertSecretArgUserAccessUserAccessResultUserAccessResultsUserCloudUserCloudsUserInfoUserInfoRequestUserInfoResultUserInfoResultsUserModelUserModelListValueVolumeAttachmentDetailsVolumeAttachmentInfoVolumeAttachmentPlanInfoVolumeDetailsVolumeDetailsListResultVolumeDetailsListResultsVolumeFilterVolumeFiltersVolumeInfoZoneResultZoneResults
- juju.client._client module
ActionFacadeAdminFacadeAllModelWatcherFacadeAllWatcherFacadeAnnotationsFacadeApplicationFacadeApplicationOffersFacadeBackupsFacadeBlockFacadeBundleFacadeCharmsFacadeClientFacadeCloudFacadeControllerFacadeCredentialManagerFacadeFacadeVersionsFirewallRulesFacadeHighAvailabilityFacadeImageMetadataManagerFacadeKeyManagerFacadeMachineManagerFacadeMetricsDebugFacadeModelConfigFacadeModelGenerationFacadeModelManagerFacadeModelUpgraderFacadePayloadsFacadePingerFacadeResourcesFacadeSSHClientFacadeSecretBackendsFacadeSecretsFacadeSpacesFacadeStorageFacadeSubnetsFacadeTypeFactoryUserManagerFacadelookup_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
ArgsKindRegistryReturnMapping()SchemaTypeTypeEncoderTypeRegistrybooler()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
Project
- Syncing Upstream Updates
- Changelog
- 3.6.1.2
- 3.6.1.1
- 3.6.1.0
- 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