command: Add in support for IP address-based connections
This allows our users to set preferred-device to an IP address and bypass the
avahi discovery routines.
Change-Id: Ib17d1eac940ba4412c5a0a9889bb9f51540be368
diff --git a/mdt/command.py b/mdt/command.py
index 79064b4..698281e 100644
--- a/mdt/command.py
+++ b/mdt/command.py
@@ -15,6 +15,7 @@
'''
+import re
import os
import socket
@@ -28,6 +29,9 @@
from mdt import sshclient
+IP_ADDR_REGEX = re.compile('[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
+
+
class NetworkCommand:
def __init__(self):
self.config = config.Config()
@@ -46,6 +50,9 @@
if not self.preConnectRun(args):
return 1
+ if self.device and IP_ADDR_REGEX.match(self.device):
+ self.address = self.device
+
if not self.address:
if self.device:
print('Waiting for device {0}...'.format(self.device))