Commit 880bf167 authored by Benjamin Blanc's avatar Benjamin Blanc

testnode: Add getting Slapos Master Url (for scalability)

parent ba7a3d65
...@@ -494,6 +494,8 @@ revision = %(revision2)s ...@@ -494,6 +494,8 @@ revision = %(revision2)s
return "key" return "key"
def patch_getSlaposAccountCertificate(self, *args, **kw): def patch_getSlaposAccountCertificate(self, *args, **kw):
return "Certificate" return "Certificate"
def patch_getSlaposUrl(self, *args, **kw):
return "http://Foo"
def patch_generateConfiguration(self, *args, **kw): def patch_generateConfiguration(self, *args, **kw):
return json.dumps({"configuration_list": [], "involved_nodes_computer_guid"\ return json.dumps({"configuration_list": [], "involved_nodes_computer_guid"\
: [], "error_message": "No error.", "launcher_nodes_computer_guid": [], \ : [], "error_message": "No error.", "launcher_nodes_computer_guid": [], \
...@@ -566,6 +568,7 @@ revision = %(revision2)s ...@@ -566,6 +568,7 @@ revision = %(revision2)s
if my_test_type == "ScalabilityTest": if my_test_type == "ScalabilityTest":
original_getSlaposAccountKey = TaskDistributor.getSlaposAccountKey original_getSlaposAccountKey = TaskDistributor.getSlaposAccountKey
original_getSlaposAccountCertificate = TaskDistributor.getSlaposAccountCertificate original_getSlaposAccountCertificate = TaskDistributor.getSlaposAccountCertificate
original_getSlaposUrl = TaskDistributor.getSlaposUrl
original_generateConfiguration = TaskDistributor.generateConfiguration original_generateConfiguration = TaskDistributor.generateConfiguration
original_isMasterTestnode = TaskDistributor.isMasterTestnode original_isMasterTestnode = TaskDistributor.isMasterTestnode
original_updateInstanceXML = RunnerClass._updateInstanceXML original_updateInstanceXML = RunnerClass._updateInstanceXML
...@@ -574,6 +577,7 @@ revision = %(revision2)s ...@@ -574,6 +577,7 @@ revision = %(revision2)s
original_SlapOSMasterCommunicator__init__ = SlapOSMasterCommunicator.__init__ original_SlapOSMasterCommunicator__init__ = SlapOSMasterCommunicator.__init__
TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey
TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate
TaskDistributor.getSlaposUrl = patch_getSlaposUrl
TaskDistributor.generateConfiguration = patch_generateConfiguration TaskDistributor.generateConfiguration = patch_generateConfiguration
TaskDistributor.isMasterTestnode = patch_isMasterTestnode TaskDistributor.isMasterTestnode = patch_isMasterTestnode
RunnerClass._updateInstanceXML = doNothing RunnerClass._updateInstanceXML = doNothing
...@@ -605,6 +609,7 @@ revision = %(revision2)s ...@@ -605,6 +609,7 @@ revision = %(revision2)s
if my_test_type == "ScalabilityTest": if my_test_type == "ScalabilityTest":
TaskDistributor.getSlaposAccountKey = original_getSlaposAccountKey TaskDistributor.getSlaposAccountKey = original_getSlaposAccountKey
TaskDistributor.getSlaposAccountCertificate = original_getSlaposAccountCertificate TaskDistributor.getSlaposAccountCertificate = original_getSlaposAccountCertificate
TaskDistributor.getSlaposUrl = original_getSlaposUrl
TaskDistributor.generateConfiguration = original_generateConfiguration TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.isMasterTestnode = original_isMasterTestnode TaskDistributor.isMasterTestnode = original_isMasterTestnode
RunnerClass._updateInstanceXML = original_updateInstanceXML RunnerClass._updateInstanceXML = original_updateInstanceXML
...@@ -665,6 +670,8 @@ revision = %(revision2)s ...@@ -665,6 +670,8 @@ revision = %(revision2)s
return "key" return "key"
def patch_getSlaposAccountCertificate(self, *args, **kw): def patch_getSlaposAccountCertificate(self, *args, **kw):
return "Certificate" return "Certificate"
def patch_getSlaposUrl(self, *args, **kw):
return "http://Foo"
def patch_generateConfiguration(self, *args, **kw): def patch_generateConfiguration(self, *args, **kw):
return json.dumps({"configuration_list": [], "involved_nodes_computer_guid"\ return json.dumps({"configuration_list": [], "involved_nodes_computer_guid"\
: [], "error_message": "No error.", "launcher_nodes_computer_guid": [], \ : [], "error_message": "No error.", "launcher_nodes_computer_guid": [], \
...@@ -723,6 +730,7 @@ revision = %(revision2)s ...@@ -723,6 +730,7 @@ revision = %(revision2)s
if my_test_type == "ScalabilityTest": if my_test_type == "ScalabilityTest":
original_getSlaposAccountKey = TaskDistributor.getSlaposAccountKey original_getSlaposAccountKey = TaskDistributor.getSlaposAccountKey
original_getSlaposAccountCertificate = TaskDistributor.getSlaposAccountCertificate original_getSlaposAccountCertificate = TaskDistributor.getSlaposAccountCertificate
original_getSlaposUrl = TaskDistributor.getSlaposUrl
original_generateConfiguration = TaskDistributor.generateConfiguration original_generateConfiguration = TaskDistributor.generateConfiguration
original_isMasterTestnode = TaskDistributor.isMasterTestnode original_isMasterTestnode = TaskDistributor.isMasterTestnode
original_supply = SlapOSControler.supply original_supply = SlapOSControler.supply
...@@ -733,6 +741,7 @@ revision = %(revision2)s ...@@ -733,6 +741,7 @@ revision = %(revision2)s
original_SlapOSMasterCommunicator__init__ = SlapOSMasterCommunicator.__init__ original_SlapOSMasterCommunicator__init__ = SlapOSMasterCommunicator.__init__
TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey
TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate
TaskDistributor.getSlaposUrl = patch_getSlaposUrl
TaskDistributor.generateConfiguration = patch_generateConfiguration TaskDistributor.generateConfiguration = patch_generateConfiguration
TaskDistributor.isMasterTestnode = patch_isMasterTestnode TaskDistributor.isMasterTestnode = patch_isMasterTestnode
SlapOSControler.supply = doNothing SlapOSControler.supply = doNothing
...@@ -764,6 +773,7 @@ revision = %(revision2)s ...@@ -764,6 +773,7 @@ revision = %(revision2)s
if my_test_type == "ScalabilityTest": if my_test_type == "ScalabilityTest":
TaskDistributor.getSlaposAccountKey = original_getSlaposAccountKey TaskDistributor.getSlaposAccountKey = original_getSlaposAccountKey
TaskDistributor.getSlaposAccountCertificate = original_getSlaposAccountCertificate TaskDistributor.getSlaposAccountCertificate = original_getSlaposAccountCertificate
TaskDistributor.getSlaposUrl = original_getSlaposUrl
TaskDistributor.generateConfiguration = original_generateConfiguration TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.isMasterTestnode = original_isMasterTestnode TaskDistributor.isMasterTestnode = original_isMasterTestnode
SlapOSControler.supply =original_supply SlapOSControler.supply =original_supply
...@@ -944,6 +954,8 @@ revision = %(revision2)s ...@@ -944,6 +954,8 @@ revision = %(revision2)s
return "key" return "key"
def patch_getSlaposAccountCertificate(self, *args, **kw): def patch_getSlaposAccountCertificate(self, *args, **kw):
return "Certificate" return "Certificate"
def patch_getSlaposUrl(self, *args, **kw):
return "http://Foo"
def patch_getTestType(self, *args, **kw): def patch_getTestType(self, *args, **kw):
return "ScalabilityTest" return "ScalabilityTest"
def patch_isHostingSubscriptionReady(self, *args, **kw): def patch_isHostingSubscriptionReady(self, *args, **kw):
...@@ -960,6 +972,7 @@ revision = %(revision2)s ...@@ -960,6 +972,7 @@ revision = %(revision2)s
original_sleep = time.sleep original_sleep = time.sleep
original_getSlaposAccountKey = TaskDistributor.getSlaposAccountKey original_getSlaposAccountKey = TaskDistributor.getSlaposAccountKey
original_getSlaposAccountCertificate = TaskDistributor.getSlaposAccountCertificate original_getSlaposAccountCertificate = TaskDistributor.getSlaposAccountCertificate
original_getSlaposUrl = TaskDistributor.getSlaposUrl
original_generateConfiguration = TaskDistributor.generateConfiguration original_generateConfiguration = TaskDistributor.generateConfiguration
original_isMasterTestnode = TaskDistributor.isMasterTestnode original_isMasterTestnode = TaskDistributor.isMasterTestnode
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
...@@ -979,6 +992,7 @@ revision = %(revision2)s ...@@ -979,6 +992,7 @@ revision = %(revision2)s
time.sleep = doNothing time.sleep = doNothing
TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey TaskDistributor.getSlaposAccountKey = patch_getSlaposAccountKey
TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate
TaskDistributor.getSlaposUrl = patch_getSlaposUrl
TaskDistributor.generateConfiguration = patch_generateConfiguration TaskDistributor.generateConfiguration = patch_generateConfiguration
TaskDistributor.isMasterTestnode = patch_isMasterTestnode TaskDistributor.isMasterTestnode = patch_isMasterTestnode
TaskDistributor.startTestSuite = patch_startTestSuite TaskDistributor.startTestSuite = patch_startTestSuite
...@@ -999,6 +1013,7 @@ revision = %(revision2)s ...@@ -999,6 +1013,7 @@ revision = %(revision2)s
# Restore methods # Restore methods
TaskDistributor.getSlaposAccountKey = original_getSlaposAccountKey TaskDistributor.getSlaposAccountKey = original_getSlaposAccountKey
TaskDistributor.getSlaposAccountCertificate = original_getSlaposAccountCertificate TaskDistributor.getSlaposAccountCertificate = original_getSlaposAccountCertificate
TaskDistributor.getSlaposUrl = original_getSlaposUrl
TaskDistributor.generateConfiguration = original_generateConfiguration TaskDistributor.generateConfiguration = original_generateConfiguration
TaskDistributor.isMasterTestnode = original_isMasterTestnode TaskDistributor.isMasterTestnode = original_isMasterTestnode
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
......
...@@ -570,6 +570,13 @@ class TaskDistributor(RPCRetry): ...@@ -570,6 +570,13 @@ class TaskDistributor(RPCRetry):
""" """
return self._retryRPC('getSlaposAccountCertificate') return self._retryRPC('getSlaposAccountCertificate')
def getSlaposUrl(self):
"""
Returns the url of slapos master related to the distributor
"""
return self._retryRPC('getSlaposUrl')
class DummyTaskDistributionTool(object): class DummyTaskDistributionTool(object):
""" """
Fake remote server. Fake remote server.
......
...@@ -63,8 +63,17 @@ class ScalabilityTestRunner(): ...@@ -63,8 +63,17 @@ class ScalabilityTestRunner():
# Create the slapos account configuration file and dir # Create the slapos account configuration file and dir
key = self.testnode.test_suite_portal.getSlaposAccountKey() key = self.testnode.test_suite_portal.getSlaposAccountKey()
certificate = self.testnode.test_suite_portal.getSlaposAccountCertificate() certificate = self.testnode.test_suite_portal.getSlaposAccountCertificate()
# Get Slapos Master Url
slapos_url = ''
try:
slapos_url = self.testnode.test_suite_portal.getSlaposUrl()
if not slapos_url:
slapos_url = self.testnode.config['server_url']
except:
slapos_url = self.testnode.config['server_url']
self.key_path, self.cert_path, config_path = self.slapos_controler.createSlaposConfigurationFileAccount( self.key_path, self.cert_path, config_path = self.slapos_controler.createSlaposConfigurationFileAccount(
key, certificate, self.testnode.config) key, certificate, slapos_url, self.testnode.config)
self.slapos_communicator = None self.slapos_communicator = None
self.remaining_software_installation_dict = {} self.remaining_software_installation_dict = {}
......
...@@ -77,7 +77,7 @@ class SlapOSControler(object): ...@@ -77,7 +77,7 @@ class SlapOSControler(object):
#TODO: implement a method to get all instance related the slapOS account #TODO: implement a method to get all instance related the slapOS account
# and deleting all old instances (based on creation date or name etc...) # and deleting all old instances (based on creation date or name etc...)
def createSlaposConfigurationFileAccount(self, key, certificate, config): def createSlaposConfigurationFileAccount(self, key, certificate, slapos_url, config):
# Create "slapos_account" directory in the "slapos_directory" # Create "slapos_account" directory in the "slapos_directory"
slapos_account_directory = os.path.join(config['slapos_directory'], "slapos_account") slapos_account_directory = os.path.join(config['slapos_directory'], "slapos_account")
createFolder(slapos_account_directory) createFolder(slapos_account_directory)
...@@ -87,7 +87,7 @@ class SlapOSControler(object): ...@@ -87,7 +87,7 @@ class SlapOSControler(object):
configuration_file_path = os.path.join(slapos_account_directory, "slapos.cfg") configuration_file_path = os.path.join(slapos_account_directory, "slapos.cfg")
configuration_file_value = "[slapos]\nmaster_url = %s\n\ configuration_file_value = "[slapos]\nmaster_url = %s\n\
[slapconsole]\ncert_file = %s\nkey_file = %s" %( [slapconsole]\ncert_file = %s\nkey_file = %s" %(
config['server_url'], slapos_url,
slapos_account_certificate_path, slapos_account_certificate_path,
slapos_account_key_path) slapos_account_key_path)
createFile(slapos_account_key_path, "w", key) createFile(slapos_account_key_path, "w", key)
......
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