def saveInitialSnapshot(self, logLevel=logging.INFO):
     log.info("=== Saving initial snapshot on node %s", self.name())
     if self.imageMode() == "snapshot":
         self.saveSnapshot("initial", logLevel)
     elif self.imageMode() == "persistent":
         self.shutdown(waitForState=True)
         bigtest.run("rm -f %s.initial" % self.image())
         bigtest.run("cp %s %s.initial" % (self.image(), self.image()))
         self.powerOn()
     log.info("=== Finished saving initial snapshot on node %s", self.name())
Exemple #2
0
 def saveInitialSnapshot(self, logLevel=logging.INFO):
     log.info("=== Saving initial snapshot on node %s", self.name())
     if self.imageMode() == "snapshot":
         self.saveSnapshot("initial", logLevel)
     elif self.imageMode() == "persistent":
         self.shutdown(waitForState=True)
         bigtest.run("rm -f %s.initial" % self.image())
         bigtest.run("cp %s %s.initial" % (self.image(), self.image()))
         self.powerOn()
     log.info("=== Finished saving initial snapshot on node %s",
              self.name())
 def revertToInitialSnapshot(self, logLevel=logging.INFO):
     log.info("=== Reverting to initial snapshot on node %s", self.name())
     if self.imageMode() == "snapshot":
         self.revertToSnapshot("initial", logLevel)
         self.serialLogin(logLevel)
         cli = bigtest.cli.Cli(self.serialConsole(logLevel), self.imageType())
         cli.runCmd("sudo hwclock -s -u")
     elif self.imageMode() == "persistent":
         self.powerOff()
         bigtest.run("rm -f %s" % self.image())
         bigtest.run("cp %s.initial %s" % (self.image(), self.image()))
         self.powerOn()
     log.info("=== Finished reverting to initial snapshot on node %s", self.name())
Exemple #4
0
 def stop(self):
     bigtest.tryToStopProcess(bigtest.readPidFile(os.path.join(self.statedir_, "pid")))
     bridges, intfBridges = bigtest.bridgeInfo()
     config = self.config()
     sw = 0
     for vlans in config.get("switch_intf_vlans"):
         intf = 0
         for v in vlans:
             bridge = intfBridges.get("%s.%s" % (self.name_, v))
             if os.path.exists("/sys/class/net/%s" % bridge):
                 bigtest.sudo(["ifconfig", bridge, "down"])
                 bigtest.sudo(["brctl", "delbr", bridge])
             intf += 1
         sw += 1
     bigtest.run(["rm", "-rf", self.statedir_])
Exemple #5
0
 def revertToInitialSnapshot(self, logLevel=logging.INFO):
     log.info("=== Reverting to initial snapshot on node %s", self.name())
     if self.imageMode() == "snapshot":
         self.revertToSnapshot("initial", logLevel)
         self.serialLogin(logLevel)
         cli = bigtest.cli.Cli(self.serialConsole(logLevel),
                               self.imageType())
         cli.runCmd("sudo hwclock -s -u")
     elif self.imageMode() == "persistent":
         self.powerOff()
         bigtest.run("rm -f %s" % self.image())
         bigtest.run("cp %s.initial %s" % (self.image(), self.image()))
         self.powerOn()
     log.info("=== Finished reverting to initial snapshot on node %s",
              self.name())
Exemple #6
0
 def stop(self):
     bigtest.tryToStopProcess(
         bigtest.readPidFile(os.path.join(self.statedir_, "pid")))
     bridges, intfBridges = bigtest.bridgeInfo()
     config = self.config()
     sw = 0
     for vlans in config.get("switch_intf_vlans"):
         intf = 0
         for v in vlans:
             bridge = intfBridges.get("%s.%s" % (self.name_, v))
             if os.path.exists("/sys/class/net/%s" % bridge):
                 bigtest.sudo(["ifconfig", bridge, "down"])
                 bigtest.sudo(["brctl", "delbr", bridge])
             intf += 1
         sw += 1
     bigtest.run(["rm", "-rf", self.statedir_])
Exemple #7
0
 def start(self, controlBridge):
     bigtest.run(["rm", "-rf", self.statedir_])
     bigtest.run(["mkdir", "-p", self.statedir_])
     file(os.path.join(self.statedir_, "class"), "w").write(
         "%s.%s\n" % (self.__class__.__module__, self.__class__.__name__))
     config = self.config()
     x = config.get("host")
     if ":" in x:
         host, port = x.split(":")
     else:
         host, port = x, "5094"
     user = pwd.getpwuid(os.getuid())[0]
     try:
         bigtest.sudo(["openvpn", "--daemon", "--user", user,
                      "--writepid", os.path.join(self.statedir_, "pid"),
                      "--log", os.path.join(self.statedir_, "log"),
                      "--dev", self.name_, "--dev-type", "tap",
                      "--auth", "none", "--cipher", "none",
                      "--ping", "10", "--ping-restart", "60",
                      "--nobind", "--remote", host, port])
         for fn in ["log", "pid"]:
             bigtest.sudo(["chown", user, os.path.join(self.statedir_, fn)])
         bigtest.sudo(["ifconfig", self.name_, "up"])
         controlVlan = str(config.get("control_vlan"))
         bigtest.sudo(["vconfig", "add", self.name_, controlVlan])
         bigtest.sudo(["ifconfig", "%s.%s" % (self.name_, controlVlan), "up"])
         bigtest.sudo(["brctl", "addif", controlBridge, "%s.%s" % (self.name_, controlVlan)])
         sw = 0
         for vlans in config.get("switch_intf_vlans"):
             intf = 0
             for v in vlans:
                 vlan = "%s" % v
                 bridge = "%s-s%d-p%dbr" % (self.name_, sw, intf)
                 bigtest.sudo(["vconfig", "add", self.name_, vlan])
                 bigtest.sudo(["ifconfig", "%s.%s" % (self.name_, vlan), "up"])
                 if os.path.exists("/sys/class/net/%s" % bridge):
                     bigtest.sudo(["ifconfig", bridge, "down"])
                     bigtest.sudo(["brctl", "delbr", bridge])
                 bigtest.sudo(["brctl", "addbr", bridge])
                 bigtest.sudo(["ifconfig", bridge, "up"])
                 bigtest.sudo(["brctl", "addif", bridge, "%s.%s" % (self.name_, vlan)])
                 intf += 1
             sw += 1
         for i in reversed(range(10)):
             try:
                 bigtest.run(["ping", "-c", "2", config.get("control_ipaddr")])
                 break
             except bigtest.CalledProcessError:
                 if i < 1:
                     raise Exception("Failed to communicate with %s control address" % self.name_)
     except:
         bigtest.sudo(["cat", os.path.join(self.statedir_, "log")])
         raise
Exemple #8
0
 def stop(self):
     bigtest.run(["rm", "-rf", self.statedir_])
Exemple #9
0
 def setConsoleCommand(self, command):
     c = bigtest.run(["which", command], captureStdout=True)
     self._writeKeyValueToStateDir("command", c)
Exemple #10
0
 def start(self):
     bigtest.run(["rm", "-rf", self.statedir_])
     bigtest.run(["mkdir", "-p", self.statedir_])
     self._writeKeyValueToStateDir("class",
         "%s.%s\n" % (self.__class__.__module__, self.__class__.__name__))
Exemple #11
0
 def start(self, controlBridge):
     bigtest.run(["rm", "-rf", self.statedir_])
     bigtest.run(["mkdir", "-p", self.statedir_])
     file(os.path.join(self.statedir_, "class"), "w").write(
         "%s.%s\n" % (self.__class__.__module__, self.__class__.__name__))
     config = self.config()
     x = config.get("host")
     if ":" in x:
         host, port = x.split(":")
     else:
         host, port = x, "5094"
     user = pwd.getpwuid(os.getuid())[0]
     try:
         bigtest.sudo([
             "openvpn", "--daemon", "--user", user, "--writepid",
             os.path.join(self.statedir_, "pid"), "--log",
             os.path.join(self.statedir_,
                          "log"), "--dev", self.name_, "--dev-type", "tap",
             "--auth", "none", "--cipher", "none", "--ping", "10",
             "--ping-restart", "60", "--nobind", "--remote", host, port
         ])
         for fn in ["log", "pid"]:
             bigtest.sudo(["chown", user, os.path.join(self.statedir_, fn)])
         bigtest.sudo(["ifconfig", self.name_, "up"])
         controlVlan = str(config.get("control_vlan"))
         bigtest.sudo(["vconfig", "add", self.name_, controlVlan])
         bigtest.sudo(
             ["ifconfig",
              "%s.%s" % (self.name_, controlVlan), "up"])
         bigtest.sudo([
             "brctl", "addif", controlBridge,
             "%s.%s" % (self.name_, controlVlan)
         ])
         sw = 0
         for vlans in config.get("switch_intf_vlans"):
             intf = 0
             for v in vlans:
                 vlan = "%s" % v
                 bridge = "%s-s%d-p%dbr" % (self.name_, sw, intf)
                 bigtest.sudo(["vconfig", "add", self.name_, vlan])
                 bigtest.sudo(
                     ["ifconfig",
                      "%s.%s" % (self.name_, vlan), "up"])
                 if os.path.exists("/sys/class/net/%s" % bridge):
                     bigtest.sudo(["ifconfig", bridge, "down"])
                     bigtest.sudo(["brctl", "delbr", bridge])
                 bigtest.sudo(["brctl", "addbr", bridge])
                 bigtest.sudo(["ifconfig", bridge, "up"])
                 bigtest.sudo([
                     "brctl", "addif", bridge,
                     "%s.%s" % (self.name_, vlan)
                 ])
                 intf += 1
             sw += 1
         for i in reversed(range(10)):
             try:
                 bigtest.run(
                     ["ping", "-c", "2",
                      config.get("control_ipaddr")])
                 break
             except bigtest.CalledProcessError:
                 if i < 1:
                     raise Exception(
                         "Failed to communicate with %s control address" %
                         self.name_)
     except:
         bigtest.sudo(["cat", os.path.join(self.statedir_, "log")])
         raise