3 ##############################
5 ### preparation / requirements
7 ### two separate instances of myplc
8 ### for now they are located on the same box on lurch
11 ### your myplcs should more or less come out of the box,
12 ### I prefer not to alter the default PLC_ROOT_USER value,
13 ### instead we create a PI account on the site_id=1
15 ##############################
19 plc1={ 'name':'plc1 in federation',
20 'url':'https://lurch.cs.princeton.edu:443/',
21 'builtin_admin_id':'root@localhost.localdomain',
22 'builtin_admin_password':'root',
23 'peer_admin_name':'plc1@planet-lab.org',
24 'peer_admin_password':'peer',
25 'nodename':'n11.plc1.org'
27 plc2={ 'name':'plc2 in federation',
28 'url':'https://planetlab-devbox.inria.fr:443/',
29 'builtin_admin_id':'root@localhost.localdomain',
30 'builtin_admin_password':'root',
31 'peer_admin_name':'plc2@planet-lab.org',
32 'peer_admin_password':'peer',
33 'nodename':'n21.plc2.org'
36 ## we use indexes 1 and 2
40 # the authentication objects
47 ### cant use digits in slice login name
54 raise Exception,"Unexpected input in plain_name"
56 def test00_init (args=[1,2]):
58 ## have you loaded this file already (support for reload)
64 url=plc[i]['url']+'/PLCAPI/'
65 s[i]=xmlrpclib.Server(url)
66 print 'initializing s[%d]'%i,url
67 aa[i]={'Username':plc[i]['builtin_admin_id'],
68 'AuthMethod':'password',
69 'AuthString':plc[i]['builtin_admin_password'],
71 print 'initialized aa[%d]'%i, aa[i]
72 a[i]={'Username':plc[i]['peer_admin_name'],
73 'AuthMethod':'password',
74 'AuthString':plc[i]['peer_admin_password'],
76 print 'initialized a[%d]'%i, a[i]
78 def test00_print (args=[1,2]):
82 print 'aa[%d]'%i, aa[i]
85 def test00_admin (args=[1,2]):
89 person_id=s[i].AddPerson(aa[i],{'first_name':'Local', 'last_name':'PeerPoint', 'role_ids':[10],
90 'email':plc[i]['peer_admin_name'],'password':plc[i]['peer_admin_password']})
91 print '%02d: created peer admin account %d, %s - %s'%(i,person_id,plc[i]['peer_admin_name'],plc[i]['peer_admin_password'])
92 plc[i]['peer_admin_id']=person_id
94 def test00_enable (args=[1,2]):
98 s[i].AdmSetPersonEnabled(aa[i],plc[i]['peer_admin_id'],True)
99 s[i].AddRoleToPerson(aa[i],'admin',plc[i]['peer_admin_id'])
100 print '%02d: enabled+admin on account %d:%s'%(i,plc[i]['peer_admin_id'],plc[i]['peer_admin_name'])
102 def test01_check (args=[1,2]):
105 n=len(s[i].GetNodes(aa[i]))
106 f=len(s[i].GetForeignNodes(a[i]))
107 print '%02d: Checking connection: got %d local nodes & %d foreign nodes'%(i,n,f)
109 def test01_node (args=[1,2]):
112 n=s[i].AddNode(a[i],1,{'hostname': plc[i]['nodename']})
113 print '%02d: Added node %d %s'%(i,n,plc[i]['nodename'])
115 def test01_peer_person (args=[1,2]):
119 person_id = s[i].AddPerson (a[i], {'first_name':'Peering(plain passwd)', 'last_name':plc[peer]['name'], 'role_ids':[3000],
120 'email':plc[peer]['peer_admin_name'],'password':plc[peer]['peer_admin_password']})
121 print '02%d:Created person %d as the peer person'%(i,person_id)
122 plc[i]['peer_person_id']=person_id
124 def test01_peer (args=[1,2]):
128 peer_id=s[i].AddPeer (a[i], {'peername':plc[peer]['name'],'peer_url':plc[peer]['url'],'person_id':plc[i]['peer_person_id']})
129 # NOTE : need to manually reset the encrypted password through SQL at this point
130 print '%02d:Created peer %d'%(i,peer_id)
131 plc[i]['peer_id']=peer_id
132 print "Please MANUALLY set passwd for person_id=%d in DB%d"%(plc[i]['peer_person_id'],i)
134 def test02_refresh (args=[1,2]):
137 print '%02d: Refreshing peer'%(i)
138 s[i].RefreshPeer(a[i],plc[i]['peer_id'])
140 def test03_site (args=[1,2]):
144 ### create a site (required for creating a slice)
145 sitename="site"+str(i)
146 abbrev_name="abbr"+str(i)
148 site_id=s[i].AddSite (a[i], {'name':plc[i]['name'],
149 'abbreviated_name': abbrev_name,
152 'url': 'http://%s.com/'%abbrev_name,
154 ### max_slices does not seem taken into account at that stage
155 s[i].UpdateSite(a[i],plc[i]['site_id'],{'max_slices':10})
156 print '%02d: Created site %d with max_slices=10'%(i,site_id)
157 plc[i]['site_id']=site_id
159 def test03_slice (args=[1,2]):
165 slice_name="slic"+str(i)
166 slice_id=s[i].AddSlice (a[i],{'name':'%s_%s'%(plain,slice_name),
167 'description':'slice %s_%s on plc %s'%(plain,slice_name,plc[i]['name']),
168 'url':'http://planet-lab.org/%s'%slice_name,
170 'instanciation':'plc-instantiated',
172 print '%02d: created slice %d'%(i,slice_id)
173 plc[i]['slice_id']=slice_id
176 def test04_lnode (args=[1,2]):
180 hostname=plc[i]['nodename']
181 s[i].AddSliceToNodes (a[i], plc[i]['slice_id'],hostname)
182 print '%02d: added local node %s'%(i,hostname)
184 def test04_fnode (args=[1,2]):
189 hostname=plc[peer]['nodename']
190 s[i].AddSliceToNodes (a[i], plc[i]['slice_id'],hostname)
191 print '%02d: added local node %s'%(i,hostname)
193 def catch_up (args=[1,2]):
195 plc[i]['peer_admin_id']=3
196 plc[i]['peer_person_id']=4