1 # Create/update the default administrator account (should be person_id 2).
3 admin = { 'person_id': 2,
4 'first_name': "Default",
5 'last_name': "Administrator",
6 'email': plc['root_user'],
7 'password': plc['root_password'] }
8 persons = GetPersons([admin['person_id']])
10 person_id = AddPerson(admin)
11 if person_id != admin['person_id']:
12 # Huh? Someone deleted the account manually from the database.
13 DeletePerson(person_id)
14 raise Exception, "Someone deleted the \"%s %s\" account from the database!" % \
15 (admin['first_name'], admin['last_name'])
16 UpdatePerson(person_id, { 'enabled': True })
18 person_id = persons[0]['person_id']
19 UpdatePerson(person_id, admin)
21 # Create/update the default site (should be site_id 1)
22 if plc_www['port'] == '80':
23 url = "http://" + plc_www['host'] + "/"
24 elif plc_www['port'] == '443':
25 url = "https://" + plc_www['host'] + "/"
27 url = "http://" + plc_www['host'] + ":" + plc_www['port'] + "/"
31 site = { 'site_id': 1,
32 'name': plc['name'] + " Central",
33 'abbreviated_name': plc['name'],
34 'login_base': plc['slice_prefix'],
39 sites = GetSites([site['site_id']])
41 site_id = AddSite(site['name'], site['abbreviated_name'], site['login_base'], site)
42 if site_id != site['site_id']:
44 raise Exception, "Someone deleted the \"%s\" site from the database!" % \
48 # Must call UpdateSite() even after AddSite() to update max_slices
49 site_id = sites[0]['site_id']
50 UpdateSite(site_id, site)
52 # The default administrator account must be associated with a site
54 AddPersonToSite(admin['person_id'], site['site_id'])
55 SetPersonPrimarySite(admin['person_id'], site['site_id'])
57 # Grant admin and PI roles to the default administrator account
58 AddRoleToPerson(10, admin['person_id'])
59 AddRoleToPerson(20, admin['person_id'])