argument checking refactored
@@ -85,13 +85,15 @@ class FoglampProcess(ABC):
self._name = getattr(namespace, 'name')
self._core_management_host = getattr(namespace, 'address')
self._core_management_port = getattr(namespace, 'port')
- if self._core_management_host.strip() != 'localhost':
- if (re.match(
- "(^[2][0-5][0-5]|^[1]{0,1}[0-9]{1,2})\.([0-2][0-5][0-5]|[1]{0,1}[0-9]{1,2})\.([0-2][0-5][0-5]|[1]{0,1}[0-9]{1,2})\.([0-2][0-5][0-5]|[1]{0,1}[0-9]{1,2})$",
- self._core_management_host) is None):
- raise ArgumentParserError("Invalid Host: {}".format(self._core_management_host))
if self._core_management_port < 1 or self._core_management_port > 65535:
raise ArgumentParserError("Invalid Port: {}".format(self._core_management_port))
+ for item in args:
+ if item.startswith('--'):
+ kv = item.split('=')
+ if len(kv) == 2:
+ if len(kv[1].strip()) == 0:
+ raise ArgumentParserError("Invalid value {} for optional arg {}".format(kv[1], kv[0]))
+
except ArgumentParserError as ex:
_logger.error("Arg parser error: %s", str(ex))
raise
