Skip to content

Instantly share code, notes, and snippets.

@marcoceppi
Forked from buggtb/gist:328f36919bd637811a61
Last active March 2, 2016 14:52
Show Gist options
  • Save marcoceppi/d91d6b2cc5072f8204d2 to your computer and use it in GitHub Desktop.
Save marcoceppi/d91d6b2cc5072f8204d2 to your computer and use it in GitHub Desktop.
@when('leadership.is_leader')
def add_leader_config():
render_master_config()
@when_not('leadership.is_leader')
def add_slave_config():
render_slave_config()
@when('leadership.is_leader')
@when_not('self.leader_configured')
def change_leader():
leader_set(hostname=hookenv.unit_private_ip())
leader_set(public_ip=hookenv.unit_public_ip())
leader_set(port=hookenv.config('carte_port'))
leader_set(username='cluster')
leader_set(password=hookenv.config('carte_password'))
leader_set(init=True)
render_master_config()
restart(None)
set_state('self.leader_configured')
@when('leadership.changed')
@when_not('leadership.is_leader')
def change_slave():
render_slave_config()
restart(None)
def render_slave_config():
render('carte-config/slave.xml.j2', '/opt/data-integration/pwd/carte-config.xml', {
'carteslaveport': hookenv.config('carte_port'),
'carteslavehostname': hookenv.unit_private_ip(),
'cartemasterhostname': leader_get('hostname'),
'carteslavepassword': leader_get('password'),
'cartemasterpassword': leader_get('password'),
'cartemasterport': hookenv.config('carte_port')
})
def render_master_config():
render('carte-config/master.xml.j2', '/opt/data-integration/pwd/carte-config.xml', {
'carteport': hookenv.config('carte_port'),
'cartehostname': hookenv.unit_private_ip()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment