Commit eb13c474 authored by Romain Courteaud's avatar Romain Courteaud

slapos_*: drop open/personal allocation_scope

parent c959af77
...@@ -4,7 +4,7 @@ kw['url_string'] = context.getUrlString() ...@@ -4,7 +4,7 @@ kw['url_string'] = context.getUrlString()
software_installation_list = context.portal_catalog(**kw) software_installation_list = context.portal_catalog(**kw)
compute_node_list = [] compute_node_list = []
allocation_scope_list = ['open/personal', 'open/public', 'open/friend'] allocation_scope_list = ['open/public', 'open/friend']
for software_installation in software_installation_list: for software_installation in software_installation_list:
compute_node = software_installation.getAggregateValue() compute_node = software_installation.getAggregateValue()
if software_installation.getSlapState() == 'start_requested' and \ if software_installation.getSlapState() == 'start_requested' and \
......
...@@ -2,7 +2,6 @@ compute_node = state_change['object'] ...@@ -2,7 +2,6 @@ compute_node = state_change['object']
portal = compute_node.getPortalObject() portal = compute_node.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue() person = portal.portal_membership.getAuthenticatedMember().getUserValue()
compute_node.edit( compute_node.edit(
allocation_scope='open/personal',
source_administration_value=person, source_administration_value=person,
upgrade_scope='auto', upgrade_scope='auto',
capacity_scope='open' capacity_scope='open'
......
<?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_checkAndUpdateComputeNodeAllocationScope</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Automatically turn allocation scope of public and friend compute_node to personnal if the owner is not a service provider.</string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_crm_check_update_allocation_scope</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple>
<int>5</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value> <int>1</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>1399420800.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>Check and Update Compute Node Allocation Scope</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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_checkAndUpdatePersonalComputeNodeAllocationScope</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Automatically turn allocation scope of personal compute_node to closed if the compute_node were never used.</string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_crm_check_update_personal_allocation_scope</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple>
<int>22</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple>
<int>30</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value>
<none/>
</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>1399420800.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>Check and Update Personal Compute Node Allocation Scope</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None)
category_subscription = portal.restrictedTraverse("portal_categories/allocation_scope/open/subscription", None)
category_friend = portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None)
if category_public is not None:
portal.portal_catalog.searchAndActivate(
portal_type='Compute Node',
default_allocation_scope_uid=[category_public.getUid(), category_friend.getUid(), category_subscription.getUid()],
validation_state="validated",
method_id='ComputeNode_checkAndUpdateAllocationScope',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
<?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>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkAndUpdateComputeNodeAllocationScope</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from DateTime import DateTime
# from erp5.component.module.DateUtils import addToDate
# from Products.ZSQLCatalog.SQLCatalog import Query
portal = context.getPortalObject()
category_personal = portal.restrictedTraverse("portal_categories/allocation_scope/open/personal", None)
if category_personal is not None:
portal.portal_catalog.searchAndActivate(
portal_type='Compute Node',
validation_state='validated',
# XXX - creation_date is not indexed for compute_node
# creation_date=Query(range="max", creation_date=addToDate(DateTime(), {'day': -30})),
default_allocation_scope_uid=category_personal.getUid(),
method_id='ComputeNode_checkAndUpdatePersonalAllocationScope',
activate_kw={'tag': tag})
context.activate(after_tag=tag).getId()
<?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>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkAndUpdatePersonalComputeNodeAllocationScope</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -8,9 +8,6 @@ public_category_uid = portal.restrictedTraverse( ...@@ -8,9 +8,6 @@ public_category_uid = portal.restrictedTraverse(
friend_category_uid = portal.restrictedTraverse( friend_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/friend", None).getUid() "portal_categories/allocation_scope/open/friend", None).getUid()
personal_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/personal", None).getUid()
l = [] l = []
...@@ -24,7 +21,7 @@ def checkForError(reference): ...@@ -24,7 +21,7 @@ def checkForError(reference):
return 1 return 1
for compute_node in portal.portal_catalog( for compute_node in portal.portal_catalog(
default_allocation_scope_uid = [personal_category_uid, public_category_uid, friend_category_uid], default_allocation_scope_uid = [public_category_uid, friend_category_uid],
select_list={"reference": None}, select_list={"reference": None},
**kw): **kw):
......
from DateTime import DateTime
compute_node = context
portal = context.getPortalObject()
allocation_scope = compute_node.getAllocationScope()
compute_node_reference = compute_node.getReference()
if allocation_scope not in ['open/public', 'open/friend', 'open/personal']:
return
if allocation_scope == target_allocation_scope:
# already changed
return
person = compute_node.getSourceAdministrationValue(portal_type="Person")
if not person:
return
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' % (compute_node_reference,
target_allocation_scope)
request_description = 'Allocation scope has been changed to ' \
'%s for %s' % (target_allocation_scope, compute_node_reference)
support_request = person.Base_getSupportRequestInProgress(
title=request_title,
aggregate=context.getRelativeUrl()
)
if support_request is None:
person.notify(support_request_title=request_title,
support_request_description=request_description,
aggregate=context.getRelativeUrl())
support_request_relative_url = context.REQUEST.get("support_request_relative_url")
support_request = portal.restrictedTraverse(support_request_relative_url)
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(
reference=notification_message_reference)
if notification_message is not None:
mapping_dict = {'compute_node_title':compute_node.getTitle(),
'compute_node_id':compute_node_reference,
'compute_node_url':compute_node.getRelativeUrl(),
'allocation_scope':allocation_scope}
message = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict': mapping_dict})
event = support_request.SupportRequest_getLastEvent(request_title)
if event is None:
support_request.notify(message_title=request_title, message=message)
event = support_request.REQUEST.get("ticket_notified_item")
if event is not None:
# event added, suspend ticket
if portal.portal_workflow.isTransitionPossible(support_request, 'suspend'):
support_request.suspend()
elif not force:
return support_request
compute_node.edit(**edit_kw)
return support_request
elif force:
# Update compute_node event if ticket is not created
compute_node.edit(**edit_kw)
<?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>target_allocation_scope=\'open/personal\', notification_message_reference=\'slapos-crm-compute_node_allocation_scope.notification\', check_service_provider=True, force=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_checkAndUpdateAllocationScope</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
if context.ComputeNode_hasContactedRecently():
return
return context.ComputeNode_checkAndUpdateAllocationScope(
target_allocation_scope = 'close/outdated',
notification_message_reference='slapos-crm-compute-node-allocation-scope-closed.notification',
check_service_provider=False,
force=True)
<?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>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_checkAndUpdatePersonalAllocationScope</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -80,7 +80,7 @@ if aggregate_portal_type == "Instance Tree": ...@@ -80,7 +80,7 @@ if aggregate_portal_type == "Instance Tree":
instance.getUrlString(), compute_node.getReference(), instance.getUrlString(), compute_node.getReference(),
compute_node.getAllocationScope())) compute_node.getAllocationScope()))
if instance.getPortalType() == "Software Instance" and \ if instance.getPortalType() == "Software Instance" and \
compute_node.getAllocationScope() in ["closed/outdated", "open/personal"] and \ compute_node.getAllocationScope() in ["closed/outdated"] and \
instance.getSlapState() == "start_requested" and \ instance.getSlapState() == "start_requested" and \
instance.SoftwareInstance_hasReportedError(): instance.SoftwareInstance_hasReportedError():
message_list.append("%s on a %s compute_node" % (instance.getReference(), compute_node.getAllocationScope()) ) message_list.append("%s on a %s compute_node" % (instance.getReference(), compute_node.getAllocationScope()) )
......
...@@ -20,10 +20,6 @@ if scope == 'open/public': ...@@ -20,10 +20,6 @@ if scope == 'open/public':
return {"Auditor": ["R-SHADOW-PERSON"]} return {"Auditor": ["R-SHADOW-PERSON"]}
elif scope == 'open/subscription': elif scope == 'open/subscription':
return {"Auditor": ["R-SHADOW-PERSON"]} return {"Auditor": ["R-SHADOW-PERSON"]}
elif scope == 'open/personal':
person = compute_node.getSourceAdministrationValue(portal_type="Person")
if person is not None:
return {"Auditor": ["SHADOW-%s" % person.getUserId()]}
elif scope == 'open/friend': elif scope == 'open/friend':
person_list = compute_node.getDestinationSectionValueList(portal_type="Person") person_list = compute_node.getDestinationSectionValueList(portal_type="Person")
if person_list: if person_list:
......
...@@ -9,10 +9,6 @@ elif allocation_scope == 'open/friend': ...@@ -9,10 +9,6 @@ elif allocation_scope == 'open/friend':
# Capacity is not handled for 'private' compute_nodes # Capacity is not handled for 'private' compute_nodes
capacity_scope = 'open' capacity_scope = 'open'
monitor_scope = 'enabled' monitor_scope = 'enabled'
elif allocation_scope == 'open/personal':
capacity_scope = 'open'
# Keep the same.
monitor_scope = compute_node.getMonitorScope("disabled")
else: else:
monitor_scope = 'disabled' monitor_scope = 'disabled'
capacity_scope = 'close' capacity_scope = 'close'
...@@ -32,10 +28,6 @@ if allocation_scope in ['open/public', 'open/subscription']: ...@@ -32,10 +28,6 @@ if allocation_scope in ['open/public', 'open/subscription']:
# reset friends and update in place # reset friends and update in place
edit_kw['subject_list'] = [''] edit_kw['subject_list'] = ['']
edit_kw['destination_section'] = None edit_kw['destination_section'] = None
elif allocation_scope == 'open/personal':
# reset friends to self and update in place
edit_kw['subject_list'] = [self_email]
edit_kw['destination_section'] = self_person.getRelativeUrl()
else: else:
subject_list = compute_node.getSubjectList() subject_list = compute_node.getSubjectList()
if self_email not in subject_list: if self_email not in subject_list:
......
...@@ -106,7 +106,6 @@ ...@@ -106,7 +106,6 @@
"Closed forever", "Closed forever",
"Closed outdated", "Closed outdated",
"Open for Friends only", "Open for Friends only",
"Open for Personal use only",
"Open Public", "Open Public",
"Open for Subscribers only", "Open for Subscribers only",
"Network", "Network",
...@@ -172,9 +171,8 @@ ...@@ -172,9 +171,8 @@
[results[2][15], 'close/forever'], [results[2][15], 'close/forever'],
[results[2][16], 'close/outdated'], [results[2][16], 'close/outdated'],
[results[2][17], 'open/friend'], [results[2][17], 'open/friend'],
[results[2][18], 'open/personal'], [results[2][18], 'open/public'],
[results[2][19], 'open/public'], [results[2][19], 'open/subscription']],
[results[2][20], 'open/subscription']],
i, i,
len = results[1].data.total_rows; len = results[1].data.total_rows;
......
...@@ -263,7 +263,7 @@ ...@@ -263,7 +263,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1000.58064.4435.24422</string> </value> <value> <string>998.18207.59213.64375</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -281,7 +281,7 @@ ...@@ -281,7 +281,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1656716026.45</float> <float>1652949235.86</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -2,13 +2,11 @@ portal = context.getPortalObject() ...@@ -2,13 +2,11 @@ portal = context.getPortalObject()
category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None) category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None)
category_friend = portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None) category_friend = portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None)
category_personal = portal.restrictedTraverse("portal_categories/allocation_scope/open/personal", None)
return portal.portal_catalog( return portal.portal_catalog(
portal_type='Compute Node', portal_type='Compute Node',
default_allocation_scope_uid=[ default_allocation_scope_uid=[
category_public.getUid(), category_public.getUid(),
category_friend.getUid(), category_friend.getUid()],
category_personal.getUid()],
validation_state="validated", validation_state="validated",
) )
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