Skip to content
Snippets Groups Projects
Commit 4209cf88 authored by Peter Hartman's avatar Peter Hartman
Browse files

2021/10/26 9:00

parent e9321f9d
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
from pathlib import Path
from subprocess import Popen, PIPE
default_project_map = "project_map"
class OnboardTool:
def __init__(self, projectfile):
self.basepath = None
self.project_list = []
self.fs_name = None
self.projectfile = projectfile
def load_project_map(self):
with open(self.projectfile, 'r') as prjfile:
for line in prjfile.readlines():
print("line[0] = \"{}\"".format(line[0]))
if not line[0].isalnum():
continue
else:
print("line = {}".format(line))
prj_id = line.split()[0]
quota_tb = line.split()[1]
prj_path = line.split()[2]
self.project_list.append({'project_id': prj_id, 'quota': quota_tb, 'prj_path': prj_path})
def verify_prj_ids(self):
for count, project in enumerate(self.project_list):
project_id = project['project_id']
process = Popen(["getent", "group", project_id], stdout=PIPE)
(output, err) = process.communicate()
exit_code = process.wait()
if exit_code != 0:
print("Project ID {} not found in getent".format(project_id))
exit(1)
self.project_list[count]["GID"] = output.split(sep=':')[2]
print(self.project_list)
def run_tool(project_map=default_project_map):
tool = OnboardTool(project_map)
tool.load_project_map()
print(tool.project_list)
if __name__ == '__main__':
run_tool()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment