<s> from django . core import urlresolvers <EOL> from django . http import Http404 <EOL> from django . template . defaultfilters import title <EOL> from django . utils . http import urlencode <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from django . utils . translation import ungettext_lazy <EOL> from horizon import messages <EOL> from horizon import tables <EOL> from horizon . utils import filters <EOL> from heatclient import exc <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . dashboards . project . stacks import mappings <EOL> class LaunchStack ( tables . LinkAction ) : <EOL> name = "<STR_LIT>" <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> url = "<STR_LIT>" <EOL> classes = ( "<STR_LIT>" , ) <EOL> icon = "<STR_LIT>" <EOL> policy_rules = ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) <EOL> class ChangeStackTemplate ( tables . LinkAction ) : <EOL> name = "<STR_LIT>" <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> url = "<STR_LIT>" <EOL> classes = ( "<STR_LIT>" , ) <EOL> icon = "<STR_LIT>" <EOL> def get_link_url ( self , stack ) : <EOL> return urlresolvers . reverse ( self . url , args = [ stack . id ] ) <EOL> class DeleteStack ( tables . DeleteAction ) : <EOL> @ staticmethod <EOL> def action_present ( count ) : <EOL> return ungettext_lazy ( <EOL> u"<STR_LIT>" , <EOL> u"<STR_LIT>" , <EOL> count <EOL> ) <EOL> @ staticmethod <EOL> def action_past ( count ) : <EOL> return ungettext_lazy ( <EOL> u"<STR_LIT>" , <EOL> u"<STR_LIT>" , <EOL> count <EOL> ) <EOL> policy_rules = ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) <EOL> def delete ( self , request , stack_id ) : <EOL> api . heat . stack_delete ( request , stack_id ) <EOL> def allowed ( self , request , stack ) : <EOL> if stack is not None : <EOL> return stack . stack_status != '<STR_LIT>' <EOL> return True <EOL> class StacksUpdateRow ( tables . Row ) : <EOL> ajax = True <EOL> def can_be_selected ( self , datum ) : <EOL> return datum . stack_status != '<STR_LIT>' <EOL> def get_data ( self , request , stack_id ) : <EOL> try : <EOL> stack = api . heat . stack_get ( request , stack_id ) <EOL> if stack . stack_status == '<STR_LIT>' : <EOL> raise Http404 <EOL> return stack <EOL> except Http404 : <EOL> raise <EOL> except Exception as e : <EOL> messages . error ( request , e ) <EOL> raise <EOL> class StacksTable ( tables . DataTable ) : <EOL> STATUS_CHOICES = ( <EOL> ( "<STR_LIT>" , True ) , <EOL> ( "<STR_LIT>" , False ) , <EOL> ) <EOL> name = tables . Column ( "<STR_LIT>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> link = "<STR_LIT>" , ) <EOL> created = tables . Column ( "<STR_LIT>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> filters = ( filters . parse_isotime , <EOL> filters . timesince_or_never ) ) <EOL> updated = tables . Column ( "<STR_LIT>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> filters = ( filters . parse_isotime , <EOL> filters . timesince_or_never ) ) <EOL> status = tables . Column ( "<STR_LIT:status>" , <EOL> filters = ( title , filters . replace_underscores ) , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> status = True , <EOL> status_choices = STATUS_CHOICES ) <EOL> def get_object_display ( self , stack ) : <EOL> return stack . stack_name <EOL> class Meta : <EOL> name = "<STR_LIT>" <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> pagination_param = '<STR_LIT>' <EOL> status_columns = [ "<STR_LIT:status>" , ] <EOL> row_class = StacksUpdateRow <EOL> table_actions = ( LaunchStack , DeleteStack , ) <EOL> row_actions = ( DeleteStack , <EOL> ChangeStackTemplate ) <EOL> def get_resource_url ( obj ) : <EOL> return urlresolvers . reverse ( '<STR_LIT>' , <EOL> args = ( obj . stack_id , obj . resource_name ) ) <EOL> class EventsTable ( tables . DataTable ) : <EOL> logical_resource = tables . Column ( '<STR_LIT>' , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> link = get_resource_url ) <EOL> physical_resource = tables . Column ( '<STR_LIT>' , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> link = mappings . resource_to_url ) <EOL> timestamp = tables . Column ( '<STR_LIT>' , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> filters = ( filters . parse_isotime , <EOL> filters . timesince_or_never ) ) <EOL> status = tables . Column ( "<STR_LIT>" , <EOL> filters = ( title , filters . replace_underscores ) , <EOL> verbose_name = _ ( "<STR_LIT>" ) , ) <EOL> statusreason = tables . Column ( "<STR_LIT>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , ) <EOL> class Meta : <EOL> name = "<STR_LIT>" <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> class ResourcesUpdateRow ( tables . Row ) : <EOL> ajax = True <EOL> def get_data ( self , request , resource_name ) : <EOL> try : <EOL> stack = self . table . stack <EOL> stack_identifier = '<STR_LIT>' % ( stack . stack_name , stack . id ) <EOL> return api . heat . resource_get ( <EOL> request , stack_identifier , resource_name ) <EOL> except exc . HTTPNotFound : <EOL> raise Http404 <EOL> except Exception as e : <EOL> messages . error ( request , e ) <EOL> class ResourcesTable ( tables . DataTable ) : <EOL> STATUS_CHOICES = ( <EOL> ( "<STR_LIT>" , True ) , <EOL> ( "<STR_LIT>" , False ) , <EOL> ) <EOL> logical_resource = tables . Column ( '<STR_LIT>' , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> link = get_resource_url ) <EOL> physical_resource = tables . Column ( '<STR_LIT>' , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> link = mappings . resource_to_url ) <EOL> resource_type = tables . Column ( "<STR_LIT>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , ) <EOL> updated_time = tables . Column ( '<STR_LIT>' , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> filters = ( filters . parse_isotime , <EOL> filters . timesince_or_never ) ) <EOL> status = tables . Column ( "<STR_LIT>" , <EOL> filters = ( title , filters . replace_underscores ) , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> status = True , <EOL> status_choices = STATUS_CHOICES ) <EOL> statusreason = tables . Column ( "<STR_LIT>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , ) <EOL> def __init__ ( self , request , data = None , <EOL> needs_form_wrapper = None , ** kwargs ) : <EOL> super ( ResourcesTable , self ) . __init__ ( <EOL> request , data , needs_form_wrapper , ** kwargs ) <EOL> self . stack = kwargs [ '<STR_LIT>' ] <EOL> def get_object_id ( self , datum ) : <EOL> return datum . resource_name <EOL> class Meta : <EOL> name = "<STR_LIT>" <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> status_columns = [ "<STR_LIT:status>" , ] <EOL> row_class = ResourcesUpdateRow </s>
