<s> """<STR_LIT>""" <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 import workflows <EOL> from openstack_dashboard import api <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> def get_data ( self ) : <EOL> try : <EOL> tenant_id = self . request . user . tenant_id <EOL> networks = api . neutron . network_list_for_tenant ( self . request , <EOL> tenant_id ) <EOL> except Exception : <EOL> networks = [ ] <EOL> msg = _ ( '<STR_LIT>' ) <EOL> exceptions . handle ( self . request , msg ) <EOL> for n in networks : <EOL> n . set_id_as_name_if_empty ( ) <EOL> return networks <EOL> class CreateView ( workflows . WorkflowView ) : <EOL> workflow_class = project_workflows . CreateNetwork <EOL> def get_initial ( self ) : <EOL> pass <EOL> class UpdateView ( forms . ModalFormView ) : <EOL> form_class = project_forms . UpdateNetwork <EOL> template_name = '<STR_LIT>' <EOL> context_object_name = '<STR_LIT>' <EOL> success_url = reverse_lazy ( "<STR_LIT>" ) <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( UpdateView , self ) . get_context_data ( ** kwargs ) <EOL> context [ "<STR_LIT>" ] = self . kwargs [ '<STR_LIT>' ] <EOL> return context <EOL> def _get_object ( self , * args , ** kwargs ) : <EOL> if not hasattr ( self , "<STR_LIT>" ) : <EOL> network_id = self . kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> self . _object = api . neutron . network_get ( self . request , <EOL> network_id ) <EOL> except Exception : <EOL> redirect = self . success_url <EOL> msg = _ ( '<STR_LIT>' ) <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> return self . _object <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> class DetailView ( tables . MultiTableView ) : <EOL> table_classes = ( subnet_tables . SubnetsTable , port_tables . PortsTable ) <EOL> template_name = '<STR_LIT>' <EOL> failure_url = reverse_lazy ( '<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> for s in subnets : <EOL> s . set_id_as_name_if_empty ( ) <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> for p in ports : <EOL> p . set_id_as_name_if_empty ( ) <EOL> return ports <EOL> def _get_data ( self ) : <EOL> if not hasattr ( self , "<STR_LIT>" ) : <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 , redirect = self . failure_url ) <EOL> self . _network = network <EOL> return self . _network <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( DetailView , self ) . get_context_data ( ** kwargs ) <EOL> context [ "<STR_LIT>" ] = self . _get_data ( ) <EOL> return context </s>
