Exemplo n.º 1
0
    def GetBackups(self, request, context):
        response = medusa_pb2.GetBackupsResponse()
        try:
            backups = medusa.listing.get_backups(self.config, True)
            for backup in backups:
                summary = medusa_pb2.BackupSummary()
                summary.backupName = backup.name
                if backup.started is None:
                    summary.starTime = 0
                else:
                    summary.startTime = backup.started
                if backup.finished is None:
                    summary.finishTime = 0
                else:
                    summary.finishTime = backup.finished
                summary.totalNodes = len(backup.tokenmap)
                summary.finishedNodes = len(backup.complete_nodes())
                for node in backup.tokenmap:
                    tokenmapNode = medusa_pb2.BackupNode()
                    tokenmapNode.host = node
                    tokenmapNode.datacenter = backup.tokenmap[node][
                        "dc"] if "dc" in backup.tokenmap[node] else ""
                    tokenmapNode.rack = backup.tokenmap[node][
                        "rack"] if "rack" in backup.tokenmap[node] else ""
                    if "tokens" in backup.tokenmap[node]:
                        for token in backup.tokenmap[node]["tokens"]:
                            tokenmapNode.tokens.append(token)
                    summary.nodes.append(tokenmapNode)
                response.backups.append(summary)

            return response
        except Exception as e:
            context.set_details("failed to get backups: {}".format(e))
            context.set_code(grpc.StatusCode.INTERNAL)
            return response
Exemplo n.º 2
0
    def GetBackups(self, request, context):
        response = medusa_pb2.GetBackupsResponse()
        last_status = medusa_pb2.StatusType.UNKNOWN
        try:
            # cluster backups
            backups = get_backups(self.config, True)
            for backup in backups:
                summary = medusa_pb2.BackupSummary()
                summary.backupName = backup.name
                if backup.started is None:
                    summary.startTime = 0
                else:
                    summary.startTime = backup.started

                if backup.finished is None:
                    summary.finishTime = 0
                    summary.status = medusa_pb2.StatusType.IN_PROGRESS
                    last_status = medusa_pb2.StatusType.IN_PROGRESS
                else:
                    summary.finishTime = backup.finished
                    if last_status != medusa_pb2.StatusType.IN_PROGRESS:
                        summary.status = medusa_pb2.StatusType.SUCCESS

                summary.totalNodes = len(backup.tokenmap)
                summary.finishedNodes = len(backup.complete_nodes())

                for node in backup.tokenmap:
                    summary.nodes.append(create_token_map_node(backup, node))

                response.backups.append(summary)

        except Exception as e:
            context.set_details(
                "Failed to get backups due to error: {}".format(e))
            context.set_code(grpc.StatusCode.INTERNAL)
            response.status = medusa_pb2.StatusType.UNKNOWN
        return response
Exemplo n.º 3
0
    def GetBackups(self, request, context):
        response = medusa_pb2.GetBackupsResponse()
        try:
            backups = medusa.listing.get_backups(self.config, True)
            for backup in backups:
                summary = medusa_pb2.BackupSummary()
                summary.backupName = backup.name
                if backup.started is None:
                    summary.starTime = 0
                else:
                    summary.startTime = backup.started
                if backup.finished is None:
                    summary.finishTime = 0
                else:
                    summary.finishTime = backup.finished
                summary.totalNodes = len(backup.tokenmap)
                summary.finishedNodes = len(backup.complete_nodes())
                response.backups.append(summary)

            return response
        except Exception as e:
            context.set_details("failed to get backups: {}".format(e))
            context.set_code(grpc.StatusCode.INTERNAL)
            return response