Esempio n. 1
0
 def get(cls, phase, proc, volume):
     """
     get all the backups of the given proc's volume
     """
     check_phase(phase[0])
     appname = lain_yaml_data()['appname']
     route = "api/v2/app/%s/proc/%s/backups?volume=%s" % (appname, proc[0], volume[0])
     data = cls._request('GET', phase[0], route, None)
     if data:
         print json.dumps(data, indent=2)
Esempio n. 2
0
 def delete(cls, phase, proc, files):
     """
     delete a backup of a proc
     """
     check_phase(phase[0])
     appname = lain_yaml_data()['appname']
     route = "api/v2/app/%s/proc/%s/backups/actions/delete" % (appname, proc[0])
     data = cls._request('POST', phase[0], route, {'files': files})
     if data:
         print data
Esempio n. 3
0
 def jobs(cls, phase):
     """
     list backup jobs for this lain app
     """
     check_phase(phase)
     appname = lain_yaml_data()['appname']
     route = "api/v2/app/%s/cron/jobs" % appname
     data = cls._request('GET', phase, route, None)
     if data:
         print json.dumps(data, indent=2)
Esempio n. 4
0
 def run(cls, phase, id):
     """
     run a job right now
     """
     check_phase(phase[0])
     appname = lain_yaml_data()['appname']
     route = "api/v2/app/%s/cron/jobs/%s/actions/run" % (appname, id[0])
     data = cls._request('POST', phase[0], route, None)
     if data:
         print data
Esempio n. 5
0
 def list(cls, phase, proc, path):
     """
     list files in the incremental backup direcotry
     """
     check_phase(phase[0])
     appname = lain_yaml_data()['appname']
     route = "api/v2/app/%s/proc/%s/backups/%s?open=true" % (appname, proc[0], path[0])
     data = cls._request('GET', phase[0], route, None)
     if data:
         print "%-10sFILENAME" % "SIZE"
         for item in data:
             print "%-10s%s%s" % (item['size'], item['name'], '/' if item['dir'] else '')
Esempio n. 6
0
 def recover(cls, phase, proc, backup, files):
     """
     recover the volume from given backup
     """
     check_phase(phase[0])
     appname = lain_yaml_data()['appname']
     if not files:
         route = "api/v2/app/%s/proc/%s/backups/%s/actions/recover" % (appname, proc[0], backup[0])
         data = cls._request('POST', phase[0], route, None)
     else:
         route = "api/v2/app/%s/proc/%s/backups/%s/actions/recover" % (appname, proc[0], backup[0])
         data = cls._request('POST', phase[0], route, {"files": files})
     if data:
         data
Esempio n. 7
0
 def records(cls, phase, rid, num=10):
     """
     list job records of this lain app
     """
     check_phase(phase[0])
     appname = lain_yaml_data()['appname']
     route = "api/v2/app/%s/cron/records" % appname
     if rid:
         route = "%s/%s" % (route, rid)
     else:
         route += "?total=%d" % num
     data = cls._request('GET', phase[0], route, None)
     if data:
         print json.dumps(data, indent=2)
Esempio n. 8
0
 def migrate(cls, phase, proc, backup, files, volume="", to=0):
     """
     recover a instance's volume from other instance's backup
     """
     check_phase(phase[0])
     appname = lain_yaml_data()['appname']
     if not files:
         route = "api/v2/app/%s/proc/%s/backups/%s/actions/migrate" % (appname, proc[0], backup[0])
         data = cls._request('POST', phase[0], route, {"volume": volume, "to": to})
     else:
         route = "api/v2/app/%s/proc/%s/backups/%s/actions/migrate" % (appname, proc[0], backup[0])
         data = cls._request('POST', phase[0], route, {"volume": volume, "to": to, "files": files})
     if data:
         data