<s> from oslo_config import cfg <EOL> from networking_cisco . _i18n import _ <EOL> global_opts = [ <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> ] <EOL> cfg . CONF . register_opts ( global_opts ) <EOL> apic_opts = [ <EOL> cfg . ListOpt ( '<STR_LIT>' , <EOL> default = [ ] , <EOL> help = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) , secret = True ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . BoolOpt ( '<STR_LIT>' , default = True , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . ListOpt ( '<STR_LIT>' , <EOL> default = [ ] , <EOL> help = _ ( '<STR_LIT>' ) ) , <EOL> cfg . ListOpt ( '<STR_LIT>' , <EOL> default = [ ] , <EOL> help = _ ( '<STR_LIT>' ) ) , <EOL> cfg . StrOpt ( '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . IntOpt ( '<STR_LIT>' , <EOL> default = <NUM_LIT:0> , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> cfg . FloatOpt ( '<STR_LIT>' , <EOL> default = <NUM_LIT:30> , <EOL> help = _ ( '<STR_LIT>' ) ) , <EOL> cfg . FloatOpt ( '<STR_LIT>' , <EOL> default = <NUM_LIT:2> , <EOL> help = _ ( '<STR_LIT>' ) ) , <EOL> ] <EOL> cfg . CONF . register_opts ( apic_opts , "<STR_LIT>" ) <EOL> def _get_specific_config ( prefix ) : <EOL> """<STR_LIT>""" <EOL> conf_dict = { } <EOL> multi_parser = cfg . MultiConfigParser ( ) <EOL> multi_parser . read ( cfg . CONF . config_file ) <EOL> for parsed_file in multi_parser . parsed : <EOL> for parsed_item in parsed_file . keys ( ) : <EOL> if parsed_item . startswith ( prefix ) : <EOL> switch , switch_id = parsed_item . split ( '<STR_LIT::>' ) <EOL> if switch . lower ( ) == prefix : <EOL> conf_dict [ switch_id ] = parsed_file [ parsed_item ] . items ( ) <EOL> return conf_dict <EOL> def create_switch_dictionary ( ) : <EOL> switch_dict = { } <EOL> conf = _get_specific_config ( '<STR_LIT>' ) <EOL> for switch_id in conf : <EOL> switch_dict [ switch_id ] = switch_dict . get ( switch_id , { } ) <EOL> for host_list , port in conf [ switch_id ] : <EOL> hosts = host_list . split ( '<STR_LIT:U+002C>' ) <EOL> port = port [ <NUM_LIT:0> ] <EOL> switch_dict [ switch_id ] [ port ] = ( <EOL> switch_dict [ switch_id ] . get ( port , [ ] ) + hosts ) <EOL> return switch_dict <EOL> def create_vpc_dictionary ( ) : <EOL> vpc_dict = { } <EOL> for pair in cfg . CONF . ml2_cisco_apic . apic_vpc_pairs : <EOL> pair_tuple = pair . split ( '<STR_LIT::>' ) <EOL> if ( len ( pair_tuple ) != <NUM_LIT:2> or <EOL> any ( map ( lambda x : not x . isdigit ( ) , pair_tuple ) ) ) : <EOL> continue <EOL> vpc_dict [ pair_tuple [ <NUM_LIT:0> ] ] = pair_tuple [ <NUM_LIT:1> ] <EOL> vpc_dict [ pair_tuple [ <NUM_LIT:1> ] ] = pair_tuple [ <NUM_LIT:0> ] <EOL> return vpc_dict <EOL> def create_external_network_dictionary ( ) : <EOL> router_dict = { } <EOL> conf = _get_specific_config ( '<STR_LIT>' ) <EOL> for net_id in conf : <EOL> router_dict [ net_id ] = router_dict . get ( net_id , { } ) <EOL> for key , value in conf [ net_id ] : <EOL> router_dict [ net_id ] [ key ] = value [ <NUM_LIT:0> ] if value else None <EOL> return router_dict </s>
