예제 #1
0
    def populate_cluster_template_choices(self, request, context):
        templates = saharaclient.cluster_template_list(request)

        plugin, hadoop_version = whelpers.\
            get_plugin_and_hadoop_version(request)

        choices = [(template.id, template.name)
                   for template in templates
                   if (template.hadoop_version == hadoop_version and
                       template.plugin_name == plugin)]

        if not choices:
            choices.append(("", _("No Templates Available")))
        # cluster_template_id comes from cluster templates table, when
        # Create Cluster from template is clicked there
        selected_template_name = None
        if request.REQUEST.get("cluster_template_name"):
            selected_template_name = (
                request.REQUEST.get("cluster_template_name"))
        if selected_template_name:
            for template in templates:
                if template.name == selected_template_name:
                    selected_template_id = template.id
                    break
        else:
            selected_template_id = (
                request.REQUEST.get("cluster_template_id", None))

        for template in templates:
            if template.id == selected_template_id:
                self.fields['cluster_template'].initial = template.id

        return choices
예제 #2
0
파일: create.py 프로젝트: ypraveen/horizon
    def populate_cluster_template_choices(self, request, context):
        templates = saharaclient.cluster_template_list(request)

        plugin, hadoop_version = whelpers.\
            get_plugin_and_hadoop_version(request)

        choices = [(template.id, template.name) for template in templates
                   if (template.hadoop_version == hadoop_version
                       and template.plugin_name == plugin)]

        if not choices:
            choices.append(("", _("No Templates Available")))
        # cluster_template_id comes from cluster templates table, when
        # Create Cluster from template is clicked there
        selected_template_name = None
        resolver_match = urlresolvers.resolve(request.path)
        if "cluster_template_name" in resolver_match.kwargs:
            selected_template_name = (
                resolver_match.kwargs["cluster_template_name"])
        if selected_template_name:
            for template in templates:
                if template.name == selected_template_name:
                    selected_template_id = template.id
                    break
        else:
            selected_template_id = (request.REQUEST.get(
                "cluster_template_id", None))

        for template in templates:
            if template.id == selected_template_id:
                self.fields['cluster_template'].initial = template.id

        return choices
예제 #3
0
파일: views.py 프로젝트: 1oscar/horizon
 def get_data(self):
     try:
         cluster_templates = saharaclient.cluster_template_list(
             self.request)
     except Exception:
         cluster_templates = []
         exceptions.handle(self.request,
                           _("Unable to fetch cluster template list"))
     return cluster_templates
예제 #4
0
 def get_data(self):
     try:
         cluster_templates = saharaclient.cluster_template_list(
             self.request)
     except Exception:
         cluster_templates = []
         exceptions.handle(self.request,
                           _("Unable to fetch cluster template list"))
     return cluster_templates
예제 #5
0
파일: views.py 프로젝트: MindMincer/oph
 def get_data(self):
     try:
         search_opts = {}
         filter = self.get_server_filter_info(self.request)
         if filter['value'] and filter['field']:
             search_opts = {filter['field']: filter['value']}
         cluster_templates = saharaclient.cluster_template_list(
             self.request, search_opts)
     except Exception:
         cluster_templates = []
         exceptions.handle(self.request,
                           _("Unable to fetch cluster template list"))
     return cluster_templates
예제 #6
0
 def get_data(self):
     try:
         search_opts = {}
         filter = self.get_server_filter_info(self.request)
         if filter['value'] and filter['field']:
             search_opts = {filter['field']: filter['value']}
         cluster_templates = saharaclient.cluster_template_list(
             self.request, search_opts)
     except Exception:
         cluster_templates = []
         exceptions.handle(self.request,
                           _("Unable to fetch cluster template list"))
     return cluster_templates
예제 #7
0
파일: create.py 프로젝트: miurahr/horizon
    def populate_cluster_template_choices(self, request, context):
        templates = saharaclient.cluster_template_list(request)

        plugin, hadoop_version = whelpers.\
            get_plugin_and_hadoop_version(request)

        choices = [(template.id, template.name) for template in templates
                   if (template.hadoop_version == hadoop_version
                       and template.plugin_name == plugin)]

        # cluster_template_id comes from cluster templates table, when
        # Create Cluster from template is clicked there
        selected_template_id = request.REQUEST.get("cluster_template_id", None)

        for template in templates:
            if template.id == selected_template_id:
                self.fields['cluster_template'].initial = template.id

        return choices
예제 #8
0
파일: create.py 프로젝트: 308576950/test
    def populate_cluster_template_choices(self, request, context):
        templates = saharaclient.cluster_template_list(request)

        plugin, hadoop_version = whelpers.\
            get_plugin_and_hadoop_version(request)

        choices = [(template.id, template.name)
                   for template in templates
                   if (template.hadoop_version == hadoop_version and
                       template.plugin_name == plugin)]

        # cluster_template_id comes from cluster templates table, when
        # Create Cluster from template is clicked there
        selected_template_id = request.REQUEST.get("cluster_template_id", None)

        for template in templates:
            if template.id == selected_template_id:
                self.fields['cluster_template'].initial = template.id

        return choices
예제 #9
0
파일: views.py 프로젝트: Antoine-A/horizon
 def get_data(self):
     cluster_templates = saharaclient.cluster_template_list(self.request)
     return cluster_templates