@@ -161,6 +161,36 @@ 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+ element_dict = dict (element )
181+ if element_dict not in controller_config [section ]:
182+ config_to_send [section ] = element_dict
183+
184+ if device_section and isinstance (device_section , dict ):
185+ for config in controller_config [section ]:
186+ device_config = device_section .get (config , None )
187+ if device_config and device_config != controller_config [section ][config ]:
188+ if not config_to_send .get (section , None ):
189+ config_to_send [section ] = {}
190+ config_to_send [section ][config ] = device_config
191+
192+ return config_to_send
193+
164194 def generate (self ):
165195 """
166196 Returns a ``BytesIO`` instance representing an in-memory tar.gz archive
0 commit comments