<s> import argparse <EOL> from cliff import show <EOL> from oslo_serialization import jsonutils <EOL> from neutronclient . _i18n import _ <EOL> from neutronclient . common import exceptions <EOL> from neutronclient . neutron import v2_0 <EOL> class ShowAutoAllocatedTopology ( v2_0 . NeutronCommand , show . ShowOne ) : <EOL> """<STR_LIT>""" <EOL> resource = '<STR_LIT>' <EOL> def get_parser ( self , prog_name ) : <EOL> parser = super ( ShowAutoAllocatedTopology , self ) . get_parser ( prog_name ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> help = _ ( '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> action = '<STR_LIT:store_true>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , metavar = '<STR_LIT>' , <EOL> help = _ ( '<STR_LIT>' ) ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> help = argparse . SUPPRESS , nargs = '<STR_LIT:?>' ) <EOL> return parser <EOL> def take_action ( self , parsed_args ) : <EOL> client = self . get_client ( ) <EOL> extra_values = v2_0 . parse_args_to_dict ( self . values_specs ) <EOL> if extra_values : <EOL> raise exceptions . CommandError ( <EOL> _ ( "<STR_LIT>" ) % '<STR_LIT>' . join ( extra_values ) ) <EOL> tenant_id = parsed_args . tenant_id or parsed_args . pos_tenant_id <EOL> if parsed_args . dry_run : <EOL> data = client . validate_auto_allocated_topology_requirements ( <EOL> tenant_id ) <EOL> else : <EOL> data = client . get_auto_allocated_topology ( tenant_id ) <EOL> if self . resource in data : <EOL> for k , v in data [ self . resource ] . items ( ) : <EOL> if isinstance ( v , list ) : <EOL> value = "<STR_LIT>" <EOL> for _item in v : <EOL> if value : <EOL> value += "<STR_LIT:\n>" <EOL> if isinstance ( _item , dict ) : <EOL> value += jsonutils . dumps ( _item ) <EOL> else : <EOL> value += str ( _item ) <EOL> data [ self . resource ] [ k ] = value <EOL> elif v == "<STR_LIT>" : <EOL> return ( "<STR_LIT>" , ) , ( "<STR_LIT>" , ) <EOL> elif v is None : <EOL> data [ self . resource ] [ k ] = '<STR_LIT>' <EOL> return zip ( * sorted ( data [ self . resource ] . items ( ) ) ) <EOL> else : <EOL> return None </s>
