]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: usercmd: ifquery lists user commands and sets unknown status
authorJulien Fortin <julien@cumulusnetworks.com>
Wed, 16 Nov 2016 11:02:54 +0000 (12:02 +0100)
committerJulien Fortin <julien@cumulusnetworks.com>
Wed, 23 Nov 2016 03:54:39 +0000 (04:54 +0100)
Ticket: CM-12724
Reviewed By: Roopa, Nikhil G, Daniel W
Testing Done:

$ ifquery br0
auto br0
iface br0
      bridge-ports tap17 tap19
          up ls -l

$ ifquery br0 -c
auto br0
iface br0                                                           [pass]
      up ls -l                                                        []
      bridge-ports tap17 tap19       [pass]

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
addons/usercmds.py

index 2358266b50a605a1646dd8a1338a8bc0ee25caff..212d6616d0974eb5ecc0802f108c33f0b236e776 100644 (file)
@@ -50,12 +50,24 @@ class usercmds(ifupdownaddons.modulebase.moduleBase):
                                                         str(e).strip('\n')))
                     pass
 
+    def _query_check(self, ifaceobj, ifaceobjcurr):
+        if ifaceobj.config:
+            for ops in ['pre-up',
+                        'up',
+                        'post-up',
+                        'pre-down',
+                        'down',
+                        'post-down']:
+                for cmd in ifaceobj.config.get(ops, []):
+                    ifaceobjcurr.update_config_with_status(ops, cmd, -1)
+
     _run_ops = {'pre-up' : _run_command,
                'pre-down' : _run_command,
                'up' : _run_command,
                'post-up' : _run_command,
                'down' : _run_command,
-               'post-down' : _run_command}
+               'post-down' : _run_command,
+               'query-checkcurr': _query_check}
 
     def get_ops(self):
         """ returns list of ops supported by this module """
@@ -80,4 +92,7 @@ class usercmds(ifupdownaddons.modulebase.moduleBase):
         op_handler = self._run_ops.get(operation)
         if not op_handler:
             return
-        op_handler(self, ifaceobj, operation)
+        if operation == 'query-checkcurr':
+            op_handler(self, ifaceobj, query_ifaceobj)
+        else:
+            op_handler(self, ifaceobj, operation)