Add import acl script
This commit is contained in:
parent
5e930c80f0
commit
3855386c65
0
vm/extract_acl.py
Normal file → Executable file
0
vm/extract_acl.py
Normal file → Executable file
38
vm/import_acl.py
Executable file
38
vm/import_acl.py
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
def import_acls(input_file):
|
||||
print(f"Importing ACLs from {input_file}...")
|
||||
|
||||
with open(input_file, "r") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
path, user, role = line.split()
|
||||
print(f"Adding ACL: Path={path}, User={user}, Role={role}")
|
||||
|
||||
result = subprocess.run(["pveum", "acl", "modify", path, "--users", user, "--roles", role])
|
||||
|
||||
if result.returncode != 0:
|
||||
print(f"Error adding ACL: {result.stderr}")
|
||||
else:
|
||||
print(f"Successfully added ACL for {path}")
|
||||
|
||||
print("ACL import completed.")
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print(f"Usage: {sys.argv[0]} <input_file>")
|
||||
sys.exit(1)
|
||||
|
||||
input_file = sys.argv[1]
|
||||
import_acls(input_file)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user