예제 #1
0
   def _getFullComputerInformation(computer_id, user):
     user_document = self.getPortalObject().portal_catalog.getResultValue(
       reference=user, portal_type=['Person', 'Computer', 'Software Instance'])
     user_type = user_document.getPortalType()
     self.REQUEST.response.setHeader('Content-Type', 'text/xml')
     slap_computer = Computer(computer_id)
     parent_uid = self._getComputerUidByReference(computer_id)
 
     slap_computer._computer_partition_list = []
     if user_type == 'Computer':
       slap_computer._software_release_list = \
          self._getSoftwareReleaseValueListForComputer(computer_id, full=True)
     else:
       slap_computer._software_release_list = []
     for computer_partition in self.getPortalObject().portal_catalog(
                     parent_uid=parent_uid,
                     validation_state="validated",
                     portal_type="Computer Partition"):
       slap_computer._computer_partition_list.append(
           self._getSlapPartitionByPackingList(computer_partition.getObject()))
     return xml_marshaller.xml_marshaller.dumps(slap_computer)
예제 #2
0
파일: views.py 프로젝트: JuRogn/slapos.core
def getFullComputerInformation():
  computer_id = request.args['computer_id']
  if app.config['computer_id'] == computer_id:
    slap_computer = Computer(computer_id)
    slap_computer._software_release_list = []
    for sr in execute_db('software', 'select * from %s'):
      slap_computer._software_release_list.append(SoftwareRelease(
        software_release=sr['url'], computer_guid=computer_id))
    slap_computer._computer_partition_list = []
    for partition in execute_db('partition', 'SELECT * FROM %s'):
      slap_computer._computer_partition_list.append(partitiondict2partition(
        partition))
    return xml_marshaller.xml_marshaller.dumps(slap_computer)
  else:
    raise NotFoundError('Only accept request for: %s' % app.config['computer_id'])
예제 #3
0
def getFullComputerInformation():
  computer_id = request.args['computer_id']
  computer_list = execute_db('computer', 'SELECT * FROM %s WHERE reference=?', [computer_id])
  if len(computer_list) != 1:
    # Backward compatibility
    if computer_id != app.config['computer_id']:
      raise NotFoundError('%s is not registered.' % computer_id)
  slap_computer = Computer(computer_id)
  slap_computer._software_release_list = []
  for sr in execute_db('software', 'select * from %s WHERE computer_reference=?', [computer_id]):
    slap_computer._software_release_list.append(SoftwareRelease(
      software_release=sr['url'], computer_guid=computer_id))
  slap_computer._computer_partition_list = []
  for partition in execute_db('partition', 'SELECT * FROM %s WHERE computer_reference=?', [computer_id]):
    slap_computer._computer_partition_list.append(partitiondict2partition(
      partition))
  return xml_marshaller.xml_marshaller.dumps(slap_computer)
예제 #4
0
  def getComputerInformation(self, computer_id):
    """Returns marshalled XML of all needed information for computer

    Includes Software Releases, which may contain Software Instances.

    Reuses slap library for easy marshalling.
    """
    self.REQUEST.response.setHeader('Content-Type', 'text/xml')
    slap_computer = Computer(computer_id)
    parent_uid = self._getComputerUidByReference(computer_id)

    slap_computer._computer_partition_list = []
    slap_computer._software_release_list = \
         self._getSoftwareReleaseValueListForComputer(computer_id)
    for computer_partition in self.getPortalObject().portal_catalog(
                    parent_uid=parent_uid,
                    portal_type="Computer Partition"):
      slap_computer._computer_partition_list.append(
          self._getSlapPartitionByPackingList(computer_partition.getObject()))
    return xml_marshaller.xml_marshaller.dumps(slap_computer)