---
title: Charmhub | Deploy Compound Status using Charmhub - The Open Operator Collection
description: Deploy the latest version of Compound Status on any cloud.
url: https://charmhub.io/compound-status/libraries/compound_status
---

# Compound Status

[Pietro Pasotti](https://charmhub.io/publisher/ppasotti "View all packages from Pietro Pasotti")

* [Pietro Pasotti](https://charmhub.io/publisher/ppasotti "View all packages from Pietro Pasotti")

Platform:

20.04

stable 1

```
juju deploy compound-status
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/compound-status/libraries/compound_status#drawer)

## charms.compound\_status.v0.compound\_status

* [*Docstrings*Docstrings](https://charmhub.io/compound-status/libraries/compound_status)
  [*Code*Source code](https://charmhub.io/compound-status/libraries/compound_status/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.compound_status.v0.compound_status
    ```

    [Download compound\_status.py](https://charmhub.io/compound-status/libraries/compound_status/download)
  + *Last updated* 26 Jul 2022
  + *Revision* Library version 0.5

This charm lib provides a CompoundStatus utility.

Example usage:

> > > class StatusPool(CompoundStatus):
> > > SKIP\_UNKNOWN = True
> > >
> > > ```
> > > workload = Status()
> > > relation_1 = Status()
> > > relation_2 = Status(tag='rel2')
> > > ```
> > >
> > > class TesterCharm(CharmBase):
> > > def **init**(self, framework, key=None):
> > > super().**init**(framework, key)
> > > status\_pool = StatusPool(self)
> > >
> > > ```
> > >     # pro tip: keep the messages short
> > >     status_pool.relation_1 = ActiveStatus('✅')
> > >     status_pool.commit()  # sync with juju
> > >     # equivalent to self.unit.status = status_pool.coalesce()
> > >
> > >     status_pool.relation_1.unset()  # send status_1 back to unknown, until you set it again.
> > >
> > >     status_pool.relation_2 = WaitingStatus('𝌗: foo')
> > >     status_pool.workload.warning('some debug message about why the workload is blocked')
> > >     status_pool.workload.info('some info about the workload')
> > >     status_pool.workload.error('whoopsiedaisies')
> > >     status_pool.workload = BlockedStatus('blocked', 'see debug-log for the reason')
> > >     status_pool.commit()
> > > ```

---

Index

* [class Status](https://charmhub.io/compound-status/libraries/compound_status#status)
* + [def \_\_repr\_\_(
    self)](https://charmhub.io/compound-status/libraries/compound_status#status-__repr__)
* + [def \_\_init\_\_(
    self,
    tag,
    priority)](https://charmhub.io/compound-status/libraries/compound_status#status-__init__)
* + [def priority(
    self)](https://charmhub.io/compound-status/libraries/compound_status#status-priority)
* + [def priority\_key(
    status)](https://charmhub.io/compound-status/libraries/compound_status#status-priority_key)
* + [def sort(
    statuses)](https://charmhub.io/compound-status/libraries/compound_status#status-sort)
* + [def log(
    self,
    level,
    msg)](https://charmhub.io/compound-status/libraries/compound_status#status-log)
* + [def critical(
    self,
    msg)](https://charmhub.io/compound-status/libraries/compound_status#status-critical)
* + [def error(
    self,
    msg)](https://charmhub.io/compound-status/libraries/compound_status#status-error)
* + [def warning(
    self,
    msg)](https://charmhub.io/compound-status/libraries/compound_status#status-warning)
* + [def info(
    self,
    msg)](https://charmhub.io/compound-status/libraries/compound_status#status-info)
* + [def debug(
    self,
    msg)](https://charmhub.io/compound-status/libraries/compound_status#status-debug)
* + [def unset(
    self)](https://charmhub.io/compound-status/libraries/compound_status#status-unset)
* + [def \_\_get\_\_(
    self,
    instance,
    owner)](https://charmhub.io/compound-status/libraries/compound_status#status-__get__)
* + [def \_\_set\_\_(
    self,
    instance,
    value)](https://charmhub.io/compound-status/libraries/compound_status#status-__set__)
* + [def status(
    self)](https://charmhub.io/compound-status/libraries/compound_status#status-status)
* + [def name(
    self)](https://charmhub.io/compound-status/libraries/compound_status#status-name)
* + [def message(
    self)](https://charmhub.io/compound-status/libraries/compound_status#status-message)
* + [def \_\_hash\_\_(
    self)](https://charmhub.io/compound-status/libraries/compound_status#status-__hash__)
* + [def \_\_eq\_\_(
    self,
    other)](https://charmhub.io/compound-status/libraries/compound_status#status-__eq__)
* [class Clobberer](https://charmhub.io/compound-status/libraries/compound_status#clobberer)
* + [def clobber(
    self,
    statuses,
    skip\_unknown)](https://charmhub.io/compound-status/libraries/compound_status#clobberer-clobber)
* [class WorstOnly](https://charmhub.io/compound-status/libraries/compound_status#worstonly)
* + [def \_\_init\_\_(
    self,
    fmt,
    sep)](https://charmhub.io/compound-status/libraries/compound_status#worstonly-__init__)
* + [def clobber(
    self,
    statuses,
    skip\_unknown)](https://charmhub.io/compound-status/libraries/compound_status#worstonly-clobber)
* [class Summary](https://charmhub.io/compound-status/libraries/compound_status#summary)
* + [def \_\_init\_\_(
    self,
    fmt,
    sep)](https://charmhub.io/compound-status/libraries/compound_status#summary-__init__)
* + [def clobber(
    self,
    statuses,
    skip\_unknown)](https://charmhub.io/compound-status/libraries/compound_status#summary-clobber)
* [class Condensed](https://charmhub.io/compound-status/libraries/compound_status#condensed)
* + [def \_\_init\_\_(
    self,
    fmt,
    sep)](https://charmhub.io/compound-status/libraries/compound_status#condensed-__init__)
* + [def clobber(
    self,
    statuses,
    skip\_unknown)](https://charmhub.io/compound-status/libraries/compound_status#condensed-clobber)
* [class MasterStatus](https://charmhub.io/compound-status/libraries/compound_status#masterstatus)
* + [def \_\_init\_\_(
    self,
    tag,
    clobberer,
    priority)](https://charmhub.io/compound-status/libraries/compound_status#masterstatus-__init__)
* + [def message(
    self)](https://charmhub.io/compound-status/libraries/compound_status#masterstatus-message)
* + [def status(
    self)](https://charmhub.io/compound-status/libraries/compound_status#masterstatus-status)
* + [def coalesce(
    self)](https://charmhub.io/compound-status/libraries/compound_status#masterstatus-coalesce)
* + [def unset(
    self)](https://charmhub.io/compound-status/libraries/compound_status#masterstatus-unset)
* + [def \_\_repr\_\_(
    self)](https://charmhub.io/compound-status/libraries/compound_status#masterstatus-__repr__)
* [class StatusPool](https://charmhub.io/compound-status/libraries/compound_status#statuspool)
* + [def \_\_init\_\_(
    self,
    charm,
    key)](https://charmhub.io/compound-status/libraries/compound_status#statuspool-__init__)
* + [def get\_status(
    self,
    attr)](https://charmhub.io/compound-status/libraries/compound_status#statuspool-get_status)
* + [def set\_status(
    self,
    attr,
    status)](https://charmhub.io/compound-status/libraries/compound_status#statuspool-set_status)
* + [def add\_status(
    self,
    status,
    attr)](https://charmhub.io/compound-status/libraries/compound_status#statuspool-add_status)
* + [def remove\_status(
    self,
    status)](https://charmhub.io/compound-status/libraries/compound_status#statuspool-remove_status)
* + [def \_\_setattr\_\_(
    self,
    key,
    value)](https://charmhub.io/compound-status/libraries/compound_status#statuspool-__setattr__)
* + [def commit(
    self)](https://charmhub.io/compound-status/libraries/compound_status#statuspool-commit)
* + [def unset(
    self)](https://charmhub.io/compound-status/libraries/compound_status#statuspool-unset)
* + [def \_\_repr\_\_(
    self)](https://charmhub.io/compound-status/libraries/compound_status#statuspool-__repr__)

#### class Status

Description

Represents a status. None

Methods

Status.
\_\_repr\_\_(

*self*
)

Status.
\_\_init\_\_(

*self*

,
tag

,
priority
)

Status.
priority(

*self*
)

Description

Return the priority of this status. None

Status.
priority\_key(

status
)

Description

Return the priority key. None

Status.
sort(

statuses
)

Description

Return the statuses, sorted worst-to-best. None

Status.
log(

*self*

,
level: int

,
msg: str
)

Description

Associate with this status a log entry with level `log`. None

Status.
critical(

*self*

,
msg: str
)

Description

Associate with this status a log entry with level `critical`. None

Status.
error(

*self*

,
msg: str
)

Description

Associate with this status a log entry with level `error`. None

Status.
warning(

*self*

,
msg: str
)

Description

Associate with this status a log entry with level `warning`. None

Status.
info(

*self*

,
msg: str
)

Description

Associate with this status a log entry with level `info`. None

Status.
debug(

*self*

,
msg: str
)

Description

Associate with this status a log entry with level `debug`. None

Status.
unset(

*self*
)

Unsets status and message.

Description

This status will go back to its initial state and be removed from the
Master clobber.

Status.
\_\_get\_\_(

*self*

,
instance

,
owner
)

Status.
\_\_set\_\_(

*self*

,
instance

,
value: StatusBase
)

Status.
status(

*self*
)

Description

Return the string representing this status. None

Status.
name(

*self*
)

Description

Alias for interface-compatibility with ops.model.StatusBase. None

Status.
message(

*self*
)

Description

Return the message associated with this status. None

Status.
\_\_hash\_\_(

*self*
)

Status.
\_\_eq\_\_(

*self*

,
other
)

#### class Clobberer

Description

Clobberer. Repeat it many times fast. None

Methods

Clobberer.
clobber(

*self*

,
statuses

,
skip\_unknown: bool
)

Description

Produce a clobbered representation of the statuses. None

#### class WorstOnly

This clobberer provides a worst-only view of the current statuses in the pool.

Description

e.g. if the status pool has three statuses:
relation\_1 = ActiveStatus('✅')
relation\_2 = WaitingStatus('𝌗: foo')
workload = BlockedStatus('💔')

The Summary clobbered status will have as message::
(workload) 💔

Methods

WorstOnly.
\_\_init\_\_(

*self*

,
fmt: str

,
sep: str
)

WorstOnly.
clobber(

*self*

,
statuses

,
skip\_unknown: bool
)

Description

Produce a clobbered representation of the statuses. None

#### class Summary

This clobberer provides a worst-first, summarized view of all statuses.

Description

e.g. if the status pool has three statuses:
relation\_1 = ActiveStatus('✅')
relation\_2 = WaitingStatus('𝌗: foo')
workload = BlockedStatus('💔')

The Summary clobbered status will have as message:
(workload:blocked) 💔; (relation\_1:active) ✅; (rel2:waiting) 𝌗: foo

Methods

Summary.
\_\_init\_\_(

*self*

,
fmt: str

,
sep: str
)

Summary.
clobber(

*self*

,
statuses

,
skip\_unknown: bool
)

Description

Produce a clobbered representation of the statuses. None

#### class Condensed

This clobberer provides a very compact, summarized view of all statuses.

Description

e.g. if the status pool has three statuses:
relation\_1 = ActiveStatus('✅')
relation\_2 = WaitingStatus('✅')
relation\_3 = BlockedStatus('✅')
relation\_... = ???
relation\_N = ActiveStatus('✅')
relation\_2 = WaitingStatus('𝌗: foo')
workload = BlockedStatus('💔')

The Condensed clobbered status will have as message:
15 blocked; 43 waiting; 12 active

If all are active the message will be empty.
Priority will be ignored.

Methods

Condensed.
\_\_init\_\_(

*self*

,
fmt: str

,
sep: str
)

Condensed.
clobber(

*self*

,
statuses

,
skip\_unknown: bool
)

Description

Produce a clobbered representation of the statuses. None

#### class MasterStatus

The Master status of the pool.

Arguments

- `tag`

the name to associate the master status with.

- `fmt`

The format for each child status. Needs to contain three {}
slots, will receive three arguments in this order:

* the tag of the child status (a string)
* the name of the child status (e.g. 'blocked', or 'active')
* the message associated with the child status (another string)

- `sep`

The separator used to join together the child statuses.

Methods

MasterStatus.
\_\_init\_\_(

*self*

,
tag: str

,
clobberer: Clobberer

,
priority
)

MasterStatus.
message(

*self*
)

Description

Return the message associated with this status. None

MasterStatus.
status(

*self*
)

Description

Return the status. None

MasterStatus.
coalesce(

*self*
)

Description

Cast to an ops.model.StatusBase instance by clobbering statuses and messages. None

MasterStatus.
unset(

*self*
)

Description

Unset all child statuses, as well as any user\_set Master status. None

MasterStatus.
\_\_repr\_\_(

*self*
)

#### class StatusPool

Description

Represents the pool of statuses available to an Object. None

Methods

StatusPool.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
key
)

StatusPool.
get\_status(

*self*

,
attr: str
)

Description

Retrieve a status by name. Equivalent to getattr(self, attr). None

StatusPool.
set\_status(

*self*

,
attr: str

,
status: StatusBase
)

Description

Set a status by name. Equivalent to setattr(self, attr, status). None

StatusPool.
add\_status(

*self*

,
status: Status

,
attr
)

Add status to this pool; under attr: `attr`.

Description

If attr is not provided, status.tag will be used instead if set.

NB `attr` needs to be a valid Python identifier.

StatusPool.
remove\_status(

*self*

,
status: Status
)

Description

Remove the status and forget about it. None

StatusPool.
\_\_setattr\_\_(

*self*

,
key: str

,
value: StatusBase
)

StatusPool.
commit(

*self*
)

Description

Store the current state and sync with juju. None

StatusPool.
unset(

*self*
)

Description

Unsets master status (and all children). None

StatusPool.
\_\_repr\_\_(

*self*
)
