- Timestamp:
- Aug 21, 2008 11:49:16 AM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 1af38d6
- Parents:
- d0ae12d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_create_experiment.py
rd0ae12d r6546868 36 36 muxmax=2, 37 37 project_user = "faber", 38 # scp_exec="/bin/echo",39 38 scp_exec="/usr/bin/scp", 40 39 scripts_dir="./", 41 40 splitter=None, 42 # ssh_exec="/bin/echo",43 41 ssh_exec="/usr/bin/ssh", 44 42 ssh_identity_file=None, … … 49 47 tclsh="/usr/local/bin/otclsh", 50 48 tcl_splitter="/usr/testbed/lib/ns2ir/parse.tcl", 51 tmpdir="/tmp",52 49 trusted_certs=None, 53 50 ): … … 69 66 self.tcl_splitter = tcl_splitter 70 67 self.tbmap = tbmap 71 self.tmpdir = tmpdir72 self.tmpdir += "/split%d/" % os.getpid()73 68 self.trusted_certs=trusted_certs 74 69 … … 165 160 return True 166 161 167 def start_segment(self, tb, eid, tbparams, t imeout=0):162 def start_segment(self, tb, eid, tbparams, tmpdir, timeout=0): 168 163 host = "%s%s" % (tbparams[tb]['host'], tbparams[tb]['domain']) 169 164 user = tbparams[tb]['user'] … … 192 187 print "transferring experiment to %s" % tb 193 188 194 if not self.scp_file("%s/%s/%s" % (self.tmpdir, tb, tclfile), 195 user, host): 189 if not self.scp_file("%s/%s/%s" % (tmpdir, tb, tclfile), user, host): 196 190 return False 197 191 # Clear and create the tarfiles and rpm directories … … 207 201 # Remote experiment is active. Modify it. 208 202 for f in base_confs: 209 if not self.scp_file("%s/%s" % ( self.tmpdir, f), user, host,203 if not self.scp_file("%s/%s" % (tmpdir, f), user, host, 210 204 "%s/%s" % (proj_dir, f)): 211 205 return False 212 206 if not self.ship_scripts(host, user, proj_dir): 213 207 return False 214 if not self.ship_configs(host, user, "%s/%s" % ( self.tmpdir, tb),208 if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb), 215 209 proj_dir): 216 210 return False 217 if os.path.isdir("%s/tarfiles" % self.tmpdir):211 if os.path.isdir("%s/tarfiles" % tmpdir): 218 212 if not self.ship_configs(host, user, 219 "%s/tarfiles" % self.tmpdir, tarfiles_dir):220 return False 221 if os.path.isdir("%s/rpms" % self.tmpdir):213 "%s/tarfiles" % tmpdir, tarfiles_dir): 214 return False 215 if os.path.isdir("%s/rpms" % tmpdir): 222 216 if not self.ship_configs(host, user, 223 "%s/rpms" % self.tmpdir, tarfiles_dir):217 "%s/rpms" % tmpdir, tarfiles_dir): 224 218 return False 225 219 print "Modifying %s on %s" % (eid, tb) … … 232 226 # Remote experiment swapped out. Modify it and swap it in. 233 227 for f in base_confs: 234 if not self.scp_file("%s/%s" % ( self.tmpdir, f), user, host,228 if not self.scp_file("%s/%s" % (tmpdir, f), user, host, 235 229 "%s/%s" % (proj_dir, f)): 236 230 return False 237 231 if not self.ship_scripts(host, user, proj_dir): 238 232 return False 239 if not self.ship_configs(host, user, "%s/%s" % ( self.tmpdir, tb),233 if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb), 240 234 proj_dir): 241 235 return False 242 if os.path.isdir("%s/tarfiles" % self.tmpdir):236 if os.path.isdir("%s/tarfiles" % tmpdir): 243 237 if not self.ship_configs(host, user, 244 "%s/tarfiles" % self.tmpdir, tarfiles_dir):245 return False 246 if os.path.isdir("%s/rpms" % self.tmpdir):238 "%s/tarfiles" % tmpdir, tarfiles_dir): 239 return False 240 if os.path.isdir("%s/rpms" % tmpdir): 247 241 if not self.ship_configs(host, user, 248 "%s/rpms" % self.tmpdir, tarfiles_dir):242 "%s/rpms" % tmpdir, tarfiles_dir): 249 243 return False 250 244 print "Modifying %s on %s" % (eid, tb) … … 265 259 266 260 # Tarfiles must be present for creation to work 267 if os.path.isdir("%s/tarfiles" % self.tmpdir):261 if os.path.isdir("%s/tarfiles" % tmpdir): 268 262 if not self.ship_configs(host, user, 269 "%s/tarfiles" % self.tmpdir, tarfiles_dir):270 return False 271 if os.path.isdir("%s/rpms" % self.tmpdir):263 "%s/tarfiles" % tmpdir, tarfiles_dir): 264 return False 265 if os.path.isdir("%s/rpms" % tmpdir): 272 266 if not self.ship_configs(host, user, 273 "%s/rpms" % self.tmpdir, tarfiles_dir):267 "%s/rpms" % tmpdir, tarfiles_dir): 274 268 return False 275 269 print "Creating %s on %s" % (eid, tb) … … 280 274 # After startexp the per-experiment directories exist 281 275 for f in base_confs: 282 if not self.scp_file("%s/%s" % ( self.tmpdir, f), user, host,276 if not self.scp_file("%s/%s" % (tmpdir, f), user, host, 283 277 "%s/%s" % (proj_dir, f)): 284 278 return False 285 279 if not self.ship_scripts(host, user, proj_dir): 286 280 return False 287 if not self.ship_configs(host, user, "%s/%s" % ( self.tmpdir, tb),281 if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb), 288 282 proj_dir): 289 283 return False … … 903 897 904 898 def create_experiment(self, req, fid): 899 try: 900 tmpdir = tempfile.mkdtemp(prefix="split-") 901 except IOError: 902 raise service_error(service_error.internal, "Cannot create tmp dir") 903 905 904 gw_pubkey_base = "fed.%s.pub" % self.ssh_type 906 905 gw_secretkey_base = "fed.%s" % self.ssh_type 907 gw_pubkey = self.tmpdir + "/keys/" + gw_pubkey_base908 gw_secretkey = self.tmpdir + "/keys/" + gw_secretkey_base909 tclfile = self.tmpdir + "/experiment.tcl"906 gw_pubkey = tmpdir + "/keys/" + gw_pubkey_base 907 gw_secretkey = tmpdir + "/keys/" + gw_secretkey_base 908 tclfile = tmpdir + "/experiment.tcl" 910 909 tbparams = { } 911 910 … … 921 920 fail_soft = False 922 921 # XXX 923 startem = False 922 startem = True 923 924 924 925 925 try: 926 os.mkdir(self.tmpdir) 927 os.mkdir(self.tmpdir+"/keys") 926 os.mkdir(tmpdir+"/keys") 928 927 except OSError: 929 928 raise service_error(service_error.internal, … … 961 960 started = { } 962 961 963 parse_current_testbed = self.current_testbed(eid, self.tmpdir)962 parse_current_testbed = self.current_testbed(eid, tmpdir) 964 963 parse_allbeds = self.allbeds(self.get_access) 965 parse_gateways = self.gateways(eid, smbshare, master, self.tmpdir,964 parse_gateways = self.gateways(eid, smbshare, master, tmpdir, 966 965 gw_pubkey_base, gw_secretkey_base, self.copy_file) 967 966 parse_vtopo = self.shunt_to_file("^#\s+Begin\s+Vtopo", 968 "^#\s+End\s+Vtopo", self.tmpdir + "/vtopo.xml")967 "^#\s+End\s+Vtopo", tmpdir + "/vtopo.xml") 969 968 parse_hostnames = self.shunt_to_file("^#\s+Begin\s+hostnames", 970 "^#\s+End\s+hostnames", self.tmpdir + "/hosts")969 "^#\s+End\s+hostnames", tmpdir + "/hosts") 971 970 parse_tarfiles = self.shunt_to_list("^#\s+Begin\s+tarfiles", 972 971 "^#\s+End\s+tarfiles") … … 994 993 "Bad tcl parse? %s" % line) 995 994 996 self.genviz( self.tmpdir + "/vtopo.xml", self.tmpdir + "/viz.xml")995 self.genviz(tmpdir + "/vtopo.xml", tmpdir + "/viz.xml") 997 996 if not startem: return True 998 997 … … 1000 999 try: 1001 1000 for t in parse_tarfiles.list: 1002 if not os.path.exists("%s/tarfiles" % self.tmpdir):1003 os.mkdir("%s/tarfiles" % self.tmpdir)1001 if not os.path.exists("%s/tarfiles" % tmpdir): 1002 os.mkdir("%s/tarfiles" % tmpdir) 1004 1003 self.copy_file(t, "%s/tarfiles/%s" % \ 1005 ( self.tmpdir, os.path.basename(t)))1004 (tmpdir, os.path.basename(t))) 1006 1005 for r in parse_rpms.list: 1007 if not os.path.exists("%s/rpms" % self.tmpdir):1008 os.mkdir("%s/rpms" % self.tmpdir)1006 if not os.path.exists("%s/rpms" % tmpdir): 1007 os.mkdir("%s/rpms" % tmpdir) 1009 1008 self.copy_file(r, "%s/rpms/%s" % \ 1010 ( self.tmpdir, os.path.basename(r)))1009 (tmpdir, os.path.basename(r))) 1011 1010 except IOError, e: 1012 1011 raise service_error(service_error.internal, … … 1016 1015 for tb in allocated.iterkeys(): 1017 1016 if tb != master: 1018 if self.start_segment(tb, eid, tbparams, 0):1017 if self.start_segment(tb, eid, tbparams, tmpdir, 0): 1019 1018 started[tb] = True 1020 1019 else: … … 1022 1021 1023 1022 if len(started) == len(allocated)-1: 1024 if self.start_segment(master, eid, tbparams ):1023 if self.start_segment(master, eid, tbparams, tmpdir): 1025 1024 started[master] = True 1026 1025
Note: See TracChangeset
for help on using the changeset viewer.