<s> from django . core . urlresolvers import reverse <EOL> from horizon import exceptions <EOL> from horizon import forms <EOL> from horizon import tabs <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . dashboards . project . routers . ports import forms as project_forms <EOL> from openstack_dashboard . dashboards . project . routers . ports import tabs as project_tabs <EOL> class AddInterfaceView ( forms . ModalFormView ) : <EOL> form_class = project_forms . AddInterface <EOL> template_name = '<STR_LIT>' <EOL> success_url = '<STR_LIT>' <EOL> failure_url = '<STR_LIT>' <EOL> def get_success_url ( self ) : <EOL> return reverse ( self . success_url , <EOL> args = ( self . kwargs [ '<STR_LIT>' ] , ) ) <EOL> def get_object ( self ) : <EOL> if not hasattr ( self , "<STR_LIT>" ) : <EOL> try : <EOL> router_id = self . kwargs [ "<STR_LIT>" ] <EOL> self . _object = api . neutron . router_get ( self . request , <EOL> router_id ) <EOL> except Exception : <EOL> redirect = reverse ( self . failure_url , args = [ router_id ] ) <EOL> msg = _ ( "<STR_LIT>" ) <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> return self . _object <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( AddInterfaceView , self ) . get_context_data ( ** kwargs ) <EOL> context [ '<STR_LIT>' ] = self . get_object ( ) <EOL> return context <EOL> def get_initial ( self ) : <EOL> router = self . get_object ( ) <EOL> return { "<STR_LIT>" : self . kwargs [ '<STR_LIT>' ] , <EOL> "<STR_LIT>" : router . name } <EOL> class SetGatewayView ( forms . ModalFormView ) : <EOL> form_class = project_forms . SetGatewayForm <EOL> template_name = '<STR_LIT>' <EOL> success_url = '<STR_LIT>' <EOL> failure_url = '<STR_LIT>' <EOL> def get_success_url ( self ) : <EOL> return reverse ( self . success_url ) <EOL> def get_object ( self ) : <EOL> if not hasattr ( self , "<STR_LIT>" ) : <EOL> try : <EOL> router_id = self . kwargs [ "<STR_LIT>" ] <EOL> self . _object = api . neutron . router_get ( self . request , <EOL> router_id ) <EOL> except Exception : <EOL> redirect = reverse ( self . failure_url ) <EOL> msg = _ ( "<STR_LIT>" ) <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> return self . _object <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( SetGatewayView , self ) . get_context_data ( ** kwargs ) <EOL> context [ '<STR_LIT>' ] = self . get_object ( ) <EOL> return context <EOL> def get_initial ( self ) : <EOL> router = self . get_object ( ) <EOL> return { "<STR_LIT>" : self . kwargs [ '<STR_LIT>' ] , <EOL> "<STR_LIT>" : router . name } <EOL> class DetailView ( tabs . TabView ) : <EOL> tab_group_class = project_tabs . PortDetailTabs <EOL> template_name = '<STR_LIT>' </s>
