Skip to content
Snippets Groups Projects
Commit d5100b12 authored by Jupiter Hu's avatar Jupiter Hu
Browse files

Merge pull request #142 from CVL-GitHub/hpcidbranch10

fixed a bug
parents 35361f4a 965f4b68
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,8 @@ from karaage.institutes.models import Institute ...@@ -8,6 +8,8 @@ from karaage.institutes.models import Institute
from karaage.machines.models import MachineCategory from karaage.machines.models import MachineCategory
from karaage.people.models import Person, Group from karaage.people.models import Person, Group
CONSOLE_DEBUG = False
class HpcIdInit(): class HpcIdInit():
import django import django
django.setup() django.setup()
...@@ -17,6 +19,9 @@ class HpcIdInit(): ...@@ -17,6 +19,9 @@ class HpcIdInit():
self.path = configfile self.path = configfile
self.password = password self.password = password
self.debug = debug self.debug = debug
if not debug:
self.logfile = open("/tmp/kg_init.log", "w")
if self.path and os.path.exists(self.path): if self.path and os.path.exists(self.path):
with open(self.path) as data: with open(self.path) as data:
config_data = json.load(data) config_data = json.load(data)
...@@ -26,9 +31,14 @@ class HpcIdInit(): ...@@ -26,9 +31,14 @@ class HpcIdInit():
else: else:
log("Invalid input data") log("Invalid input data")
def __del__(self):
self.logfile.close()
def log(self, message): def log(self, message):
if self.debug: if self.debug:
print message print message
else:
self.logfile.write(message + "\n")
def getGroup(self, name): def getGroup(self, name):
group = None group = None
...@@ -173,6 +183,7 @@ class HpcIdInit(): ...@@ -173,6 +183,7 @@ class HpcIdInit():
try: try:
delegates = institute.delegates.all().filter(username = su.username) delegates = institute.delegates.all().filter(username = su.username)
if len(delegates) == 0: if len(delegates) == 0:
self.log("Create institution delegate %s"%(su.username))
institute.delegates.add(su) institute.delegates.add(su)
except: except:
result = False result = False
...@@ -216,7 +227,7 @@ def main(argv): ...@@ -216,7 +227,7 @@ def main(argv):
if len(sys.argv) > 2: if len(sys.argv) > 2:
config_path = argv[0] config_path = argv[0]
password = argv[1] password = argv[1]
debug = True debug = CONSOLE_DEBUG
if len(sys.argv) > 3: if len(sys.argv) > 3:
debug = argv[2] debug = argv[2]
init = HpcIdInit(config_path, password, debug) init = HpcIdInit(config_path, password, debug)
......
{% if slurmctrl == inventory_hostname %} {% if slurmctrl == inventory_hostname %}
{{ slurmctlddebug.log }} {{ slurmctlddebug.log }}
{{ slurmschedlog.log }} {{ slurmschedlog.log }}
{% else *} {% else %}
{{ slurmddebug.log }} {{ slurmddebug.log }}
{% endif %} {% endif %}
{ {
......
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