<s> """<STR_LIT>""" <EOL> import itertools <EOL> from nova . api . openstack import common <EOL> from nova . api . openstack import extensions <EOL> from nova . api . openstack import wsgi <EOL> authorize = extensions . soft_extension_authorizer ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class ExtendedIpsMacController ( wsgi . Controller ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( ExtendedIpsMacController , self ) . __init__ ( * args , ** kwargs ) <EOL> def _extend_server ( self , context , server , instance ) : <EOL> key = "<STR_LIT>" % Extended_ips_mac . alias <EOL> networks = common . get_networks_for_instance ( context , instance ) <EOL> for label , network in networks . items ( ) : <EOL> if label in server [ '<STR_LIT>' ] : <EOL> all_ips = itertools . chain ( network [ "<STR_LIT>" ] , <EOL> network [ "<STR_LIT>" ] ) <EOL> for i , ip in enumerate ( all_ips ) : <EOL> server [ '<STR_LIT>' ] [ label ] [ i ] [ key ] = ip [ '<STR_LIT>' ] <EOL> @ wsgi . extends <EOL> def show ( self , req , resp_obj , id ) : <EOL> context = req . environ [ '<STR_LIT>' ] <EOL> if authorize ( context ) : <EOL> server = resp_obj . obj [ '<STR_LIT>' ] <EOL> db_instance = req . get_db_instance ( server [ '<STR_LIT:id>' ] ) <EOL> self . _extend_server ( context , server , db_instance ) <EOL> @ wsgi . extends <EOL> def detail ( self , req , resp_obj ) : <EOL> context = req . environ [ '<STR_LIT>' ] <EOL> if authorize ( context ) : <EOL> servers = list ( resp_obj . obj [ '<STR_LIT>' ] ) <EOL> for server in servers : <EOL> db_instance = req . get_db_instance ( server [ '<STR_LIT:id>' ] ) <EOL> self . _extend_server ( context , server , db_instance ) <EOL> class Extended_ips_mac ( extensions . ExtensionDescriptor ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> alias = "<STR_LIT>" <EOL> namespace = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> updated = "<STR_LIT>" <EOL> def get_controller_extensions ( self ) : <EOL> controller = ExtendedIpsMacController ( ) <EOL> extension = extensions . ControllerExtension ( self , '<STR_LIT>' , controller ) <EOL> return [ extension ] </s>
