Commit 5e387dd2 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: add interaction to trigger the allocation alarm

- when instance url, type and sla are modified
- when a Node may match new SLA conditions
- when partition changes
- when Installation is requested
- when allocation supply is modified
- when Allocation Cell is checked
parent 5d367b70
...@@ -56,6 +56,12 @@ ...@@ -56,6 +56,12 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
......
...@@ -50,6 +50,12 @@ ...@@ -50,6 +50,12 @@
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Base Type</string> </value> <value> <string>Base Type</string> </value>
</item> </item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>type_class</string> </key> <key> <string>type_class</string> </key>
<value> <string>Supply</string> </value> <value> <string>Supply</string> </value>
......
<workflow_chain> <workflow_chain>
<chain> <chain>
<type>Allocation Supply</type> <type>Allocation Supply</type>
<workflow>edit_workflow, validation_workflow</workflow> <workflow>edit_workflow, slapos_cloud_interaction_workflow, validation_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Allocation Supply Cell</type> <type>Allocation Supply Cell</type>
<workflow>supply_cell_interaction_workflow</workflow> <workflow>slapos_cloud_interaction_workflow, supply_cell_interaction_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Allocation Supply Line</type> <type>Allocation Supply Line</type>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</chain> </chain>
<chain> <chain>
<type>Compute Partition</type> <type>Compute Partition</type>
<workflow>compute_partition_slap_interface_workflow</workflow> <workflow>compute_partition_slap_interface_workflow, slapos_cloud_interaction_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Computer Network</type> <type>Computer Network</type>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
</chain> </chain>
<chain> <chain>
<type>Instance Node</type> <type>Instance Node</type>
<workflow>edit_workflow, validation_workflow</workflow> <workflow>edit_workflow, slapos_cloud_interaction_workflow, validation_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Instance Tree</type> <type>Instance Tree</type>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
</chain> </chain>
<chain> <chain>
<type>Remote Node</type> <type>Remote Node</type>
<workflow>compute_node_slap_interface_workflow, edit_workflow, validation_workflow</workflow> <workflow>compute_node_slap_interface_workflow, edit_workflow, slapos_cloud_interaction_workflow, validation_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Slave Instance</type> <type>Slave Instance</type>
......
...@@ -934,7 +934,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -934,7 +934,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
) )
if disable_alarm: if disable_alarm:
# disable generation of Upgrade Decision # disable generation of Upgrade Decision
with TemporaryAlarmScript(self.portal, 'Base_reindexAndSenseAlarm', "'disabled'"): with TemporaryAlarmScript(self.portal, 'Base_reindexAndSenseAlarm', "'disabled'", attribute='comment'):
allocation_supply.validate() allocation_supply.validate()
else: else:
allocation_supply.validate() allocation_supply.validate()
......
...@@ -8,6 +8,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin): ...@@ -8,6 +8,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
def makeAllocableComputeNode(self, project, software_product, def makeAllocableComputeNode(self, project, software_product,
release_variation, type_variation): release_variation, type_variation):
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
compute_node, partition = self._makeComputeNode(project) compute_node, partition = self._makeComputeNode(project)
self.addAllocationSupply("for compute node", compute_node, software_product, self.addAllocationSupply("for compute node", compute_node, software_product,
release_variation, type_variation) release_variation, type_variation)
...@@ -27,6 +28,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin): ...@@ -27,6 +28,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
def makeAllocableSoftwareInstanceAndProduct(self, allocation_state='possible', def makeAllocableSoftwareInstanceAndProduct(self, allocation_state='possible',
shared=False, node="compute"): shared=False, node="compute"):
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
software_product, release_variation, type_variation, compute_node, partition, instance_tree = \ software_product, release_variation, type_variation, compute_node, partition, instance_tree = \
self.bootstrapAllocableInstanceTree(allocation_state=allocation_state, shared=shared, node=node) self.bootstrapAllocableInstanceTree(allocation_state=allocation_state, shared=shared, node=node)
...@@ -287,6 +289,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin): ...@@ -287,6 +289,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
compute_node.edit( compute_node.edit(
subordination_value=computer_network subordination_value=computer_network
) )
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic() self.tic()
self.assertEqual(None, software_instance.getAggregateValue( self.assertEqual(None, software_instance.getAggregateValue(
...@@ -359,6 +362,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin): ...@@ -359,6 +362,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
) )
self.portal.portal_workflow._jumpToStateFor(software_instance2, 'start_requested') self.portal.portal_workflow._jumpToStateFor(software_instance2, 'start_requested')
self.portal.portal_workflow._jumpToStateFor(software_instance2, 'validated') self.portal.portal_workflow._jumpToStateFor(software_instance2, 'validated')
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic() self.tic()
self.assertEqual(None, self.assertEqual(None,
...@@ -421,6 +425,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin): ...@@ -421,6 +425,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
compute_node2.edit(subordination_value=computer_network1) compute_node2.edit(subordination_value=computer_network1)
compute_node3.edit(subordination_value=computer_network2) compute_node3.edit(subordination_value=computer_network2)
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic() self.tic()
self.assertEqual(None, software_instance.getAggregateValue( self.assertEqual(None, software_instance.getAggregateValue(
...@@ -560,6 +565,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin): ...@@ -560,6 +565,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
compute_node1.edit(subordination_value=computer_network) compute_node1.edit(subordination_value=computer_network)
compute_node2.edit(subordination_value=computer_network) compute_node2.edit(subordination_value=computer_network)
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic() self.tic()
self.assertEqual(None, software_instance.getAggregateValue( self.assertEqual(None, software_instance.getAggregateValue(
...@@ -581,9 +587,9 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin): ...@@ -581,9 +587,9 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
) )
self.portal.portal_workflow._jumpToStateFor(software_instance2, 'start_requested') self.portal.portal_workflow._jumpToStateFor(software_instance2, 'start_requested')
self.portal.portal_workflow._jumpToStateFor(software_instance2, 'validated') self.portal.portal_workflow._jumpToStateFor(software_instance2, 'validated')
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic() self.tic()
self.assertEqual(None, self.assertEqual(None,
software_instance.getAggregateValue(portal_type='Compute Partition')) software_instance.getAggregateValue(portal_type='Compute Partition'))
...@@ -635,6 +641,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin): ...@@ -635,6 +641,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
self.assertEqual(compute_node.getAllocationScope(), "open") self.assertEqual(compute_node.getAllocationScope(), "open")
self.assertEqual(compute_node.getCapacityScope(), "open") self.assertEqual(compute_node.getCapacityScope(), "open")
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic() self.tic()
self.assertEqual(None, software_instance.getAggregateValue( self.assertEqual(None, software_instance.getAggregateValue(
...@@ -718,6 +725,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin): ...@@ -718,6 +725,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
self.assertEqual(compute_node.getAllocationScope(), "open") self.assertEqual(compute_node.getAllocationScope(), "open")
self.assertEqual(compute_node.getCapacityScope(), "open") self.assertEqual(compute_node.getCapacityScope(), "open")
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic() self.tic()
self.assertEqual(None, software_instance.getAggregateValue( self.assertEqual(None, software_instance.getAggregateValue(
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Base_triggerAllocationAlarm</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interaction_AllocationSupplyCell_edit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<tuple>
<string>Allocation Supply Cell</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>trigger_method_id</string> </key>
<value>
<tuple>
<string>_setAllocable.*</string>
</tuple>
</value>
</item>
<item>
<key> <string>trigger_once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Base_triggerAllocationAlarm</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interaction_AllocationSupply_edit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<tuple>
<string>Allocation Supply</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>trigger_method_id</string> </key>
<value>
<tuple>
<string>_setAggregate.*</string>
<string>_setDestination.*</string>
<string>_setSlaveOnSameInstanceTreeAllocable.*</string>
<string>_setStartDate.*</string>
<string>validate</string>
</tuple>
</value>
</item>
<item>
<key> <string>trigger_once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Base_triggerAllocationAlarm</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interaction_ComputePartition_edit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<tuple>
<string>Compute Partition</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>trigger_method_id</string> </key>
<value>
<tuple>
<string>_setSubject.*</string>
<string>markFree</string>
<string>markBusy</string>
</tuple>
</value>
</item>
<item>
<key> <string>trigger_once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Instance_triggerAllocationAlarm</string> <string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Base_triggerAllocationAlarm</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>interaction_Instance_validate</string> </value> <value> <string>interaction_Instance_edit</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
...@@ -52,12 +52,15 @@ ...@@ -52,12 +52,15 @@
<value> <value>
<tuple> <tuple>
<string>validate</string> <string>validate</string>
<string>_setUrlString.*</string>
<string>_setSourceReference.*</string>
<string>_setSlaXml.*</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>trigger_once_per_transaction</string> </key> <key> <string>trigger_once_per_transaction</string> </key>
<value> <int>1</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>trigger_type</string> </key> <key> <string>trigger_type</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Base_triggerAllocationAlarm</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interaction_Node_edit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<tuple>
<string>Compute Node</string>
<string>Remote Node</string>
<string>Instance Node</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>trigger_method_id</string> </key>
<value>
<tuple>
<string>validate</string>
<string>_setSubordination.*</string>
<string>_setAllocationScope.*</string>
<string>_setCapacityScope.*</string>
<string>_setGroup.*</string>
<string>_setCpuCore.*</string>
<string>_setCpuFrequency.*</string>
<string>_setCpuType.*</string>
<string>_setLocalAreaNetworkType.*</string>
<string>_setRegion.*</string>
<string>_setMemorySize.*</string>
<string>_setMemoryType.*</string>
<string>_setStorageCapacity.*</string>
<string>_setStorageInterface.*</string>
<string>_setStorageRedundancy.*</string>
</tuple>
</value>
</item>
<item>
<key> <string>trigger_once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<value> <value>
<tuple> <tuple>
<string>before_commit_script/portal_workflow/slapos_cloud_interaction_workflow/script_SoftwareInstallation_reindexComputeNode</string> <string>before_commit_script/portal_workflow/slapos_cloud_interaction_workflow/script_SoftwareInstallation_reindexComputeNode</string>
<string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Base_triggerAllocationAlarm</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>script_Instance_triggerAllocationAlarm</string> </value> <value> <string>script_Base_triggerAllocationAlarm</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
Allocation Supply Cell | slapos_cloud_interaction_workflow
Allocation Supply Cell | supply_cell_interaction_workflow Allocation Supply Cell | supply_cell_interaction_workflow
Allocation Supply Line | edit_workflow Allocation Supply Line | edit_workflow
Allocation Supply Line | reindex_object_interaction_workflow Allocation Supply Line | reindex_object_interaction_workflow
Allocation Supply Line | supply_line_interaction_workflow Allocation Supply Line | supply_line_interaction_workflow
Allocation Supply | edit_workflow Allocation Supply | edit_workflow
Allocation Supply | slapos_cloud_interaction_workflow
Allocation Supply | validation_workflow Allocation Supply | validation_workflow
Compute Node | compute_node_slap_interface_workflow Compute Node | compute_node_slap_interface_workflow
Compute Node | slapos_cloud_interaction_workflow Compute Node | slapos_cloud_interaction_workflow
Compute Partition | compute_partition_slap_interface_workflow Compute Partition | compute_partition_slap_interface_workflow
Compute Partition | slapos_cloud_interaction_workflow
Computer Network | network_slap_interface_workflow Computer Network | network_slap_interface_workflow
Hosting Subscription | edit_workflow Hosting Subscription | edit_workflow
Hosting Subscription | hosting_subscription_workflow Hosting Subscription | hosting_subscription_workflow
Instance Node | edit_workflow Instance Node | edit_workflow
Instance Node | slapos_cloud_interaction_workflow
Instance Node | validation_workflow Instance Node | validation_workflow
Instance Tree | edit_workflow Instance Tree | edit_workflow
Instance Tree | instance_slap_interface_workflow Instance Tree | instance_slap_interface_workflow
...@@ -21,6 +25,7 @@ Person | person_slap_interface_workflow ...@@ -21,6 +25,7 @@ Person | person_slap_interface_workflow
Project | project_slap_interface_workflow Project | project_slap_interface_workflow
Remote Node | compute_node_slap_interface_workflow Remote Node | compute_node_slap_interface_workflow
Remote Node | edit_workflow Remote Node | edit_workflow
Remote Node | slapos_cloud_interaction_workflow
Remote Node | validation_workflow Remote Node | validation_workflow
Slave Instance | edit_workflow Slave Instance | edit_workflow
Slave Instance | instance_slap_interface_workflow Slave Instance | instance_slap_interface_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