<s> """<STR_LIT>""" <EOL> from django . core . urlresolvers import reverse <EOL> from django . core . urlresolvers import reverse_lazy <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from horizon import exceptions <EOL> from horizon import forms <EOL> from horizon import tables <EOL> from horizon . utils import memoized <EOL> from horizon import workflows <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . utils import filters <EOL> from openstack_dashboard . dashboards . project . networks import forms as project_forms <EOL> from openstack_dashboard . dashboards . project . networks . ports import tables as port_tables <EOL> from openstack_dashboard . dashboards . project . networks . subnets import tables as subnet_tables <EOL> from openstack_dashboard . dashboards . project . networks import tables as project_tables <EOL> from openstack_dashboard . dashboards . project . networks import workflows as project_workflows <EOL> class IndexView ( tables . DataTableView ) : <EOL> table_class = project_tables . NetworksTable <EOL> template_name = '<STR_LIT>' <EOL> page_title = _ ( "<STR_LIT>" ) <EOL> def get_data ( self ) : <EOL> try : <EOL> tenant_id = self . request . user . tenant_id <EOL> networks = api . neutron . network_list_for_tenant ( <EOL> self . request , tenant_id , include_external = True ) <EOL> except Exception : <EOL> networks = [ ] <EOL> msg = _ ( '<STR_LIT>' ) <EOL> exceptions . handle ( self . request , msg ) <EOL> return networks <EOL> class CreateView ( workflows . WorkflowView ) : <EOL> workflow_class = project_workflows . CreateNetwork <EOL> class UpdateView ( forms . ModalFormView ) : <EOL> context_object_name = '<STR_LIT>' <EOL> form_class = project_forms . UpdateNetwork <EOL> form_id = "<STR_LIT>" <EOL> modal_header = _ ( "<STR_LIT>" ) <EOL> submit_label = _ ( "<STR_LIT>" ) <EOL> submit_url = "<STR_LIT>" <EOL> success_url = reverse_lazy ( "<STR_LIT>" ) <EOL> template_name = '<STR_LIT>' <EOL> page_title = _ ( "<STR_LIT>" ) <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( UpdateView , self ) . get_context_data ( ** kwargs ) <EOL> args = ( self . kwargs [ '<STR_LIT>' ] , ) <EOL> context [ "<STR_LIT>" ] = self . kwargs [ '<STR_LIT>' ] <EOL> context [ "<STR_LIT>" ] = reverse ( self . submit_url , args = args ) <EOL> return context <EOL> @ memoized . memoized_method <EOL> def _get_object ( self , * args , ** kwargs ) : <EOL> network_id = self . kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> return api . neutron . network_get ( self . request , network_id ) <EOL> except Exception : <EOL> redirect = self . success_url <EOL> msg = _ ( '<STR_LIT>' ) <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> def get_initial ( self ) : <EOL> network = self . _get_object ( ) <EOL> return { '<STR_LIT>' : network [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : network [ '<STR_LIT>' ] , <EOL> '<STR_LIT:name>' : network [ '<STR_LIT:name>' ] , <EOL> '<STR_LIT>' : network [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : network [ '<STR_LIT>' ] } <EOL> class DetailView ( tables . MultiTableView ) : <EOL> table_classes = ( subnet_tables . SubnetsTable , port_tables . PortsTable ) <EOL> template_name = '<STR_LIT>' <EOL> page_title = '<STR_LIT>' <EOL> def get_subnets_data ( self ) : <EOL> try : <EOL> network = self . _get_data ( ) <EOL> subnets = api . neutron . subnet_list ( self . request , <EOL> network_id = network . id ) <EOL> except Exception : <EOL> subnets = [ ] <EOL> msg = _ ( '<STR_LIT>' ) <EOL> exceptions . handle ( self . request , msg ) <EOL> return subnets <EOL> def get_ports_data ( self ) : <EOL> try : <EOL> network_id = self . kwargs [ '<STR_LIT>' ] <EOL> ports = api . neutron . port_list ( self . request , network_id = network_id ) <EOL> except Exception : <EOL> ports = [ ] <EOL> msg = _ ( '<STR_LIT>' ) <EOL> exceptions . handle ( self . request , msg ) <EOL> return ports <EOL> @ memoized . memoized_method <EOL> def _get_data ( self ) : <EOL> try : <EOL> network_id = self . kwargs [ '<STR_LIT>' ] <EOL> network = api . neutron . network_get ( self . request , network_id ) <EOL> network . set_id_as_name_if_empty ( length = <NUM_LIT:0> ) <EOL> except Exception : <EOL> msg = _ ( '<STR_LIT>' ) % ( network_id ) <EOL> exceptions . handle ( self . request , msg , <EOL> redirect = self . get_redirect_url ( ) ) <EOL> return network <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( DetailView , self ) . get_context_data ( ** kwargs ) <EOL> network = self . _get_data ( ) <EOL> context [ "<STR_LIT>" ] = network <EOL> table = project_tables . NetworksTable ( self . request ) <EOL> context [ "<STR_LIT:url>" ] = self . get_redirect_url ( ) <EOL> context [ "<STR_LIT>" ] = table . render_row_actions ( network ) <EOL> choices = project_tables . STATUS_DISPLAY_CHOICES <EOL> network . status_label = ( <EOL> filters . get_display_label ( choices , network . status ) ) <EOL> choices = project_tables . DISPLAY_CHOICES <EOL> network . admin_state_label = ( <EOL> filters . get_display_label ( choices , network . admin_state ) ) <EOL> return context <EOL> @ staticmethod <EOL> def get_redirect_url ( ) : <EOL> return reverse_lazy ( '<STR_LIT>' ) </s>
