original_docstring: Main function for VPP agent functionality.
docstring: Main function for VPP agent functionality.
docstring_tokens: Main function for VPP agent functionality .
code: def main():
      """Main function for VPP agent functionality."""
  
      openstack_base_setup('vpp_agent')
  
      setup_privsep()
  
      neutron.conf.plugins.ml2.config.register_ml2_plugin_opts(cfg.CONF)
      neutron.conf.agent.securitygroups_rpc.register_securitygroups_opts(
          cfg.CONF)
      config_opts.register_vpp_opts(cfg.CONF)
  
      # Pull physnets out of config and interpret them
      if not cfg.CONF.ml2_vpp.physnets:
          LOG.critical("Missing physnets config. Exiting...")
          sys.exit(1)
  
      physnet_list = cfg.CONF.ml2_vpp.physnets.replace(' ', '').split(',')
      physnets = {}
      for f in physnet_list:
          if f:
              try:
                  (k, v) = f.split(':')
              except Exception:
                  LOG.error("Could not parse physnet to interface mapping "
                            "check the format in the config file: "
                            "physnets = physnet1:<interface1>, "
                            "physnet2:<interface>")
                  sys.exit(1)
              if len(v) > MAX_PHYSNET_LENGTH:
                  LOG.error("Physnet '%(physnet_name)s' is longer than "
                            "%(len)d characters.",
                            {'physnet_name': v, 'len': MAX_PHYSNET_LENGTH})
                  sys.exit(1)
              physnets[k] = v
  
      # Deal with VPP-side setup
  
      if cfg.CONF.ml2_vpp.enable_vpp_restart:
          VPPRestart().wait()
  
      # Convert to the minutes unit that VPP uses:
      # (we round *up*)
      # py3 note: using // since we want integer division
      mac_age_min = int((cfg.CONF.ml2_vpp.mac_age + 59) // 60)
      vppf = VPPForwarder(physnets,
                          mac_age=mac_age_min,
                          vpp_cmd_queue_len=cfg.CONF.ml2_vpp.vpp_cmd_queue_len
                          )
  
      # Deal with etcd-side setup
  
      LOG.debug("Using etcd host:%s port:%s user:%s password:***",
                cfg.CONF.ml2_vpp.etcd_host,
                cfg.CONF.ml2_vpp.etcd_port,
                cfg.CONF.ml2_vpp.etcd_user)
  
      client_factory = etcdutils.EtcdClientFactory(cfg.CONF.ml2_vpp)
  
      # Do the work
  
      ops = EtcdListener(cfg.CONF.host, client_factory, vppf, physnets)
  
      names = cfg.CONF.ml2_vpp.vpp_agent_extensions
      if names != '':
          mgr = ExtensionManager(
              'networking_vpp.vpp_agent.extensions',
              names,
              VPPAgentExtensionBase)
          mgr.call_all('run', cfg.CONF.host, client_factory, vppf, ops.pool)
  
      ops.process_ops()
code_tokens: def main ( ) : openstack_base_setup ( 'vpp_agent' ) setup_privsep ( ) neutron . conf . plugins . ml2 . config . register_ml2_plugin_opts ( cfg . CONF ) neutron . conf . agent . securitygroups_rpc . register_securitygroups_opts ( cfg . CONF ) config_opts . register_vpp_opts ( cfg . CONF ) if not cfg . CONF . ml2_vpp . physnets : LOG . critical ( "Missing physnets config. Exiting..." ) sys . exit ( 1 ) physnet_list = cfg . CONF . ml2_vpp . physnets . replace ( ' ' , '' ) . split ( ',' ) physnets = { } for f in physnet_list : if f : try : ( k , v ) = f . split ( ':' ) except Exception : LOG . error ( "Could not parse physnet to interface mapping " "check the format in the config file: " "physnets = physnet1:<interface1>, " "physnet2:<interface>" ) sys . exit ( 1 ) if len ( v ) > MAX_PHYSNET_LENGTH : LOG . error ( "Physnet '%(physnet_name)s' is longer than " "%(len)d characters." , { 'physnet_name' : v , 'len' : MAX_PHYSNET_LENGTH } ) sys . exit ( 1 ) physnets [ k ] = v if cfg . CONF . ml2_vpp . enable_vpp_restart : VPPRestart ( ) . wait ( ) mac_age_min = int ( ( cfg . CONF . ml2_vpp . mac_age + 59 ) // 60 ) vppf = VPPForwarder ( physnets , mac_age = mac_age_min , vpp_cmd_queue_len = cfg . CONF . ml2_vpp . vpp_cmd_queue_len ) LOG . debug ( "Using etcd host:%s port:%s user:%s password:***" , cfg . CONF . ml2_vpp . etcd_host , cfg . CONF . ml2_vpp . etcd_port , cfg . CONF . ml2_vpp . etcd_user ) client_factory = etcdutils . EtcdClientFactory ( cfg . CONF . ml2_vpp ) ops = EtcdListener ( cfg . CONF . host , client_factory , vppf , physnets ) names = cfg . CONF . ml2_vpp . vpp_agent_extensions if names != '' : mgr = ExtensionManager ( 'networking_vpp.vpp_agent.extensions' , names , VPPAgentExtensionBase ) mgr . call_all ( 'run' , cfg . CONF . host , client_factory , vppf , ops . pool ) ops . process_ops ( )
short_docstring: Main function for VPP agent functionality.
short_docstring_tokens: Main function for VPP agent functionality .
comment: """Main function for VPP agent functionality."""$SEP$# Pull physnets out of config and interpret them$SEP$# Deal with VPP-side setup$SEP$# Convert to the minutes unit that VPP uses:$SEP$# (we round *up*)$SEP$# py3 note: using // since we want integer division$SEP$# Deal with etcd-side setup$SEP$# Do the work