Sandrine commits:
[sfa.git] / testbeds / iotlab / tests / sfi_client_tests.py
1 #!/usr/bin/env python
2
3 import os
4 from sfa.iotlab.LDAPapi import LDAPapi
5 from difflib import SequenceMatcher
6
7 # check if the firexp user (uid user) is already in LDAP
8 # in this is the case, delete it :
9 ldap_server = LDAPapi()
10 dn = 'uid=' + 'user' + ',' + ldap_server.baseDN
11 result = ldap_server.LdapSearch('(uid=user)', [])
12
13 if result != []:
14         retval = ldap_server.LDAPDelete(dn)
15         print "deleting firexp user : %s " , retval
16
17
18 print "config sfi"
19 with open ("/root/.sfi/sfi_config", "r") as sfi_config:
20         sfi_config_txt = [line for line in sfi_config]
21
22 with open("/root/.sfi/sfi_config_iotlab", "r") as sfi_config_iotlab:
23         sfi_config_iotlab_txt = [line for line in sfi_config_iotlab]
24
25 with open("/root/.sfi/sfi_config_firexp", "r") as sfi_config_firexp:
26         sfi_config_firexp_txt  =  [line for line in sfi_config_firexp]
27 # check that we are using the iotlab sfi configuration
28 result1 = SequenceMatcher(None, sfi_config_txt, sfi_config_iotlab_txt)
29
30 result2 = SequenceMatcher(None, sfi_config_txt, sfi_config_firexp_txt)
31
32 if result1.ratio() != 1.0:
33         os.system('cp /root/.sfi/sfi_config_iotlab /root/.sfi/sfi_config')
34
35 os.system('cat /root/.sfi/sfi_config')
36 os.system('rm /root/tests_rspecs/iotlab_devlille_OUTPUT.rspec')
37
38 print " =================    SFI.PY LIST IOTLAB        ============="
39 os.system('sfi.py list iotlab')
40
41
42 print " =================    SFI.PY RESOURCES          ============="
43 raw_input("Press Enter to continue...")
44 os.system('sfi.py resources')
45
46
47 print " ================= SFI.PY RESOURCES -R IOTLAB        ============="
48 raw_input("Press Enter to continue...")
49 os.system('sfi.py resources -r iotlab')
50
51
52 print " =================    SFI.PY RESOURCES -L ALL      ============="
53 raw_input("Press Enter to continue...")
54 os.system('sfi.py resources -l all')
55
56 print " ================= SFI.PY RESOURCES -R IOTLAB -L ALL ============="
57 raw_input("Press Enter to continue...")
58 os.system('sfi.py resources -r iotlab -l all')
59
60 print " ================= SFI.PY RESOURCES -O  output rspec ==========="
61 os.system('sfi.py resources -o /root/tests_rspecs/iotlab_devlille_OUTPUT.rspec')
62
63 print " ================= SFI.PY RESOURCES -L LEASES  ============="
64 raw_input("Press Enter to continue...")
65 os.system('sfi.py resources -l leases')
66
67
68 print " =================    SFI.PY SHOW USER   ============="
69 raw_input("Press Enter to continue...")
70 os.system('sfi.py show iotlab.avakian')
71
72 print " =================    SFI.PY SHOW NODE   ============="
73 os.system('sfi.py show iotlab.node6.devlille.senslab.info')
74
75 print " =================    SFI.PY SLICES       ============="
76 raw_input("Press Enter to continue...")
77 os.system('sfi.py slices')
78
79 print " =================    SFI.PY STATUS SLICE   ============="
80 os.system('sfi.py status iotlab.avakian_slice')
81
82 print " =================    SFI.PY CREATE SLICE  on iotlab only  ============="
83 raw_input("Press Enter to continue...")
84 os.system('sfi.py create iotlab.avakian_slice /root/tests_rspecs/iotlab_devlille.rspec')
85
86
87 print " ================= SFI.PY RESOURCES -l all iotlab.avakian_slice ============="
88 raw_input("Press Enter to continue...")
89 os.system('sfi.py resources -l all iotlab.avakian_slice')
90
91
92 print " =================    SFI.PY DELETE SLICE   ============="
93 raw_input("Press Enter to continue...")
94 os.system('sfi.py delete iotlab.avakian_slice')
95
96
97 print " =================    SFI.PY CREATE SLICE  on iotlab and firexp  ============="
98 raw_input("Press Enter to continue...")
99 os.system('sfi.py create iotlab.avakian_slice /root/tests_rspecs/test_bidir.rspec')
100
101
102 print " ================= SFI.PY RESOURCES -l all -r iotlab iotlab.avakian_slice ============="
103 raw_input("Press Enter to continue...")
104 os.system('sfi.py resources -l all -r iotlab iotlab.avakian_slice')
105
106
107 print " =================SFI.PY RESOURCES -L LEASES -R IOTLAB ============== "
108 os.system('sfi.py resources -r iotlab -l leases')
109
110
111 print " =================    SFI.PY DELETE SLICE   ============="
112 raw_input("Press Enter to continue...")
113 os.system('sfi.py delete iotlab.avakian_slice')
114
115 print "\r\n \r\n"
116
117 print " *********changing to firexp sfi config ***************"
118 os.system('cp /root/.sfi/sfi_config_firexp /root/.sfi/sfi_config')
119
120
121
122 print " =================    SFI.PY CREATE SLICE  on iotlab and firexp  ============="
123 raw_input("Press Enter to continue...")
124 os.system('sfi.py create firexp.flab.iotlab_slice /root/tests_rspecs/mynodes.rspec')
125
126
127 print " =================    SFI.PY SHOW SLICE   ============="
128 raw_input("Press Enter to continue...")
129 os.system('sfi.py show firexp.flab.iotlab_slice')
130
131
132 print " ================= SFI.PY RESOURCES -l leases firexp.flab.iotlab_slice ============="
133 raw_input("Press Enter to continue...")
134 os.system('sfi.py resources -l leases firexp.flab.iotlab_slice')
135
136
137 print " ================= SFI.PY RESOURCES firexp.flab.iotlab_slice  ============="
138 raw_input("Press Enter to continue...")
139 os.system('sfi.py resources firexp.flab.iotlab_slice')
140
141
142
143