]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: adding '--with-defaults' option for base ifquery
authorNikhil <nikhil@cumulusnetworks.com>
Tue, 26 Apr 2016 22:00:08 +0000 (15:00 -0700)
committerNikhil <nikhil@cumulusnetworks.com>
Tue, 26 Apr 2016 22:04:17 +0000 (15:04 -0700)
Ticket: CM-7840
Reviewed By: Roopa Prabhu
Testing Done: yes, with different configurations for physical & logical devices

This patch adds 'ifquery --with-defaults' to print the policy default
values for unconfigured attributes.

Signed-off-by: Nikhil <nikhil@cumulusnetworks.com>
addons/bridge.py
addons/ethtool.py
addons/vrf.py

index 799cfee23001cb92e827e01b4f4bab4f3bdef8ca..8caa1e4ab1b78b7e2ee411ea029d2ccdfd17f745 100644 (file)
@@ -1694,7 +1694,8 @@ class bridge(moduleBase):
 
     def _query(self, ifaceobj, **kwargs):
         """ add default policy attributes supported by the module """
-        if not (ifaceobj.link_kind & ifaceLinkKind.BRIDGE):
+        if (not (ifaceobj.link_kind & ifaceLinkKind.BRIDGE) or
+            ifaceobj.get_attr_value_first('bridge-stp')):
             return
         if self.default_stp_on:
             ifaceobj.update_config('bridge-stp', 'yes')
index c7a48509068738061efe1a284c25f5671a6803a8..26176020dc036324d018d5f5f209900aa7baf7c4 100644 (file)
@@ -232,10 +232,26 @@ class ethtool(moduleBase,utilsBase):
 
         return
 
+    def _query(self, ifaceobj, **kwargs):
+        """ add default policy attributes supported by the module """
+        if ifaceobj.link_kind:
+            return
+        for attr in ['speed', 'duplex', 'autoneg']:
+            if ifaceobj.get_attr_value_first('link-%s'%attr):
+                continue
+            default = policymanager.policymanager_api.get_iface_default(
+                        module_name='ethtool',
+                        ifname=ifaceobj.name,
+                        attr='link-%s' %attr)
+            if not default:
+                continue
+            ifaceobj.update_config('link-%s' %attr, default)
+
     _run_ops = {'pre-down' : _pre_down,
                 'post-up' : _post_up,
                 'query-checkcurr' : _query_check,
-                'query-running' : _query_running }
+                'query-running' : _query_running,
+                'query' : _query}
 
     def get_ops(self):
         """ returns list of ops supported by this module """
index 2b44ce1d2291486bb1a4098a9b06c599968f6ccb..420eaf10905d139a18179245270fbfd29bf1da87 100644 (file)
@@ -816,10 +816,18 @@ class vrf(moduleBase):
         except Exception, e:
             self.log_warn(str(e))
 
+    def _query(self, ifaceobj, **kwargs):
+        if not self.vrf_helper:
+            return
+        if (ifaceobj.link_kind & ifaceLinkKind.VRF):
+            ifaceobj.update_config('vrf-helper', '%s %s' %(self.vrf_helper,
+                                   ifaceobj.name))
+
     _run_ops = {'pre-up' : _up,
                'post-down' : _down,
                'query-running' : _query_running,
-               'query-checkcurr' : _query_check}
+               'query-checkcurr' : _query_check,
+               'query' : _query}
 
     def get_ops(self):
         """ returns list of ops supported by this module """