Пример #1
0
    def snapshot(self):
        logger.debug("Making snapshot")
        for obj_data in self.conf.objects:
            logger.debug("Dumping: %s", obj_data)
            driver = Driver.getDriver(obj_data, self.conf)
            driver.snapshot()
        logger.debug("Archiving dump directory: %s", self.conf.target)

        compress(self.conf.target, self.conf.compression_level)

        with open(self.conf.lastdump, "w") as fo:
            fo.write("{0}.tar.xz".format(self.conf.target))
        return "{0}.tar.xz".format(self.conf.target)
Пример #2
0
 def snapshot(self):
     logger.debug("Making snapshot")
     for obj_data in self.conf.objects:
         logger.debug("Dumping: %s", obj_data)
         driver = Driver.getDriver(obj_data, self.conf)
         driver.snapshot()
     logger.debug("Archiving dump directory: %s", self.conf.target)
     execute("tar zcf {0}.tgz -C {1} {2}"
             "".format(self.conf.target, os.path.dirname(self.conf.target),
                       os.path.basename(self.conf.target)))
     execute("rm -r {0}".format(self.conf.target))
     with open(self.conf.lastdump, "w") as fo:
         fo.write("{0}.tgz".format(self.conf.target))
     return "{0}.tgz".format(self.conf.target)
Пример #3
0
    def snapshot(self):
        logger.debug("Making snapshot")
        utils.execute("rm -rf {0}".format(os.path.dirname(self.conf.target)))
        for obj_data in self.conf.objects:
            logger.debug("Dumping: %s", obj_data)
            driver = Driver.getDriver(obj_data, self.conf)
            driver.snapshot()
        logger.debug("Archiving dump directory: %s", self.conf.target)

        utils.compress(self.conf.target, self.conf.compression_level)

        with open(self.conf.lastdump, "w") as fo:
            fo.write("{0}.tar.xz".format(self.conf.target))
        return "{0}.tar.xz".format(self.conf.target)
Пример #4
0
 def snapshot(self):
     logger.debug("Making snapshot")
     for obj_data in self.conf.objects:
         logger.debug("Dumping: %s", obj_data)
         driver = Driver.getDriver(obj_data, self.conf)
         driver.snapshot()
     logger.debug("Archiving dump directory: %s", self.conf.target)
     execute("tar zcf {0}.tgz -C {1} {2}"
             "".format(self.conf.target,
                       os.path.dirname(self.conf.target),
                       os.path.basename(self.conf.target)))
     execute("rm -r {0}".format(self.conf.target))
     with open(self.conf.lastdump, "w") as fo:
         fo.write("%s.tgz" % self.conf.target)
     return "%s.tgz" % self.conf.target
Пример #5
0
 def action_single(self, obj, action='snapshot'):
     driver = Driver.getDriver(obj, self.conf)
     try:
         return getattr(driver, action)()
     except fabric.exceptions.NetworkError:
         self.conf.on_network_error(obj)
Пример #6
0
 def action_single(self, object, action='snapshot'):
     driver = Driver.getDriver(object, self.conf)
     try:
         return getattr(driver, action)()
     except fabric.exceptions.NetworkError:
         self.conf.on_network_error(object)
Пример #7
0
import sys
import os
import json

sys.path[:0] = [os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))]

from shotgun.driver import Driver
from shotgun.config import Config

with open("snapshot.json", "r") as fo:
    data = json.loads(fo.read())
    config = Config(data)

data = list(config.objects)[0]
driver = Driver(data, config)

out = driver.command("ls -l /tmp | grep -v tmp")
print "return_code: %s" % out.return_code
print "out: %s" % out.stdout
print "err: %s" % out.stderr