]> git.datanom.net - netconf.git/commitdiff
Add checks. Fix some bugs
authorMichael Rasmussen <mir@datanom.net>
Sun, 2 Apr 2017 22:16:33 +0000 (22:16 +0000)
committerMichael Rasmussen <mir@datanom.net>
Sun, 2 Apr 2017 22:16:33 +0000 (22:16 +0000)
netconf

diff --git a/netconf b/netconf
index 07bf06018335e965a605ca55318dd282d34084aa..a4811ca78a814c8b01b9a43e2eebd47ae8e2b1b7 100644 (file)
--- 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()
This page took 0.032274 seconds and 5 git commands to generate.