Commit c0a5fc4d authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Include entry point to customise allocation decision

This helps to introduce some scripting for allocation algorithm for specialise certain nodes.

This change was originally introduce by Alain Takoudjou.
parent 7e89b8bc
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>query_kw = dict()\n
\n
return query_kw\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>software_release_url, software_type, software_instance_portal_type, filter_kw, computer_network_query=None, test_mode=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputerPartition_getCustomAllocationParameterDict</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -57,6 +57,7 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery\n
person = context\n
\n
computer_partition = None\n
filter_kw_copy = filter_kw.copy()\n
query_kw = {\n
\'software_release_url\': software_release_url,\n
\'portal_type\': \'Computer Partition\',\n
......@@ -128,6 +129,12 @@ query_kw["capacity_scope_uid"] = context.getPortalObject().portal_categories.cap
# # Only allocation on public computer\n
# query_kw["allocation_scope_uid"] = context.getPortalObject().portal_categories.allocation_scope.open.public.getUid()\n
\n
extra_query_kw = context.ComputerPartition_getCustomAllocationParameterDict(\n
software_release_url, software_type, software_instance_portal_type,\n
filter_kw_copy, computer_network_query, test_mode)\n
if extra_query_kw:\n
query_kw.update(extra_query_kw)\n
\n
if filter_kw.keys():\n
# XXX Drop all unexpected keys\n
query_kw["uid"] = "-1"\n
......
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