Ops (`ops`)

API reference. Source: Github.

In Juju, Ops (ops) is a Python framework for developing charms. It uses standard Python structures to make charm development simple and straightforward, and to allow for clean, maintainable, and reusable code. It is the state-of-the-art tool for writing charms. (For a history of the previous incarnations of Ops see About charming history.)

Charms are designed to be deployed and managed by Juju. The way this works from the point of view of Ops is as follows: Juju (juju) has an API. When you deploy a charm, that deploys an agent that talks to the Juju API. By means of context variables, Juju tells the agent why it is being executed (what changed in the model to trigger this call). By means of the hook tools, the agent can get more information, when needed, from the controller, and send some data back (e.g., relation data). Each hook tool invocation corresponds to an API call. Ops provides an object-oriented, high-level wrapper to interact with hook tools. More specifically, Ops has input given by hook tool calls and environment variables and output given by hook tools.

image

Last updated 4 months ago. Help improve this document in the forum.