Created
May 6, 2015 19:02
-
-
Save bcsaller/6fb14c5b39b2219aadf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from charmhelpers.relations import hook, RelationBase | |
class MysqlClient(RelationBase): | |
cache_keys = ['host', 'port', 'user', 'password'] | |
@hook('relation-changed') | |
def db_connectable(self): | |
data = self.data_available(self.dsn_keys) | |
if data: | |
self.record("dsn", | |
"mysql:%(user)s@%(password)s/%(host)s:%(port)s" % data) | |
self.set_state("%s.connectable" % self.current_relation_name) | |
else: | |
self.remove_state("%s.connectable" % self.current_relation_name) | |
def create_table_space(self, name): | |
"""Can be called after the connectable event has been addressed.""" | |
self.relation_set('db_name', name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment