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 @@
<none/>
</value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
......@@ -50,6 +50,12 @@
<key> <string>portal_type</string> </key>
<value> <string>Base Type</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>Supply</string> </value>
......
<workflow_chain>
<chain>
<type>Allocation Supply</type>
<workflow>edit_workflow, validation_workflow</workflow>
<workflow>edit_workflow, slapos_cloud_interaction_workflow, validation_workflow</workflow>
</chain>
<chain>
<type>Allocation Supply Cell</type>
<workflow>supply_cell_interaction_workflow</workflow>
<workflow>slapos_cloud_interaction_workflow, supply_cell_interaction_workflow</workflow>
</chain>
<chain>
<type>Allocation Supply Line</type>
......@@ -17,7 +17,7 @@
</chain>
<chain>
<type>Compute Partition</type>
<workflow>compute_partition_slap_interface_workflow</workflow>
<workflow>compute_partition_slap_interface_workflow, slapos_cloud_interaction_workflow</workflow>
</chain>
<chain>
<type>Computer Network</type>
......@@ -29,7 +29,7 @@
</chain>
<chain>
<type>Instance Node</type>
<workflow>edit_workflow, validation_workflow</workflow>
<workflow>edit_workflow, slapos_cloud_interaction_workflow, validation_workflow</workflow>
</chain>
<chain>
<type>Instance Tree</type>
......@@ -49,7 +49,7 @@
</chain>
<chain>
<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>
<type>Slave Instance</type>
......
......@@ -934,7 +934,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
)
if disable_alarm:
# disable generation of Upgrade Decision
with TemporaryAlarmScript(self.portal, 'Base_reindexAndSenseAlarm', "'disabled'"):
with TemporaryAlarmScript(self.portal, 'Base_reindexAndSenseAlarm', "'disabled'", attribute='comment'):
allocation_supply.validate()
else:
allocation_supply.validate()
......
......@@ -8,36 +8,38 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
def makeAllocableComputeNode(self, project, software_product,
release_variation, type_variation):
compute_node, partition = self._makeComputeNode(project)
self.addAllocationSupply("for compute node", compute_node, software_product,
release_variation, type_variation)
self._installSoftware(
compute_node,
release_variation.getUrlString()
)
open_order = self.portal.open_sale_order_module.newContent(
portal_type="Open Sale Order",
)
open_order.newContent(
aggregate_value=compute_node
)
self.portal.portal_workflow._jumpToStateFor(open_order, 'validated')
self.tic()
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
compute_node, partition = self._makeComputeNode(project)
self.addAllocationSupply("for compute node", compute_node, software_product,
release_variation, type_variation)
self._installSoftware(
compute_node,
release_variation.getUrlString()
)
open_order = self.portal.open_sale_order_module.newContent(
portal_type="Open Sale Order",
)
open_order.newContent(
aggregate_value=compute_node
)
self.portal.portal_workflow._jumpToStateFor(open_order, 'validated')
self.tic()
return compute_node, partition
def makeAllocableSoftwareInstanceAndProduct(self, allocation_state='possible',
shared=False, node="compute"):
software_product, release_variation, type_variation, compute_node, partition, instance_tree = \
self.bootstrapAllocableInstanceTree(allocation_state=allocation_state, shared=shared, node=node)
self.addAllocationSupply("for compute node", compute_node, software_product,
release_variation, type_variation)
real_compute_node = partition.getParentValue()
self._installSoftware(
real_compute_node,
release_variation.getUrlString()
)
self.tic()
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
software_product, release_variation, type_variation, compute_node, partition, instance_tree = \
self.bootstrapAllocableInstanceTree(allocation_state=allocation_state, shared=shared, node=node)
self.addAllocationSupply("for compute node", compute_node, software_product,
release_variation, type_variation)
real_compute_node = partition.getParentValue()
self._installSoftware(
real_compute_node,
release_variation.getUrlString()
)
self.tic()
self.assertEqual(real_compute_node.getAllocationScope(), "open")
self.assertEqual(real_compute_node.getCapacityScope(), "open")
......@@ -287,7 +289,8 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
compute_node.edit(
subordination_value=computer_network
)
self.tic()
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic()
self.assertEqual(None, software_instance.getAggregateValue(
portal_type='Compute Partition'))
......@@ -359,7 +362,8 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
)
self.portal.portal_workflow._jumpToStateFor(software_instance2, 'start_requested')
self.portal.portal_workflow._jumpToStateFor(software_instance2, 'validated')
self.tic()
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic()
self.assertEqual(None,
software_instance.getAggregateValue(portal_type='Compute Partition'))
......@@ -421,7 +425,8 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
compute_node2.edit(subordination_value=computer_network1)
compute_node3.edit(subordination_value=computer_network2)
self.tic()
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic()
self.assertEqual(None, software_instance.getAggregateValue(
portal_type='Compute Partition'))
......@@ -560,7 +565,8 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
compute_node1.edit(subordination_value=computer_network)
compute_node2.edit(subordination_value=computer_network)
self.tic()
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic()
self.assertEqual(None, software_instance.getAggregateValue(
portal_type='Compute Partition'))
......@@ -581,8 +587,8 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
)
self.portal.portal_workflow._jumpToStateFor(software_instance2, 'start_requested')
self.portal.portal_workflow._jumpToStateFor(software_instance2, 'validated')
self.tic()
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic()
self.assertEqual(None,
software_instance.getAggregateValue(portal_type='Compute Partition'))
......@@ -635,7 +641,8 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
self.assertEqual(compute_node.getAllocationScope(), "open")
self.assertEqual(compute_node.getCapacityScope(), "open")
self.tic()
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic()
self.assertEqual(None, software_instance.getAggregateValue(
portal_type='Compute Partition'))
......@@ -718,7 +725,8 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
self.assertEqual(compute_node.getAllocationScope(), "open")
self.assertEqual(compute_node.getCapacityScope(), "open")
self.tic()
with TemporaryAlarmScript(self.portal, 'SoftwareInstance_tryToAllocatePartition'):
self.tic()
self.assertEqual(None, software_instance.getAggregateValue(
portal_type='Compute Partition'))
......
<?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 @@
<key> <string>categories</string> </key>
<value>
<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>
</value>
</item>
......@@ -22,7 +22,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interaction_Instance_validate</string> </value>
<value> <string>interaction_Instance_edit</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......@@ -52,12 +52,15 @@
<value>
<tuple>
<string>validate</string>
<string>_setUrlString.*</string>
<string>_setSourceReference.*</string>
<string>_setSlaXml.*</string>
</tuple>
</value>
</item>
<item>
<key> <string>trigger_once_per_transaction</string> </key>
<value> <int>1</int> </value>
<value> <int>0</int> </value>
</item>
<item>
<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 @@
<value>
<tuple>
<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>
</value>
</item>
......
......@@ -60,7 +60,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Instance_triggerAllocationAlarm</string> </value>
<value> <string>script_Base_triggerAllocationAlarm</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
Allocation Supply Cell | slapos_cloud_interaction_workflow
Allocation Supply Cell | supply_cell_interaction_workflow
Allocation Supply Line | edit_workflow
Allocation Supply Line | reindex_object_interaction_workflow
Allocation Supply Line | supply_line_interaction_workflow
Allocation Supply | edit_workflow
Allocation Supply | slapos_cloud_interaction_workflow
Allocation Supply | validation_workflow
Compute Node | compute_node_slap_interface_workflow
Compute Node | slapos_cloud_interaction_workflow
Compute Partition | compute_partition_slap_interface_workflow
Compute Partition | slapos_cloud_interaction_workflow
Computer Network | network_slap_interface_workflow
Hosting Subscription | edit_workflow
Hosting Subscription | hosting_subscription_workflow
Instance Node | edit_workflow
Instance Node | slapos_cloud_interaction_workflow
Instance Node | validation_workflow
Instance Tree | edit_workflow
Instance Tree | instance_slap_interface_workflow
......@@ -21,6 +25,7 @@ Person | person_slap_interface_workflow
Project | project_slap_interface_workflow
Remote Node | compute_node_slap_interface_workflow
Remote Node | edit_workflow
Remote Node | slapos_cloud_interaction_workflow
Remote Node | validation_workflow
Slave Instance | edit_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