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 ### ----------------------------------------
20 ### # run sql commands - PLC1
22 ### $ chroot /plc1/root psql planetlab4 pgsqluser
24 ### # run sql commands - PLC2
26 ### $ chroot /plc2/root psql -h localhost -p 5433 planetlab4 pgsqluser
27 ### but then a password is required
28 ### 9a61ae18-779e-41b6-8a6c-67c439dc73e5
30 ### ----------------------------------------
31 ### # connecting to the API - PLC1
33 ### $ chroot /plc1/root
34 ### $ ./Shell.py --config /plc1/root/data/etc/planetlab/plc_config
36 ### # connecting to the API - PLC2
38 ### $ chroot /plc2/root
40 ### $ ./Shell.py --config /plc2/root/data/etc/planetlab/plc_config -h https://localhost:444/PLCAPI/
42 ### ----------------------------------------
43 ##############################
47 plc1={ 'name':'plc1 in federation',
49 'url':'https://lurch.cs.princeton.edu:443/',
50 'admin_id':'plc1@planet-lab.org',
51 'admin_password':'root',
53 'nodename':'n11.plc1.org'
55 plc2={ 'name':'plc2 in federation',
57 'url':'https://lurch.cs.princeton.edu:444/',
58 'admin_id':'plc2@planet-lab.org',
59 'admin_password':'root',
61 'nodename':'n21.plc2.org'
67 # the authentication objects
70 ### cant use digits in slice login name
77 raise Exception,"Unexpected input in plain_name"
79 def test00_init (args=[0,1]):
82 url=plc[i]['url']+'/PLCAPI/'
83 s[i]=xmlrpclib.Server(url)
84 print 'initializing s[%d]'%i,url
85 a[i]={'Username':plc[i]['admin_id'],
86 'AuthMethod':'password',
87 'AuthString':plc[i]['admin_password'],
89 print 'initialized a[%d]'%i, a[i]
91 def test00_check (args=[0,1]):
94 n=len(s[i].GetNodes(a[i]))
95 f=len(s[i].GetForeignNodes(a[i]))
96 print 'Checking connection: got %d local nodes & %d foreign nodes'%(n,f)
98 def test01_pi (args=[0,1]):
102 plc[i]['pi_id']=s[i].AddPerson(a[i],{'first_name':'Local', 'last_name':'PI', 'role_ids':[20],
103 'email':plc[i]['admin_id'],'password':plc[id]['admin_password']})
105 def test01_node (args=[0,1]):
108 n=s[i].AddNode(a[i],1,{'hostname': plc[i]['nodename']})
109 print '%02d: Added node %d %s',(i+1,n,plc[i]['nodename'])
111 def test01_peer_person (args=[0,1]):
115 person_id = s[i].AddPerson (a[i], {'first_name':'Peering', 'last_name':plc[peer]['name'], 'role_ids':[3000],
116 'email':plc[peer]['admin_id'],'password':plc[peer]['admin_password']})
117 print '02%d:Created person %d as the peer person'%(i+1,person_id)
118 plc[i]['peer_person_id']=person_id
120 def test01_peer (args=[0,1]):
124 peer_id=s[i].AddPeer (a[i], {'peername':plc[peer]['name'],'peer_url':plc[peer]['url'],'person_id':plc[i]['peer_person_id']})
125 # NOTE : need to manually reset the encrypted password through SQL at this point
126 print '%02d:Created peer %d'%(i+1,peer_id)
127 plc[i]['peer_id']=peer_id
128 print "Please MANUALLY set passwd for person_id=%d in DB%d"%(person_id,i+1)
130 def test02_refresh (args=[0,1]):
133 print '%02d: Refreshing peer'%(i+1)
134 s[i].RefreshPeer(plc[i]['peer_id'])
135 ###### at this stage both sites know about two nodes, one local and one foreign
137 def test03_site (args=[0,1]):
141 ### create a site (required for creating a slice)
142 sitename="site"+str(i+1)
143 abbrev_name="abbr"+str(i+1)
144 plain=plain_name(i+1)
145 site_id=s[i].AddSite (a[i], {'name':plc[i]['name'],
146 'abbreviated_name': abbrev_name,
149 'url': 'http://%s.com/'%abbrev_name,
151 ### max_slices does not seem taken into account at that stage
152 s[i].UpdateSite(a[i],plc[i]['site_id'],{'max_slices':10})
153 print '%02d: Created site %d with max_slices=10'%(i+1,site_id)
154 plc[i]['site_id']=site_id
156 def test03_slice (args=[0,1]):
160 plain=plain_name(i+1)
162 slice_name="slic"+str(i+1)
163 slice_id=s[i].AddSlice (a[i],{'name':'%s_%s'%(plain,slice_name),
164 'description':'slice %s_%s on plc %s'%(plain,slice_name,plc[i]['name']),
165 'url':'http://planet-lab.org/%s'%slice_name,
167 'instanciation':'plc-instantiated',
169 print '%02d: created slice %d'%(i+1,slice_id)
170 plc[i]['slice_id']=slice_id
173 def test04_lnode (args=[0,1]):
177 hostname=plc[i]['nodename']
178 s[i].AddSliceToNodes (a[i], plc[i]['slice_id'],hostname)
179 print '%02d: added local node %s'%(i+1,hostname)
181 def test04_fnode (args=[0,1]):
186 hostname=plc[peer]['nodename']
187 s[i].AddSliceToNodes (a[i], plc[i]['slice_id'],hostname)
188 print '%02d: added local node %s'%(i+1,hostname)