@@ -92,8 +92,8 @@ def to_netjson(self, remove_block=True):
9292 to a NetJSON configuration dictionary (``self.config``)
9393 """
9494 result = OrderedDict ()
95- # copy list
96- intermediate_data = list (self .intermediate_data [self .intermediate_key ])
95+ # Clean intermediate data
96+ intermediate_data = self . clean_intermediate_data ( list (self .intermediate_data [self .intermediate_key ]) )
9797 # iterate over copied intermediate data structure
9898 for index , block in enumerate (intermediate_data ):
9999 if self .should_skip_block (block ):
@@ -109,6 +109,19 @@ def to_netjson(self, remove_block=True):
109109 # return result, expects dict
110110 return result
111111
112+ def clean_intermediate_data (self , intermediate_data ):
113+ """
114+ Utility method called to clean data for backend in ``to_netjson``
115+ """
116+ clean_intermediate_data , appendto_clean_intermediate_data = [], []
117+ for block in intermediate_data :
118+ if '.type' in block and block ['.type' ] == 'switch_vlan' :
119+ appendto_clean_intermediate_data .append (block )
120+ else :
121+ clean_intermediate_data .append (block )
122+ clean_intermediate_data .extend (appendto_clean_intermediate_data )
123+ return clean_intermediate_data
124+
112125 def to_netjson_loop (self , block , result , index = None ): # pragma: nocover
113126 """
114127 Utility method called in the loop of ``to_netjson``
0 commit comments