Beispiel #1
0
    def get_data(self):
        filters = self.get_filters()

        prev_marker = self.request.GET.get(
            ClustersTable._meta.prev_pagination_param, None)

        if prev_marker is not None:
            marker = prev_marker
        else:
            marker = self.request.GET.get(
                ClustersTable._meta.pagination_param, None)
        reversed_order = prev_marker is not None
        try:
            clusters, self._more, self._prev = senlin.cluster_list(
                self.request,
                marker=marker,
                paginate=True,
                reversed_order=reversed_order,
                filters=filters)
        except Exception:
            self._prev = self._more = False
            clusters = []
            msg = _('Unable to retrieve clusters.')
            exceptions.handle(self.request, msg)
        return clusters
Beispiel #2
0
 def get_data(self):
     try:
         params = {}
         clusters = senlin.cluster_list(self.request, params)
     except Exception:
         clusters = []
         exceptions.handle(self.request,
                           _('Unable to retrieve clusters.'))
     return clusters
Beispiel #3
0
    def __init__(self, request, *args, **kwargs):
        super(CreateForm, self).__init__(request, *args, **kwargs)
        profiles = senlin.profile_list(request, params={})
        self.fields['profile_id'].choices = (
            [("", _("Select Profile"))] + [(profile.id, profile.name)
                                           for profile in profiles])

        clusters = senlin.cluster_list(request, params={})
        self.fields['cluster_id'].choices = (
            [("", _("Select Cluster"))] + [(cluster.id, cluster.name)
                                           for cluster in clusters])
Beispiel #4
0
    def __init__(self, request, *args, **kwargs):
        super(CreateForm, self).__init__(request, *args, **kwargs)
        profiles = senlin.profile_list(request)[0]
        self.fields['profile_id'].choices = (
            [("", _("Select Profile"))] + [(profile.id, profile.name)
                                           for profile in profiles])

        clusters = senlin.cluster_list(request)[0]
        self.fields['cluster_id'].choices = (
            [("", _("Select Cluster"))] + [(cluster.id, cluster.name)
                                           for cluster in clusters])
Beispiel #5
0
    def __init__(self, request, *args, **kwargs):
        super(CreateReceiverForm, self).__init__(request, *args, **kwargs)
        clusters = senlin.cluster_list(request, params={})
        self.fields['cluster_id'].choices = (
            [("", _("Select Cluster"))] + [(cluster.id, cluster.name)
                                           for cluster in clusters])

        type_choices = [
            ('', _("Select Type")),
            ("webhook", "webhook"),
        ]
        self.fields['type'].choices = type_choices
Beispiel #6
0
    def __init__(self, request, *args, **kwargs):
        super(CreateReceiverForm, self).__init__(request, *args, **kwargs)
        clusters = senlin.cluster_list(request)[0]
        self.fields['cluster_id'].choices = ([("", _("Select Cluster"))] +
                                             [(cluster.id, cluster.name)
                                              for cluster in clusters])

        type_choices = [
            ('', _("Select Type")),
            ("webhook", "webhook"),
        ]
        self.fields['type'].choices = type_choices
Beispiel #7
0
    def get(self, request):
        """Get a list of clusters."""

        filters, kwargs = rest_utils.parse_filters_kwargs(request,
                                                          CLIENT_KEYWORDS)

        clusters, has_more_data, has_prev_data = senlin.cluster_list(
            request, filters=filters, **kwargs)

        return {
            'items': [c.to_dict() for c in clusters],
            'has_more_data': has_more_data,
            'has_prev_data': has_prev_data,
        }
Beispiel #8
0
    def get(self, request):
        """Get a list of clusters."""

        filters, kwargs = rest_utils.parse_filters_kwargs(
            request, CLIENT_KEYWORDS)

        clusters, has_more_data, has_prev_data = senlin.cluster_list(
            request, filters=filters, **kwargs)

        return {
            'items': [c.to_dict() for c in clusters],
            'has_more_data': has_more_data,
            'has_prev_data': has_prev_data,
        }
Beispiel #9
0
    def get_data(self):
        filters = self.get_filters()

        prev_marker = self.request.GET.get(ClustersTable._meta.prev_pagination_param, None)

        if prev_marker is not None:
            marker = prev_marker
        else:
            marker = self.request.GET.get(ClustersTable._meta.pagination_param, None)
        reversed_order = prev_marker is not None
        try:
            clusters, self._more, self._prev = senlin.cluster_list(
                self.request, marker=marker, paginate=True, reversed_order=reversed_order, filters=filters
            )
        except Exception:
            self._prev = self._more = False
            clusters = []
            msg = _("Unable to retrieve clusters.")
            exceptions.handle(self.request, msg)
        return clusters