Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*swp
builds
deps
12 changes: 11 additions & 1 deletion layer.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
includes: ['layer:basic'] # if you use any interfaces, add them here
includes:
- layer:basic
- layer:apt
- interface:mysql
options:
# basic:
# packages:
# - python3-psycopg2
apt:
packages:
- git
3 changes: 3 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ tags:
- misc
subordinate: false
series: ['xenial']
requires:
mysqlbackend:
interface: mysql
35 changes: 20 additions & 15 deletions reactive/simple_react.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
from charms.reactive import when, when_not, set_state
from charmhelpers.core.hookenv import status_set, log
from charms.reactive import endpoint_from_flag

import charms.apt

@when_not('simple-react.installed')
def install_simple_react():
# Do your setup here.
#
# If your charm has other dependencies before it can install,
# add those as @when() clauses above., or as additional @when()
# decorated handlers below
#
# See the following for information about reactive charms:
#
# * https://jujucharms.com/docs/devel/developer-getting-started
# * https://github.com/juju-solutions/layer-basic#overview
#
print("I hope this is logged!")
set_state('simple-react.installed')
@when_not('apt.installed.git')
def git_not_installed_yet():
log("DEBUG: 1: Waiting for git to be installed")
status_set('waiting', 'DEBUG: 1: Waiting for git to be installed')

@when('apt.installed.git')
def git_installed():
log('DEBUG: 2: Git is now installed, waiting for db to be connected')
set_state('simple-react.wait4db')
status_set('blocked', 'Waiting for db to be connected')

@when('mysqlbackend.available')
@when('simple-react.wait4db')
def announce_no_db():
mysql = endpoint_from_flag('mysqlbackend.available')
log('DEBUG: 3: The MySQL backend is not yet available at ' + mysql.connection_string())
status_set('active', 'The MySQL backend is available at ' + mysql.connection_string())