Commit e28916c9 authored by Rafael Monnerat's avatar Rafael Monnerat

slapgrid&SlapTool: Don't post if software release state is already the one expected

  Avoid to excessively post to master if the state is the same as the once expected,
  this decreases significantly the number of posts to master.
parent 31dff4c1
...@@ -375,6 +375,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -375,6 +375,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
<dictionary id='i43'> <dictionary id='i43'>
<string>_computer_guid</string> <string>_computer_guid</string>
<string>%(computer_id)s</string> <string>%(computer_id)s</string>
<string>_known_state</string>
<string>error</string>
<string>_requested_state</string> <string>_requested_state</string>
<string>destroyed</string> <string>destroyed</string>
<string>_software_instance_list</string> <string>_software_instance_list</string>
...@@ -391,6 +393,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -391,6 +393,8 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
<dictionary id='i46'> <dictionary id='i46'>
<string>_computer_guid</string> <string>_computer_guid</string>
<string>%(computer_id)s</string> <string>%(computer_id)s</string>
<string>_known_state</string>
<string>error</string>
<string>_requested_state</string> <string>_requested_state</string>
<string>available</string> <string>available</string>
<string>_software_instance_list</string> <string>_software_instance_list</string>
...@@ -742,7 +746,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin): ...@@ -742,7 +746,7 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
<string>created_at</string> <string>created_at</string>
<string>%(created_at)s</string> <string>%(created_at)s</string>
<string>text</string> <string>text</string>
<string>building software release %(url_string)s</string> <string>#building software release %(url_string)s</string>
<string>user</string> <string>user</string>
<string>%(computer_id)s</string> <string>%(computer_id)s</string>
</dictionary> </dictionary>
......
...@@ -996,7 +996,7 @@ class SlapTool(BaseTool): ...@@ -996,7 +996,7 @@ class SlapTool(BaseTool):
user = self.getPortalObject().portal_membership.\ user = self.getPortalObject().portal_membership.\
getAuthenticatedMember().getUserName() getAuthenticatedMember().getUserName()
self._logAccess(user, software_installation_reference, self._logAccess(user, software_installation_reference,
'building software release %s' % url) '#building software release %s' % url)
@convertToREST @convertToREST
def _availableSoftwareRelease(self, url, computer_id): def _availableSoftwareRelease(self, url, computer_id):
...@@ -1596,6 +1596,15 @@ class SlapTool(BaseTool): ...@@ -1596,6 +1596,15 @@ class SlapTool(BaseTool):
software_release_response._requested_state = 'destroyed' software_release_response._requested_state = 'destroyed'
else: else:
software_release_response._requested_state = 'available' software_release_response._requested_state = 'available'
known_state = self._getTextAccessStatus(software_installation.getReference())
if known_state.startswith("#access"):
software_release_response._known_state = 'available'
elif known_state.startswith("#building"):
software_release_response._known_state = 'building'
else:
software_release_response._known_state = 'error'
software_release_list.append(software_release_response) software_release_list.append(software_release_response)
return software_release_list return software_release_list
......
...@@ -158,14 +158,17 @@ class SoftwareRelease(SlapDocument): ...@@ -158,14 +158,17 @@ class SoftwareRelease(SlapDocument):
(logger or fallback_logger).exception('') (logger or fallback_logger).exception('')
def available(self): def available(self):
self._connection_helper.POST('availableSoftwareRelease', data={ if getattr(self, '_known_state', 'unknown') != "available":
'url': self.getURI(), # Not required to repost if not needed.
'computer_id': self.getComputerId()}) self._connection_helper.POST('availableSoftwareRelease', data={
'url': self.getURI(),
'computer_id': self.getComputerId()})
def building(self): def building(self):
self._connection_helper.POST('buildingSoftwareRelease', data={ if getattr(self, '_known_state', 'unknown') != "building":
'url': self.getURI(), self._connection_helper.POST('buildingSoftwareRelease', data={
'computer_id': self.getComputerId()}) 'url': self.getURI(),
'computer_id': self.getComputerId()})
def destroyed(self): def destroyed(self):
self._connection_helper.POST('destroyedSoftwareRelease', data={ self._connection_helper.POST('destroyedSoftwareRelease', data={
......
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