Skip to content

Instantly share code, notes, and snippets.

@marcoceppi
Forked from lazypower/looking.py
Last active August 29, 2015 13:55
Show Gist options
  • Save marcoceppi/8713685 to your computer and use it in GitHub Desktop.
Save marcoceppi/8713685 to your computer and use it in GitHub Desktop.
def validate_database_relationship():
#Connect to the sentrys and fetch the transmitted details
sent_config = d.sentry.unit['mysql/0'].relation('db', 'owncloud:db')
#Connect to owncloud's sentry and read the configuration PHP file
prod_config = d.sentry.unit['owncloud/0'].file_contents('/var/www/owncloud/config/config.php')
cfg_to_check = {'dbuser': 'user', 'dbpass': 'password', 'dbhost': 'host'}
for cfg_file_key, juju_cfg_key in cfg_to_check.items():
#Search the return string of the config for the transmit values
if prod_config.find("'%s' => '%s'" % (cfg_file_key, sent_config[juju_cfg_key]) == -1:
amulet.raise_status(amulet.SKIP, msg="Unable to validate db sent %s" % juju_cfg_key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment