Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
95225969
Commit
95225969
authored
Mar 12, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alarm to stop subscription.
parent
c5d09554
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
755 additions
and
1 deletion
+755
-1
master/bt5/slapos_crm/PathTemplateItem/portal_alarms/slapos_crm_stop_hosting_subscription.xml
...em/portal_alarms/slapos_crm_stop_hosting_subscription.xml
+103
-0
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_stopHostingSubscriptionFromRegularisationRequest.xml
...larm_stopHostingSubscriptionFromRegularisationRequest.xml
+83
-0
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/HostingSubscription_stopFromRegularisationRequest.xml
...crm/HostingSubscription_stopFromRegularisationRequest.xml
+87
-0
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_stopHostingSubscriptionList.xml
...crm/RegularisationRequest_stopHostingSubscriptionList.xml
+88
-0
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMAlarm.py
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMAlarm.py
+102
-0
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSkins.py
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSkins.py
+290
-0
master/bt5/slapos_crm/bt/revision
master/bt5/slapos_crm/bt/revision
+1
-1
master/bt5/slapos_crm/bt/template_path_list
master/bt5/slapos_crm/bt/template_path_list
+1
-0
No files found.
master/bt5/slapos_crm/PathTemplateItem/portal_alarms/slapos_crm_stop_hosting_subscription.xml
0 → 100644
View file @
95225969
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Alarm"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
active_sense_method_id
</string>
</key>
<value>
<string>
Alarm_stopHostingSubscriptionFromRegularisationRequest
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
enabled
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
slapos_crm_stop_hosting_subscription
</string>
</value>
</item>
<item>
<key>
<string>
periodicity_hour
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_hour_frequency
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
periodicity_minute
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_minute_frequency
</string>
</key>
<value>
<int>
30
</int>
</value>
</item>
<item>
<key>
<string>
periodicity_month
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_month_day
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
periodicity_start_date
</string>
</key>
<value>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1288051200.0
</float>
<string>
GMT
</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
periodicity_week
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Alarm
</string>
</value>
</item>
<item>
<key>
<string>
sense_method_id
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Stop Hosting Subscription
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Alarm_stopHostingSubscriptionFromRegularisationRequest.xml
0 → 100644
View file @
95225969
<?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>
portal = context.getPortalObject()\n
sub_tag = "RegularisationRequest_stopHostingSubscriptionList"\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Regularisation Request", \n
simulation_state=["suspended"],\n
default_resource_uid=[\n
portal.service_module.slapos_crm_stop_acknowledgement.getUid(),\n
portal.service_module.slapos_crm_delete_reminder.getUid(),\n
],\n
method_id=\'RegularisationRequest_stopHostingSubscriptionList\',\n
method_args=(sub_tag,),\n
# Limit activity number, as method_id also calls searchAndActivate\n
activity_count=1,\n
packet_size=1,\n
activate_kw={\'tag\': tag, \'after_tag\': sub_tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
tag, fixit, params
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Alarm_stopHostingSubscriptionFromRegularisationRequest
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/HostingSubscription_stopFromRegularisationRequest.xml
0 → 100644
View file @
95225969
<?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>
from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
hosting_subscription = context\n
assert hosting_subscription.getDefaultDestinationSection() == person_relative_url\n
person = hosting_subscription.getDefaultDestinationSectionValue()\n
\n
slap_state = hosting_subscription.getSlapState()\n
if (slap_state == \'start_requested\'):\n
person.requestSoftwareInstance(\n
state=\'stopped\',\n
software_release=hosting_subscription.getUrlString(),\n
software_title=hosting_subscription.getTitle(),\n
software_type=hosting_subscription.getSourceReference(),\n
instance_xml=hosting_subscription.getTextContent(),\n
sla_xml=hosting_subscription.getSlaXml(),\n
shared=hosting_subscription.isRootSlave()\n
)\n
return True\n
return False\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
person_relative_url, REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
HostingSubscription_stopFromRegularisationRequest
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_stopHostingSubscriptionList.xml
0 → 100644
View file @
95225969
<?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>
from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
ticket = context\n
state = ticket.getSimulationState()\n
person = ticket.getSourceProjectValue(portal_type="Person")\n
if (state == \'suspended\') and \\\n
(person is not None) and \\\n
(ticket.getResource() in [\'service_module/slapos_crm_stop_acknowledgement\', \'service_module/slapos_crm_delete_reminder\']):\n
\n
portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Hosting Subscription",\n
validation_state=["validated"],\n
default_destination_section_uid=person.getUid(),\n
method_id=\'HostingSubscription_stopFromRegularisationRequest\',\n
method_args=(person.getRelativeUrl(),),\n
activate_kw={\'tag\': tag}\n
)\n
return True\n
return False\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
tag, REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
RegularisationRequest_stopHostingSubscriptionList
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMAlarm.py
View file @
95225969
...
...
@@ -570,3 +570,105 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by R
self
.
assertNotEqual
(
'Visited by RegularisationRequest_triggerDeleteReminderEscalation'
,
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
class
TestSlapOSCrmStopHostingSubscription
(
testSlapOSMixin
):
def
beforeTearDown
(
self
):
transaction
.
abort
()
def
createRegularisationRequest
(
self
):
new_id
=
self
.
generateNewId
()
return
self
.
portal
.
regularisation_request_module
.
newContent
(
portal_type
=
'Regularisation Request'
,
title
=
"Test Reg. Req.%s"
%
new_id
,
reference
=
"TESTREGREQ-%s"
%
new_id
,
)
def
_simulateRegularisationRequest_stopHostingSubscriptionList
(
self
):
script_name
=
'RegularisationRequest_stopHostingSubscriptionList'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
'*args, **kwargs'
,
'# Script body
\
n
'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by RegularisationRequest_stopHostingSubscriptionList') """
)
transaction
.
commit
()
def
_dropRegularisationRequest_stopHostingSubscriptionList
(
self
):
script_name
=
'RegularisationRequest_stopHostingSubscriptionList'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
test_alarm_matching_regularisation_request
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
edit
(
resource
=
'service_module/slapos_crm_delete_reminder'
)
ticket
.
validate
()
ticket
.
suspend
()
self
.
tic
()
self
.
_simulateRegularisationRequest_stopHostingSubscriptionList
()
try
:
self
.
portal
.
portal_alarms
.
\
slapos_crm_stop_hosting_subscription
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropRegularisationRequest_stopHostingSubscriptionList
()
self
.
assertEqual
(
'Visited by RegularisationRequest_stopHostingSubscriptionList'
,
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_matching_regularisation_request_2
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
edit
(
resource
=
'service_module/slapos_crm_stop_acknowledgement'
)
ticket
.
validate
()
ticket
.
suspend
()
self
.
tic
()
self
.
_simulateRegularisationRequest_stopHostingSubscriptionList
()
try
:
self
.
portal
.
portal_alarms
.
\
slapos_crm_stop_hosting_subscription
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropRegularisationRequest_stopHostingSubscriptionList
()
self
.
assertEqual
(
'Visited by RegularisationRequest_stopHostingSubscriptionList'
,
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_not_suspended
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
edit
(
resource
=
'service_module/slapos_crm_stop_acknowledgement'
)
ticket
.
validate
()
self
.
tic
()
self
.
_simulateRegularisationRequest_stopHostingSubscriptionList
()
try
:
self
.
portal
.
portal_alarms
.
\
slapos_crm_stop_hosting_subscription
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropRegularisationRequest_stopHostingSubscriptionList
()
self
.
assertNotEqual
(
'Visited by RegularisationRequest_stopHostingSubscriptionList'
,
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_other_resource
(
self
):
ticket
=
self
.
createRegularisationRequest
()
ticket
.
edit
(
resource
=
'service_module/slapos_acknowledgement'
)
ticket
.
validate
()
ticket
.
suspend
()
self
.
tic
()
self
.
_simulateRegularisationRequest_stopHostingSubscriptionList
()
try
:
self
.
portal
.
portal_alarms
.
\
slapos_crm_stop_hosting_subscription
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropRegularisationRequest_stopHostingSubscriptionList
()
self
.
assertNotEqual
(
'Visited by RegularisationRequest_stopHostingSubscriptionList'
,
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSkins.py
View file @
95225969
This diff is collapsed.
Click to expand it.
master/bt5/slapos_crm/bt/revision
View file @
95225969
15
\ No newline at end of file
16
\ No newline at end of file
master/bt5/slapos_crm/bt/template_path_list
View file @
95225969
...
...
@@ -2,6 +2,7 @@ event_module/slapos_crm_web_message_template
portal_alarms/slapos_crm_cancel_invoice
portal_alarms/slapos_crm_create_regularisation_request
portal_alarms/slapos_crm_invalidate_suspended_regularisation_request
portal_alarms/slapos_crm_stop_hosting_subscription
portal_alarms/slapos_crm_trigger_acknowledgment_escalation
portal_alarms/slapos_crm_trigger_delete_reminder_escalation
portal_alarms/slapos_crm_trigger_stop_acknowledgment_escalation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment