Commit 0699cba5 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Rafael Monnerat

Base_generateSupportRequestForSlapOS should include some indications

parent eee63a74
...@@ -59,6 +59,8 @@ if source_project_value.getPortalType() == "Computer":\n ...@@ -59,6 +59,8 @@ if source_project_value.getPortalType() == "Computer":\n
destination_decision = source_project_value.getSourceAdministration()\n destination_decision = source_project_value.getSourceAdministration()\n
elif source_project_value.getPortalType() == "Software Instance":\n elif source_project_value.getPortalType() == "Software Instance":\n
destination_decision = source_project_value.getSpecialiseValue().getDestinationSection()\n destination_decision = source_project_value.getSpecialiseValue().getDestinationSection()\n
elif source_project_value.getPortalType() == "Hosting Subscription":\n
destination_decision = source_project_value.getDestinationSection()\n
else:\n else:\n
destination_decision = None\n destination_decision = None\n
\n \n
...@@ -66,6 +68,7 @@ if portal.ERP5Site_isSupportRequestCreationClosed(destination_decision):\n ...@@ -66,6 +68,7 @@ if portal.ERP5Site_isSupportRequestCreationClosed(destination_decision):\n
# Stop ticket creation\n # Stop ticket creation\n
return\n return\n
\n \n
title = \'[MONITORING] \' + title\n
support_request_in_progress = portal.portal_catalog.getResultValue(\n support_request_in_progress = portal.portal_catalog.getResultValue(\n
portal_type = \'Support Request\',\n portal_type = \'Support Request\',\n
title = title,\n title = title,\n
...@@ -74,6 +77,8 @@ support_request_in_progress = portal.portal_catalog.getResultValue(\n ...@@ -74,6 +77,8 @@ support_request_in_progress = portal.portal_catalog.getResultValue(\n
)\n )\n
\n \n
if support_request_in_progress is None:\n if support_request_in_progress is None:\n
ressource = portal.service_module.\\\n
slapos_crm_monitoring.getRelativeUrl()\n
support_request = portal.\\\n support_request = portal.\\\n
support_request_module.\\\n support_request_module.\\\n
slapos_crm_support_request_template_for_monitoring.\\\n slapos_crm_support_request_template_for_monitoring.\\\n
...@@ -83,7 +88,8 @@ if support_request_in_progress is None:\n ...@@ -83,7 +88,8 @@ if support_request_in_progress is None:\n
description = description,\n description = description,\n
start_date = DateTime(),\n start_date = DateTime(),\n
destination_decision=destination_decision,\n destination_decision=destination_decision,\n
source_project_value = source_relative_url\n source_project_value = source_relative_url,\n
ressource=ressource\n
)\n )\n
support_request.validate()\n support_request.validate()\n
\n \n
......
...@@ -184,6 +184,23 @@ class TestSlapOSCloudSupportRequestGeneration(testSlapOSMixin): ...@@ -184,6 +184,23 @@ class TestSlapOSCloudSupportRequestGeneration(testSlapOSMixin):
self.assertEquals(support_request.getDestinationDecision(), self.assertEquals(support_request.getDestinationDecision(),
host_sub.getDestinationSection()) host_sub.getDestinationSection())
def test_hosting_subscription_Base_generateSupportRequestForSlapOS(self):
host_sub = self._makeHostingSubscription(self.new_id)
title = "Test Support Request %s" % self.new_id
support_request = host_sub.Base_generateSupportRequestForSlapOS(
title, title, host_sub.getRelativeUrl()
)
self.tic()
self.assertNotEqual(support_request, None)
support_request = self.portal.restrictedTraverse(support_request)
# The support request is added to computer owner.
self.assertEquals(support_request.getDestinationDecision(),
host_sub.getDestinationSection())
def test_Base_generateSupportRequestForSlapOS_do_not_recreate_if_open(self): def test_Base_generateSupportRequestForSlapOS_do_not_recreate_if_open(self):
title = "Test Support Request %s" % self.new_id title = "Test Support Request %s" % self.new_id
computer = self._makeComputer(self.new_id) computer = self._makeComputer(self.new_id)
...@@ -775,7 +792,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -775,7 +792,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
computer.workflow_history['edit_workflow'][-1]['comment']) computer.workflow_history['edit_workflow'][-1]['comment'])
def _simulateHostingSubscription_checkSofwareInstanceState(self): def _simulateHostingSubscription_checkSofwareInstanceState(self):
script_name = 'HostingSubscription_checkSofwareInstanceState' script_name = 'HostingSubscription_checkSofwareInstanceAllocationState'
if script_name in self.portal.portal_skins.custom.objectIds(): if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name) raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom, createZODBPythonScript(self.portal.portal_skins.custom,
...@@ -783,11 +800,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -783,11 +800,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
'*args, **kw', '*args, **kw',
'# Script body\n' '# Script body\n'
"""portal_workflow = context.portal_workflow """portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by HostingSubscription_checkSofwareInstanceState') """ ) portal_workflow.doActionFor(context, action='edit_action', comment='Visited by HostingSubscription_checkSofwareInstanceAllocationState') """ )
transaction.commit() transaction.commit()
def _dropHostingSubscription_checkSofwareInstanceState(self): def _dropHostingSubscription_checkSofwareInstanceState(self):
script_name = 'HostingSubscription_checkSofwareInstanceState' script_name = 'HostingSubscription_checkSofwareInstanceAllocationState'
if script_name in self.portal.portal_skins.custom.objectIds(): if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name) self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit() transaction.commit()
...@@ -806,6 +823,6 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H ...@@ -806,6 +823,6 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H
finally: finally:
self._dropHostingSubscription_checkSofwareInstanceState() self._dropHostingSubscription_checkSofwareInstanceState()
self.assertEqual('Visited by HostingSubscription_checkSofwareInstanceState', self.assertEqual('Visited by HostingSubscription_checkSofwareInstanceAllocationState',
host_sub.workflow_history['edit_workflow'][-1]['comment']) host_sub.workflow_history['edit_workflow'][-1]['comment'])
\ No newline at end of file
39 40
\ No newline at end of file \ No newline at end of file
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