Commit 80485e0b authored by Łukasz Nowak's avatar Łukasz Nowak

Formatting and whitespaces.

parent 62fbed4d
...@@ -81,7 +81,8 @@ def convertToREST(function): ...@@ -81,7 +81,8 @@ def convertToREST(function):
self.REQUEST.response.setStatus(408) self.REQUEST.response.setStatus(408)
return self.REQUEST.response return self.REQUEST.response
except ValidationFailed: except ValidationFailed:
LOG('SlapTool', INFO, 'Converting ValidationFailed to ValidationFailed, real error:', LOG('SlapTool', INFO, 'Converting ValidationFailed to ValidationFailed,'\
' real error:',
error=True) error=True)
raise ValidationFailed raise ValidationFailed
...@@ -123,7 +124,8 @@ class SlapTool(BaseTool): ...@@ -123,7 +124,8 @@ class SlapTool(BaseTool):
# Public GET methods # Public GET methods
#################################################### ####################################################
security.declareProtected(Permissions.AccessContentsInformation, 'getComputerInformation') security.declareProtected(Permissions.AccessContentsInformation,
'getComputerInformation')
def getComputerInformation(self, computer_id): def getComputerInformation(self, computer_id):
"""Returns marshalled XML of all needed information for computer """Returns marshalled XML of all needed information for computer
...@@ -149,7 +151,8 @@ class SlapTool(BaseTool): ...@@ -149,7 +151,8 @@ class SlapTool(BaseTool):
self._convertToSlapPartition(slave_partition_document, computer_id)) self._convertToSlapPartition(slave_partition_document, computer_id))
return xml_marshaller.xml_marshaller.dumps(slap_computer) return xml_marshaller.xml_marshaller.dumps(slap_computer)
security.declareProtected(Permissions.AccessContentsInformation, 'getComputerPartitionCertificate') security.declareProtected(Permissions.AccessContentsInformation,
'getComputerPartitionCertificate')
def getComputerPartitionCertificate(self, computer_id, computer_partition_id): def getComputerPartitionCertificate(self, computer_id, computer_partition_id):
"""Method to fetch certificate""" """Method to fetch certificate"""
self.REQUEST.response.setHeader('Content-Type', 'text/xml') self.REQUEST.response.setHeader('Content-Type', 'text/xml')
...@@ -165,7 +168,8 @@ class SlapTool(BaseTool): ...@@ -165,7 +168,8 @@ class SlapTool(BaseTool):
# Public POST methods # Public POST methods
#################################################### ####################################################
security.declareProtected(Permissions.AccessContentsInformation, 'setComputerPartitionConnectionXml') security.declareProtected(Permissions.AccessContentsInformation,
'setComputerPartitionConnectionXml')
def setComputerPartitionConnectionXml(self, computer_id, def setComputerPartitionConnectionXml(self, computer_id,
computer_partition_id, computer_partition_id,
connection_xml): connection_xml):
...@@ -176,42 +180,48 @@ class SlapTool(BaseTool): ...@@ -176,42 +180,48 @@ class SlapTool(BaseTool):
computer_partition_id, computer_partition_id,
connection_xml) connection_xml)
security.declareProtected(Permissions.AccessContentsInformation, 'buildingSoftwareRelease') security.declareProtected(Permissions.AccessContentsInformation,
'buildingSoftwareRelease')
def buildingSoftwareRelease(self, url, computer_id): def buildingSoftwareRelease(self, url, computer_id):
""" """
Reports that Software Release is being build Reports that Software Release is being build
""" """
return self._buildingSoftwareRelease(url, computer_id) return self._buildingSoftwareRelease(url, computer_id)
security.declareProtected(Permissions.AccessContentsInformation, 'availableSoftwareRelease') security.declareProtected(Permissions.AccessContentsInformation,
'availableSoftwareRelease')
def availableSoftwareRelease(self, url, computer_id): def availableSoftwareRelease(self, url, computer_id):
""" """
Reports that Software Release is available Reports that Software Release is available
""" """
return self._availableSoftwareRelease(url, computer_id) return self._availableSoftwareRelease(url, computer_id)
security.declareProtected(Permissions.AccessContentsInformation, 'softwareReleaseError') security.declareProtected(Permissions.AccessContentsInformation,
'softwareReleaseError')
def softwareReleaseError(self, url, computer_id, error_log): def softwareReleaseError(self, url, computer_id, error_log):
""" """
Add an error for a software Release workflow Add an error for a software Release workflow
""" """
return self._softwareReleaseError(url, computer_id, error_log) return self._softwareReleaseError(url, computer_id, error_log)
security.declareProtected(Permissions.AccessContentsInformation, 'buildingComputerPartition') security.declareProtected(Permissions.AccessContentsInformation,
'buildingComputerPartition')
def buildingComputerPartition(self, computer_id, computer_partition_id): def buildingComputerPartition(self, computer_id, computer_partition_id):
""" """
Reports that Computer Partition is being build Reports that Computer Partition is being build
""" """
return self._buildingComputerPartition(computer_id, computer_partition_id) return self._buildingComputerPartition(computer_id, computer_partition_id)
security.declareProtected(Permissions.AccessContentsInformation, 'availableComputerPartition') security.declareProtected(Permissions.AccessContentsInformation,
'availableComputerPartition')
def availableComputerPartition(self, computer_id, computer_partition_id): def availableComputerPartition(self, computer_id, computer_partition_id):
""" """
Reports that Computer Partition is available Reports that Computer Partition is available
""" """
return self._availableComputerPartition(computer_id, computer_partition_id) return self._availableComputerPartition(computer_id, computer_partition_id)
security.declareProtected(Permissions.AccessContentsInformation, 'softwareInstanceError') security.declareProtected(Permissions.AccessContentsInformation,
'softwareInstanceError')
def softwareInstanceError(self, computer_id, def softwareInstanceError(self, computer_id,
computer_partition_id, error_log): computer_partition_id, error_log):
""" """
...@@ -220,28 +230,32 @@ class SlapTool(BaseTool): ...@@ -220,28 +230,32 @@ class SlapTool(BaseTool):
return self._softwareInstanceError(computer_id, computer_partition_id, return self._softwareInstanceError(computer_id, computer_partition_id,
error_log) error_log)
security.declareProtected(Permissions.AccessContentsInformation, 'startedComputerPartition') security.declareProtected(Permissions.AccessContentsInformation,
'startedComputerPartition')
def startedComputerPartition(self, computer_id, computer_partition_id): def startedComputerPartition(self, computer_id, computer_partition_id):
""" """
Reports that Computer Partition is started Reports that Computer Partition is started
""" """
return self._startedComputerPartition(computer_id, computer_partition_id) return self._startedComputerPartition(computer_id, computer_partition_id)
security.declareProtected(Permissions.AccessContentsInformation, 'stoppedComputerPartition') security.declareProtected(Permissions.AccessContentsInformation,
'stoppedComputerPartition')
def stoppedComputerPartition(self, computer_id, computer_partition_id): def stoppedComputerPartition(self, computer_id, computer_partition_id):
""" """
Reports that Computer Partition is stopped Reports that Computer Partition is stopped
""" """
return self._stoppedComputerPartition(computer_id, computer_partition_id) return self._stoppedComputerPartition(computer_id, computer_partition_id)
security.declareProtected(Permissions.AccessContentsInformation, 'destroyedComputerPartition') security.declareProtected(Permissions.AccessContentsInformation,
'destroyedComputerPartition')
def destroyedComputerPartition(self, computer_id, computer_partition_id): def destroyedComputerPartition(self, computer_id, computer_partition_id):
""" """
Reports that Computer Partition is destroyed Reports that Computer Partition is destroyed
""" """
return self._destroyedComputerPartition(computer_id, computer_partition_id) return self._destroyedComputerPartition(computer_id, computer_partition_id)
security.declareProtected(Permissions.AccessContentsInformation, 'requestComputerPartition') security.declareProtected(Permissions.AccessContentsInformation,
'requestComputerPartition')
def requestComputerPartition(self, computer_id, computer_partition_id, def requestComputerPartition(self, computer_id, computer_partition_id,
software_release, software_type, partition_reference, software_release, software_type, partition_reference,
shared_xml, partition_parameter_xml, filter_xml): shared_xml, partition_parameter_xml, filter_xml):
...@@ -260,7 +274,8 @@ class SlapTool(BaseTool): ...@@ -260,7 +274,8 @@ class SlapTool(BaseTool):
software_release, software_type, partition_reference, software_release, software_type, partition_reference,
shared_xml, partition_parameter_xml, filter_xml) shared_xml, partition_parameter_xml, filter_xml)
security.declareProtected(Permissions.AccessContentsInformation, 'useComputer') security.declareProtected(Permissions.AccessContentsInformation,
'useComputer')
def useComputer(self, computer_id, use_string): def useComputer(self, computer_id, use_string):
"""Entry point to reporting usage of a computer.""" """Entry point to reporting usage of a computer."""
#computer_document = self._getComputerDocument(computer_id) #computer_document = self._getComputerDocument(computer_id)
...@@ -283,7 +298,8 @@ class SlapTool(BaseTool): ...@@ -283,7 +298,8 @@ class SlapTool(BaseTool):
return 'Content properly posted.' return 'Content properly posted.'
security.declareProtected(Permissions.AccessContentsInformation, 'loadComputerConfigurationFromXML') security.declareProtected(Permissions.AccessContentsInformation,
'loadComputerConfigurationFromXML')
def loadComputerConfigurationFromXML(self, xml): def loadComputerConfigurationFromXML(self, xml):
"Load the given xml as configuration for the computer object" "Load the given xml as configuration for the computer object"
computer_dict = xml_marshaller.xml_marshaller.loads(xml) computer_dict = xml_marshaller.xml_marshaller.loads(xml)
...@@ -291,8 +307,10 @@ class SlapTool(BaseTool): ...@@ -291,8 +307,10 @@ class SlapTool(BaseTool):
computer.Computer_updateFromDict(computer_dict) computer.Computer_updateFromDict(computer_dict)
return 'Content properly posted.' return 'Content properly posted.'
security.declareProtected(Permissions.AccessContentsInformation, 'useComputerPartition') security.declareProtected(Permissions.AccessContentsInformation,
def useComputerPartition(self, computer_id, computer_partition_id, use_string): 'useComputerPartition')
def useComputerPartition(self, computer_id, computer_partition_id,
use_string):
"""Warning : deprecated method.""" """Warning : deprecated method."""
computer_document = self._getComputerDocument(computer_id) computer_document = self._getComputerDocument(computer_id)
computer_partition_document = self._getComputerPartitionDocument( computer_partition_document = self._getComputerPartitionDocument(
...@@ -303,7 +321,8 @@ class SlapTool(BaseTool): ...@@ -303,7 +321,8 @@ class SlapTool(BaseTool):
return """Content properly posted. return """Content properly posted.
WARNING : this method is deprecated. Please use useComputer.""" WARNING : this method is deprecated. Please use useComputer."""
security.declareProtected(Permissions.AccessContentsInformation, 'registerComputerPartition') security.declareProtected(Permissions.AccessContentsInformation,
'registerComputerPartition')
def registerComputerPartition(self, computer_reference, def registerComputerPartition(self, computer_reference,
computer_partition_reference): computer_partition_reference):
""" """
...@@ -414,7 +433,8 @@ class SlapTool(BaseTool): ...@@ -414,7 +433,8 @@ class SlapTool(BaseTool):
elif movement.getResource() == \ elif movement.getResource() == \
portal_preferences.getPreferredInstanceCleanupResource(): portal_preferences.getPreferredInstanceCleanupResource():
if movement.getSimulationState() in ('confirmed', 'started', 'stopped'): if movement.getSimulationState() in ('confirmed', 'started',
'stopped'):
slap_partition._need_modification = 1 slap_partition._need_modification = 1
else: else:
...@@ -440,7 +460,8 @@ class SlapTool(BaseTool): ...@@ -440,7 +460,8 @@ class SlapTool(BaseTool):
Reports that Software Release is being build Reports that Software Release is being build
""" """
computer_document = self._getComputerDocument(computer_id) computer_document = self._getComputerDocument(computer_id)
computer_document.startSoftwareReleaseInstallation(software_release_url=url) computer_document.startSoftwareReleaseInstallation(
software_release_url=url)
@convertToREST @convertToREST
def _availableSoftwareRelease(self, url, computer_id): def _availableSoftwareRelease(self, url, computer_id):
...@@ -552,7 +573,8 @@ class SlapTool(BaseTool): ...@@ -552,7 +573,8 @@ class SlapTool(BaseTool):
Returns XML representation of partition with HTTP code 200 OK Returns XML representation of partition with HTTP code 200 OK
In case if this request is still being processed data contain In case if this request is still being processed data contain
"Computer Partition is being processed" and HTTP code is 408 Request Timeout "Computer Partition is being processed" and HTTP code is 408 Request
Timeout
In any other case returns not important data and HTTP code is 403 Forbidden In any other case returns not important data and HTTP code is 403 Forbidden
""" """
...@@ -676,8 +698,8 @@ class SlapTool(BaseTool): ...@@ -676,8 +698,8 @@ class SlapTool(BaseTool):
software_instance = packing_list_line.getAggregateValue( software_instance = packing_list_line.getAggregateValue(
portal_type="Software Instance") portal_type="Software Instance")
if software_instance is None: if software_instance is None:
raise NotFound, "No software instance found for: %s - %s" % (computer_id, raise NotFound, "No software instance found for: %s - %s" % (
computer_partition_id) computer_id, computer_partition_id)
else: else:
return software_instance return software_instance
...@@ -773,7 +795,8 @@ class SlapTool(BaseTool): ...@@ -773,7 +795,8 @@ class SlapTool(BaseTool):
usage_report_sale_packing_list_document.start() usage_report_sale_packing_list_document.start()
# Adds a new SPL line for each Computer Partition # Adds a new SPL line for each Computer Partition
for computer_partition_usage in unmarshalled_usage.computer_partition_usage_list: for computer_partition_usage in unmarshalled_usage\
.computer_partition_usage_list:
#Get good packing list line for a computer_partition #Get good packing list line for a computer_partition
computer_partition_document = self.\ computer_partition_document = self.\
_getComputerPartitionDocument( _getComputerPartitionDocument(
......
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