Ejemplo n.º 1
0
 def delete_backup(self, name):
     try:
         stub = medusa_pb2_grpc.MedusaStub(self.channel)
         request = medusa_pb2.DeleteBackupRequest(name=name)
         stub.DeleteBackup(request)
     except grpc.RpcError as e:
         logging.error("Failed to delete backup for name: {} due to error: {}".format(name, e))
Ejemplo n.º 2
0
 def backup_exists(self, name):
     try:
         stub = medusa_pb2_grpc.MedusaStub(self.channel)
         request = medusa_pb2.BackupStatusRequest(backupName=name)
         stub.BackupStatus(request)
         return True
     except grpc.RpcError as e:
         logging.error("Failed to determine if backup exists for backup name: {} due to error: {}".format(name, e))
         return False
Ejemplo n.º 3
0
 def get_backup_status(self, name):
     try:
         stub = medusa_pb2_grpc.MedusaStub(self.channel)
         request = medusa_pb2.BackupStatusRequest(backupName=name)
         resp = stub.BackupStatus(request)
         return resp.status
     except grpc.RpcError as e:
         logging.error("Failed to determine backup status for name: {} due to error: {}".format(name, e))
         return medusa_pb2.StatusType.UNKNOWN
Ejemplo n.º 4
0
 def get_backups(self):
     try:
         stub = medusa_pb2_grpc.MedusaStub(self.channel)
         request = medusa_pb2.GetBackupsRequest()
         response = stub.GetBackups(request)
         return response.backups
     except grpc.RpcError as e:
         logging.error("Failed to obtain list of backups due to error: {}".format(e))
         return None
Ejemplo n.º 5
0
 def create_backup_stub(self, mode):
     stub = medusa_pb2_grpc.MedusaStub(self.channel)
     if mode == "differential":
         backup_mode = 0
     elif mode == "full":
         backup_mode = 1
     else:
         raise RuntimeError("{} is not a recognized backup mode".format(mode))
     return backup_mode, stub
Ejemplo n.º 6
0
 def backup_exists(self, name):
     stub = medusa_pb2_grpc.MedusaStub(self.channel)
     try:
         request = medusa_pb2.BackupStatusRequest(backupName=name)
         stub.BackupStatus(request)
         return True
     except grpc.RpcError as e:
         if e.code() == grpc.StatusCode.NOT_FOUND:
             return False
         raise e
Ejemplo n.º 7
0
    def backup(self, name, mode):
        stub = medusa_pb2_grpc.MedusaStub(self.channel)
        if mode == "differential":
            backup_mode = 0
        elif mode == "full":
            backup_mode = 1
        else:
            raise Exception("{} is not a recognized backup mode".format(mode))

        request = medusa_pb2.BackupRequest(name=name, mode=backup_mode)
        return stub.Backup(request)
Ejemplo n.º 8
0
 def get_backups(self):
     stub = medusa_pb2_grpc.MedusaStub(self.channel)
     request = medusa_pb2.GetBackupsRequest()
     response = stub.GetBackups(request)
     return response.backups
Ejemplo n.º 9
0
 def delete_backup(self, name):
     stub = medusa_pb2_grpc.MedusaStub(self.channel)
     request = medusa_pb2.DeleteBackupRequest(name=name)
     stub.DeleteBackup(request)