Commit c8d33446 authored by Roque's avatar Roque

All my changes since beginning. Includes tasks: 1 to 4 (done) and 5 (current).

parent 646852df
This diff is collapsed.
...@@ -37,6 +37,8 @@ import argparse ...@@ -37,6 +37,8 @@ import argparse
import json import json
from slapos import client from slapos import client
from ConfigParser import ConfigParser
MAX_PARTIONS = 10 MAX_PARTIONS = 10
MAX_SR_RETRIES = 3 MAX_SR_RETRIES = 3
...@@ -78,7 +80,7 @@ class SlapOSControler(object): ...@@ -78,7 +80,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, slapos_url, config): def createSlaposConfigurationFileAccount(self, key, certificate, slapos_url, config, slapos_rest_url):
# 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)
...@@ -86,9 +88,10 @@ class SlapOSControler(object): ...@@ -86,9 +88,10 @@ class SlapOSControler(object):
slapos_account_key_path = os.path.join(slapos_account_directory, "key") slapos_account_key_path = os.path.join(slapos_account_directory, "key")
slapos_account_certificate_path = os.path.join(slapos_account_directory, "certificate") slapos_account_certificate_path = os.path.join(slapos_account_directory, "certificate")
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\nmaster_rest_url = %s\n\
[slapconsole]\ncert_file = %s\nkey_file = %s" %( [slapconsole]\ncert_file = %s\nkey_file = %s" %(
slapos_url, slapos_url,
slapos_rest_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)
...@@ -109,11 +112,19 @@ class SlapOSControler(object): ...@@ -109,11 +112,19 @@ class SlapOSControler(object):
parser.add_argument("software_url") parser.add_argument("software_url")
parser.add_argument("node") parser.add_argument("node")
if os.path.exists(self.configuration_file_path): if os.path.exists(self.configuration_file_path):
self.log("configuration_file_path: " + str(self.configuration_file_path))
args = parser.parse_args([self.configuration_file_path, software_url, computer_id]) args = parser.parse_args([self.configuration_file_path, software_url, computer_id])
config = client.Config() self.log("parsed args: " + str(args))
config.setConfig(args, args.configuration_file) #config = client.Config()
#config.setConfig(args, args.configuration_file)
self.log("Creating clientConfig...")
configp = ConfigParser()
configp.read(self.configuration_file_path)
config = client.ClientConfig(args, configp)
try: try:
local = client.init(config) self.log("config instantiated. Calling client.init(config)...")
local = client.init(config, self.log)
self.log("local instantiated with client.init!")
local['supply'](software_url, computer_guid=computer_id, state=state) local['supply'](software_url, computer_guid=computer_id, state=state)
self.log('SlapOSControler : supply %s %s %s' %(software_url, computer_id, state)) self.log('SlapOSControler : supply %s %s %s' %(software_url, computer_id, state))
except: except:
......
...@@ -65,6 +65,7 @@ class TestNode(object): ...@@ -65,6 +65,7 @@ class TestNode(object):
max_temp_time=MAX_TEMP_TIME): max_temp_time=MAX_TEMP_TIME):
self.testnode_log = log self.testnode_log = log
self.log = log self.log = log
self.log("Config parameter in TestNode.init(): " + str(config))
self.config = config or {} self.config = config or {}
self.process_manager = ProcessManager(log) self.process_manager = ProcessManager(log)
self.working_directory = config['working_directory'] self.working_directory = config['working_directory']
...@@ -405,9 +406,14 @@ shared = true ...@@ -405,9 +406,14 @@ shared = true
node_test_suite.edit(test_result=test_result) node_test_suite.edit(test_result=test_result)
# get cluster configuration for this test suite, this is needed to # get cluster configuration for this test suite, this is needed to
# know slapos parameters to user for creating instances # know slapos parameters to user for creating instances
node_test_suite.edit(cluster_configuration=Utils.deunicodeData(
json.loads(self.test_suite_portal.generateConfiguration( log("Getting configuration from test suite " + str(node_test_suite.test_suite_title))
node_test_suite.test_suite_title))['configuration_list'][0])) generated_config = self.test_suite_portal.generateConfiguration(node_test_suite.test_suite_title)
log("Generated configuration: " + str(generated_config))
jsonData = json.loads(generated_config)
cluster_configuration = Utils.deunicodeData(jsonData['configuration_list'][0])
node_test_suite.edit(cluster_configuration=cluster_configuration)
# Now prepare the installation of SlapOS and create instance # Now prepare the installation of SlapOS and create instance
status_dict = runner.prepareSlapOSForTestSuite(node_test_suite) status_dict = runner.prepareSlapOSForTestSuite(node_test_suite)
# Give some time so computer partitions may start # Give some time so computer partitions may start
......
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