Commit 608437ce authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: include support to slave when display the reported state

Slave will display state of the Software Instance which it is attached to.
parent adf0a95c
Pipeline #7565 passed with stage
in 0 seconds
from zExceptions import UnauthorizedError
if REQUEST is not None:
raise UnauthorizedError
from DateTime import DateTime
import json
......@@ -5,7 +9,7 @@ slap_state = context.getSlapState()
_translate = context.Base_translateString
NOT_ALLOCATED = _translate("Searching Partition")
NOT_ALLOCATED = _translate("Searching for partition")
STARTING = _translate("Starting")
STARTED = _translate("Started")
STOPPING = _translate("Stopping")
......@@ -18,11 +22,15 @@ UNKNOWN = _translate("Waiting contact from the instance")
computer_partition = context.getAggregateValue(portal_type="Computer Partition")
if computer_partition is not None:
memcached_dict = context.Base_getSlapToolMemcachedDict()
instance = context
if instance.getPortalType() == "Slave Instance":
instance = computer_partition.getAggregateRelatedValue(portal_type="Software Instance")
memcached_dict = instance.Base_getSlapToolMemcachedDict()
try:
d = memcached_dict[context.getReference()]
d = memcached_dict[instance.getReference()]
except KeyError:
return _translate(context.getSlapStateTitle())
return _translate(instance.getSlapStateTitle())
d = json.loads(d)
result = d['text']
......@@ -33,7 +41,6 @@ if computer_partition is not None:
if slap_state == "destroy_requested":
return DESTROYING
if reported_state == "stopped":
if slap_state == "start_requested":
if result.startswith('#error '):
......@@ -51,7 +58,7 @@ if computer_partition is not None:
return FAILING_STOP
return STOPPING
raise ValueError("%s %s %s Unknown State" % (context.getRelativeUrl(), result, slap_state))
raise ValueError("%s %s %s Unknown State" % (instance.getRelativeUrl(), result, slap_state))
if slap_state == "destroy_requested":
......
......@@ -50,7 +50,15 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </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