Add a constant value for instance communcation tap prefix "gnt.com.", named INSTANCE_COMMUNICATION_TAP_PREFIX.
Signed-off-by: Dimitris Bliablias <db...@skroutz.gr> --- lib/hypervisor/hv_base.py | 6 +++--- lib/hypervisor/hv_xen.py | 3 ++- src/Ganeti/Constants.hs | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/hypervisor/hv_base.py b/lib/hypervisor/hv_base.py index d4261c6..cb53ccd 100644 --- a/lib/hypervisor/hv_base.py +++ b/lib/hypervisor/hv_base.py @@ -196,8 +196,8 @@ def GenerateTapName(): if len(parts) < 2: raise errors.HypervisorError("Failed to parse TUN/TAP interfaces") - r = re.match(r"gnt\.com\.([0-9]+)", parts[1]) - + r = re.match(r"%s([0-9]+)" % constants.INSTANCE_COMMUNICATION_TAP_PREFIX, + parts[1]) if r is not None: idxs.add(int(r.group(1))) @@ -206,7 +206,7 @@ def GenerateTapName(): else: idx = 0 - return "gnt.com.%d" % idx + return "".join((constants.INSTANCE_COMMUNICATION_TAP_PREFIX, str(idx))) def ConfigureNIC(cmd, instance, seq, nic, tap): diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index 2bf021f..7a98a2f 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -899,7 +899,8 @@ class XenHypervisor(hv_base.BaseHypervisor): result.output, stashed_config)) for nic_seq, nic in enumerate(instance.nics): - if nic.name and nic.name.startswith("gnt.com."): + if (nic.name and + nic.name.startswith(constants.INSTANCE_COMMUNICATION_TAP_PREFIX)): _ConfigureNIC(instance, nic_seq, nic, nic.name) def StopInstance(self, instance, force=False, retry=False, name=None, diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs index 7e81446..cf0e689 100644 --- a/src/Ganeti/Constants.hs +++ b/src/Ganeti/Constants.hs @@ -5463,6 +5463,9 @@ instanceCommunicationNetworkMode = nicModeRouted instanceCommunicationNicPrefix :: String instanceCommunicationNicPrefix = "ganeti:communication:" +instanceCommunicationTapPrefix :: String +instanceCommunicationTapPrefix = "gnt.com." + -- | Parameters that should be protected -- -- Python does not have a type system and can't automatically infer what should -- 2.1.4