---
title: Charmhub | Deploy mongos using Charmhub - The Open Operator Collection
description: Deploy the latest version of mongos on any cloud.
url: https://charmhub.io/mongos/libraries/set_status/source-code
---

# mongos

[Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")

* [Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")

Platform:

24.04

22.04

8/stable 82

```
juju deploy mongos --channel 8/stable
```

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

[Toggle side navigation](https://charmhub.io/mongos/libraries/set_status/source-code#drawer)

##

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

    Fetch library

    ```
    charmcraft fetch-lib
    ```

    [Download set\_status.py](https://charmhub.io/mongos/libraries/set_status/download)
  + *Last updated*
  + *Revision* Library version 0.2

```
#!/usr/bin/env python3
"""Code for handing statuses in the app and unit."""
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

from ops.charm import CharmBase
from ops.framework import Object
from ops.model import StatusBase

import logging
from ops.model import ActiveStatus

logger = logging.getLogger(__name__)

# The unique Charmhub library identifier, never change it
LIBID = "0713372afa0841359edbb777273ecdbf"

# Increment this major API version when introducing breaking changes
LIBAPI = 0

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 2

class MongosStatusHandler(Object):
    """Verifies versions across multiple integrated applications."""

    def __init__(
        self,
        charm: CharmBase,
    ) -> None:
        """Constructor for CrossAppVersionChecker.

        Args:
            charm: charm to inherit from.
        """
        super().__init__(charm, None)
        self.charm = charm

        # TODO Future Feature/Epic: handle update_status

    # BEGIN Helpers

    def set_and_share_status(self, status: StatusBase):
        """Sets the charm status and shares it where applicable."""
        # TODO Future Feature/Epic: process other statuses, i.e. only set provided status if its
        # appropriate.
        self.charm.unit.status = status

        self.set_app_status()

    def set_app_status(self):
        """TODO Future Feature/Epic: parse statuses and set a status for the entire app."""

    def clear_status(self, status_to_clear):
        """Clears the provided status."""
        if self.charm.unit.status != status_to_clear:
            logger.debug(
                "cannot clear status: %s, unit not in that status, unit in %s",
                status_to_clear,
                self.charm.unit.status,
            )
            return

        # TODO: In the future compute the next highest priority status.
        self.charm.unit.status = ActiveStatus()

    # END: Helpers
```
