7 email_list = [ 'monitor@planet-lab.org',
8 # 'soltesz@cs.princeton.edu',
9 # 'justin@cs.arizona.edu',
10 # 'bakers@cs.arizona.edu',
11 # 'jhh@cs.arizona.edu',
12 # 'mfreed@cs.nyu.edu',
13 # 'kyoungso@cs.princeton.edu',
14 # 'nspring@cs.umd.edu',
15 # 'vivek@cs.princeton.edu',
19 api = plc.PLC(config.API_AUTH, config.API_SERVER)
20 api06 = plc.PLC(config.API_AUTH06, config.API_SERVER06)
23 # add planetlab-15.cs.princeton.edu, and use the key on the CD.
24 id = api06.AddNode(1, {'boot_state': 'rins', 'model': 'Dell Optiplex',
25 'hostname' : 'planetlab-15.cs.princeton.edu',
27 api06.AddNodeNetwork(id, {'ip': '128.112.139.39',
31 api06.UpdateNode(id, {'key': "wptNagk8SgRxzN1lXfKMAjUYhQbOBymKnKg9Uv0LwGM"})
34 #print "adding vsys attributes"
35 #api06.AddSliceAttribute('princeton_slicestat', 'vsys', 'pl-ps')
36 #api06.AddSliceAttribute('princeton_slicestat', 'vsys', 'vtop')
37 #api06.AddSliceAttribute('pl_netflow', 'vsys', 'pfmount')
39 #print "preserve princeton_chopstix"
43 #attr_types = api.GetSliceAttributeTypes()
44 #attr_types06 = api06.GetSliceAttributeTypes()
45 #attr_types06_names = [a['name'] for a in attr_types06]
46 #for type in attr_types:
47 # if type['name'] not in attr_types06_names:
48 # print "adding %s " % type
49 # api06.AddSliceAttributeType(type)
50 def person_exists(user):
52 x = api06.GetPersons({'email':user['email']})
60 def site_exists(site):
62 x = api06.GetSites({'login_base':site['login_base']})
70 def slice_exists(slice):
72 x = api06.GetSlices({'name':slice['name']})
81 slices = api06.GetSlices()
83 print "Updating expiration of %s" % slice['name']
84 api06.UpdateSlice(slice['name'], {'expires': int(time.time()) + 7*24*60*60})
88 for email in email_list:
89 user = api.GetPersons({'email': email})
91 print "User not found: %s" % email
96 print "adding person %s " % user['email']
97 if not person_exists(user):
100 api06.UpdatePerson(email, {'enabled': True})
102 print "adding person keys %s " % user['email']
103 key = api.GetKeys({'person_id': user['person_id']})[0]
104 key06 = {'key': key['key'], 'key_type': key['key_type']}
105 api06.AddPersonKey(user['email'], key06)
107 print "updating person roles: ",
108 for role in user['roles']:
110 api06.AddRoleToPerson(role, user['email'])
114 sites = api.GetSites(user['site_ids'])
115 print "Adding sites:",
117 if not site_exists(site):
118 print "%s" % site['login_base'],
120 api06.AddPersonToSite(user['email'], site['login_base'])
124 nodes = api06.GetNodes()
125 slices = api.GetSlices(user['slice_ids'])
129 if not slice_exists(slice):
130 print "Adding slice %s" % slice['name']
132 api06.AddSlice(slice)
133 attr = api.GetSliceAttributes({'slice_attribute_id' :
134 slice['slice_attribute_ids']})
135 print "adding attributes:",
138 print "%s" % a['name'],
139 #if a['name'] not in added_attr:
140 api06.AddSliceAttribute(slice['name'], a['name'], a['value'])
141 # added_attr.append(a['name'])
146 print "error with ", slice['name']
149 print "adding nodes and %s to slice %s" % (user['email'], slice['name'])
150 # add all api06 nodes to slice
151 api06.AddSliceToNodes(slice['name'], [n['hostname'] for n in nodes])
153 api06.AddPersonToSlice(user['email'], slice['name'])