示例#1
0
            lgroup.delete()
        except self._group.DoesNotExist:
            # it doesn't matter if it doesn't exist
            pass

    def set_group_name(self, group, old_name, new_name):
        """ Group was renamed. """
        lgroup = self._groups().get(cn=old_name)
        lgroup.rename(cn=new_name)

    def get_group_details(self, group):
        """ Get the group details. """
        result = {}
        try:
            lgroup = self._groups().get(cn=group.name)
        except self._group.DoesNotExist:
            return result
        for i, j in lgroup.get_fields():
            if j is not None:
                result[i] = j
        result['dn'] = lgroup.dn
        result['primary_accounts'] = [
            a.dn for a in lgroup.primary_accounts.all()]
        result['secondary_accounts'] = [
            a.dn for a in lgroup.secondary_accounts.all()]
        return result


trace.attach(trace.trace(logger), GlobalDataStore)
trace.attach(trace.trace(logger), MachineCategoryDataStore)
示例#2
0
        """ Group was deleted. """
        try:
            lgroup = self._get_group(group.name)
            delete(lgroup, database=self._database)
        except ObjectDoesNotExist:
            # it doesn't matter if it doesn't exist
            pass

    def set_group_name(self, group, old_name, new_name):
        """ Group was renamed. """
        lgroup = self._get_group(old_name)
        rename(lgroup, database=self._database, cn=new_name)

    def get_group_details(self, group):
        """ Get the group details. """
        result = {}
        try:
            lgroup = self._get_group(group.name)
            lgroup = preload(lgroup, database=self._database)
        except ObjectDoesNotExist:
            return result

        for i, j in lgroup.items():
            if j is not None:
                result[i] = j

        return result


trace.attach(trace.trace(logger), DataStore)
示例#3
0
        self._call(["gmkaccount", "-a", pid, "-u", "MEMBERS"])

    def _set_project(self, pid, description, institute):
        self._call([
            "gchaccount",
            "-d", self._filter_string(description),
            "-a", pid])
        self._call([
            "gchaccount",
            "-X", "Organization=%s"
            % self._filter_string(institute.name),
            "-a", pid])

    def _delete_project(self, pid):
        self._call(["grmaccount", "-a", pid])


def MamDataStore(config):
    ds = MamDataStore71(config)
    if ds.check_version():
        return ds
    ds = MamDataStore72(config)
    if ds.check_version():
        return ds
    raise RuntimeError("We do not support this version of MAM")


trace.attach(trace.trace(logger), MamDataStoreBase)
trace.attach(trace.trace(logger), MamDataStore71)
trace.attach(trace.trace(logger), MamDataStore72)
示例#4
0
文件: slurm.py 项目: vlsci/karaage
                self._call(["delete", "account", "name=%s" % pid])

        return

    def delete_project(self, project):
        """ Called when project is deleted. """
        pid = project.pid

        # project deleted

        ds_project = self.get_project(pid)
        if ds_project is not None:
            self._call(["delete", "account", "name=%s" % pid])

        return

    def get_project_details(self, project):
        """ Get the project details. """
        result = self.get_project(project.pid)
        if result is None:
            result = {}
        return result

    def set_project_pid(self, project, old_pid, new_pid):
        """ Project's pid was changed. """
        # FIXME
        return


trace.attach(trace.trace(logger), SlurmDataStore)
示例#5
0
        """ Group was deleted. """
        try:
            lgroup = self._get_group(group.name)
            delete(lgroup, database=self._database)
        except ObjectDoesNotExist:
            # it doesn't matter if it doesn't exist
            pass

    def set_group_name(self, group, old_name, new_name):
        """ Group was renamed. """
        lgroup = self._get_group(old_name)
        rename(lgroup, database=self._database, cn=new_name)

    def get_group_details(self, group):
        """ Get the group details. """
        result = {}
        try:
            lgroup = self._get_group(group.name)
            lgroup = preload(lgroup, database=self._database)
        except ObjectDoesNotExist:
            return result

        for i, j in lgroup.items():
            if j is not None:
                result[i] = j

        return result


trace.attach(trace.trace(logger), DataStore)
示例#6
0
                self._call(["delete", "account", "name=%s" % pid])

        return

    def delete_project(self, project):
        """ Called when project is deleted. """
        pid = project.pid

        # project deleted

        ds_project = self.get_project(pid)
        if ds_project is not None:
            self._call(["delete", "account", "name=%s" % pid])

        return

    def get_project_details(self, project):
        """ Get the project details. """
        result = self.get_project(project.pid)
        if result is None:
            result = {}
        return result

    def set_project_pid(self, project, old_pid, new_pid):
        """ Project's pid was changed. """
        # FIXME
        return


trace.attach(trace.trace(logger), SlurmDataStore)
示例#7
0
    def _create_project(self, pid):
        self._call(["gmkaccount", "-a", pid, "-u", "MEMBERS"])

    def _set_project(self, pid, description, institute):
        self._call(
            ["gchaccount", "-d",
             self._filter_string(description), "-a", pid])
        self._call([
            "gchaccount", "-X",
            "Organization=%s" % self._filter_string(institute.name), "-a", pid
        ])

    def _delete_project(self, pid):
        self._call(["grmaccount", "-a", pid])


def MamDataStore(config):
    ds = MamDataStore71(config)
    if ds.check_version():
        return ds
    ds = MamDataStore72(config)
    if ds.check_version():
        return ds
    raise RuntimeError("We do not support this version of MAM")


trace.attach(trace.trace(logger), MamDataStoreBase)
trace.attach(trace.trace(logger), MamDataStore71)
trace.attach(trace.trace(logger), MamDataStore72)
示例#8
0
            # it doesn't matter if it doesn't exist
            pass

    def set_group_name(self, group, old_name, new_name):
        """ Group was renamed. """
        lgroup = self._groups().get(cn=old_name)
        lgroup.rename(cn=new_name)

    def get_group_details(self, group):
        """ Get the group details. """
        result = {}
        try:
            lgroup = self._groups().get(cn=group.name)
        except self._group.DoesNotExist:
            return result
        for i, j in lgroup.get_fields():
            if j is not None:
                result[i] = j
        result['dn'] = lgroup.dn
        result['primary_accounts'] = [
            a.dn for a in lgroup.primary_accounts.all()
        ]
        result['secondary_accounts'] = [
            a.dn for a in lgroup.secondary_accounts.all()
        ]
        return result


trace.attach(trace.trace(logger), GlobalDataStore)
trace.attach(trace.trace(logger), MachineCategoryDataStore)