Commit 7b613a01 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

slapos_jio_api_style: Generate Hash document for instances hosting shared instances

parent 03d74ad9
...@@ -5,8 +5,19 @@ data = { ...@@ -5,8 +5,19 @@ data = {
"reference": context.getReference(), "reference": context.getReference(),
"md5sum": hashlib.md5(context.asJSONText()).hexdigest(), "md5sum": hashlib.md5(context.asJSONText()).hexdigest(),
"method": "python: hashlib.md5(json_text).hexdigest()", "method": "python: hashlib.md5(json_text).hexdigest()",
"data-schema": context.getJSONSchemaUrl() "data-schema": context.getJSONSchemaUrl(),
} }
import json import json
context.getPortalObject().restrictedTraverse(active_process).postResult( context.getPortalObject().restrictedTraverse(active_process).postResult(
ActiveResult(detail=json.dumps(data).encode('utf8').encode('zlib'))) ActiveResult(detail=json.dumps(data).encode('utf8').encode('zlib')))
if context.getPortalType() == "Software Instance":
host_shared_instance = context.getPortalObject().portal_catalog(
limit=1,
default_aggregate_uid=context.getAggregateUid(),
portal_type="Slave Instance",
validation_state="validated",
**{"slapos_item.slap_state": "start_requested"}
)
if host_shared_instance:
context.activate().SlapOSNode_generateHashFile()
...@@ -7,7 +7,7 @@ result_list = [ json.loads(result.detail.decode('zlib')) for result in active_pr ...@@ -7,7 +7,7 @@ result_list = [ json.loads(result.detail.decode('zlib')) for result in active_pr
result_list.sort() result_list.sort()
data = { data = {
"compute_node_id":context.getReference(), "node_id":context.getReference(),
# Here it should not be hardcoded # Here it should not be hardcoded
"document_hash_list": result_list, "document_hash_list": result_list,
"timestamp": timestamp "timestamp": timestamp
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ComputeNode_aggregateHashFile</string> </value> <value> <string>SlapOSNode_aggregateHashFile</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -7,14 +7,27 @@ if portal.portal_activities.countMessageWithTag(tag) or \ ...@@ -7,14 +7,27 @@ if portal.portal_activities.countMessageWithTag(tag) or \
portal.portal_activities.countMessageWithTag(aggregate_tag): portal.portal_activities.countMessageWithTag(aggregate_tag):
return return
compute_partition_list = portal.portal_catalog( if context.getPortalType() == "Compute Node":
compute_partition_list = portal.portal_catalog(
portal_type="Compute Partition", portal_type="Compute Partition",
validation_state="validated" validation_state="validated"
) )
if not compute_partition_list: if not compute_partition_list:
return return
compute_partition_uid_list = [x.uid for x in compute_partition_list]
compute_partition_uid_list = [x.uid for x in compute_partition_list] search_kw = {
"portal_type":"Software Instance",
"default_aggregate_uid":compute_partition_uid_list,
"validation_state":"validated",
}
else:
# Case the Node is an Instance
search_kw = {
"default_aggregate_uid": context.getAggregateUid(),
"portal_type": "Slave Instance",
"validation_state": "validated",
"slapos_item.slap_state": "start_requested",
}
import time import time
now = int(time.time()) now = int(time.time())
...@@ -25,25 +38,13 @@ portal.portal_catalog.searchAndActivate( ...@@ -25,25 +38,13 @@ portal.portal_catalog.searchAndActivate(
method_id="Base_postAsJSONResultToActiveProcess", method_id="Base_postAsJSONResultToActiveProcess",
activate_kw=dict(tag=tag, priority=priority), activate_kw=dict(tag=tag, priority=priority),
method_kw=dict(active_process=compute_node_active_process.getRelativeUrl()), method_kw=dict(active_process=compute_node_active_process.getRelativeUrl()),
portal_type="Software Instance", **search_kw
default_aggregate_uid=compute_partition_uid_list,
validation_state="validated",
)
portal.portal_catalog.searchAndActivate(
method_id="Base_postAsJSONResultToActiveProcess",
activate_kw=dict(tag=tag, priority=priority),
method_kw=dict(active_process=compute_node_active_process.getRelativeUrl()),
default_aggregate_uid=compute_partition_uid_list,
portal_type="Slave Instance",
validation_state="validated",
**{"slapos_item.slap_state": "start_requested"}
) )
context.activate( context.activate(
tag=aggregate_tag, tag=aggregate_tag,
after_tag=tag, after_tag=tag,
activity='SQLQueue').ComputeNode_aggregateHashFile( activity='SQLQueue').SlapOSNode_aggregateHashFile(
timestamp=now, timestamp=now,
active_process=compute_node_active_process.getRelativeUrl() active_process=compute_node_active_process.getRelativeUrl()
) )
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ComputeNode_generateHashFile</string> </value> <value> <string>SlapOSNode_generateHashFile</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
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