Resiliency: allow takeover script to be configurable.

Add a way to takeover remotely.
parent f2a688d5
...@@ -8,7 +8,8 @@ log = logging.getLogger(__name__) ...@@ -8,7 +8,8 @@ log = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
def takeover(server_url, key_file, cert_file, computer_guid, def takeover(server_url, key_file, cert_file, computer_guid,
partition_id, software_release, namebase): partition_id, software_release, namebase,
winner_instance_suffix = None):
""" """
This function does This function does
...@@ -24,11 +25,19 @@ def takeover(server_url, key_file, cert_file, computer_guid, ...@@ -24,11 +25,19 @@ def takeover(server_url, key_file, cert_file, computer_guid,
slap = slapos.slap.slap() slap = slapos.slap.slap()
slap.initializeConnection(server_url, key_file, cert_file) slap.initializeConnection(server_url, key_file, cert_file)
current_partition = slap.registerComputerPartition(computer_guid=computer_guid,
partition_id=partition_id)
# partition that will take over. # partition that will take over.
if winner_instance_suffix:
winner_instance_name = namebase + winner_instance_suffix
# XXX: we hardcode a lot of values here, because request is a settergetter, all at once.
cp_winner = current_partition.request(software_release=software_release,
software_type='importer',
partition_reference=winner_instance_name)
else:
# This script is run in the winning partition: use this one as winner # This script is run in the winning partition: use this one as winner
cp_winner = slap.registerComputerPartition(computer_guid=computer_guid, cp_winner = current_partition
partition_id=partition_id)
# XXX although we can already rename cp_winner, to change its software type we need to # XXX although we can already rename cp_winner, to change its software type we need to
# get hold of the root cp as well # get hold of the root cp as well
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment