Skip to content

Instantly share code, notes, and snippets.

@lazypower
Created January 30, 2014 17:13
Show Gist options
  • Save lazypower/8713668 to your computer and use it in GitHub Desktop.
Save lazypower/8713668 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')
#Search the return string of the config for the transmit values
user_search = prod_config.find("'dbuser' => '{}'".format(sent_config['user']))
pass_search = prod_config.find("'dbpass' => '{}'".format(sent_config['password']))
host_search = prod_config.find("'dbhost' => '{}'".format(sent_config['host']))
#Predicates
if user_search == -1:
amulet.raise_status(amulet.SKIP, msg="Unable to validate db sent user")
if pass_search == -1:
amulet.raise_status(amulet.SKIP, msg="Unable to validate db sent pass")
if host_search == -1:
amulet.raise_status(amulet.SKIP, msg="Unable to validate db sent host")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment