Commit 00b13ea2 authored by Rafael Monnerat's avatar Rafael Monnerat

Merge branch 'master' into operation-control

parents 29b20686 c1d54067
Changes Changes
======= =======
1.2.1 (2014-08-21)
------------------
* slapproxy: add automatic migration to new database schema if needed.
1.2.0 (2014-08-18)
------------------
Note: not officially released as egg.
* slapproxy: add correct support for slaves, instance_guid, state.
* slapproxy: add getComputerPartitionStatus dummy support.
* slapproxy: add multi-nodes support
1.1.2 (2014-06-02) 1.1.2 (2014-06-02)
------------------ ------------------
......
...@@ -50,10 +50,13 @@ ...@@ -50,10 +50,13 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n <value> <string encoding="cdata"><![CDATA[
portal = context.getPortalObject()\n
\n \n
category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None)\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_friend = portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None)\n
category_personal = portal.restrictedTraverse("portal_categories/allocation_scope/open/personal", None)\n
\n \n
if category_public is not None:\n if category_public is not None:\n
portal.portal_catalog.searchAndActivate(\n portal.portal_catalog.searchAndActivate(\n
...@@ -63,8 +66,23 @@ if category_public is not None:\n ...@@ -63,8 +66,23 @@ if category_public is not None:\n
method_id=\'Computer_checkAndUpdateAllocationScope\',\n method_id=\'Computer_checkAndUpdateAllocationScope\',\n
activate_kw={\'tag\': tag}\n activate_kw={\'tag\': tag}\n
)\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 context.activate(after_tag=tag).getId()\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
......
...@@ -57,7 +57,11 @@ portal = context.getPortalObject()\n ...@@ -57,7 +57,11 @@ portal = context.getPortalObject()\n
allocation_scope = computer.getAllocationScope()\n allocation_scope = computer.getAllocationScope()\n
computer_reference = computer.getReference()\n computer_reference = computer.getReference()\n
\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 return\n
\n \n
person = computer.getSourceAdministrationValue(portal_type="Person")\n person = computer.getSourceAdministrationValue(portal_type="Person")\n
...@@ -65,17 +69,15 @@ if not person:\n ...@@ -65,17 +69,15 @@ if not person:\n
return\n return\n
\n \n
if not person.Person_isServiceProvider():\n if not person.Person_isServiceProvider():\n
#Turn this computer allocation scope to \'open/personal\'\n
edit_kw = {\n edit_kw = {\n
\'allocation_scope\': \'open/personal\',\n \'allocation_scope\': target_allocation_scope,\n
}\n }\n
computer.edit(**edit_kw)\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 = \'We have changed allocation scope for %s\' % computer_reference\n request_title = \'We have changed allocation scope for %s\' % computer_reference\n
request_description = \'Allocation scope has been changed back to \' \\\n request_description = \'Allocation scope has been changed to \' \\\n
\'open/personal for %s\' % computer_reference\n \'%s for %s\' % (target_allocation_scope, computer_reference)\n
\n \n
support_request_url = context.Base_generateSupportRequestForSlapOS(\n support_request_url = context.Base_generateSupportRequestForSlapOS(\n
request_title,\n request_title,\n
...@@ -91,7 +93,7 @@ if not person.Person_isServiceProvider():\n ...@@ -91,7 +93,7 @@ if not person.Person_isServiceProvider():\n
support_request = portal.portal_catalog.getResultValue(\n support_request = portal.portal_catalog.getResultValue(\n
portal_type = \'Support Request\',\n portal_type = \'Support Request\',\n
title = request_title,\n title = request_title,\n
simulation_state = \'suspended\',\n simulation_state = [\'suspended\', \'open\'],\n
source_project_uid = computer.getUid()\n source_project_uid = computer.getUid()\n
)\n )\n
if support_request is None:\n if support_request is None:\n
...@@ -100,7 +102,7 @@ if not person.Person_isServiceProvider():\n ...@@ -100,7 +102,7 @@ if not person.Person_isServiceProvider():\n
\n \n
# Send notification message\n # Send notification message\n
notification_message = portal.portal_notifications.getDocumentValue(\n notification_message = portal.portal_notifications.getDocumentValue(\n
reference=\'slapos-crm-computer_allocation_scope.notification\')\n reference=notification_message_reference)\n
\n \n
if notification_message is not None:\n if notification_message is not None:\n
mapping_dict = {\'computer_title\':computer.getTitle(),\n mapping_dict = {\'computer_title\':computer.getTitle(),\n
...@@ -111,13 +113,16 @@ if not person.Person_isServiceProvider():\n ...@@ -111,13 +113,16 @@ if not person.Person_isServiceProvider():\n
else:\n else:\n
message = request_description\n message = request_description\n
\n \n
support_request.SupportRequest_trySendNotificationMessage(request_title,\n event = support_request.SupportRequest_trySendNotificationMessage(request_title,\n
message, person.getRelativeUrl())\n message, person.getRelativeUrl())\n
\n
if event is not None:\n
computer.edit(**edit_kw)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
<?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>
...@@ -1867,7 +1867,8 @@ class TestSlapOSComputer_notifyWrongAllocationScope(testSlapOSMixin): ...@@ -1867,7 +1867,8 @@ class TestSlapOSComputer_notifyWrongAllocationScope(testSlapOSMixin):
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \ 'context, action="edit_action", ' \
'comment="Visited by SupportRequest_trySendNotificationMessage ' \ '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): def test_computerNotAllowedAllocationScope_OpenPublic(self):
computer = self._makeComputer(self.new_id) computer = self._makeComputer(self.new_id)
person = computer.getSourceAdministrationValue() person = computer.getSourceAdministrationValue()
...@@ -1899,7 +1900,8 @@ class TestSlapOSComputer_notifyWrongAllocationScope(testSlapOSMixin): ...@@ -1899,7 +1900,8 @@ class TestSlapOSComputer_notifyWrongAllocationScope(testSlapOSMixin):
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \ 'context, action="edit_action", ' \
'comment="Visited by SupportRequest_trySendNotificationMessage ' \ '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): def test_computerNotAllowedAllocationScope_OpenFriend(self):
computer = self._makeComputer(self.new_id) computer = self._makeComputer(self.new_id)
person = computer.getSourceAdministrationValue() person = computer.getSourceAdministrationValue()
...@@ -1922,6 +1924,38 @@ class TestSlapOSComputer_notifyWrongAllocationScope(testSlapOSMixin): ...@@ -1922,6 +1924,38 @@ class TestSlapOSComputer_notifyWrongAllocationScope(testSlapOSMixin):
'Test NM content\n%s\n' % computer.getReference(), person.getRelativeUrl(), '1'), 'Test NM content\n%s\n' % computer.getReference(), person.getRelativeUrl(), '1'),
ticket.workflow_history['edit_workflow'][-1]['comment']) 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): def test_computerNormalAllocationScope_OpenPersonal(self):
computer = self._makeComputer(self.new_id) computer = self._makeComputer(self.new_id)
......
...@@ -367,8 +367,6 @@ class TestSlapOSCloudSupportRequestGeneration(testSlapOSMixin): ...@@ -367,8 +367,6 @@ class TestSlapOSCloudSupportRequestGeneration(testSlapOSMixin):
self.assertEqual(event.getTitle(), title) 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)
...@@ -838,6 +836,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -838,6 +836,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self.assertEqual('Visited by Computer_checkAndUpdateAllocationScope', self.assertEqual('Visited by Computer_checkAndUpdateAllocationScope',
computer.workflow_history['edit_workflow'][-1]['comment']) computer.workflow_history['edit_workflow'][-1]['comment'])
def test_Alarm_notAllowedAllocationScope_OpenFriend(self): def test_Alarm_notAllowedAllocationScope_OpenFriend(self):
computer = self._makeComputer(self.new_id) computer = self._makeComputer(self.new_id)
computer.edit(allocation_scope = 'open/friend') computer.edit(allocation_scope = 'open/friend')
...@@ -868,6 +867,52 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -868,6 +867,52 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self.assertNotEqual('Visited by Computer_checkAndUpdateAllocationScope', self.assertNotEqual('Visited by Computer_checkAndUpdateAllocationScope',
computer.workflow_history['edit_workflow'][-1]['comment']) 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): def _simulateHostingSubscription_checkSofwareInstanceState(self):
script_name = 'HostingSubscription_checkSofwareInstanceAllocationState' script_name = 'HostingSubscription_checkSofwareInstanceAllocationState'
if script_name in self.portal.portal_skins.custom.objectIds(): if script_name in self.portal.portal_skins.custom.objectIds():
......
49 51
\ No newline at end of file \ No newline at end of file
event_module/slapos_crm_web_message_template event_module/slapos_crm_web_message_template
person_module/allocation_tester person_module/allocation_tester
portal_alarms/slapos_check_cloud_is_full
portal_alarms/slapos_check_computer_state portal_alarms/slapos_check_computer_state
portal_alarms/slapos_check_software_instance_state portal_alarms/slapos_check_software_instance_state
portal_alarms/slapos_crm_cancel_invoice portal_alarms/slapos_crm_cancel_invoice
......
<type_roles> <type_roles>
<role id='Auditor'>
<property id='title'>Agent as auditor</property>
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='base_category'>agent</multi_property>
</role>
<role id='Assignor'> <role id='Assignor'>
<property id='title'>Group company</property> <property id='title'>Group company</property>
<multi_property id='category'>group/company</multi_property> <multi_property id='category'>group/company</multi_property>
......
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
<type>Person</type> <type>Person</type>
<workflow>local_permission_slapos_interaction_workflow</workflow> <workflow>local_permission_slapos_interaction_workflow</workflow>
</chain> </chain>
<chain>
<type>Restricted Access Token</type>
<workflow>local_permission_slapos_interaction_workflow</workflow>
</chain>
<chain> <chain>
<type>Sale Invoice Transaction</type> <type>Sale Invoice Transaction</type>
<workflow>local_permission_slapos_interaction_workflow</workflow> <workflow>local_permission_slapos_interaction_workflow</workflow>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value>
<list>
<string>Base_updateAllLocalRoles</string>
</list>
</value>
</item>
<item>
<key> <string>before_commit_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>RestrictedAccessToken_edit</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>_setAgent.*</string>
</list>
</value>
</item>
<item>
<key> <string>once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<list>
<string>Restricted Access Token</string>
</list>
</value>
</item>
<item>
<key> <string>script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value>
<list>
<string>Base_updateAllLocalRoles</string>
</list>
</value>
</item>
<item>
<key> <string>before_commit_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>UpgradeDecision_edit</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>_setDestinationSection.*</string>
</list>
</value>
</item>
<item>
<key> <string>once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<list>
<string>Upgrade Decision</string>
</list>
</value>
</item>
<item>
<key> <string>script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -7,6 +7,7 @@ Integration Site | local_permission_slapos_interaction_workflow ...@@ -7,6 +7,7 @@ Integration Site | local_permission_slapos_interaction_workflow
Payment Transaction | local_permission_slapos_interaction_workflow Payment Transaction | local_permission_slapos_interaction_workflow
Payzen Event | local_permission_slapos_interaction_workflow Payzen Event | local_permission_slapos_interaction_workflow
Person | local_permission_slapos_interaction_workflow Person | local_permission_slapos_interaction_workflow
Restricted Access Token | local_permission_slapos_interaction_workflow
Sale Invoice Transaction | local_permission_slapos_interaction_workflow Sale Invoice Transaction | local_permission_slapos_interaction_workflow
Sale Packing List | local_permission_slapos_interaction_workflow Sale Packing List | local_permission_slapos_interaction_workflow
Slave Instance | local_permission_slapos_interaction_workflow Slave Instance | local_permission_slapos_interaction_workflow
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>active_sense_method_id</string> </key> <key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_checkCloudIsFull</string> </value> <value> <string>Alarm_processStoppedUpgradeDecision</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -22,7 +22,13 @@ ...@@ -22,7 +22,13 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>slapos_check_cloud_is_full</string> </value> <value> <string>slapos_pdm_upgrade_decision_process_stopped</string> </value>
</item>
<item>
<key> <string>periodicity_day_frequency</string> </key>
<value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>periodicity_hour</string> </key> <key> <string>periodicity_hour</string> </key>
...@@ -32,7 +38,9 @@ ...@@ -32,7 +38,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 +50,7 @@ ...@@ -42,9 +50,7 @@
</item> </item>
<item> <item>
<key> <string>periodicity_minute_frequency</string> </key> <key> <string>periodicity_minute_frequency</string> </key>
<value> <value> <int>5</int> </value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>periodicity_month</string> </key> <key> <string>periodicity_month</string> </key>
...@@ -70,7 +76,7 @@ ...@@ -70,7 +76,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1377608640.0</float> <float>3660.0</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
...@@ -87,15 +93,9 @@ ...@@ -87,15 +93,9 @@
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value> <value> <string>Alarm</string> </value>
</item> </item>
<item>
<key> <string>sense_method_id</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Check if vifib cloud is full</string> </value> <value> <string>Process Stopped Upgrade Decisions</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -51,19 +51,12 @@ ...@@ -51,19 +51,12 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n <value> <string>portal = context.getPortalObject()\n
\n portal.portal_catalog.searchAndActivate(\n
software_release_preference = portal.portal_preferences.getPreferredSoftwareReleaseToTestForSpace()\n portal_type=\'Upgrade Decision\',\n
\n simulation_state=\'stopped\',\n
if software_release_preference != \'\':\n method_id=\'UpgradeDecision_notifyDelivered\',\n
software_release_list = software_release_preference.split("\\n")\n activate_kw={\'tag\': tag }\n
\n )\n
portal.portal_catalog.searchAndActivate(\n
portal_type = \'Software Release\',\n
url_string = software_release_list,\n
\n
method_id = \'SoftwareRelease_testForAllocation\',\n
activate_kw = {\'tag\':tag} \n
)\n
\n \n
context.activate(after_tag=tag).getId()\n context.activate(after_tag=tag).getId()\n
</string> </value> </string> </value>
...@@ -74,7 +67,7 @@ context.activate(after_tag=tag).getId()\n ...@@ -74,7 +67,7 @@ context.activate(after_tag=tag).getId()\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Alarm_checkCloudIsFull</string> </value> <value> <string>Alarm_processStoppedUpgradeDecision</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -74,11 +74,12 @@ if not person_url:\n ...@@ -74,11 +74,12 @@ if not person_url:\n
\n \n
upgrade_decision = portal.upgrade_decision_module.\\\n upgrade_decision = portal.upgrade_decision_module.\\\n
template_upgrade_decision.Base_createCloneDocument(batch_mode=1)\n template_upgrade_decision.Base_createCloneDocument(batch_mode=1)\n
upgrade_decision.edit(\n \n
title=title,\n upgrade_decision.edit(title=title)\n
destination_section=person_url,\n \n
destination_decision=person_url\n upgrade_decision.setDestinationSection(person_url)\n
)\n upgrade_decision.setDestinationDecision(person_url)\n
\n
decision_line_list = upgrade_decision.contentValues(\n decision_line_list = upgrade_decision.contentValues(\n
portal_type=\'Upgrade Decision Line\')\n portal_type=\'Upgrade Decision Line\')\n
if len(decision_line_list) > 0:\n if len(decision_line_list) > 0:\n
......
<?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
\n
notification_message = portal.portal_notifications.getDocumentValue(\n
reference=\'slapos-upgrade-computer.notification\')\n
\n
title = "New Software available for Installation at %s" % computer.getTitle()\n
mapping_dict = {\'software_product_title\': software_product_title,\n
\'computer_title\': computer.getTitle(),\n
\'computer_reference\': computer.getReference(),\n
\'software_release_name\': software_release.getTitle(),\n
\'software_release_reference\': software_release.getReference(),\n
\'upgrade_accept_link\': \n
\'Base_acceptUpgradeDecision?reference=%s\' % reference,\n
\'upgrade_reject_link\':\n
\'Base_rejectUpgradeDecision?reference=%s\' % reference,\n
\'new_software_release_url\': software_release.getUrlString(),\n
}\n
\n
\n
if notification_message is not None:\n
message = notification_message.asEntireHTML(\n
substitution_method_parameter_dict={\'mapping_dict\': mapping_dict})\n
else:\n
raise ValueError("No Notification Message")\n
\n
return title, message\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>computer</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>UpgradeDecision_getComputerNotificationMessage</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,34 +50,34 @@ ...@@ -50,34 +50,34 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n <value> <string encoding="cdata"><![CDATA[
software_release = context\n
software_release_url = software_release.getUrlString()\n portal = context.getPortalObject()\n
\n \n
user = portal.person_module.allocation_tester\n hosting_subscription = context.UpgradeDecision_getHostingSubscription()\n
computer = context.UpgradeDecision_getComputer()\n
software_release = context.UpgradeDecision_getSoftwareRelease()\n
\n \n
result = user.Person_restrictMethodAsShadowUser(\n if hosting_subscription is not None:\n
shadow_document=user,\n if hosting_subscription.getUrlString() == software_release.getUrlString():\n
callable_object=user.Person_findPartition,\n return True\n
argument_list=[\n
software_release_url,\n
\'\',\n
\'Software Instance\',\n
{}\n
],\n
argument_dict={\n
\'test_mode\': True})\n
\n \n
if not result:\n elif computer is not None:\n
title = "Can\'t allocate new instances for software release %s" % software_release_url\n full_software_release_list = [si for si in \n
description = "Need more public computers that can instanciate the software release %s" % software_release_url\n portal.portal_catalog(\n
portal_type=\'Software Installation\',\n
url_string=software_release.getUrlString(),\n
default_aggregate_uid=computer.getUid(),\n
validation_state=\'validated\'\n
) if si.getSlapState() == \'start_requested\']\n
\n \n
return software_release.Base_generateSupportRequestForSlapOS(\n if len(full_software_release_list) > 0:\n
title,\n return True\n
description,\n \n
software_release.getRelativeUrl()\n return False\n
)\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
...@@ -85,7 +85,7 @@ if not result:\n ...@@ -85,7 +85,7 @@ if not result:\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SoftwareRelease_testForAllocation</string> </value> <value> <string>UpgradeDecision_isUpgradeFinished</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<?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 DateTime import DateTime\n
\n
if context.getSimulationState() != \'stopped\':\n
return \n
\n
if context.UpgradeDecision_isUpgradeFinished():\n
return \n
\n
portal = context.getPortalObject()\n
\n
person = context.getDestinationDecisionValue(portal_type="Person")\n
if not person:\n
raise ValueError("Inconsistent Upgrade Decision, No Destination Decision")\n
\n
hosting_subscription = context.UpgradeDecision_getHostingSubscription()\n
computer = context.UpgradeDecision_getComputer()\n
software_release = context.UpgradeDecision_getSoftwareRelease()\n
software_product_title = software_release.getAggregateTitle(\n
portal_type="Software Product")\n
\n
reference = context.getReference()\n
\n
mapping_dict = {\n
\'software_product_title\': software_product_title,\n
\'software_release_name\': software_release.getTitle(),\n
\'software_release_reference\': software_release.getReference(),\n
\'new_software_release_url\': software_release.getUrlString(),\n
}\n
\n
if hosting_subscription is not None:\n
notification_message_reference = \'slapos-upgrade-delivered-hosting-subscription.notification\'\n
title = "Upgrade Processed for %s (%s)" % (hosting_subscription.getTitle(), \n
software_release.getReference())\n
mapping_dict.update(**{\n
\'hosting_subscription_title\': hosting_subscription.getTitle(),\n
\'old_software_release_url\': hosting_subscription.getUrlString()})\n
\n
elif computer is not None:\n
\n
notification_message_reference = \'slapos-upgrade-delivered-computer.notification\' \n
\n
title = "Upgrade processed at %s for %s" % (computer.getTitle(), software_release.getReference()) \n
mapping_dict.update(**{\'computer_title\': computer.getTitle(),\n
\'computer_reference\': computer.getReference()})\n
\n
\n
if notification_message_reference is None:\n
raise ValueError("No Notification Message")\n
\n
notification_message = portal.portal_notifications.getDocumentValue(\n
reference=notification_message_reference)\n
\n
message = notification_message.asEntireHTML(\n
substitution_method_parameter_dict={\'mapping_dict\': mapping_dict})\n
\n
event = context.SupportRequest_trySendNotificationMessage(title,\n
message, person.getRelativeUrl())\n
\n
if event is not None:\n
context.deliver()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>UpgradeDecision_notifyDelivered</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -87,6 +87,23 @@ return %s ...@@ -87,6 +87,23 @@ return %s
upgrade_decision.workflow_history['edit_workflow'][-1]['comment']) upgrade_decision.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_upgrade_decision_process_stopped(self):
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.start()
upgrade_decision.stop()
self.tic()
self._simulateScript('UpgradeDecision_notifyDelivered')
try:
self.portal.portal_alarms.slapos_pdm_upgrade_decision_process_stopped.\
activeSense()
self.tic()
finally:
self._dropScript('UpgradeDecision_notifyDelivered')
self.assertEqual('Visited by UpgradeDecision_notifyDelivered',
upgrade_decision.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_computer_create_upgrade_decision(self): def test_alarm_computer_create_upgrade_decision(self):
computer = self._makeComputer(self.new_id) computer = self._makeComputer(self.new_id)
computer.edit(allocation_scope = 'open/public') computer.edit(allocation_scope = 'open/public')
......
...@@ -1394,6 +1394,37 @@ class TestSlapOSPDMSkins(testSlapOSMixin): ...@@ -1394,6 +1394,37 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
"?portal_status_message=Upgrade%20Decision%20is%20already%20Rejected%21"), "?portal_status_message=Upgrade%20Decision%20is%20already%20Rejected%21"),
"%s contains the wrong message" % redirect_url) "%s contains the wrong message" % redirect_url)
def testUpgradeDecision_isUpgradeFinished_computer(self):
computer = self._makeComputer(self.new_id)
software_release = self._makeSoftwareRelease(self.new_id)
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release, computer])
upgrade_decision.confirm()
upgrade_decision.stop()
self.assertFalse(upgrade_decision.UpgradeDecision_isUpgradeFinished())
self._makeSoftwareInstallation(self.new_id, computer,
software_release.getUrlString())
self.tic()
self.assertTrue(upgrade_decision.UpgradeDecision_isUpgradeFinished())
def testUpgradeDecision_isUpgradeFinished_hosting_subscription(self):
hosting_subscription = self._makeHostingSubscription(self.new_id)
software_release = self._makeSoftwareRelease(self.new_id)
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release,
hosting_subscription])
upgrade_decision.confirm()
upgrade_decision.stop()
self.assertFalse(upgrade_decision.UpgradeDecision_isUpgradeFinished())
hosting_subscription.setUrlString(software_release.getUrlString())
self.assertTrue(upgrade_decision.UpgradeDecision_isUpgradeFinished())
@simulate('NotificationTool_getDocumentValue', @simulate('NotificationTool_getDocumentValue',
'reference=None', 'reference=None',
'assert reference == "slapos-upgrade-computer.notification"\n' \ 'assert reference == "slapos-upgrade-computer.notification"\n' \
...@@ -1525,3 +1556,133 @@ ${new_software_release_url}""", ...@@ -1525,3 +1556,133 @@ ${new_software_release_url}""",
self.assertEquals(event.getSimulationState(), "delivered") self.assertEquals(event.getSimulationState(), "delivered")
@simulate('NotificationTool_getDocumentValue',
'reference=None',
'assert reference == "slapos-upgrade-delivered-computer.notification"\n' \
'return context.restrictedTraverse(' \
'context.REQUEST["testUpgradeDecision_notifyDelivered_computer"])')
@simulate('UpgradeDecision_isUpgradeFinished',
'', 'return 0')
def testUpgradeDecision_notifyDelivered_computer(self):
person = self._makePerson(self.new_id)
computer = self._makeComputer(self.new_id)
software_release = self._makeSoftwareRelease(self.new_id)
software_product = self._makeSoftwareProduct(self.new_id)
software_release.setAggregateValue(software_product)
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.edit(destination_decision_value=person)
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release, computer])
notification_message = self.portal.notification_message_module.newContent(
portal_type="Notification Message",
title='Test NM title %s' % self.new_id,
text_content_substitution_mapping_method_id=
"NotificationMessage_getSubstitutionMappingDictFromArgument",
text_content="""${software_product_title}
${computer_title}
${computer_reference}
${software_release_name}
${software_release_reference}
${new_software_release_url}""",
content_type='text/html',
)
self.portal.REQUEST\
['testUpgradeDecision_notifyDelivered_computer'] = \
notification_message.getRelativeUrl()
self.tic()
self.assertEquals(None, upgrade_decision.UpgradeDecision_notifyDelivered())
upgrade_decision.start()
upgrade_decision.stop()
self.tic()
self.assertEquals(None, upgrade_decision.UpgradeDecision_notifyDelivered())
self.tic()
self.assertEquals(upgrade_decision.getSimulationState(), 'delivered')
self.assertEquals(len(upgrade_decision.getFollowUpRelatedValueList()), 1)
event = upgrade_decision.getFollowUpRelatedValue()
self.assertEquals(event.getTitle(),
"Upgrade processed at %s for %s" % (computer.getTitle(),
software_release.getReference()))
self.assertEqual(event.getTextContent().splitlines(),
[software_product.getTitle(), computer.getTitle(), computer.getReference(),
software_release.getTitle(), software_release.getReference(),
software_release.getUrlString()])
self.assertEquals(event.getSimulationState(), "delivered")
@simulate('NotificationTool_getDocumentValue',
'reference=None',
'assert reference == "slapos-upgrade-delivered-hosting-subscription.notification"\n' \
'return context.restrictedTraverse(' \
'context.REQUEST["testUpgradeDecision_notifyDelivered_hosting_subscription"])')
@simulate('UpgradeDecision_isUpgradeFinished',
'', 'return 0')
def testUpgradeDecision_notifyDelivered_hosting_subscription(self):
person = self._makePerson(self.new_id)
hosting_subscription = self._makeHostingSubscription(self.new_id)
software_release = self._makeSoftwareRelease(self.new_id)
software_product = self._makeSoftwareProduct(self.new_id)
software_release.setAggregateValue(software_product)
upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.edit(destination_decision_value=person)
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release,
hosting_subscription])
old_url = hosting_subscription.getUrlString()
notification_message = self.portal.notification_message_module.newContent(
portal_type="Notification Message",
title='Test NM title %s' % self.new_id,
text_content_substitution_mapping_method_id=
"NotificationMessage_getSubstitutionMappingDictFromArgument",
text_content="""${software_product_title}
${hosting_subscription_title}
${old_software_release_url}
${software_release_name}
${software_release_reference}
${new_software_release_url}""",
content_type='text/html',
)
self.portal.REQUEST\
['testUpgradeDecision_notifyDelivered_hosting_subscription'] = \
notification_message.getRelativeUrl()
self.tic()
self.assertEquals(None, upgrade_decision.UpgradeDecision_notifyDelivered())
upgrade_decision.start()
upgrade_decision.stop()
self.tic()
self.assertEquals(None, upgrade_decision.UpgradeDecision_notifyDelivered())
self.tic()
self.assertEquals(upgrade_decision.getSimulationState(), 'delivered')
self.assertEquals(len(upgrade_decision.getFollowUpRelatedValueList()), 1)
event = upgrade_decision.getFollowUpRelatedValue()
self.assertEquals(event.getTitle(),
"Upgrade Processed for %s (%s)" % (hosting_subscription.getTitle(),
software_release.getReference()))
self.assertEqual(event.getTextContent().splitlines(),
[software_product.getTitle(), hosting_subscription.getTitle(),
old_url, software_release.getTitle(), software_release.getReference(),
software_release.getUrlString()])
self.assertEquals(event.getSimulationState(), "delivered")
...@@ -3,6 +3,7 @@ portal_alarms/slapos_pdm_computer_create_upgrade_decision ...@@ -3,6 +3,7 @@ portal_alarms/slapos_pdm_computer_create_upgrade_decision
portal_alarms/slapos_pdm_hosting_subscription_create_upgrade_decision portal_alarms/slapos_pdm_hosting_subscription_create_upgrade_decision
portal_alarms/slapos_pdm_upgrade_decision_process_planned portal_alarms/slapos_pdm_upgrade_decision_process_planned
portal_alarms/slapos_pdm_upgrade_decision_process_started portal_alarms/slapos_pdm_upgrade_decision_process_started
portal_alarms/slapos_pdm_upgrade_decision_process_stopped
software_product_module/template_software_product software_product_module/template_software_product
software_release_module/template_software_release software_release_module/template_software_release
upgrade_decision_module/template_upgrade_decision upgrade_decision_module/template_upgrade_decision
\ No newline at end of file
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n <value> <string>portal = context.getPortalObject()\n
kw[\'portal_type\'] = ["Support Request", "Regularisation Request"]\n kw[\'portal_type\'] = ["Support Request", "Regularisation Request", "Upgrader Decision"]\n
kw[\'simulation_state\'] = [\'validated\',\'submitted\']\n \n
\n \n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
if person:\n if person:\n
......
...@@ -57,6 +57,9 @@ import json\n ...@@ -57,6 +57,9 @@ import json\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
\n \n
if person is None:\n
raise ValueError("User Not Found")\n
\n
web_site = context.getWebSiteValue()\n web_site = context.getWebSiteValue()\n
request_url = "%s/%s" % (web_site.absolute_url(), "feed")\n request_url = "%s/%s" % (web_site.absolute_url(), "feed")\n
\n \n
...@@ -69,22 +72,24 @@ for token_item in portal.portal_catalog(\n ...@@ -69,22 +72,24 @@ for token_item in portal.portal_catalog(\n
):\n ):\n
if token_item.getUrlString() == request_url:\n if token_item.getUrlString() == request_url:\n
access_token = token_item\n access_token = token_item\n
reference = access_token.getReference()\n
break;\n break;\n
\n \n
if access_token is None:\n if access_token is None:\n
access_token = portal.access_token_module.newContent(\n access_token = portal.access_token_module.newContent(\n
portal_type="Restricted Access Token",\n portal_type="Restricted Access Token",\n
agent_value=person,\n
url_string=request_url,\n url_string=request_url,\n
url_method="GET",\n url_method="GET",\n
)\n )\n
access_token.setAgentValue(person)\n
reference = access_token.getReference() \n
access_token.validate()\n access_token.validate()\n
\n \n
url = "%s/%s?portal_skin=RSS&access_token=%s&access_token_secret=%s" % (\n url = "%s/%s?portal_skin=RSS&access_token=%s&access_token_secret=%s" % (\n
web_site.absolute_url(),\n web_site.absolute_url(),\n
"feed",\n "feed",\n
access_token.getId(),\n access_token.getId(),\n
access_token.getReference())\n reference)\n
\n \n
request = context.REQUEST\n request = context.REQUEST\n
response = request.RESPONSE\n response = request.RESPONSE\n
......
...@@ -79,7 +79,7 @@ def do_collect(conf): ...@@ -79,7 +79,7 @@ def do_collect(conf):
raise raise
log_directory = "%s/var/data-log" % conf.get("slapos", "instance_root") log_directory = "%s/var/data-log" % conf.get("slapos", "instance_root")
mkdir_p(log_directory) mkdir_p(log_directory, 0o755)
database = Database(log_directory) database = Database(log_directory)
computer = Computer(ComputerSnapshot()) computer = Computer(ComputerSnapshot())
......
...@@ -37,6 +37,7 @@ import subprocess ...@@ -37,6 +37,7 @@ import subprocess
import sys import sys
import tempfile import tempfile
import time import time
import stat
import traceback import traceback
import warnings import warnings
import logging import logging
...@@ -352,8 +353,17 @@ class Slapgrid(object): ...@@ -352,8 +353,17 @@ class Slapgrid(object):
raise OSError('%s does not exist.' % self.instance_root) raise OSError('%s does not exist.' % self.instance_root)
# Creates everything needed # Creates everything needed
# Create directory accessible for the instances.
var_directory = os.path.join(self.instance_root, 'var')
if not os.path.isdir(var_directory):
os.mkdir(var_directory)
os.chmod(var_directory, stat.S_IRWXU | stat.S_IROTH | stat.S_IXOTH | \
stat.S_IRGRP | stat.S_IXGRP )
mkdir_p(os.path.join(self.instance_root, 'var'), 0o755)
# Creates instance_root structure # Creates instance_root structure
createPrivateDirectory(os.path.join(self.instance_root, 'var'))
createPrivateDirectory(os.path.join(self.instance_root, 'var', 'log')) createPrivateDirectory(os.path.join(self.instance_root, 'var', 'log'))
createPrivateDirectory(os.path.join(self.instance_root, 'var', 'run')) createPrivateDirectory(os.path.join(self.instance_root, 'var', 'run'))
......
--version:10 --version:11
CREATE TABLE IF NOT EXISTS software%(version)s (url VARCHAR(255) UNIQUE); CREATE TABLE IF NOT EXISTS software%(version)s (
url VARCHAR(255),
computer_reference VARCHAR(255) DEFAULT '%(computer)s',
CONSTRAINT uniq PRIMARY KEY (url, computer_reference)
);
CREATE TABLE IF NOT EXISTS computer%(version)s ( CREATE TABLE IF NOT EXISTS computer%(version)s (
reference VARCHAR(255) DEFAULT '%(computer)s',
address VARCHAR(255), address VARCHAR(255),
netmask VARCHAR(255), netmask VARCHAR(255),
CONSTRAINT uniq PRIMARY KEY (address, netmask)); CONSTRAINT uniq PRIMARY KEY (reference)
);
CREATE TABLE IF NOT EXISTS partition%(version)s ( CREATE TABLE IF NOT EXISTS partition%(version)s (
reference VARCHAR(255) UNIQUE, reference VARCHAR(255),
computer_reference VARCHAR(255) DEFAULT '%(computer)s',
slap_state VARCHAR(255) DEFAULT 'free', slap_state VARCHAR(255) DEFAULT 'free',
software_release VARCHAR(255), software_release VARCHAR(255),
xml TEXT, xml TEXT,
...@@ -16,11 +24,13 @@ CREATE TABLE IF NOT EXISTS partition%(version)s ( ...@@ -16,11 +24,13 @@ CREATE TABLE IF NOT EXISTS partition%(version)s (
partition_reference VARCHAR(255), partition_reference VARCHAR(255),
requested_by VARCHAR(255), -- only used for debugging, requested_by VARCHAR(255), -- only used for debugging,
-- slapproxy does not support proper scope -- slapproxy does not support proper scope
requested_state VARCHAR(255) NOT NULL DEFAULT 'started' requested_state VARCHAR(255) NOT NULL DEFAULT 'started',
CONSTRAINT uniq PRIMARY KEY (reference, computer_reference)
); );
CREATE TABLE IF NOT EXISTS slave%(version)s ( CREATE TABLE IF NOT EXISTS slave%(version)s (
reference VARCHAR(255) UNIQUE, reference VARCHAR(255),
computer_reference VARCHAR(255) DEFAULT '%(computer)s',
connection_xml TEXT, connection_xml TEXT,
hosted_by VARCHAR(255), hosted_by VARCHAR(255),
asked_by VARCHAR(255) -- only used for debugging, asked_by VARCHAR(255) -- only used for debugging,
...@@ -29,7 +39,9 @@ CREATE TABLE IF NOT EXISTS slave%(version)s ( ...@@ -29,7 +39,9 @@ CREATE TABLE IF NOT EXISTS slave%(version)s (
CREATE TABLE IF NOT EXISTS partition_network%(version)s ( CREATE TABLE IF NOT EXISTS partition_network%(version)s (
partition_reference VARCHAR(255), partition_reference VARCHAR(255),
computer_reference VARCHAR(255) DEFAULT '%(computer)s',
reference VARCHAR(255), reference VARCHAR(255),
address VARCHAR(255), address VARCHAR(255),
netmask VARCHAR(255) netmask VARCHAR(255)
); );
This diff is collapsed.
...@@ -34,6 +34,7 @@ import shutil ...@@ -34,6 +34,7 @@ import shutil
import signal import signal
import socket import socket
import sys import sys
import stat
import tempfile import tempfile
import textwrap import textwrap
import time import time
...@@ -535,6 +536,8 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase): ...@@ -535,6 +536,8 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
self.assertEqual(self.grid.processComputerPartitionList(), slapgrid.SLAPGRID_SUCCESS) self.assertEqual(self.grid.processComputerPartitionList(), slapgrid.SLAPGRID_SUCCESS)
self.assertItemsEqual(os.listdir(self.instance_root), ['etc', 'var']) self.assertItemsEqual(os.listdir(self.instance_root), ['etc', 'var'])
self.assertItemsEqual(os.listdir(self.software_root), []) self.assertItemsEqual(os.listdir(self.software_root), [])
st = os.stat(os.path.join(self.instance_root, 'var'))
self.assertEquals(stat.S_IMODE(st.st_mode), 0o755)
def test_one_partition(self): def test_one_partition(self):
computer = ComputerForTest(self.software_root, self.instance_root) computer = ComputerForTest(self.software_root, self.instance_root)
......
-- Real world example of webrunner database running version 10 of proxy db.
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE software10 (url VARCHAR(255) UNIQUE);
INSERT INTO "software10" VALUES('/srv/slapgrid//srv//runner/project//slapos/software.cfg');
CREATE TABLE computer10 (
address VARCHAR(255),
netmask VARCHAR(255),
CONSTRAINT uniq PRIMARY KEY (address, netmask));
INSERT INTO "computer10" VALUES('127.0.0.1','255.255.255.255');
CREATE TABLE partition10 (
reference VARCHAR(255) UNIQUE,
slap_state VARCHAR(255) DEFAULT 'free',
software_release VARCHAR(255),
xml TEXT,
connection_xml TEXT,
slave_instance_list TEXT,
software_type VARCHAR(255),
partition_reference VARCHAR(255),
requested_by VARCHAR(255), -- only used for debugging,
-- slapproxy does not support proper scope
requested_state VARCHAR(255) NOT NULL DEFAULT 'started'
);
INSERT INTO "partition10" VALUES('slappart0','busy','/srv/slapgrid//srv//runner/project//slapos/software.cfg','<?xml version=''1.0'' encoding=''utf-8''?>
<instance>
<parameter id="json">{
"site-id": "erp5"
}
}</parameter>
</instance>
',NULL,NULL,'production','slapos',NULL,'started');
INSERT INTO "partition10" VALUES('slappart1','busy','/srv/slapgrid//srv//runner/project//slapos/software.cfg','<?xml version=''1.0'' encoding=''utf-8''?>
<instance/>
','<?xml version=''1.0'' encoding=''utf-8''?>
<instance>
<parameter id="url">mysql://127.0.0.1:45678/erp5</parameter>
</instance>
',NULL,'mariadb','MariaDB DataBase','slappart0','started');
INSERT INTO "partition10" VALUES('slappart2','busy','/srv/slapgrid//srv//runner/project//slapos/software.cfg','<?xml version=''1.0'' encoding=''utf-8''?>
<instance>
<parameter id="cloudooo-json"></parameter>
</instance>
','<?xml version=''1.0'' encoding=''utf-8''?>
<instance>
<parameter id="url">cloudooo://127.0.0.1:23000/</parameter>
</instance>
',NULL,'cloudooo','Cloudooo','slappart0','started');
INSERT INTO "partition10" VALUES('slappart3','busy','/srv/slapgrid//srv//runner/project//slapos/software.cfg','<?xml version=''1.0'' encoding=''utf-8''?>
<instance/>
','<?xml version=''1.0'' encoding=''utf-8''?>
<instance>
<parameter id="url">memcached://127.0.0.1:11000/</parameter>
</instance>
',NULL,'memcached','Memcached','slappart0','started');
INSERT INTO "partition10" VALUES('slappart4','busy','/srv/slapgrid//srv//runner/project//slapos/software.cfg','<?xml version=''1.0'' encoding=''utf-8''?>
<instance/>
','<?xml version=''1.0'' encoding=''utf-8''?>
<instance>
<parameter id="url">memcached://127.0.0.1:13301/</parameter>
</instance>
',NULL,'kumofs','KumoFS','slappart0','started');
INSERT INTO "partition10" VALUES('slappart5','busy','/srv/slapgrid//srv//runner/project//slapos/software.cfg','<?xml version=''1.0'' encoding=''utf-8''?>
<instance>
<parameter id="kumofs-url">memcached://127.0.0.1:13301/</parameter>
<parameter id="memcached-url">memcached://127.0.0.1:11000/</parameter>
<parameter id="cloudooo-url">cloudooo://127.0.0.1:23000/</parameter>
</instance>
','<?xml version=''1.0'' encoding=''utf-8''?>
<instance>
<parameter id="url">https://[fc00::1]:10001</parameter>
</instance>
',NULL,'tidstorage','TidStorage','slappart0','started');
INSERT INTO "partition10" VALUES('slappart6','free',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'started');
INSERT INTO "partition10" VALUES('slappart7','free',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'started');
INSERT INTO "partition10" VALUES('slappart8','free',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'started');
INSERT INTO "partition10" VALUES('slappart9','free',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'started');
CREATE TABLE slave10 (
reference VARCHAR(255) UNIQUE,
connection_xml TEXT,
hosted_by VARCHAR(255),
asked_by VARCHAR(255) -- only used for debugging,
-- slapproxy does not support proper scope
);
CREATE TABLE partition_network10 (
partition_reference VARCHAR(255),
reference VARCHAR(255),
address VARCHAR(255),
netmask VARCHAR(255)
);
INSERT INTO "partition_network10" VALUES('slappart0','slappart0','127.0.0.1','255.255.255.255');
INSERT INTO "partition_network10" VALUES('slappart0','slappart0','fc00::1','ffff:ffff:ffff::');
INSERT INTO "partition_network10" VALUES('slappart1','slappart1','127.0.0.1','255.255.255.255');
INSERT INTO "partition_network10" VALUES('slappart1','slappart1','fc00::1','ffff:ffff:ffff::');
INSERT INTO "partition_network10" VALUES('slappart2','slappart2','127.0.0.1','255.255.255.255');
INSERT INTO "partition_network10" VALUES('slappart2','slappart2','fc00::1','ffff:ffff:ffff::');
INSERT INTO "partition_network10" VALUES('slappart3','slappart3','127.0.0.1','255.255.255.255');
INSERT INTO "partition_network10" VALUES('slappart3','slappart3','fc00::1','ffff:ffff:ffff::');
INSERT INTO "partition_network10" VALUES('slappart4','slappart4','127.0.0.1','255.255.255.255');
INSERT INTO "partition_network10" VALUES('slappart4','slappart4','fc00::1','ffff:ffff:ffff::');
INSERT INTO "partition_network10" VALUES('slappart5','slappart5','127.0.0.1','255.255.255.255');
INSERT INTO "partition_network10" VALUES('slappart5','slappart5','fc00::1','ffff:ffff:ffff::');
INSERT INTO "partition_network10" VALUES('slappart6','slappart6','127.0.0.1','255.255.255.255');
INSERT INTO "partition_network10" VALUES('slappart6','slappart6','fc00::1','ffff:ffff:ffff::');
INSERT INTO "partition_network10" VALUES('slappart7','slappart7','127.0.0.1','255.255.255.255');
INSERT INTO "partition_network10" VALUES('slappart7','slappart7','fc00::1','ffff:ffff:ffff::');
INSERT INTO "partition_network10" VALUES('slappart8','slappart8','127.0.0.1','255.255.255.255');
INSERT INTO "partition_network10" VALUES('slappart8','slappart8','fc00::1','ffff:ffff:ffff::');
INSERT INTO "partition_network10" VALUES('slappart9','slappart9','127.0.0.1','255.255.255.255');
INSERT INTO "partition_network10" VALUES('slappart9','slappart9','fc00::1','ffff:ffff:ffff::');
COMMIT;
...@@ -26,4 +26,4 @@ ...@@ -26,4 +26,4 @@
# #
############################################################################## ##############################################################################
version = '1.1.2' version = '1.2.1'
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