-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin: add multifactor priority plugin #122
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f4d71dc
association_table: add userid field
cmoussa1 52f57cb
fetch_usg_bins: change index of dataframe values
cmoussa1 8ae03b4
test: change tests to account for new userid field
cmoussa1 901b64a
flux-account: add uid arg to add-user subcommand
cmoussa1 25c6c4f
association_table: change default val of fairshare
cmoussa1 66114ef
plugins: add multifactor priority plugin
cmoussa1 783d222
plugins: add external service
cmoussa1 ea3cdb6
make: add Makefile for plugin
cmoussa1 7f89794
docker: specify latest version of flux-core
cmoussa1 be6d976
t: add rc directory
cmoussa1 bd152a1
sharness: drop --bootstrap=selfpmi
cmoussa1 c9aec4a
.github: add checks-annotate.sh
cmoussa1 14214d4
t: add tests for multi-factor priority plugin
cmoussa1 b69f252
make: add t1001-mf-priority to make check
cmoussa1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SUBDIRS = common cmd fairness bindings | ||
SUBDIRS = common cmd fairness bindings plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
AM_LDFLAGS = -module -shared $(CODE_COVERAGE_LDFLAGS) | ||
|
||
AM_CPPFLAGS = -I$(top_srcdir) $(FLUX_CORE_CFLAGS) | ||
|
||
AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS) -fPIC -shared | ||
|
||
lib_LTLIBRARIES = mf_priority.la | ||
mf_priority_la_SOURCES = mf_priority.cpp | ||
mf_priority_la_LDFLAGS = $(fluxplugin_ldflags) -module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env python3 | ||
|
||
############################################################### | ||
# Copyright 2020 Lawrence Livermore National Security, LLC | ||
# (c.f. AUTHORS, NOTICE.LLNS, COPYING) | ||
# | ||
# This file is part of the Flux resource manager framework. | ||
# For details, see https://github.com/flux-framework. | ||
# | ||
# SPDX-License-Identifier: LGPL-3.0 | ||
############################################################### | ||
import flux | ||
import argparse | ||
import sys | ||
import os | ||
import sqlite3 | ||
|
||
import fluxacct.accounting | ||
|
||
|
||
def set_db_loc(args): | ||
path = args.path if args.path else fluxacct.accounting.db_path | ||
|
||
return path | ||
|
||
|
||
def est_sqlite_conn(path): | ||
# try to open database file; will exit with -1 if database file not found | ||
if not os.path.isfile(path): | ||
print(f"Database file does not exist: {path}", file=sys.stderr) | ||
sys.exit(1) | ||
|
||
db_uri = "file:" + path + "?mode=rw" | ||
try: | ||
conn = sqlite3.connect(db_uri, uri=True) | ||
# set foreign keys constraint | ||
conn.execute("PRAGMA foreign_keys = 1") | ||
except sqlite3.OperationalError: | ||
print(f"Unable to open database file: {db_uri}", file=sys.stderr) | ||
sys.exit(1) | ||
|
||
return conn | ||
|
||
|
||
def bulk_update(path): | ||
conn = est_sqlite_conn(path) | ||
cur = conn.cursor() | ||
|
||
# fetch all rows from association_table (will print out tuples) | ||
for row in cur.execute("SELECT userid, bank, fairshare FROM association_table"): | ||
# create a JSON payload with the results of the query | ||
data = {"userid": str(row[0]), "bank": str(row[1]), "fairshare": str(row[2])} | ||
|
||
flux.Flux().rpc("job-manager.mf_priority.rec_update", data).get() | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description=""" | ||
Description: Send a bulk update of user information from a | ||
flux-accounting database to the multi-factor priority plugin. | ||
""" | ||
) | ||
|
||
parser.add_argument( | ||
"-p", "--path", dest="path", help="specify location of database file" | ||
) | ||
args = parser.parse_args() | ||
|
||
path = set_db_loc(args) | ||
|
||
bulk_update(path) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file have a copyright header? I'm actually unsure, but might as well throw it in here just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, thank you for pointing this out. I just pushed up a fix that adds a copyright header. Sorry for forgetting to put one. 🤦♂️