Skip to content

Instantly share code, notes, and snippets.

@buggtb
Created March 2, 2016 14:44
Show Gist options
  • Save buggtb/328f36919bd637811a61 to your computer and use it in GitHub Desktop.
Save buggtb/328f36919bd637811a61 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.changed')
@when('leadership.is_leader')
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)
@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