From 3c03759a671d30a7c2bfa15c335460870166fd6c Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 29 Sep 2008 13:15:33 +0000
Subject: [PATCH] Move a hardcoded constant to constants.py
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

For now we only use the β€˜C’ protocol so we can put it in constants.py
instead of hardcoding it.

Reviewed-by: imsnah
---
 lib/bdev.py      | 9 ++++++---
 lib/constants.py | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/bdev.py b/lib/bdev.py
index 8910f8006..2d16666bb 100644
--- a/lib/bdev.py
+++ b/lib/bdev.py
@@ -1253,7 +1253,8 @@ class DRBD8(BaseDRBD):
         res_r = self._AssembleNet(minor,
                                   (self._lhost, self._lport,
                                    self._rhost, self._rport),
-                                  "C", hmac=constants.DRBD_HMAC_ALG,
+                                  constants.DRBD_NET_PROTOCOL,
+                                  hmac=constants.DRBD_HMAC_ALG,
                                   secret=self._secret
                                   )
         if res_r:
@@ -1283,7 +1284,8 @@ class DRBD8(BaseDRBD):
         # local storage (i.e. one or more of the _[lr](host|port) is
         # None)
         if (self._AssembleNet(minor, (self._lhost, self._lport,
-                                      self._rhost, self._rport), "C",
+                                      self._rhost, self._rport),
+                              constants.DRBD_NET_PROTOCOL,
                               hmac=constants.DRBD_HMAC_ALG,
                               secret=self._secret) and
             self._MatchesNet(self._GetDevInfo(self._GetShowData(minor)))):
@@ -1337,7 +1339,8 @@ class DRBD8(BaseDRBD):
       result = self._AssembleNet(minor,
                                  (self._lhost, self._lport,
                                   self._rhost, self._rport),
-                                 "C", hmac=constants.DRBD_HMAC_ALG,
+                                 constants.DRBD_NET_PROTOCOL,
+                                 hmac=constants.DRBD_HMAC_ALG,
                                  secret=self._secret)
       if not result:
         if need_localdev_teardown:
diff --git a/lib/constants.py b/lib/constants.py
index f830f1437..c5bf7d6bb 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -178,6 +178,7 @@ LD_FILE = "file"
 
 # drbd constants
 DRBD_HMAC_ALG = "md5"
+DRBD_NET_PROTOCOL = "C"
 
 # file backend driver
 FD_LOOP = "loop"
-- 
GitLab