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 = {
"reference": context.getReference(),
"md5sum": hashlib.md5(context.asJSONText()).hexdigest(),
"method": "python: hashlib.md5(json_text).hexdigest()",
"data-schema": context.getJSONSchemaUrl()
"data-schema": context.getJSONSchemaUrl(),
}
import json
context.getPortalObject().restrictedTraverse(active_process).postResult(
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
result_list.sort()
data = {
"compute_node_id":context.getReference(),
"node_id":context.getReference(),
# Here it should not be hardcoded
"document_hash_list": result_list,
"timestamp": timestamp
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_aggregateHashFile</string> </value>
<value> <string>SlapOSNode_aggregateHashFile</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -7,14 +7,27 @@ if portal.portal_activities.countMessageWithTag(tag) or \
portal.portal_activities.countMessageWithTag(aggregate_tag):
return
compute_partition_list = portal.portal_catalog(
portal_type="Compute Partition",
validation_state="validated"
)
if not compute_partition_list:
return
compute_partition_uid_list = [x.uid for x in compute_partition_list]
if context.getPortalType() == "Compute Node":
compute_partition_list = portal.portal_catalog(
portal_type="Compute Partition",
validation_state="validated"
)
if not compute_partition_list:
return
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
now = int(time.time())
......@@ -25,25 +38,13 @@ 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()),
portal_type="Software Instance",
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"}
**search_kw
)
context.activate(
tag=aggregate_tag,
after_tag=tag,
activity='SQLQueue').ComputeNode_aggregateHashFile(
activity='SQLQueue').SlapOSNode_aggregateHashFile(
timestamp=now,
active_process=compute_node_active_process.getRelativeUrl()
)
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_generateHashFile</string> </value>
<value> <string>SlapOSNode_generateHashFile</string> </value>
</item>
</dictionary>
</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