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
from zExceptions import UnauthorizedError
if REQUEST is not None:
raise UnauthorizedError
from DateTime import DateTime from DateTime import DateTime
import json import json
...@@ -5,7 +9,7 @@ slap_state = context.getSlapState() ...@@ -5,7 +9,7 @@ slap_state = context.getSlapState()
_translate = context.Base_translateString _translate = context.Base_translateString
NOT_ALLOCATED = _translate("Searching Partition") NOT_ALLOCATED = _translate("Searching for partition")
STARTING = _translate("Starting") STARTING = _translate("Starting")
STARTED = _translate("Started") STARTED = _translate("Started")
STOPPING = _translate("Stopping") STOPPING = _translate("Stopping")
...@@ -18,11 +22,15 @@ UNKNOWN = _translate("Waiting contact from the instance") ...@@ -18,11 +22,15 @@ UNKNOWN = _translate("Waiting contact from the instance")
computer_partition = context.getAggregateValue(portal_type="Computer Partition") computer_partition = context.getAggregateValue(portal_type="Computer Partition")
if computer_partition is not None: 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: try:
d = memcached_dict[context.getReference()] d = memcached_dict[instance.getReference()]
except KeyError: except KeyError:
return _translate(context.getSlapStateTitle()) return _translate(instance.getSlapStateTitle())
d = json.loads(d) d = json.loads(d)
result = d['text'] result = d['text']
...@@ -33,7 +41,6 @@ if computer_partition is not None: ...@@ -33,7 +41,6 @@ if computer_partition is not None:
if slap_state == "destroy_requested": if slap_state == "destroy_requested":
return DESTROYING return DESTROYING
if reported_state == "stopped": if reported_state == "stopped":
if slap_state == "start_requested": if slap_state == "start_requested":
if result.startswith('#error '): if result.startswith('#error '):
...@@ -51,7 +58,7 @@ if computer_partition is not None: ...@@ -51,7 +58,7 @@ if computer_partition is not None:
return FAILING_STOP return FAILING_STOP
return STOPPING 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": if slap_state == "destroy_requested":
......
...@@ -50,7 +50,15 @@ ...@@ -50,7 +50,15 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <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