Пример #1
0
 def test_multiple_entries(self):
     '''Ensure multiple criteria handled correctly'''
     criteria = [
         'ARCH=i86pc', 'MEM=1024', 'IPV4=129.224.45.185',
         'PLATFORM=SUNW,Sun-Fire-T1000',
         'MAC=0:14:4F:20:53:94-0:14:4F:20:53:A0'
     ]
     cri_dict = publish_manifest.criteria_to_dict(criteria)
     self.assertEquals(len(cri_dict), 5)
     self.assertTrue(cri_dict['arch'], 'i86pc')
     self.assertTrue(cri_dict['mem'], '1024')
     self.assertTrue(cri_dict['ipv4'], '129.224.45.185')
     self.assertTrue(cri_dict['platform'], 'sunw,sun-fire-t1000')
     self.assertTrue(cri_dict['mac'], '0:14:4f:20:53:94-0:14:4f:20:53:a0')
Пример #2
0
 def test_no_criteria(self):
     '''Ensure case of no criteria is handled'''
     criteria = []
     cri_dict = publish_manifest.criteria_to_dict(criteria)
     self.assertEquals(len(cri_dict), 0)
     self.assertTrue(isinstance(cri_dict, dict))
Пример #3
0
 def test_lower_case_conversion(self):
     '''Ensure keys and values converted to lower case'''
     criteria = ['ARCH=SPARC']
     cri_dict = publish_manifest.criteria_to_dict(criteria)
     self.assertEquals(len(cri_dict), 1)
     self.assertEquals(cri_dict['arch'], 'sparc')
Пример #4
0
 def test_range_values(self):
     '''Ensure ranges saved correctly'''
     criteria = ['mem=1048-2096']
     cri_dict = publish_manifest.criteria_to_dict(criteria)
     self.assertEquals(len(cri_dict), 1)
     self.assertTrue(cri_dict['mem'], '1048-2096')
Пример #5
0
    # Open the database
    db = AIdb.DB(database, commit=True)

    # Check to make sure that the manifest whose criteria we're
    # updating exists in the install service.
    if not check_published_manifest(service_dir, db, options.manifest_name):
        raise SystemExit(1)

    # Process and validate criteria from -a, -c, or -C, and store
    # store the criteria in a Criteria object.
    try:
        if options.criteria_file:
            root = pub_man.verifyCriteria(pub_man.DataFiles.criteriaSchema,
                                          options.criteria_file, db)
        elif options.criteria_a:
            criteria_dict = pub_man.criteria_to_dict(options.criteria_a)
            root = pub_man.verifyCriteriaDict(pub_man.DataFiles.criteriaSchema,
                                              criteria_dict, db)
        elif options.criteria_c:
            criteria_dict = pub_man.criteria_to_dict(options.criteria_c)
            root = pub_man.verifyCriteriaDict(pub_man.DataFiles.criteriaSchema,
                                              criteria_dict, db)
    except (AssertionError, IOError, ValueError) as err:
        raise SystemExit(err)
    except (lxml.etree.LxmlError) as err:
        raise SystemExit(_("Error:\tmanifest error: %s") % err)

    # Instantiate a Criteria object with the XML DOM of the criteria.
    criteria = pub_man.Criteria(root)

    # Ensure the criteria we're adding/setting for this manifest doesn't