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
Ophélie Gagnard
slapos.core
Commits
30017fbb
Commit
30017fbb
authored
Sep 02, 2016
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: create alarm to close personal computer which didn't contact for too long
Change allocation scope to close/outdated
parent
e3376cbf
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
147 additions
and
30 deletions
+147
-30
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkAndUpdatePersonalComputerAllocationScope.py
...ng/Alarm_checkAndUpdatePersonalComputerAllocationScope.py
+3
-6
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Base_generateSupportRequestForSlapOS.py
...os_crm_monitoring/Base_generateSupportRequestForSlapOS.py
+4
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_checkAndUpdateAllocationScope.py
..._crm_monitoring/Computer_checkAndUpdateAllocationScope.py
+32
-18
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_checkAndUpdateAllocationScope.xml
...crm_monitoring/Computer_checkAndUpdateAllocationScope.xml
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_checkAndUpdatePersonalAllocationScope.py
...itoring/Computer_checkAndUpdatePersonalAllocationScope.py
+7
-2
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_hasContactedRecently.py
...ns/slapos_crm_monitoring/Computer_hasContactedRecently.py
+35
-0
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_hasContactedRecently.xml
...s/slapos_crm_monitoring/Computer_hasContactedRecently.xml
+62
-0
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_trySendNotificationMessage.py
...m_monitoring/SupportRequest_trySendNotificationMessage.py
+2
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_trySendNotificationMessage.xml
..._monitoring/SupportRequest_trySendNotificationMessage.xml
+1
-1
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkAndUpdatePersonalComputerAllocationScope.py
View file @
30017fbb
...
...
@@ -4,12 +4,9 @@ category_personal = portal.restrictedTraverse("portal_categories/allocation_scop
if
category_personal
is
not
None
:
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
'Computer'
,
validation_state
=
'validated'
,
modification_date
=
(
DateTime
()
-
30
).
strftime
(
'<=%Y/%m/%d'
),
default_allocation_scope_uid
=
category_personal
.
getUid
(),
left_join_list
=
[
'aggregate_related_uid'
],
aggregate_related_uid
=
None
,
portal_type
=
'Computer'
,
validation_state
=
'validated'
,
default_allocation_scope_uid
=
category_personal
.
getUid
(),
method_id
=
'Computer_checkAndUpdatePersonalAllocationScope'
,
activate_kw
=
{
'tag'
:
tag
})
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Base_generateSupportRequestForSlapOS.py
View file @
30017fbb
...
...
@@ -31,7 +31,10 @@ if support_request_in_progress is not None:
support_request_in_progress
=
context
.
REQUEST
.
get
(
"support_request_in_progress"
,
None
)
if
support_request_in_progress
is
not
None
:
return
portal
.
restrictedTraverse
(
support_request_in_progress
)
support_request
=
portal
.
restrictedTraverse
(
support_request_in_progress
)
if
support_request
.
getTitle
()
==
title
and
\
support_request
.
getSourceProjectUid
()
==
source_project_value
.
getUid
():
return
portal
.
restrictedTraverse
(
support_request_in_progress
)
resource
=
portal
.
service_module
.
\
slapos_crm_monitoring
.
getRelativeUrl
()
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_checkAndUpdateAllocationScope.py
View file @
30017fbb
...
...
@@ -16,25 +16,29 @@ person = computer.getSourceAdministrationValue(portal_type="Person")
if
not
person
:
return
if
not
person
.
Person_isServiceProvider
():
edit_kw
=
{
'allocation_scope'
:
target_allocation_scope
,
}
# Create a ticket (or re-open it) for this issue!
request_title
=
'We have changed allocation scope for %s'
%
computer_reference
request_description
=
'Allocation scope has been changed to '
\
'%s for %s'
%
(
target_allocation_scope
,
computer_reference
)
support_request
=
context
.
Base_generateSupportRequestForSlapOS
(
request_title
,
request_description
,
computer
.
getRelativeUrl
()
)
if
check_service_provider
and
person
.
Person_isServiceProvider
():
return
edit_kw
=
{
'allocation_scope'
:
target_allocation_scope
,
}
# Create a ticket (or re-open it) for this issue!
request_title
=
'Allocation scope of %s changed to %s'
%
(
computer_reference
,
target_allocation_scope
)
request_description
=
'Allocation scope has been changed to '
\
'%s for %s'
%
(
target_allocation_scope
,
computer_reference
)
support_request
=
context
.
Base_generateSupportRequestForSlapOS
(
request_title
,
request_description
,
computer
.
getRelativeUrl
()
)
if
support_request
is
not
None
:
if
support_request
.
getSimulationState
()
!=
"validated"
:
support_request
.
validate
()
# Send notification message
message
=
request_description
notification_message
=
portal
.
portal_notifications
.
getDocumentValue
(
...
...
@@ -43,8 +47,9 @@ if not person.Person_isServiceProvider():
if
notification_message
is
not
None
:
mapping_dict
=
{
'computer_title'
:
computer
.
getTitle
(),
'computer_id'
:
computer_reference
,
'computer_url'
:
computer
.
getRelativeUrl
(),
'allocation_scope'
:
allocation_scope
}
message
=
notification_message
.
asText
(
substitution_method_parameter_dict
=
{
'mapping_dict'
:
mapping_dict
})
...
...
@@ -52,6 +57,15 @@ if not person.Person_isServiceProvider():
request_title
,
message
,
person
.
getRelativeUrl
())
if
event
is
not
None
:
computer
.
edit
(
**
edit_kw
)
# event added, suspend ticket
if
portal
.
portal_workflow
.
isTransitionPossible
(
support_request
,
'suspend'
):
support_request
.
suspend
()
elif
not
force
:
return
support_request
computer
.
edit
(
**
edit_kw
)
return
support_request
elif
force
:
# Update computer event if ticket is not created
computer
.
edit
(
**
edit_kw
)
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_checkAndUpdateAllocationScope.xml
View file @
30017fbb
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
target_allocation_scope=\'open/personal\', notification_message_reference=\'slapos-crm-computer_allocation_scope.notification\'
</string>
</value>
<value>
<string>
target_allocation_scope=\'open/personal\', notification_message_reference=\'slapos-crm-computer_allocation_scope.notification\'
, check_service_provider=True, force=False
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_checkAndUpdatePersonalAllocationScope.py
View file @
30017fbb
if
context
.
Computer_hasContactedRecently
():
return
return
context
.
Computer_checkAndUpdateAllocationScope
(
target_allocation_scope
=
'close/termination'
,
notification_message_reference
=
'slapos-crm-computer_personal_allocation_scope.notification'
)
target_allocation_scope
=
'close/outdated'
,
notification_message_reference
=
'slapos-crm-computer-allocation-scope-closed.notification'
,
check_service_provider
=
False
,
force
=
True
)
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_hasContactedRecently.py
0 → 100644
View file @
30017fbb
portal
=
context
.
getPortalObject
()
computer
=
context
maximum_days
=
31
now_date
=
DateTime
()
if
(
now_date
-
computer
.
getCreationDate
())
<
maximum_days
:
# This computer was created recently skip
return
True
memcached_dict
=
portal
.
portal_memcached
.
getMemcachedDict
(
key_prefix
=
'slap_tool'
,
plugin_path
=
'portal_memcached/default_memcached_plugin'
)
# Check if there is some information in memcached
try
:
d
=
memcached_dict
[
computer
.
getReference
()]
except
KeyError
:
message_dict
=
{}
else
:
message_dict
=
json
.
loads
(
d
)
if
message_dict
.
has_key
(
'created_at'
):
contact_date
=
DateTime
(
message_dict
.
get
(
'created_at'
).
encode
(
'utf-8'
))
return
(
now_date
-
contact_date
)
<
maximum_days
# If no memcached, check in consumption report
for
sale_packing_list
in
portal
.
portal_catalog
(
portal_type
=
"Sale Packing List Line"
,
simulation_state
=
"delivered"
,
default_aggregate_uid
=
computer
.
getUid
(),
sort_on
=
[(
'movement.start_date'
,
'DESC'
)],
limit
=
1
):
return
(
now_date
-
sale_packing_list
.
getStartDate
())
<
maximum_days
return
False
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Computer_hasContactedRecently.xml
0 → 100644
View file @
30017fbb
<?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>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Computer_hasContactedRecently
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_trySendNotificationMessage.py
View file @
30017fbb
...
...
@@ -20,7 +20,8 @@ event.edit(
text_content
=
message
,
start_date
=
DateTime
(),
resource
=
resource
,
source
=
source_relative_url
,
source
=
support_request
.
getSource
(),
destination
=
destination_relative_url
,
follow_up
=
support_request
.
getRelativeUrl
(),
)
event
.
stop
()
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_trySendNotificationMessage.xml
View file @
30017fbb
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
message_title, message,
source
_relative_url
</string>
</value>
<value>
<string>
message_title, message,
destination
_relative_url
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
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