Skip to content

Instantly share code, notes, and snippets.

@jnsgruk
Last active May 5, 2021 12:15
Show Gist options
  • Save jnsgruk/322c0058e361255fd7a529dc8fd6d196 to your computer and use it in GitHub Desktop.
Save jnsgruk/322c0058e361255fd7a529dc8fd6d196 to your computer and use it in GitHub Desktop.
Test Machine Charm

Test Charm

To deploy this charm and reproduce its behaviour:

git clone https://gist.github.com/jnsgruk/322c0058e361255fd7a529dc8fd6d196.git machine-charm
cd machine-charm
# Make the charm code executable
chmod +x charm.py
# Build the charm
charmcraft pack -e charm.py
# Deploy the charm
juju deploy ./machine-charm.charm
#!/usr/bin/env python3
import logging
from ops.charm import CharmBase
from ops.main import main
from ops.model import ActiveStatus
logger = logging.getLogger(__name__)
class MachineOperatorCharm(CharmBase):
def __init__(self, *args):
super().__init__(*args)
self.framework.observe(self.on.start, self._on_start)
def _on_start(self, event):
logger.info("Started a machine charm!")
self.unit.status = ActiveStatus()
if __name__ == "__main__":
main(MachineOperatorCharm)
name: machine-charm
description: |
Charm for experimenting with different bases in
machine charms using metadata v2
summary: Test charm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment