Ops (`ops`)

API reference. Source: Github.

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.)

Like the Charmed Operator Framework Juju as a whole, Ops is sometimes also called “the Charmed Operator Framework”. However, here it means “a framework for building charms”, whereas there it has the broader meaning of “a framework for cloud deployment using charms”.

Charms are designed to be deployed and managed by the Juju OLM. 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 to 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 set 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.


Last updated 4 months ago.