From: Michael Rasmussen Date: Sun, 2 Apr 2017 22:16:33 +0000 (+0000) Subject: Add checks. Fix some bugs X-Git-Url: http://git.datanom.net/netconf.git/commitdiff_plain/f5cdd6555a5e6d81fa8981ab39b5e918a5a0b58b Add checks. Fix some bugs --- diff --git a/netconf b/netconf index 07bf060..a4811ca 100644 --- a/netconf +++ b/netconf @@ -153,8 +153,8 @@ def parse_input(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], - 'ha:g:i:m:n', ['help', 'address=', 'gateway=', - 'interface=', 'netmask=', 'nameserver=']) + 'ha:g:i:m:n:', ['help', 'address=', 'gateway=', + 'interface=', 'netmask=', 'nameserver=']) except getopt.GetoptError as err: print str(err) usage() @@ -207,7 +207,15 @@ def main(): if interactive: nic = make_menu(interfaces) else: - nic[0] = options[0] + nic = options + found = False + for i in interfaces: + if nic[0] == i[0]: + found = True + break + if not found: + err = '%s: No such interface' % nic[0] + raise RuntimeError(err) if nic: if interactive: (ip,mask,gw) = get_config()