def get_vlan_config_commands(vlan, vid):
 reverse_value_map = {'admin_state': {'down': 'shutdown', 'up': 'no shutdown'}}
 if vlan.get('admin_state'):
  vlan = apply_value_map(reverse_value_map, vlan)
 VLAN_ARGS = {'name': 'name {0}', 'vlan_state': 'state {0}', 'admin_state': '{0}', 'mode': 'mode {0}', 'mapped_vni': 'vn-segment {0}'}
 commands = []
 for (param, value) in vlan.iteritems():
  if ((param == 'mapped_vni') and (value == 'default')):
   command = 'no vn-segment'
  else:
   command = VLAN_ARGS.get(param).format(vlan.get(param))
  if command:
   commands.append(command)
 commands.insert(0, ('vlan ' + vid))
 commands.append('exit')
 return commands

def get_vlan_config_commands ( vlan , vid ) : reverse_value_map = { 'admin_state' : { 'down' : 'shutdown' , 'up' : 'no shutdown' } } if vlan . get ( 'admin_state' ) : vlan = apply_value_map ( reverse_value_map , vlan ) VLAN_ARGS = { 'name' : 'name {0}' , 'vlan_state' : 'state {0}' , 'admin_state' : '{0}' , 'mode' : 'mode {0}' , 'mapped_vni' : 'vn-segment {0}' } commands = [ ] for ( param , value ) in vlan . iteritems ( ) : if ( ( param == 'mapped_vni' ) and ( value == 'default' ) ) : command = 'no vn-segment' else : command = VLAN_ARGS . get ( param ) . format ( vlan . get ( param ) ) if command : commands . append ( command ) commands . insert ( 0 , ( 'vlan ' + vid ) ) commands . append ( 'exit' ) return commands
build command list required for vlan configuration .