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
Hardik Juneja
slapos.core
Commits
3f737526
Commit
3f737526
authored
Jul 29, 2014
by
Alain Takoudjou
Committed by
Rafael Monnerat
Jul 30, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve "Unavailable Computer" Support Request
parent
2e3a0761
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
296 additions
and
33 deletions
+296
-33
master/bt5/slapos_crm/PathTemplateItem/portal_alarms/slapos_check_computer_state.xml
...emplateItem/portal_alarms/slapos_check_computer_state.xml
+4
-4
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Computer_checkAndUpdateAllocationScope.xml
...ins/slapos_crm/Computer_checkAndUpdateAllocationScope.xml
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Computer_checkState.xml
...plateItem/portal_skins/slapos_crm/Computer_checkState.xml
+55
-12
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/SupportRequest_trySendNotificationMessage.xml
.../slapos_crm/SupportRequest_trySendNotificationMessage.xml
+4
-2
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSkins.py
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSkins.py
+190
-13
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSupportRequestGeneration.py
...TestTemplateItem/testSlapOSCRMSupportRequestGeneration.py
+41
-0
master/bt5/slapos_crm/bt/revision
master/bt5/slapos_crm/bt/revision
+1
-1
No files found.
master/bt5/slapos_crm/PathTemplateItem/portal_alarms/slapos_check_computer_state.xml
View file @
3f737526
...
@@ -32,7 +32,9 @@
...
@@ -32,7 +32,9 @@
</item>
</item>
<item>
<item>
<key>
<string>
periodicity_hour_frequency
</string>
</key>
<key>
<string>
periodicity_hour_frequency
</string>
</key>
<value>
<int>
1
</int>
</value>
<value>
<none/>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
periodicity_minute
</string>
</key>
<key>
<string>
periodicity_minute
</string>
</key>
...
@@ -42,9 +44,7 @@
...
@@ -42,9 +44,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
periodicity_minute_frequency
</string>
</key>
<key>
<string>
periodicity_minute_frequency
</string>
</key>
<value>
<value>
<int>
30
</int>
</value>
<none/>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
periodicity_month
</string>
</key>
<key>
<string>
periodicity_month
</string>
</key>
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Computer_checkAndUpdateAllocationScope.xml
View file @
3f737526
...
@@ -80,7 +80,7 @@ if not is_service_provider:\n
...
@@ -80,7 +80,7 @@ if not is_service_provider:\n
\n
\n
# Create a ticket (or re-open it) for this issue!\n
# Create a ticket (or re-open it) for this issue!\n
support_request = None\n
support_request = None\n
request_title = \'Allocation scope has been changed for %s\' % computer_reference\n
request_title = \'
[MONITORING]
Allocation scope has been changed for %s\' % computer_reference\n
request_description = \'Allocation scope has been changed back to \' \\\n
request_description = \'Allocation scope has been changed back to \' \\\n
\'open/personal for %s\' % computer_reference\n
\'open/personal for %s\' % computer_reference\n
message_title = \'We have changed allocation scope for %s\' % computer_reference\n
message_title = \'We have changed allocation scope for %s\' % computer_reference\n
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/Computer_checkState.xml
View file @
3f737526
...
@@ -62,29 +62,72 @@ if portal.ERP5Site_isSupportRequestCreationClosed():\n
...
@@ -62,29 +62,72 @@ if portal.ERP5Site_isSupportRequestCreationClosed():\n
return\n
return\n
\n
\n
reference = context.getReference()\n
reference = context.getReference()\n
computer_title = context.getTitle()\n
ticket_title = "[MONITORING] Lost contact with computer %s" % reference\n
description = ""\n
should_notify = True\n
last_contact = "No Contact Information"\n
\n
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
key_prefix=\'slap_tool\',\n
key_prefix=\'slap_tool\',\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
\n
\n
try:\n
try:\n
d = memcached_dict[reference]\n
d = memcached_dict[reference]\n
d = json.loads(d)\n
last_contact = DateTime(d.get(\'created_at\'))\n
if (DateTime() - last_contact) >
1:\n
description = "The Computer %s (%s) has not contacted the server for more than 24 hours" \\\n
"(last contact date: %s)" % (computer_title, reference, last_contact)\n
else:\n
should_notify = False\n
except KeyError:\n
except KeyError:\n
return context.Base_generateSupportRequestForSlapOS(\n
ticket_title = "[MONITORING] No information about %s" % reference\n
"No information about %s" % reference,\n
description = "The Computer %s (%s) has not contacted the server (No Contact Information)" % (\n
"%s has not contacted the server (No Contact Information)" % reference,\n
computer_title, reference)\n
context.getRelativeUrl()\n
)\n
\n
\n
\n
\n
d = json.loads(d)\n
if should_notify:\n
last_contact = DateTime(d.get(\'created_at\'))\n
support_request_url = context.Base_generateSupportRequestForSlapOS(\n
\n
ticket_title,\n
if (DateTime() - last_contact) >
1:\n
description,\n
return context.Base_generateSupportRequestForSlapOS(\n
"Lost contact with %s" % reference,\n
"%s has not contacted the server for more than 24 hours (last contact date: %s)" % (reference, last_contact),\n
context.getRelativeUrl()\n
context.getRelativeUrl()\n
)\n
)\n
\n
support_request = None\n
person = context.getSourceAdministrationValue(portal_type="Person")\n
if not person:\n
return support_request_url\n
\n
if support_request_url:\n
support_request = portal.restrictedTraverse(support_request_url, None)\n
else:\n
# XXX - the support request might already exists\n
support_request = portal.portal_catalog.getResultValue(\n
portal_type = \'Support Request\',\n
title = ticket_title,\n
simulation_state = \'validated\',\n
source_project_uid = context.getUid()\n
)\n
if support_request is None:\n
# Existing ticket not found, can not create event for the moment\n
return support_request_url\n
\n
# Send Notification message\n
notification_reference = \'slapos-crm-computer_check_state.notification\'\n
notification_message = portal.portal_notifications.getDocumentValue(\n
reference=notification_reference)\n
mapping_dict = {\'computer_title\':context.getTitle(),\n
\'computer_id\':reference,\n
\'last_contact\':last_contact}\n
message = notification_message.asText(\n
substitution_method_parameter_dict={\'mapping_dict\':mapping_dict})\n
\n
support_request.SupportRequest_trySendNotificationMessage(\n
ticket_title.replace(\'[MONITORING] \', \'\'),\n
message, person.getRelativeUrl(), 5)\n
\n
return support_request_url\n
]]>
</string>
</value>
]]>
</string>
</value>
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/SupportRequest_trySendNotificationMessage.xml
View file @
3f737526
...
@@ -62,7 +62,7 @@ last_event = context.portal_catalog.getResultValue(\n
...
@@ -62,7 +62,7 @@ last_event = context.portal_catalog.getResultValue(\n
sort_on=[(\'delivery.start_date\', \'DESC\')],\n
sort_on=[(\'delivery.start_date\', \'DESC\')],\n
)\n
)\n
if last_event and \\\n
if last_event and \\\n
(DateTime() - last_event.getStartDate() <
1
):\n
(DateTime() - last_event.getStartDate() <
interval_of_day
):\n
# User has already been notified this last 24h.\n
# User has already been notified this last 24h.\n
return\n
return\n
event = portal.event_module.slapos_crm_web_message_template.\\\n
event = portal.event_module.slapos_crm_web_message_template.\\\n
...
@@ -77,13 +77,15 @@ event.edit(\n
...
@@ -77,13 +77,15 @@ event.edit(\n
)\n
)\n
event.stop()\n
event.stop()\n
event.deliver()\n
event.deliver()\n
\n
return event\n
]]>
</string>
</value>
]]>
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
message_title, message, source_relative_url
</string>
</value>
<value>
<string>
message_title, message, source_relative_url
, interval_of_day=1
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSkins.py
View file @
3f737526
This diff is collapsed.
Click to expand it.
master/bt5/slapos_crm/TestTemplateItem/testSlapOSCRMSupportRequestGeneration.py
View file @
3f737526
...
@@ -326,6 +326,47 @@ class TestSlapOSCloudSupportRequestGeneration(testSlapOSMixin):
...
@@ -326,6 +326,47 @@ class TestSlapOSCloudSupportRequestGeneration(testSlapOSMixin):
self
.
assertEqual
(
'Visited Base_generateSupportRequestForSlapOS'
,
self
.
assertEqual
(
'Visited Base_generateSupportRequestForSlapOS'
,
result
)
result
)
def
test_SupportRequest_trySendNotificationMessage
(
self
):
title
=
"Test Support Request %s"
%
self
.
new_id
text_content
=
'Test NM content<br/>%s<br/>'
%
self
.
new_id
computer
=
self
.
_makeComputer
(
self
.
new_id
)
support_request_url
=
computer
.
Base_generateSupportRequestForSlapOS
(
title
,
title
,
computer
.
getRelativeUrl
()
)
support_request
=
self
.
portal
.
restrictedTraverse
(
support_request_url
)
person
=
computer
.
getSourceAdministrationValue
()
time_before_next
=
2
self
.
tic
()
first_event
=
support_request
.
SupportRequest_trySendNotificationMessage
(
message_title
=
title
,
message
=
text_content
,
source_relative_url
=
person
.
getRelativeUrl
(),
interval_of_day
=
time_before_next
)
self
.
assertNotEqual
(
first_event
,
None
)
first_event
.
edit
(
start_date
=
(
DateTime
()
-
1.8
))
self
.
tic
()
event
=
support_request
.
SupportRequest_trySendNotificationMessage
(
message_title
=
title
,
message
=
text_content
,
source_relative_url
=
person
.
getRelativeUrl
(),
interval_of_day
=
time_before_next
)
self
.
assertEqual
(
event
,
None
)
time_before_next
=
1
event
=
support_request
.
SupportRequest_trySendNotificationMessage
(
message_title
=
title
,
message
=
text_content
,
source_relative_url
=
person
.
getRelativeUrl
(),
interval_of_day
=
time_before_next
)
self
.
assertEqual
(
event
.
getTitle
(),
title
)
def
test_Computer_checkState_empty_cache
(
self
):
def
test_Computer_checkState_empty_cache
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
computer
=
self
.
_makeComputer
(
self
.
new_id
)
...
...
master/bt5/slapos_crm/bt/revision
View file @
3f737526
42
43
\ No newline at end of file
\ 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