Welcome to mirror list, hosted at ThFree Co, Russian Federation.

protocolmessages.py « bsock « bareos - github.com/bareos/python-bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 78fb3a906452f1e9e20a41769b5ffa4f38c802ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Protocol messages between bareos-director and user-agent.
"""

from   bareos.bsock.connectiontype import ConnectionType

class ProtocolMessages():
    """
    strings defined by the protocol to talk to the Bareos Director.
    """
    @staticmethod
    def hello(name, type=ConnectionType.DIRECTOR):
        if type == ConnectionType.FILEDAEMON:
            return bytearray("Hello Director %s calling\n" % (name), 'utf-8')
        else:
            return bytearray("Hello %s calling\n" % (name), 'utf-8')

    #@staticmethod
    #def ok():
        #return "1000 OK:"

    @staticmethod
    def auth_ok():
        return b"1000 OK auth\n"

    @staticmethod
    def auth_failed():
        return b"1999 Authorization failed.\n"

    @staticmethod
    def is_auth_ok(msg):
        return msg == ProtocolMessages.auth_ok()