Changeset a0c12a6
- Timestamp:
- Jun 5, 2009 1:57:35 PM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- f4cc4b7
- Parents:
- b535e19
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/experiment_control.py
rb535e19 ra0c12a6 589 589 # return value. If we successfully parsed a "none" outcome, ignore the 590 590 # return code. 591 if rv != 0 and state != "none":591 if rv != 0 and state != 'none': 592 592 raise service_error(service_error.internal, 593 593 "Cannot get status of segment %s:%s/%s" % (tb, pid, eid)) 594 595 if state not in ('active', 'swapped', 'none'): 596 self.log.debug("[start_segment]:unknown state %s" % state) 597 return False 594 598 595 599 self.log.debug("[start_segment]: %s: %s" % (tb, state)) … … 611 615 return False 612 616 613 if state == ' active':614 # Create the federation config dirs (do not move outside the615 # conditional. Happens later in new expriment creation)616 if not self.ssh_cmd(user, host,617 "/bin/sh -c \"'mkdir -p %s'\"" % proj_dir):617 if state == 'none': 618 # Create a null copy of the experiment so that we capture any logs 619 # there if the modify fails. Emulab software discards the logs 620 # from a failed startexp 621 if not self.scp_file("%s/null.tcl" % tmpdir, user, host): 618 622 return False 619 # Remote experiment is active. Modify it. 620 for f in base_confs: 621 if not self.scp_file("%s/%s" % (tmpdir, f), user, host, 622 "%s/%s" % (proj_dir, f)): 623 return False 624 if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb), 625 proj_dir): 623 self.log.info("[start_segment]: Creating %s on %s" % (eid, tb)) 624 if not self.ssh_cmd(user, host, 625 "/usr/testbed/bin/startexp -i -f -w -p %s -e %s null.tcl" \ 626 % (pid, eid), "startexp"): 626 627 return False 627 if os.path.isdir("%s/tarfiles" % tmpdir): 628 if not self.ship_configs(host, user, 629 "%s/tarfiles" % tmpdir, tarfiles_dir): 630 return False 631 if os.path.isdir("%s/rpms" % tmpdir): 632 if not self.ship_configs(host, user, 633 "%s/rpms" % tmpdir, tarfiles_dir): 634 return False 635 self.log.info("[start_segment]: Modifying %s on %s" % (eid, tb)) 636 if not self.ssh_cmd(user, host, 637 "/usr/testbed/bin/modexp -r -s -w %s %s %s" % \ 638 (pid, eid, tclfile), "modexp"): 628 629 # Create the federation config dirs 630 if not self.ssh_cmd(user, host, 631 "/bin/sh -c \"'mkdir -p %s'\"" % proj_dir): 632 return False 633 for f in base_confs: 634 if not self.scp_file("%s/%s" % (tmpdir, f), user, host, 635 "%s/%s" % (proj_dir, f)): 639 636 return False 640 return True641 elif state == "swapped":642 # Create the federation config dirs (do not move outside the643 # conditional. Happens later in new expriment creation)644 if not self.s sh_cmd(user, host,645 " /bin/sh -c \"'mkdir -p %s'\"" % proj_dir):637 if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb), 638 proj_dir): 639 return False 640 if os.path.isdir("%s/tarfiles" % tmpdir): 641 if not self.ship_configs(host, user, 642 "%s/tarfiles" % tmpdir, tarfiles_dir): 646 643 return False 647 # Remote experiment swapped out. Modify it and swap it in. 648 for f in base_confs: 649 if not self.scp_file("%s/%s" % (tmpdir, f), user, host, 650 "%s/%s" % (proj_dir, f)): 651 return False 652 if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb), 653 proj_dir): 644 if os.path.isdir("%s/rpms" % tmpdir): 645 if not self.ship_configs(host, user, 646 "%s/rpms" % tmpdir, tarfiles_dir): 654 647 return False 655 if os.path.isdir("%s/tarfiles" % tmpdir): 656 if not self.ship_configs(host, user, 657 "%s/tarfiles" % tmpdir, tarfiles_dir): 658 return False 659 if os.path.isdir("%s/rpms" % tmpdir): 660 if not self.ship_configs(host, user, 661 "%s/rpms" % tmpdir, tarfiles_dir): 662 return False 663 self.log.info("[start_segment]: Modifying %s on %s" % (eid, tb)) 664 if not self.ssh_cmd(user, host, 665 "/usr/testbed/bin/modexp -w %s %s %s" % (pid, eid, tclfile), 666 "modexp"): 667 return False 668 self.log.info("[start_segment]: Swapping %s in on %s" % (eid, tb)) 648 # Stage the new configuration (active experiments will stay swapped in 649 # now) 650 self.log.info("[start_segment]: Modifying %s on %s" % (eid, tb)) 651 if not self.ssh_cmd(user, host, 652 "/usr/testbed/bin/modexp -r -s -w %s %s %s" % \ 653 (pid, eid, tclfile), 654 "modexp"): 655 return False 656 # Active experiments are still swapped, this swaps the others in. 657 if state != 'active': 658 self.log.info("[start_segment]: Swapping %s in on %s" % \ 659 (eid, tb)) 669 660 if not self.ssh_cmd(user, host, 670 661 "/usr/testbed/bin/swapexp -w %s %s in" % (pid, eid), 671 662 "swapexp"): 672 663 return False 673 return True 674 elif state == "none": 675 # No remote experiment. Create one. We do this in 2 steps so we 676 # can put the configuration files and scripts into the new 677 # experiment directories. 678 679 # Tarfiles must be present for creation to work 680 if os.path.isdir("%s/tarfiles" % tmpdir): 681 if not self.ship_configs(host, user, 682 "%s/tarfiles" % tmpdir, tarfiles_dir): 683 return False 684 if os.path.isdir("%s/rpms" % tmpdir): 685 if not self.ship_configs(host, user, 686 "%s/rpms" % tmpdir, tarfiles_dir): 687 return False 688 self.log.info("[start_segment]: Creating %s on %s" % (eid, tb)) 689 if not self.ssh_cmd(user, host, 690 "/usr/testbed/bin/startexp -i -f -w -p %s -e %s %s" % \ 691 (pid, eid, tclfile), "startexp"): 692 return False 693 # Create the federation config dirs (do not move outside the 694 # conditional.) 695 if not self.ssh_cmd(user, host, 696 "/bin/sh -c \"'mkdir -p %s'\"" % proj_dir): 697 return False 698 # After startexp the per-experiment directories exist 699 for f in base_confs: 700 if not self.scp_file("%s/%s" % (tmpdir, f), user, host, 701 "%s/%s" % (proj_dir, f)): 702 return False 703 if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb), 704 proj_dir): 705 return False 706 self.log.info("[start_segment]: Swapping %s in on %s" % (eid, tb)) 707 if not self.ssh_cmd(user, host, 708 "/usr/testbed/bin/swapexp -w %s %s in" % (pid, eid), 709 "swapexp"): 710 return False 711 return True 712 else: 713 self.log.debug("[start_segment]:unknown state %s" % state) 714 return False 664 return True 715 665 716 666 def stop_segment(self, tb, eid, tbparams): … … 1760 1710 self.copy_file(r, "%s/rpms/%s" % \ 1761 1711 (tmpdir, os.path.basename(r))) 1712 # A null experiment file in case we need to create a remote 1713 # experiment from scratch 1714 f = open("%s/null.tcl" % tmpdir, "w") 1715 print >>f, """ 1716 set ns [new Simulator] 1717 source tb_compat.tcl 1718 1719 set a [$ns node] 1720 1721 $ns rtproto Session 1722 $ns run 1723 """ 1724 f.close() 1725 1762 1726 except IOError, e: 1763 1727 raise service_error(service_error.internal,
Note: See TracChangeset
for help on using the changeset viewer.