Esempio n. 1
0
    def backup(self,
               name,
               snapshot_name,
               source,
               rbd,
               from_version,
               tag=None,
               expire=None,
               continue_version=None):
        expire_date = None
        if expire:
            try:
                expire_date = parse_expire_date(expire)
            except ValueError as e:
                logger.error(str(e))
                exit(1)

        backy = self.backy()
        hints = None
        if rbd:
            data = ''.join([line for line in fileinput.input(rbd).readline()])
            hints = hints_from_rbd_diff(data)
        if tag:
            tags = [t.strip() for t in list(csv.reader(StringIO(tag)))[0]]
        else:
            tags = None
        version_uid = backy.backup(name, snapshot_name, source, hints,
                                   from_version, tags, expire_date,
                                   continue_version)
        if self.machine_output:
            print(version_uid)
        backy.close()
Esempio n. 2
0
 def expire(self, version_uid, expire):
     if not expire:  # empty string
         expire_date = None
     else:
         try:
             expire_date = parse_expire_date(expire)
         except ValueError as e:
             logger.error(str(e))
             exit(1)
     try:
         backy = self.backy()
         backy.expire_version(version_uid, expire_date)
         backy.close()
     except:
         logger.warn('Unable to expire version.')