Commit 2cd6cbc3 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: add Remote Node portal type

It will be used to create cross master allocation
parent 4547aafa
......@@ -13,6 +13,7 @@
</portal_type>
<portal_type id="Compute Node Module">
<item>Instance Node</item>
<item>Remote Node</item>
</portal_type>
<portal_type id="Hosting Subscription Module">
<item>Hosting Subscription</item>
......@@ -20,6 +21,9 @@
<portal_type id="Instance Tree Module">
<item>Instance Tree</item>
</portal_type>
<portal_type id="Remote Node">
<item>Compute Partition</item>
</portal_type>
<portal_type id="Software Installation Module">
<item>Software Installation</item>
</portal_type>
......
......@@ -26,6 +26,9 @@
<portal_type id="Instance Tree Module">
<item>business_application</item>
</portal_type>
<portal_type id="Remote Node">
<item>specialise</item>
</portal_type>
<portal_type id="Slave Instance">
<item>aggregate</item>
<item>specialise</item>
......
......@@ -5,4 +5,7 @@
<portal_type id="Hosting Subscription Module">
<item>Hosting Subscription</item>
</portal_type>
<portal_type id="Remote Node">
<item>Compute Partition</item>
</portal_type>
</hidden_content_type_list>
\ No newline at end of file
......@@ -69,6 +69,12 @@
<portal_type id="Person">
<item>SlaposPersonConstraint</item>
</portal_type>
<portal_type id="Remote Node">
<item>Computer</item>
<item>SlapOSReferenceConstraint</item>
<item>SlapOSVirtualMasterConstraint</item>
<item>SlaposComputeNodeConstraint</item>
</portal_type>
<portal_type id="Slave Instance">
<item>InstanceTree</item>
<item>Reference</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Base Type" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>content_icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>factory</string> </key>
<value> <string>addXMLObject</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<tuple>
<string>item</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Remote Node</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value> <string>RemoteNode_init</string> </value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Base Type</string> </value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>Item</string> </value>
</item>
<item>
<key> <string>type_interface</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -47,6 +47,10 @@
<type>Project</type>
<workflow>project_slap_interface_workflow</workflow>
</chain>
<chain>
<type>Remote Node</type>
<workflow>compute_node_slap_interface_workflow</workflow>
</chain>
<chain>
<type>Slave Instance</type>
<workflow>edit_workflow, instance_slap_interface_workflow, item_workflow, slapos_cloud_interaction_workflow</workflow>
......
......@@ -76,6 +76,10 @@ for compute_node_list, is_slave_on_same_instance_tree_allocable in compute_node_
shared_partition = shared_instance.getAggregateValue(portal_type='Compute Partition')
if shared_partition is not None:
partition_uid_list.append(shared_partition.getUid())
elif compute_node.getPortalType() == 'Remote Node':
parent_uid_list.append(compute_node.getUid())
else:
raise NotImplementedError('Unsupported Node type: %s' % compute_node.getPortalType())
......@@ -179,6 +183,7 @@ else:
for compute_partition_candidate in portal.portal_catalog(
limit=limit, **query_kw):
compute_partition_candidate = compute_partition_candidate.getObject()
if compute_partition_candidate.getParentValue().getCapacityScope() == "close":
# The compute_node was closed on this partition, so skip it.
continue
......
portal = context.getPortalObject()
reference = "REMOTE-%s" % portal.portal_ids.generateNewId(
id_group='slap_instance_node_reference',
id_generator='uid', default=1)
context.edit(reference=reference)
<?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>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>RemoteNode_init</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -477,6 +477,56 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
portal_type='Internet Protocol Address')],
connection_dict.values())
def checkRemoteInstanceAllocation(self, person_user_id, person_reference,
instance_title, software_release, software_type, server,
project_reference):
self.login(person_user_id)
self.personRequestInstanceNotReady(
software_release=software_release,
software_type=software_type,
partition_reference=instance_title,
project_reference=project_reference
)
self.checkCloudContract(person_user_id, person_reference,
instance_title, software_release, software_type, server)
self.stepCallSlaposAllocateInstanceAlarm()
self.tic()
self.personRequestInstance(
software_release=software_release,
software_type=software_type,
partition_reference=instance_title,
project_reference=project_reference
)
# now instantiate it on compute_node and set some nice connection dict
# XXX XXX self.simulateSlapgridCP(server)
# let's find instances of user and check connection strings
instance_tree_list = [q.getObject() for q in
self._getCurrentInstanceTreeList()
if q.getTitle() == instance_title]
self.assertEqual(1, len(instance_tree_list))
instance_tree = instance_tree_list[0]
software_instance = instance_tree.getSuccessorValue()
self.assertEqual(software_instance.getTitle(),
instance_tree.getTitle())
connection_dict = software_instance.getConnectionXmlAsDict()
self.assertSameSet((), connection_dict.keys())
"""
self.assertSameSet(('url_1', 'url_2'), connection_dict.keys())
self.login()
partition = software_instance.getAggregateValue()
self.assertSameSet(
['http://%s/' % q.getIpAddress() for q in
partition.contentValues(portal_type='Internet Protocol Address')],
connection_dict.values())"""
def checkSlaveInstanceUnallocation(self, person_user_id,
person_reference, instance_title,
software_release, software_type, server,
......
......@@ -18,7 +18,7 @@ assert compute_partition.getPortalType() == "Compute Partition"
instance.edit(aggregate_value=compute_partition, activate_kw={'tag': 'allocate_%s' % compute_partition_url})
compute_node = compute_partition.getParentValue()
compute_node.ComputeNode_checkAndUpdateCapacityScope(
allocated_instance=instance
)
if compute_node.getPortalType() == 'Compute Node':
compute_node.ComputeNode_checkAndUpdateCapacityScope(
allocated_instance=instance
)
......@@ -52,6 +52,12 @@
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_RequestedInstance_allocatePartition</string> </value>
......
installation = state_change['object']
compute_node = installation.getAggregateValue(portal_type="Compute Node")
compute_node = installation.getAggregateValue(portal_type=["Remote Node", "Compute Node"])
if compute_node is not None:
compute_node.activate(
after_path_and_method_id=(installation.getPath(), ('immediateReindexObject', 'recursiveImmediateReindexObject'))).reindexObject()
......@@ -60,6 +60,12 @@
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_SoftwareInstallation_reindexComputeNode</string> </value>
......
......@@ -2,9 +2,11 @@ Allocation Supply Line | Allocation Supply Cell
Allocation Supply Module | Allocation Supply
Allocation Supply | Allocation Supply Line
Compute Node Module | Instance Node
Compute Node Module | Remote Node
Compute Node | Certificate Login
Hosting Subscription Module | Hosting Subscription
Instance Tree Module | Instance Tree
Remote Node | Compute Partition
Software Installation Module | Software Installation
Software Instance Module | Slave Instance
Software Instance Module | Software Instance
......
......@@ -7,6 +7,7 @@ Hosting Subscription Module | business_application
Instance Node | specialise
Instance Tree Module | business_application
Instance Tree | destination_section
Remote Node | specialise
Slave Instance | aggregate
Slave Instance | specialise
Software Installation Module | business_application
......
Allocation Supply Line | Allocation Supply Cell
Hosting Subscription Module | Hosting Subscription
\ No newline at end of file
Hosting Subscription Module | Hosting Subscription
Remote Node | Compute Partition
\ No newline at end of file
......@@ -7,6 +7,7 @@ Hosting Subscription Module
Instance Node
Instance Tree
Instance Tree Module
Remote Node
Slave Instance
Software Installation
Software Installation Module
......
......@@ -36,6 +36,10 @@ Instance Tree | TextDocument
Instance Tree | Url
Instance Tree | VariationRange
Person | SlaposPersonConstraint
Remote Node | Computer
Remote Node | SlapOSReferenceConstraint
Remote Node | SlapOSVirtualMasterConstraint
Remote Node | SlaposComputeNodeConstraint
Slave Instance | InstanceTree
Slave Instance | Reference
Slave Instance | SlapOSReferenceConstraint
......
......@@ -18,6 +18,7 @@ Instance Tree | instance_tree_workflow
Organisation | organisation_slap_interface_workflow
Person | person_slap_interface_workflow
Project | project_slap_interface_workflow
Remote Node | compute_node_slap_interface_workflow
Slave Instance | edit_workflow
Slave Instance | instance_slap_interface_workflow
Slave Instance | item_workflow
......
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