Commit e35a6840 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Cédric Le Ninivin

slapconfiguration: parameters is a dict and not a json

parent 8666c359
...@@ -30,7 +30,6 @@ import logging ...@@ -30,7 +30,6 @@ import logging
import os import os
import slapos.slap import slapos.slap
from slapos.slap.slap import json_loads_byteified
from slapos.recipe.librecipe import unwrap from slapos.recipe.librecipe import unwrap
import six import six
from six.moves.configparser import RawConfigParser from six.moves.configparser import RawConfigParser
...@@ -43,6 +42,7 @@ from slapos import format as slapformat ...@@ -43,6 +42,7 @@ from slapos import format as slapformat
logger = logging.getLogger("slapos") logger = logging.getLogger("slapos")
import time
class Recipe(object): class Recipe(object):
""" """
...@@ -135,6 +135,9 @@ class Recipe(object): ...@@ -135,6 +135,9 @@ class Recipe(object):
1. SlapOS Master - for external computer/partition information 1. SlapOS Master - for external computer/partition information
2. format.Partition.resource_file - for partition specific details 2. format.Partition.resource_file - for partition specific details
""" """
start = time.time()
shared_instance_list = []
software_instance = None software_instance = None
instance_json_path = os.path.join(instance_root, SOFTWARE_INSTANCE_JSON_FILENAME) instance_json_path = os.path.join(instance_root, SOFTWARE_INSTANCE_JSON_FILENAME)
...@@ -175,7 +178,7 @@ class Recipe(object): ...@@ -175,7 +178,7 @@ class Recipe(object):
options["instance-guid"] = software_instance.get("reference") options["instance-guid"] = software_instance.get("reference")
ip_list = software_instance.get("ip_list", []) ip_list = software_instance.get("ip_list", [])
full_ip_list = software_instance.get("full_ip_list", []) full_ip_list = software_instance.get("full_ip_list", [])
parameter_dict = json_loads_byteified(software_instance.get("parameters")) parameter_dict = software_instance.get("parameters")
# Get Share instance list # Get Share instance list
if not "slave_instance_list" in software_instance: if not "slave_instance_list" in software_instance:
...@@ -190,7 +193,7 @@ class Recipe(object): ...@@ -190,7 +193,7 @@ class Recipe(object):
"portal_type": "Software Instance", "portal_type": "Software Instance",
"reference": shared_instance_brain.get("reference"), "reference": shared_instance_brain.get("reference"),
}) })
shared_instance_parameter = json_loads_byteified(shared_instance.get("parameters")) shared_instance_parameter = shared_instance.get("parameters")
shared_instance_connection = shared_instance.get("connection_parameters") shared_instance_connection = shared_instance.get("connection_parameters")
shared_instance_list.append({ shared_instance_list.append({
'slave_title': shared_instance.get("title"), 'slave_title': shared_instance.get("title"),
...@@ -198,9 +201,7 @@ class Recipe(object): ...@@ -198,9 +201,7 @@ class Recipe(object):
shared_instance.get("software_type"), shared_instance.get("software_type"),
'slave_reference': shared_instance.get("reference"), 'slave_reference': shared_instance.get("reference"),
'timestamp': shared_instance.get("processing_timestamp"), 'timestamp': shared_instance.get("processing_timestamp"),
'xml': dumps(shared_instance_parameter),
'parameters': shared_instance_parameter, 'parameters': shared_instance_parameter,
'connection_xml': dumps(shared_instance_connection),
'connection_parameters': shared_instance_connection, 'connection_parameters': shared_instance_connection,
'connection-parameter-hash': calculate_dict_hash(shared_instance_connection), 'connection-parameter-hash': calculate_dict_hash(shared_instance_connection),
}) })
...@@ -328,6 +329,14 @@ class Recipe(object): ...@@ -328,6 +329,14 @@ class Recipe(object):
options[key] = value options[key] = value
# print out augmented options to see what we are passing # print out augmented options to see what we are passing
logger.debug(str(options)) logger.debug(str(options))
end = time.time()
elapsed = end - start
logger.warning("----------------------------------------------------------------------------------------------------------------")
logger.warning("Number of hosted instances: %s" % len(shared_instance_list))
logger.warning("Elapsed time: %s" % elapsed)
logger.warning("----------------------------------------------------------------------------------------------------------------")
return self._expandParameterDict(options, parameter_dict) return self._expandParameterDict(options, parameter_dict)
def _expandParameterDict(self, options, parameter_dict): def _expandParameterDict(self, options, parameter_dict):
......
...@@ -93,7 +93,7 @@ class SlapConfigurationTestMixin(object): ...@@ -93,7 +93,7 @@ class SlapConfigurationTestMixin(object):
"10.0.246.114" "10.0.246.114"
] ]
], ],
"parameters": json.dumps(parameter_dict), "parameters": parameter_dict,
"connection_parameters": {"1": 2, "3": "YourURL"}, "connection_parameters": {"1": 2, "3": "YourURL"},
} }
if self.use_api: if self.use_api:
...@@ -159,7 +159,7 @@ class SlapConfigurationTestMixin(object): ...@@ -159,7 +159,7 @@ class SlapConfigurationTestMixin(object):
"10.0.246.114" "10.0.246.114"
] ]
], ],
"parameters": json.dumps(parameter_dict), "parameters": parameter_dict,
"connection_parameters": {"1": 2, "3": "YourURL"}, "connection_parameters": {"1": 2, "3": "YourURL"},
} }
shared_instance_parameter_dict = {"zooo": "heee", "bye": "hello"} shared_instance_parameter_dict = {"zooo": "heee", "bye": "hello"}
...@@ -183,7 +183,7 @@ class SlapConfigurationTestMixin(object): ...@@ -183,7 +183,7 @@ class SlapConfigurationTestMixin(object):
"10.0.246.114" "10.0.246.114"
] ]
], ],
"parameters": json.dumps(shared_instance_parameter_dict), "parameters": shared_instance_parameter_dict,
"connection_parameters": {"4": 6, "8": "YourURL2"}, "connection_parameters": {"4": 6, "8": "YourURL2"},
} }
if self.use_api: if self.use_api:
......
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