<s> 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 messages <EOL> from horizon import tabs <EOL> from horizon import workflows <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . dashboards . project . loadbalancers import forms as project_forms <EOL> from openstack_dashboard . dashboards . project . loadbalancers import tabs as project_tabs <EOL> from openstack_dashboard . dashboards . project . loadbalancers import workflows as project_workflows <EOL> import re <EOL> class IndexView ( tabs . TabView ) : <EOL> tab_group_class = ( project_tabs . LoadBalancerTabs ) <EOL> template_name = '<STR_LIT>' <EOL> def post ( self , request , * args , ** kwargs ) : <EOL> obj_ids = request . POST . getlist ( '<STR_LIT>' ) <EOL> action = request . POST [ '<STR_LIT:action>' ] <EOL> m = re . search ( '<STR_LIT>' , action ) . group ( <NUM_LIT:1> ) <EOL> if obj_ids == [ ] : <EOL> obj_ids . append ( re . search ( '<STR_LIT>' , action ) . group ( <NUM_LIT:1> ) ) <EOL> if m == '<STR_LIT>' : <EOL> for obj_id in obj_ids : <EOL> try : <EOL> api . lbaas . pool_health_monitor_delete ( request , obj_id ) <EOL> messages . success ( request , _ ( '<STR_LIT>' ) % obj_id ) <EOL> except Exception as e : <EOL> exceptions . handle ( request , <EOL> _ ( '<STR_LIT>' ) % e ) <EOL> if m == '<STR_LIT>' : <EOL> for obj_id in obj_ids : <EOL> try : <EOL> api . lbaas . pool_delete ( request , obj_id ) <EOL> messages . success ( request , _ ( '<STR_LIT>' ) % obj_id ) <EOL> except Exception as e : <EOL> exceptions . handle ( request , <EOL> _ ( '<STR_LIT>' ) % e ) <EOL> if m == '<STR_LIT>' : <EOL> for obj_id in obj_ids : <EOL> try : <EOL> api . lbaas . member_delete ( request , obj_id ) <EOL> messages . success ( request , _ ( '<STR_LIT>' ) % obj_id ) <EOL> except Exception as e : <EOL> exceptions . handle ( request , <EOL> _ ( '<STR_LIT>' ) % e ) <EOL> if m == '<STR_LIT>' : <EOL> for obj_id in obj_ids : <EOL> try : <EOL> vip_id = api . lbaas . pool_get ( request , obj_id ) . vip_id <EOL> except Exception as e : <EOL> exceptions . handle ( request , <EOL> _ ( '<STR_LIT>' ) <EOL> % e ) <EOL> if vip_id is not None : <EOL> try : <EOL> api . lbaas . vip_delete ( request , vip_id ) <EOL> messages . success ( request , _ ( '<STR_LIT>' ) % vip_id ) <EOL> except Exception as e : <EOL> exceptions . handle ( request , <EOL> _ ( '<STR_LIT>' ) % e ) <EOL> return self . get ( request , * args , ** kwargs ) <EOL> class AddPoolView ( workflows . WorkflowView ) : <EOL> workflow_class = project_workflows . AddPool <EOL> def get_initial ( self ) : <EOL> initial = super ( AddPoolView , self ) . get_initial ( ) <EOL> return initial <EOL> class AddVipView ( workflows . WorkflowView ) : <EOL> workflow_class = project_workflows . AddVip <EOL> def get_context_data ( self , ** kwargs ) : <EOL> context = super ( AddVipView , self ) . get_context_data ( ** kwargs ) <EOL> return context <EOL> def get_initial ( self ) : <EOL> initial = super ( AddVipView , self ) . get_initial ( ) <EOL> initial [ '<STR_LIT>' ] = self . kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> pool = api . lbaas . pool_get ( self . request , initial [ '<STR_LIT>' ] ) <EOL> initial [ '<STR_LIT>' ] = api . neutron . subnet_get ( <EOL> self . request , pool . subnet_id ) . cidr <EOL> except Exception as e : <EOL> initial [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> msg = _ ( '<STR_LIT>' ) % e <EOL> exceptions . handle ( self . request , msg ) <EOL> return initial <EOL> class AddMemberView ( workflows . WorkflowView ) : <EOL> workflow_class = project_workflows . AddMember <EOL> def get_initial ( self ) : <EOL> initial = super ( AddMemberView , self ) . get_initial ( ) <EOL> return initial <EOL> class AddMonitorView ( workflows . WorkflowView ) : <EOL> workflow_class = project_workflows . AddMonitor <EOL> def get_initial ( self ) : <EOL> initial = super ( AddMonitorView , self ) . get_initial ( ) <EOL> return initial <EOL> class PoolDetailsView ( tabs . TabView ) : <EOL> tab_group_class = ( project_tabs . PoolDetailsTabs ) <EOL> template_name = '<STR_LIT>' <EOL> class VipDetailsView ( tabs . TabView ) : <EOL> tab_group_class = ( project_tabs . VipDetailsTabs ) <EOL> template_name = '<STR_LIT>' <EOL> class MemberDetailsView ( tabs . TabView ) : <EOL> tab_group_class = ( project_tabs . MemberDetailsTabs ) <EOL> template_name = '<STR_LIT>' <EOL> class MonitorDetailsView ( tabs . TabView ) : <EOL> tab_group_class = ( project_tabs . MonitorDetailsTabs ) <EOL> template_name = '<STR_LIT>' <EOL> class UpdatePoolView ( forms . ModalFormView ) : <EOL> form_class = project_forms . UpdatePool <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 ( UpdatePoolView , 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> pool_id = self . kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> self . _object = api . lbaas . pool_get ( self . request , pool_id ) <EOL> except Exception as e : <EOL> redirect = self . success_url <EOL> msg = _ ( '<STR_LIT>' ) % e <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> return self . _object <EOL> def get_initial ( self ) : <EOL> pool = self . _get_object ( ) <EOL> return { '<STR_LIT:name>' : pool [ '<STR_LIT:name>' ] , <EOL> '<STR_LIT>' : pool [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT:description>' : pool [ '<STR_LIT:description>' ] , <EOL> '<STR_LIT>' : pool [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : pool [ '<STR_LIT>' ] } <EOL> class UpdateVipView ( forms . ModalFormView ) : <EOL> form_class = project_forms . UpdateVip <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 ( UpdateVipView , 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> vip_id = self . kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> self . _object = api . lbaas . vip_get ( self . request , vip_id ) <EOL> except Exception as e : <EOL> redirect = self . success_url <EOL> msg = _ ( '<STR_LIT>' ) % e <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> return self . _object <EOL> def get_initial ( self ) : <EOL> vip = self . _get_object ( ) <EOL> persistence = getattr ( vip , '<STR_LIT>' , None ) <EOL> if persistence : <EOL> stype = persistence [ '<STR_LIT:type>' ] <EOL> if stype == '<STR_LIT>' : <EOL> cookie = persistence [ '<STR_LIT>' ] <EOL> else : <EOL> cookie = '<STR_LIT>' <EOL> else : <EOL> stype = '<STR_LIT>' <EOL> cookie = '<STR_LIT>' <EOL> return { '<STR_LIT:name>' : vip [ '<STR_LIT:name>' ] , <EOL> '<STR_LIT>' : vip [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT:description>' : vip [ '<STR_LIT:description>' ] , <EOL> '<STR_LIT>' : vip [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : stype , <EOL> '<STR_LIT>' : cookie , <EOL> '<STR_LIT>' : vip [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : vip [ '<STR_LIT>' ] } <EOL> class UpdateMemberView ( forms . ModalFormView ) : <EOL> form_class = project_forms . UpdateMember <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 ( UpdateMemberView , 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> member_id = self . kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> self . _object = api . lbaas . member_get ( self . request , member_id ) <EOL> except Exception as e : <EOL> redirect = self . success_url <EOL> msg = _ ( '<STR_LIT>' ) % e <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> return self . _object <EOL> def get_initial ( self ) : <EOL> member = self . _get_object ( ) <EOL> return { '<STR_LIT>' : member [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : member [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : member [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : member [ '<STR_LIT>' ] } <EOL> class UpdateMonitorView ( forms . ModalFormView ) : <EOL> form_class = project_forms . UpdateMonitor <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 ( UpdateMonitorView , 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> monitor_id = self . kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> self . _object = api . lbaas . pool_health_monitor_get ( <EOL> self . request , monitor_id ) <EOL> except Exception as e : <EOL> redirect = self . success_url <EOL> msg = _ ( '<STR_LIT>' ) % e <EOL> exceptions . handle ( self . request , msg , redirect = redirect ) <EOL> return self . _object <EOL> def get_initial ( self ) : <EOL> monitor = self . _get_object ( ) <EOL> return { '<STR_LIT>' : monitor [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : monitor [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : monitor [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : monitor [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : monitor [ '<STR_LIT>' ] } <EOL> class AddPMAssociationView ( workflows . WorkflowView ) : <EOL> workflow_class = project_workflows . AddPMAssociation <EOL> def get_initial ( self ) : <EOL> initial = super ( AddPMAssociationView , self ) . get_initial ( ) <EOL> initial [ '<STR_LIT>' ] = self . kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> pool = api . lbaas . pool_get ( self . request , initial [ '<STR_LIT>' ] ) <EOL> initial [ '<STR_LIT>' ] = pool . name <EOL> initial [ '<STR_LIT>' ] = pool . health_monitors <EOL> except Exception as e : <EOL> msg = _ ( '<STR_LIT>' ) % e <EOL> exceptions . handle ( self . request , msg ) <EOL> return initial <EOL> class DeletePMAssociationView ( workflows . WorkflowView ) : <EOL> workflow_class = project_workflows . DeletePMAssociation <EOL> def get_initial ( self ) : <EOL> initial = super ( DeletePMAssociationView , self ) . get_initial ( ) <EOL> initial [ '<STR_LIT>' ] = self . kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> pool = api . lbaas . pool_get ( self . request , initial [ '<STR_LIT>' ] ) <EOL> initial [ '<STR_LIT>' ] = pool . name <EOL> initial [ '<STR_LIT>' ] = pool . health_monitors <EOL> except Exception as e : <EOL> msg = _ ( '<STR_LIT>' ) % e <EOL> exceptions . handle ( self . request , msg ) <EOL> return initial </s>
