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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
slapos.core
Commits
c106dded
Commit
c106dded
authored
Aug 14, 2014
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: Include alarm to close allocation scope if the computer were never used.
This keeps database smaller for another alarms.
parent
86f2c7a9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
194 additions
and
23 deletions
+194
-23
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkAndUpdateComputerAllocationScope.xml
...onitoring/Alarm_checkAndUpdateComputerAllocationScope.xml
+20
-2
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_checkAndUpdateAllocationScope.xml
...crm_monitoring/Computer_checkAndUpdateAllocationScope.xml
+15
-10
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_checkAndUpdatePersonalAllocationScope.xml
...toring/Computer_checkAndUpdatePersonalAllocationScope.xml
+69
-0
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSkins.py
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSkins.py
+39
-5
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSupportRequestGeneration.py
...TestTemplateItem/testSlapOSCRMSupportRequestGeneration.py
+50
-5
master/bt5/slapos_crm/bt/revision
master/bt5/slapos_crm/bt/revision
+1
-1
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkAndUpdateComputerAllocationScope.xml
View file @
c106dded
...
...
@@ -50,10 +50,13 @@
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
portal = context.getPortalObject()\n
<value>
<string
encoding=
"cdata"
>
<![CDATA[
portal = context.getPortalObject()\n
\n
category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None)\n
category_friend = portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None)\n
category_personal = portal.restrictedTraverse("portal_categories/allocation_scope/open/personal", None)\n
\n
if category_public is not None:\n
portal.portal_catalog.searchAndActivate(\n
...
...
@@ -63,8 +66,23 @@ if category_public is not None:\n
method_id=\'Computer_checkAndUpdateAllocationScope\',\n
activate_kw={\'tag\': tag}\n
)\n
\n
if category_personal is not None:\n
portal.portal_catalog.searchAndActivate(\n
portal_type=\'Computer\', \n
validation_state=\'validated\', \n
modification_date=(DateTime() - 30).strftime(\'<=%Y/%m/%d\'), \n
order_by=((\'modification_date\', "ASC"), ), \n
default_allocation_scope_uid=category_personal.getUid(), \n
left_join_list=[\'aggregate_related_uid\'], \n
aggregate_related_uid=None,\n
method_id=\'Computer_checkAndUpdatePersonalAllocationScope\',\n
activate_kw={\'tag\': tag})\n
\n
context.activate(after_tag=tag).getId()\n
</string>
</value>
]]>
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_checkAndUpdateAllocationScope.xml
View file @
c106dded
...
...
@@ -57,7 +57,11 @@ portal = context.getPortalObject()\n
allocation_scope = computer.getAllocationScope()\n
computer_reference = computer.getReference()\n
\n
if allocation_scope not in [\'open/public\', \'open/friend\']:\n
if allocation_scope not in [\'open/public\', \'open/friend\', \'open/personal\']:\n
return\n
\n
if allocation_scope == target_allocation_scope:\n
# already changed\n
return\n
\n
person = computer.getSourceAdministrationValue(portal_type="Person")\n
...
...
@@ -65,17 +69,15 @@ if not person:\n
return\n
\n
if not person.Person_isServiceProvider():\n
#Turn this computer allocation scope to \'open/personal\'\n
edit_kw = {\n
\'allocation_scope\':
\'open/personal\'
,\n
\'allocation_scope\':
target_allocation_scope
,\n
}\n
computer.edit(**edit_kw)\n
\n
# Create a ticket (or re-open it) for this issue!\n
support_request = None\n
request_title = \'We have changed allocation scope for %s\' % computer_reference\n
request_description = \'Allocation scope has been changed
back
to \' \\\n
\'
open/personal for %s\' % computer_reference
\n
request_description = \'Allocation scope has been changed to \' \\\n
\'
%s for %s\' % (target_allocation_scope, computer_reference)
\n
\n
support_request_url = context.Base_generateSupportRequestForSlapOS(\n
request_title,\n
...
...
@@ -91,7 +93,7 @@ if not person.Person_isServiceProvider():\n
support_request = portal.portal_catalog.getResultValue(\n
portal_type = \'Support Request\',\n
title = request_title,\n
simulation_state =
\'suspended\'
,\n
simulation_state =
[\'suspended\', \'open\']
,\n
source_project_uid = computer.getUid()\n
)\n
if support_request is None:\n
...
...
@@ -100,7 +102,7 @@ if not person.Person_isServiceProvider():\n
\n
# Send notification message\n
notification_message = portal.portal_notifications.getDocumentValue(\n
reference=
\'slapos-crm-computer_allocation_scope.notification\'
)\n
reference=
notification_message_reference
)\n
\n
if notification_message is not None:\n
mapping_dict = {\'computer_title\':computer.getTitle(),\n
...
...
@@ -111,13 +113,16 @@ if not person.Person_isServiceProvider():\n
else:\n
message = request_description\n
\n
support_request.SupportRequest_trySendNotificationMessage(request_title,\n
event =
support_request.SupportRequest_trySendNotificationMessage(request_title,\n
message, person.getRelativeUrl())\n
\n
if event is not None:\n
computer.edit(**edit_kw)\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
<value>
<string>
target_allocation_scope=\'open/personal\', notification_message_reference=\'slapos-crm-computer_allocation_scope.notification\'
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_checkAndUpdatePersonalAllocationScope.xml
0 → 100644
View file @
c106dded
<?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>
context.Computer_checkAndUpdateAllocationScope(\n
target_allocation_scope = \'close/termination\',\n
notification_message_reference=\'slapos-crm-computer_personal_allocation_scope.notification\')\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Computer_checkAndUpdatePersonalAllocationScope
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSkins.py
View file @
c106dded
...
...
@@ -1867,7 +1867,8 @@ class TestSlapOSComputer_notifyWrongAllocationScope(testSlapOSMixin):
'context.portal_workflow.doActionFor('
\
'context, action="edit_action", '
\
'comment="Visited by SupportRequest_trySendNotificationMessage '
\
'%s %s %s %s" % (message_title, message, source_relative_url, interval_of_day))'
)
'%s %s %s %s" % (message_title, message, source_relative_url, interval_of_day))
\
n
'
\
'return 1'
)
def
test_computerNotAllowedAllocationScope_OpenPublic
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
person
=
computer
.
getSourceAdministrationValue
()
...
...
@@ -1899,7 +1900,8 @@ class TestSlapOSComputer_notifyWrongAllocationScope(testSlapOSMixin):
'context.portal_workflow.doActionFor('
\
'context, action="edit_action", '
\
'comment="Visited by SupportRequest_trySendNotificationMessage '
\
'%s %s %s %s" % (message_title, message, source_relative_url, interval_of_day))'
)
'%s %s %s %s" % (message_title, message, source_relative_url, interval_of_day))
\
n
'
\
'return 1'
)
def
test_computerNotAllowedAllocationScope_OpenFriend
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
person
=
computer
.
getSourceAdministrationValue
()
...
...
@@ -1921,8 +1923,40 @@ class TestSlapOSComputer_notifyWrongAllocationScope(testSlapOSMixin):
(
'We have changed allocation scope for %s'
%
computer
.
getReference
(),
'Test NM content
\
n
%s
\
n
'
%
computer
.
getReference
(),
person
.
getRelativeUrl
(),
'1'
),
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'assert reference == "slapos-crm-computer_personal_allocation_scope.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["test_computerToCloseAllocationScope_OpenPersonal"])'
)
@
simulate
(
'SupportRequest_trySendNotificationMessage'
,
'message_title, message, source_relative_url, interval_of_day=1'
,
'context.portal_workflow.doActionFor('
\
'context, action="edit_action", '
\
'comment="Visited by SupportRequest_trySendNotificationMessage '
\
'%s %s %s %s" % (message_title, message, source_relative_url, interval_of_day))
\
n
'
\
'return 1'
)
def
test_computerToCloseAllocationScope_OpenPersonal
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
person
=
computer
.
getSourceAdministrationValue
()
self
.
portal
.
REQUEST
[
'test_computerToCloseAllocationScope_OpenPersonal'
]
=
\
self
.
_makeNotificationMessage
(
computer
.
getReference
())
friend_person
=
self
.
_makePerson
(
self
.
generateNewId
())
computer
.
edit
(
allocation_scope
=
'open/personal'
,
destination_section
=
friend_person
.
getRelativeUrl
())
computer
.
Computer_checkAndUpdatePersonalAllocationScope
()
self
.
tic
()
self
.
assertEquals
(
computer
.
getAllocationScope
(),
'close/termination'
)
ticket
=
self
.
_getGeneratedSupportRequest
(
computer
)
self
.
assertEquals
(
ticket
.
getSimulationState
(),
'suspended'
)
self
.
assertEqual
(
'Visited by SupportRequest_trySendNotificationMessage '
\
'%s %s %s %s'
%
\
(
'We have changed allocation scope for %s'
%
computer
.
getReference
(),
'Test NM content
\
n
%s
\
n
'
%
computer
.
getReference
(),
person
.
getRelativeUrl
(),
'1'
),
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_computerNormalAllocationScope_OpenPersonal
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
person
=
computer
.
getSourceAdministrationValue
()
...
...
@@ -2216,4 +2250,4 @@ class TestSlapOSComputer_CheckState(testSlapOSMixin):
ticket_title
.
replace
(
'[MONITORING] '
,
''
),
'Test NM content
\
n
%s
\
n
'
%
instance
.
getReference
(),
person_url
,
message_interval_per_day
),
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
\ No newline at end of file
ticket
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSupportRequestGeneration.py
View file @
c106dded
...
...
@@ -79,7 +79,7 @@ class TestSlapOSCloudSupportRequestGeneration(testSlapOSMixin):
computer
.
validate
()
return
computer
def
_makeComputerPartitions
(
self
,
computer
):
for
i
in
range
(
1
,
5
):
id_
=
'partition%s'
%
(
i
,
)
...
...
@@ -366,8 +366,6 @@ class TestSlapOSCloudSupportRequestGeneration(testSlapOSMixin):
)
self
.
assertEqual
(
event
.
getTitle
(),
title
)
def
test_Computer_checkState_empty_cache
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
...
...
@@ -837,6 +835,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self
.
assertEqual
(
'Visited by Computer_checkAndUpdateAllocationScope'
,
computer
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_Alarm_notAllowedAllocationScope_OpenFriend
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
...
...
@@ -867,7 +866,53 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self
.
assertNotEqual
(
'Visited by Computer_checkAndUpdateAllocationScope'
,
computer
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_Alarm_AllowedAllocationScope_OpenPersonal_old_computer
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
computer
.
edit
(
allocation_scope
=
'open/personal'
)
def
getModificationDate
(
self
):
return
DateTime
()
-
50
from
Products.ERP5Type.Base
import
Base
self
.
_simulateComputer_checkAndUpdateAllocationScope
()
original_get_modification
=
Base
.
getModificationDate
Base
.
getModificationDate
=
getModificationDate
try
:
self
.
portal
.
portal_alarms
.
slapos_crm_check_update_allocation_scope
.
activeSense
()
self
.
tic
()
finally
:
Base
.
getModificationDate
=
original_get_modification
self
.
_dropComputer_checkAndUpdateAllocationScope
()
self
.
assertEqual
(
'Visited by Computer_checkAndUpdateAllocationScope'
,
computer
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_Alarm_AllowedAllocationScope_OpenPersonalWithSoftwareInstallation
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
computer
.
edit
(
allocation_scope
=
'open/personal'
)
software_installation
=
self
.
_makeSoftwareInstallation
(
self
.
new_id
,
computer
,
"http://..."
)
def
getModificationDate
(
self
):
return
DateTime
()
-
50
from
Products.ERP5Type.Base
import
Base
self
.
_simulateComputer_checkAndUpdateAllocationScope
()
original_get_modification
=
Base
.
getModificationDate
Base
.
getModificationDate
=
getModificationDate
try
:
self
.
portal
.
portal_alarms
.
slapos_crm_check_update_allocation_scope
.
activeSense
()
self
.
tic
()
finally
:
Base
.
getModificationDate
=
original_get_modification
self
.
_dropComputer_checkAndUpdateAllocationScope
()
self
.
assertNotEqual
(
'Visited by Computer_checkAndUpdateAllocationScope'
,
computer
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
_simulateHostingSubscription_checkSofwareInstanceState
(
self
):
script_name
=
'HostingSubscription_checkSofwareInstanceAllocationState'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
...
...
@@ -902,4 +947,4 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H
self
.
assertEqual
(
'Visited by HostingSubscription_checkSofwareInstanceAllocationState'
,
host_sub
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
\ No newline at end of file
master/bt5/slapos_crm/bt/revision
View file @
c106dded
49
50
\ No newline at end of file
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