Skip to content

Commit

Permalink
python-bareos: improve protocolversion handling
Browse files Browse the repository at this point in the history
  • Loading branch information
joergsteffens authored and BareosBot committed Apr 8, 2024
1 parent fbd3f8a commit 2281afb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions python-bareos/bareos/bsock/directorconsole.py
Expand Up @@ -104,9 +104,11 @@ def argparser_add_default_command_line_arguments(argparser):

group.add_argument(
"--protocolversion",
default=ProtocolVersions.last,
type=int,
help="Specify the Bareos console protocol version. Default: %(default)s (current).",
choices=set(protocolversion.value for protocolversion in ProtocolVersions)
| set([0]),
default=ProtocolVersions.last.value,
help="Specify the Bareos console protocol version (0: auto-detect, %(default)s: latest). Default: %(default)s.",
dest="BAREOS_protocolversion",
)

Expand Down Expand Up @@ -192,7 +194,7 @@ def __init__(
if tls_version is not None:
self.tls_version = tls_version
self.identity_prefix = "R_CONSOLE"
if protocolversion is not None:
if protocolversion is not None and protocolversion > 0:
self.requested_protocol_version = int(protocolversion)
self.protocol_messages.set_version(self.requested_protocol_version)
self.connect(
Expand Down
6 changes: 4 additions & 2 deletions python-bareos/bareos/bsock/protocolversions.py
@@ -1,6 +1,6 @@
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2021 Bareos GmbH & Co. KG
# Copyright (C) 2019-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand All @@ -21,8 +21,10 @@
Bareos Protocol Versions.
"""

from enum import IntEnum

class ProtocolVersions(object):

class ProtocolVersions(IntEnum):
"""
Bareos Protocol Versions.
"""
Expand Down

0 comments on commit 2281afb

Please sign in to comment.