@@ -161,6 +161,48 @@ def json(self, validate=True, *args, **kwargs):
161161 config .update ({'type' : 'DeviceConfiguration' })
162162 return json .dumps (config , * args , ** kwargs )
163163
164+ def merge_native (self , templates = None ):
165+ """
166+ :param templates: ``list`` containing **NetJSON** configuration dictionaries
167+
168+ returns a dict of configuration which contains configurations
169+ that do not exist in given templates.
170+
171+ :returns: dict
172+ """
173+ config_to_send = {}
174+ controller_config = self ._merge_config ({}, templates )
175+ for section in controller_config :
176+ device_section = self .config .get (section , None )
177+
178+ if device_section and isinstance (device_section , list ):
179+ for element in device_section :
180+ """
181+ TODO: Discuss case where dns_servers set but
182+ someone removed it from device, will cause
183+ information loss.
184+ TODO: Question: in an array like interfaces,
185+ if say, mtu is changed, do I copy the entire interface
186+ or just the mtu value with interface name?
187+ Currently copying the entire thing because I feel it
188+ Should be stored together.
189+ Same for "radios"
190+ """
191+ element_dict = dict (element )
192+ if element_dict not in controller_config [section ]:
193+ config_to_send [section ] = element_dict
194+
195+
196+ if device_section and isinstance (device_section , dict ):
197+ for config in controller_config [section ]:
198+ device_config = device_section .get (config , None )
199+ if device_config and device_config != controller_config [section ][config ]:
200+ if not config_to_send .get (section , None ):
201+ config_to_send [section ] = {}
202+ config_to_send [section ][config ] = device_config
203+
204+ return config_to_send
205+
164206 def generate (self ):
165207 """
166208 Returns a ``BytesIO`` instance representing an in-memory tar.gz archive
0 commit comments