Example #1
0
 def create_model(self, form):
     try:
         return super().create_model(form)
     except Exception as e:
         log.error("could not create org", exc_info=e,
                   remote_user=request.remote_user)
         raise
Example #2
0
 def delete_model(self, model):
     try:
         log.info("deleting org", remote_user=request.remote_user,
                  id=model.get('_id'))
         return super().delete_model(model)
     except Exception as e:
         log.error("could not delete org", exc_info=e,
                   remote_user=request.remote_user, id=model.get('_id'))
         raise
Example #3
0
 def update_model(self, form, model):
     try:
         log.info("updating org", remote_user=request.remote_user,
                  id=model.get('_id'))
         return super().update_model(form, model)
     except Exception as e:
         log.error("could not update org", exc_info=e,
                   remote_user=request.remote_user, id=model.get('_id'))
         raise
    def setUp(self):
        # set and download required binaries (snapteld, snaptel, plugins)
        self.binaries = utils.set_binaries()
        utils.download_binaries(self.binaries)

        log.debug("Starting snapteld")
        self.binaries.snapteld.start()
        if not self.binaries.snapteld.isAlive():
            self.fail("snapteld thread died")

        log.debug("Waiting for snapteld to finish starting")
        if not self.binaries.snapteld.wait():
            log.error("snapteld errors: {}".format(self.binaries.snapteld.errors))
            self.binaries.snapteld.kill()
            self.fail("snapteld not ready, timeout!")
    def setUp(self):
        # set and download required binaries (snapd, snapctl, plugins)
        self.binaries = utils.set_binaries()
        utils.download_binaries(self.binaries)

        log.debug("Starting snapd")
        self.binaries.snapd.start()
        if not self.binaries.snapd.isAlive():
            self.fail("snapd thread died")

        log.debug("Waiting for snapd to finish starting")
        if not self.binaries.snapd.wait():
            log.error("snapd errors: {}".format(self.binaries.snapd.errors))
            self.binaries.snapd.kill()
            self.fail("snapd not ready, timeout!")
Example #6
0
    def get_list(self,
                 page,
                 sort_column,
                 sort_desc,
                 search,
                 filters,
                 execute=True,
                 page_size=None):
        try:
            ls = super().get_list(page,
                                  sort_column,
                                  sort_desc,
                                  search,
                                  filters,
                                  execute=execute,
                                  page_size=page_size)
            users: Iterable[Dict] = ls[1]
            to_search = [g.get('group_id') for g in mongo.db.groups.find({})]
            gs = groups.get_for_many([u.get('shib_id') for u in users],
                                     to_search)

            orgs_dict = {x[0]: x[1] for x in _get_org_refs()}

            for user in users:
                user['groups'] = gs.get(user.get('shib_id'))
                org_id = user.get('organization_id')
                if org_id:
                    user['org_name'] = orgs_dict.get(
                        org_id, "Unknown ({})".format(org_id))

            return ls
        except Exception as e:
            log.error("could not list memberships",
                      exc_info=e,
                      remote_user=request.remote_user)
            raise