예제 #1
0
    def all(cls, precheck=False):
        """ Return a generator of all of this type """
        logger.debug("Attempting to find all %r...", cls.__name__)
        type_dir = os.path.join(cf.LOCAL_REPOSITORY_PATH, cls.required_leader.lower())
        kim_codes = (
            subpath for subpath in dircache.listdir(type_dir) if (
                os.path.isdir(os.path.join(type_dir, subpath)) and
                database.iskimcode(subpath)
            )
        )

        # If this is being used for a precheck, also search the 'precheck' local repository
        if precheck:
            type_dir_precheck = os.path.join(os.path.join(cf.LOCAL_REPOSITORY_PATH, 'precheck'),
                    cls.required_leader.lower())
            kim_codes_precheck = (
                subpath for subpath in dircache.listdir(type_dir_precheck) if (
                    os.path.isdir(os.path.join(type_dir_precheck, subpath)) and
                    database.iskimcode(subpath)
                )
            )
            kim_codes_final = itertools.chain(kim_codes, kim_codes_precheck)
        else:
            kim_codes_final = kim_codes

        for x in kim_codes_final:
            try:
                yield cls(x)
            except Exception as e:
                logger.exception("Exception on formation of kim_code (%s)", x)
예제 #2
0
    def delete(self, kimid):
        self.logger.info("Deleting %r from all resources" % kimid)
        self.logger.info("Revoking jobs involving %r" % kimid)
        if database.iskimcode(kimid):
            uuids = mongodb.get_jobs_by_kimcode(kimid)
            for uuid in uuids:
                self.app.control.revoke(uuid)
        else:
            self.app.control.revoke(kimid)

        self.logger.info("Deleting %r from database" % kimid)
        mongodb.delete_object(kimid)

        self.logger.info("Requesting directors to delete items")
        self.send_job('pipeline.tasks.director_delete', args=(kimid,))
예제 #3
0
 def all(cls):
     """ Return a generator of all of this type """
     logger.debug("Attempting to find all %r...", cls.__name__)
     type_dir = os.path.join(cf.KIM_REPOSITORY_DIR, cls.required_leader.lower() )
     kim_codes = (
         subpath for subpath in dircache.listdir(type_dir) if (
             os.path.isdir(os.path.join(type_dir, subpath)) and
             database.iskimcode(subpath)
         )
     )
     for x in kim_codes:
         try:
             yield cls(x)
         except Exception as e:
             logger.exception("Exception on formation of kim_code (%s)", x)
예제 #4
0
    def delete(self, kimid):
        self.logger.info("Deleting KIMObject %r from director" % kimid)
        if database.iskimcode(kimid):
            obj = kimobjects.kim_obj(kimid)

            # If kimid is a Test Driver or Model Driver, remove all of its associated
            # Tests or Models
            # (Note that Tests, Models, Test Verifications, and Model Verifications do
            # not have any children)
            children = obj.children
            if children:
                for child in children:
                    # Remove from internal database of Director
                    self.db.delete_objects([str(child)])
                    # Delete from local repository of Director
                    child.delete()

            # Finally, remove kimid itself from the Director's internal database and
            # delete it from its local repository
            self.db.delete_objects([kimid])
            obj.delete()
예제 #5
0
    def run(self, itemid, status='approved', priority='normal', force=False):
        """
        Complete a matching or dependency task given by `job`. This message
        should be formed by calling `pipeline.network.director_update_message`
        """
        priority = network.transform_priority(priority)
        self.logger.info(
            "Director got update message for %r (%r | %r | %r)" %
            (itemid, status, priority, force)
        )

        # decide what to do with the update request based on what
        # type of object it is
        if database.isuuid(itemid):
            self.process_test_result(uuid=itemid, priority=priority)

        elif database.iskimcode(itemid):
            if status == 'approved':
                self.process_kimcode_approved(itemid, priority)
            if status == 'pending':
                self.process_kimcode_pending(itemid, priority)

        self.logger.info("Director Waiting for message...")