304 result = [] |
304 result = [] |
305 for spack in self._releaseInformation.getElementsByTagName('servicePack'): |
305 for spack in self._releaseInformation.getElementsByTagName('servicePack'): |
306 result.append(ServicePack(spack)) |
306 result.append(ServicePack(spack)) |
307 return result |
307 return result |
308 |
308 |
309 filename = property(lambda self:self._filename) |
309 @property |
|
310 def filename(self): |
|
311 return self._filename |
|
312 |
310 service = property(lambda self:self.get_releasedetails_info('service'), lambda self, value:self.set_releasedetails_info('service', value)) |
313 service = property(lambda self:self.get_releasedetails_info('service'), lambda self, value:self.set_releasedetails_info('service', value)) |
311 product = property(lambda self:self.get_releasedetails_info('product'), lambda self, value:self.set_releasedetails_info('product', value)) |
314 product = property(lambda self:self.get_releasedetails_info('product'), lambda self, value:self.set_releasedetails_info('product', value)) |
312 release = property(lambda self:self.get_releasedetails_info('release'), lambda self, value:self.set_releasedetails_info('release', value)) |
315 release = property(lambda self:self.get_releasedetails_info('release'), lambda self, value:self.set_releasedetails_info('release', value)) |
313 dependsof_service = property(lambda self:self.get_releasedetails_info('service', 'dependsOf'), lambda self, value:self.set_releasedetails_info('service', value, 'dependsOf')) |
316 dependsof_service = property(lambda self:self.get_releasedetails_info('service', 'dependsOf'), lambda self, value:self.set_releasedetails_info('service', value, 'dependsOf')) |
314 dependsof_product = property(lambda self:self.get_releasedetails_info('product', 'dependsOf'), lambda self, value:self.set_releasedetails_info('product', value, 'dependsOf')) |
317 dependsof_product = property(lambda self:self.get_releasedetails_info('product', 'dependsOf'), lambda self, value:self.set_releasedetails_info('product', value, 'dependsOf')) |
344 ReleaseMetadata.__init__(self, filename) |
347 ReleaseMetadata.__init__(self, filename) |
345 self.location = os.path.dirname(filename) |
348 self.location = os.path.dirname(filename) |
346 |
349 |
347 def is_valid(self, checkmd5=True, checkPath=True): |
350 def is_valid(self, checkmd5=True, checkPath=True): |
348 """ Run the validation mechanism. """ |
351 """ Run the validation mechanism. """ |
|
352 valid = True |
|
353 |
349 status = os.path.join(os.path.dirname(self._filename), 'HYDRASTATUS.xml') |
354 status = os.path.join(os.path.dirname(self._filename), 'HYDRASTATUS.xml') |
350 if os.path.exists(status): |
355 if os.path.exists(status): |
351 hydraxml = xml.dom.minidom.parse(open(status, "r")) |
356 hydraxml = xml.dom.minidom.parse(open(status, "r")) |
352 for t_name in hydraxml.getElementsByTagName('state')[0].childNodes: |
357 for t_name in hydraxml.getElementsByTagName('state')[0].childNodes: |
353 if t_name.nodeType == t_name.TEXT_NODE: |
358 if t_name.nodeType == t_name.TEXT_NODE: |
354 if t_name.nodeValue != 'Ready': |
359 if t_name.nodeValue != 'Ready': |
355 LOGGER.error("HYDRASTATUS.xml is not ready") |
360 LOGGER.error("HYDRASTATUS.xml is not ready") |
356 return False |
361 valid = False |
357 if checkPath: |
362 |
|
363 if valid and checkPath: |
358 if os.path.basename(self.location) != self.release: |
364 if os.path.basename(self.location) != self.release: |
359 LOGGER.error("Release doesn't match.") |
365 LOGGER.error("Release doesn't match.") |
360 return False |
366 valid = False |
361 if os.path.basename(os.path.dirname(self.location)) != self.product: |
367 if os.path.basename(os.path.dirname(self.location)) != self.product: |
362 LOGGER.error("Product doesn't match.") |
368 LOGGER.error("Product doesn't match.") |
363 return False |
369 valid = False |
364 if os.path.basename(os.path.dirname(os.path.dirname(self.location))) != self.service: |
370 if os.path.basename(os.path.dirname(os.path.dirname(self.location))) != self.service: |
365 LOGGER.error("Service doesn't match.") |
371 LOGGER.error("Service doesn't match.") |
366 return False |
372 valid = False |
367 |
373 |
368 for name in self.keys(): |
374 if valid: |
369 path = os.path.join(self.location, name) |
375 for name in self.keys(): |
370 if not os.path.exists(path): |
|
371 LOGGER.error("%s doesn't exist." % path) |
|
372 return False |
|
373 try: |
|
374 LOGGER.debug("Trying to open %s" % path) |
|
375 content_file = open(path) |
|
376 content_file.read(1) |
|
377 except IOError: |
|
378 LOGGER.error("%s is not available yet" % path) |
|
379 return False |
|
380 |
|
381 if checkmd5 and self[name].has_key('md5checksum'): |
|
382 if self[name]['md5checksum'] != None: |
|
383 if fileutils.getmd5(path).lower() != self[name]['md5checksum']: |
|
384 LOGGER.error("%s md5checksum missmatch." % path) |
|
385 return False |
|
386 |
|
387 for spack in self.servicepacks: |
|
388 for name in spack.files: |
|
389 path = os.path.join(self.location, name) |
376 path = os.path.join(self.location, name) |
390 if not os.path.exists(path): |
377 if not os.path.exists(path): |
391 LOGGER.error("%s doesn't exist." % path) |
378 LOGGER.error("%s doesn't exist." % path) |
392 return False |
379 valid = False |
393 for name in spack.instructions: |
380 break |
394 path = os.path.join(self.location, name) |
381 try: |
395 if not os.path.exists(path): |
382 LOGGER.debug("Trying to open %s" % path) |
396 LOGGER.error("%s doesn't exist." % path) |
383 content_file = open(path) |
397 return False |
384 content_file.read(1) |
398 |
385 except IOError: |
399 dependency = self.get_dependsof() |
386 LOGGER.error("%s is not available yet" % path) |
400 if dependency != None: |
387 valid = False |
401 return ValidateReleaseMetadata(dependency.filename).is_valid(checkmd5) |
388 break |
402 return True |
389 |
|
390 if checkmd5 and self[name].has_key('md5checksum'): |
|
391 if self[name]['md5checksum'] != None: |
|
392 if fileutils.getmd5(path).lower() != self[name]['md5checksum']: |
|
393 LOGGER.error("%s md5checksum missmatch." % path) |
|
394 valid = False |
|
395 |
|
396 if valid: |
|
397 for spack in self.servicepacks: |
|
398 if valid: |
|
399 for name in spack.files: |
|
400 path = os.path.join(self.location, name) |
|
401 if not os.path.exists(path): |
|
402 LOGGER.error("%s doesn't exist." % path) |
|
403 valid = False |
|
404 break |
|
405 for name in spack.instructions: |
|
406 path = os.path.join(self.location, name) |
|
407 if not os.path.exists(path): |
|
408 LOGGER.error("%s doesn't exist." % path) |
|
409 valid = False |
|
410 break |
|
411 |
|
412 if valid: |
|
413 dependency = self.get_dependsof() |
|
414 if dependency != None: |
|
415 return ValidateReleaseMetadata(dependency.filename).is_valid(checkmd5) |
|
416 |
|
417 return valid |
403 |
418 |
404 |
419 |
405 class MetadataMerger(object): |
420 class MetadataMerger(object): |
406 """ Merge packages definition to the root metadata. """ |
421 """ Merge packages definition to the root metadata. """ |
407 |
422 |
547 """ |
562 """ |
548 def __init__(self, filename): |
563 def __init__(self, filename): |
549 ValidateReleaseMetadataCached.__init__(self, filename) |
564 ValidateReleaseMetadataCached.__init__(self, filename) |
550 self.location = os.path.dirname(filename) |
565 self.location = os.path.dirname(filename) |
551 |
566 |
552 def is_valid(self, checkmd5=True): |
567 def is_valid(self, checkmd5=True, checkPath=True): |
553 """ Run the validation mechanism. """ |
568 """ Run the validation mechanism. """ |
554 tickler_path = os.path.join(self.location,"TICKLER") |
569 tickler_path = os.path.join(self.location,"TICKLER") |
555 if not os.path.exists(tickler_path): |
570 if not os.path.exists(tickler_path): |
556 LOGGER.error("Release not available yet") |
571 LOGGER.error("Release not available yet") |
557 return False |
572 return False |
558 else: |
573 else: |
559 return ValidateReleaseMetadataCached.is_valid(self, checkmd5) |
574 return ValidateReleaseMetadataCached.is_valid(self, checkmd5, checkPath) |