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

using manual steps

parent da650415
No related branches found
No related tags found
No related merge requests found
......@@ -106,13 +106,6 @@
- name: install shibboleth cache file
template: src=metadata.aaf.xml.j2 dest=/tmp/metadata.aaf.xml
- name: install karaage projects init setting file
template: src=kg_init.txt.j2 dest=/tmp/kg_init.txt
- name: install karaage init script
template: src=kg_init.j2 dest=/usr/bin/kg_init mode=755
sudo: true
-
name: "enabling Karaage configuration"
shell: a2enconf karaage3-wsgi
......@@ -155,6 +148,12 @@
sudo: true
when: karaage_db_init.stdout.find("0") == 0
-
name: "Create default projects"
shell: kg_init /tmp/kg_init.txt
sudo: true
when: karaage_db_init.stdout.find("0") == 0
- name: install postfix
apt: name=postfix state=present
sudo: true
......
#!/usr/bin/python
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = "karaage.conf.settings"
from django.conf import settings
from karaage.projects.models import Project
from karaage.institutes.models import Institute
DEFAULT_PROJECTS = [
{"project_name": "MCC2", "pid": "pMcc2", "institute_name": "Monash University"},
{"project_name": "MCC3", "pid": "pMcc3", "institute_name": "Monash University"},
{"project_name": "MASSIVE", "pid": "pMassive", "institute_name": "Monash University"},
{"project_name": "CVL", "pid": "pCvl", "institute_name": "Monash University"}
]
class InitDefaultProject():
import django
django.setup()
def __init__(self, configfile):
import json
self.path = configfile
if self.path:
with open(self.path) as data:
self.config = json.load(data)
else:
self.config = DEFAULT_PROJECTS
def log(self, message):
print message
def getGroup(self, name):
group = None
try:
group =Group.objects.get(name = name)
if group:
self.log("Find group %s" %(name))
except:
self.log("Group %s not found" %(name))
finally:
return group
def getProject(self, name):
self.log("Get Project 1 %s" %(name))
project = None
try:
project = Project.objects.get(name = name)
if project:
self.log("Find project %s" %(project.name))
group = project.group
if group:
self.log("Group name = %s" %(group.name))
else:
self.log("Project %s not found" %(project.name))
except Project.DoesNotExist:
self.log("project %s does not exists" %(name))
except:
self.log("Exception: ", traceback.format_exc())
finally:
return project
def createProject(self, pid, name, institute_name):
project = None
try:
institute = self.getInstitute(institute_name)
if institute:
self.log("Find insititute %s" %(institute.name))
project = Project.objects.create(pid = pid, name = name, institute = institute, group = institute.group, is_active = True)
if project:
self.log("Create project OK")
else:
self.log("Create project failed")
else:
self.log("Insititute %s does not exist" %(institute_name))
except:
self.log("Exception: ", traceback.format_exc())
finally:
return project
def getInstitute(self, name):
institute = None
try:
institute = Institute.objects.get(name = name)
if institute:
self.log("Institute %s exist" %(institute.name))
group = institute.group
if group:
self.log("Group name = %s" %(group.name))
else:
self.log("Institute %s not found" %(name))
except Institute.DoesNotExist:
self.log("Institute %s not found" %(name))
finally:
return institute
def defaultProjects(self):
for p in self.config:
project = self.getProject(p["project_name"])
if project:
self.log("Find project %s" %(project.name))
else:
self.log("Create project name = %s, pid = %s, institute name = %s" %(p["project_name"], p["pid"], p["institute_name"]))
project = self.createProject(p["pid"], p["project_name"], p["institute_name"])
if project:
self.log("Create project %s OK." %(project.name))
else:
self.log("Create project %s failed." %(p["project_name"]))
break
def main(argv):
config_path = None
if len(sys.argv) > 1:
config_path = argv[0]
init = InitDefaultProject(config_path)
init.defaultProjects()
if __name__ == '__main__':
main(sys.argv[1:])
[
{"project_name": "MCC2", "pid": "pMcc2", "institute_name": "Monash University"},
{"project_name": "MCC3", "pid": "pMcc3", "institute_name": "Monash University"},
{"project_name": "MASSIVE", "pid": "pMassive", "institute_name": "Monash University"},
{"project_name": "CVL", "pid": "pCvl", "institute_name": "Monash University"}
]
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