original_docstring:  This section is for arguments parsing 
docstring: This section is for arguments parsing
docstring_tokens: This section is for arguments parsing
code: def main():
      """ This section is for arguments parsing """
  
      state_map = dict(
          present='vrouter-bgp-network-add',
          absent='vrouter-bgp-network-remove'
      )
  
      module = AnsibleModule(
          argument_spec=dict(
              pn_cliswitch=dict(required=False, type='str'),
              state=dict(required=True, type='str',
                         choices=state_map.keys()),
              pn_netmask=dict(required=False, type='str'),
              pn_network=dict(required=False, type='str'),
              pn_vrouter_name=dict(required=False, type='str'),
          ),
          required_if=(
              ['state', 'present', ['pn_vrouter_name', 'pn_netmask', 'pn_network']],
              ['state', 'absent', ['pn_vrouter_name', 'pn_network']],
          ),
      )
  
      # Accessing the arguments
      state = module.params['state']
      cliswitch = module.params['pn_cliswitch']
      netmask = module.params['pn_netmask']
      network = module.params['pn_network']
      vrouter_name = module.params['pn_vrouter_name']
  
      command = state_map[state]
  
      # Building the CLI command string
      cli = pn_cli(module, cliswitch)
  
      NETWORK_EXISTS, VROUTER_EXISTS = check_cli(module, cli)
  
      if VROUTER_EXISTS is None:
          module.fail_json(
              failed=True,
              msg='vRouter %s does not exists' % vrouter_name
          )
  
      if command == 'vrouter-bgp-network-add':
          if NETWORK_EXISTS is True:
              module.exit_json(
                  skipped=True,
                  msg='Network %s already added to bgp' % network
              )
  
      if command == 'vrouter-bgp-network-remove':
          if NETWORK_EXISTS is False:
              module.exit_json(
                  skipped=True,
                  msg='Network %s does not exists' % network
              )
  
      cli += ' %s vrouter-name %s ' % (command, vrouter_name)
  
      if netmask:
          cli += ' netmask ' + netmask
      if network:
          cli += ' network ' + network
  
      run_cli(module, cli, state_map)
code_tokens: def main ( ) : state_map = dict ( present = 'vrouter-bgp-network-add' , absent = 'vrouter-bgp-network-remove' ) module = AnsibleModule ( argument_spec = dict ( pn_cliswitch = dict ( required = False , type = 'str' ) , state = dict ( required = True , type = 'str' , choices = state_map . keys ( ) ) , pn_netmask = dict ( required = False , type = 'str' ) , pn_network = dict ( required = False , type = 'str' ) , pn_vrouter_name = dict ( required = False , type = 'str' ) , ) , required_if = ( [ 'state' , 'present' , [ 'pn_vrouter_name' , 'pn_netmask' , 'pn_network' ] ] , [ 'state' , 'absent' , [ 'pn_vrouter_name' , 'pn_network' ] ] , ) , ) state = module . params [ 'state' ] cliswitch = module . params [ 'pn_cliswitch' ] netmask = module . params [ 'pn_netmask' ] network = module . params [ 'pn_network' ] vrouter_name = module . params [ 'pn_vrouter_name' ] command = state_map [ state ] cli = pn_cli ( module , cliswitch ) NETWORK_EXISTS , VROUTER_EXISTS = check_cli ( module , cli ) if VROUTER_EXISTS is None : module . fail_json ( failed = True , msg = 'vRouter %s does not exists' % vrouter_name ) if command == 'vrouter-bgp-network-add' : if NETWORK_EXISTS is True : module . exit_json ( skipped = True , msg = 'Network %s already added to bgp' % network ) if command == 'vrouter-bgp-network-remove' : if NETWORK_EXISTS is False : module . exit_json ( skipped = True , msg = 'Network %s does not exists' % network ) cli += ' %s vrouter-name %s ' % ( command , vrouter_name ) if netmask : cli += ' netmask ' + netmask if network : cli += ' network ' + network run_cli ( module , cli , state_map )
short_docstring: This section is for arguments parsing
short_docstring_tokens: This section is for arguments parsing
comment: """ This section is for arguments parsing """$SEP$# Accessing the arguments$SEP$# Building the CLI command string