Commit eb44a4aa authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_panel: Missing script used by Base_getStatusMonitorUrl

  Since the Base_getStatusMonitorUrl  uses try/except, it didn't detect that the file was missing.

  Copied from slapos_jio (which was removed).
parent 8200dfad
import json
def getCredentialFromUrl(url_string):
username = password = url = ''
param_list = url_string.split('#')
if len(param_list) == 2:
param_list = param_list[1].split('&')
for param in param_list:
key, value = param.split('=')
if key == 'url':
url = value
elif key == 'username':
username = value
elif key == 'password':
password = value
return (url, username, password,)
instance_tree = context
if instance_tree.getSlapState() == 'destroy_requested':
return json.dumps({})
instance = instance_tree.getSuccessorValue()
if instance is None or instance.getSlapState() == 'destroy_requested':
return json.dumps({})
parameter_dict = instance.getConnectionXmlAsDict()
url_string = parameter_dict.get('monitor-setup-url', '')
if url_string:
if 'monitor-user' in parameter_dict and \
'monitor-password' in parameter_dict and \
'monitor-base-url' in parameter_dict:
username = parameter_dict.get('monitor-user')
password = parameter_dict.get('monitor-password')
url = parameter_dict.get('monitor-base-url') + '/public/feeds'
else:
url, username, password = getCredentialFromUrl(url_string)
else:
return json.dumps({})
return json.dumps({
'username': username,
'password': password,
'url': url
})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InstanceTree_getMonitorParameterDict</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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