Esempio n. 1
0
 def filter_options(self, request, *args, **kwargs):
     del args, kwargs, request  # unused
     filter_options = {
         'statuses':
         statuses_dict_to_statuses_choices(
             VolumeBackupStatus.status_map.items()),
     }
     return Response(filter_options)
Esempio n. 2
0
 def filter_options(self, request):
     regions = self.get_regions_qs()
     return Response({
         'regions':
         RegionSerializer(regions, many=True).data,
         'statuses':
         statuses_dict_to_statuses_choices(
             dictionary=ClusterStatus.choices.items()),
     })
Esempio n. 3
0
 def filter_options(self, request, *args, **kwargs):
     del args, kwargs  # unused
     selected_region, regions = get_regions(request,
                                            filter_for='volumes',
                                            for_end_user=True)
     filter_options = {
         'regions':
         regions,
         'statuses':
         statuses_dict_to_statuses_choices(VolumeStatus.status_map.items()),
     }
     return Response(filter_options)
Esempio n. 4
0
 def list(self, request, *args, **kwargs):
     response = super().list(request=request, *args, **kwargs)
     response.data['permissions'] = permissions_cache.get_view_permissions(
         request.user, self.basename)
     # TODO(manu): remove region choices once filtering in frontend is based on records search
     region_name, region_options = self.get_regions(request)
     region_filtering_options = []
     for region in region_options:
         region_filtering_options.append({
             'display': region['id'],
             'value': region['id'],
         })
     filter_options = {
         'region':
         region_filtering_options,
         'status':
         statuses_dict_to_statuses_choices(
             InstanceStatus.status_map.items()),
         'task_state':
         statuses_dict_to_statuses_choices(
             InstanceTask.task_state_filtering_opts_map.items())
     }
     response.data['filter_options'] = filter_options
     return response
Esempio n. 5
0
    def create_options(self, request, *args, **kwargs):
        del args, kwargs  # unused

        selected_region, regions = get_regions(request)
        create_options = {'regions': regions,
                          'container_formats': [x for (x, y) in OpenstackImage.IMAGE_CONTAINER_FORMAT],
                          'disk_formats': [x for (x, y) in OpenstackImage.IMAGE_DISK_FORMAT],
                          'visibilities': [x for (x, y) in OpenstackImage.IMAGE_VISIBILITY],
                          'os_distros': [x for (x, y) in settings.OS_TYPES],
                          'hypervisor_types': [x for x in settings.OS_HYPERVISOR_TYPES],
                          'selected_region': selected_region,
                          'statuses': statuses_dict_to_statuses_choices(OpenstackImage.IMAGE_STATUS),
                          'allowed_formats': getattr(django_settings, 'OS_IMAGE_UPLOAD_FORMATS', [])
                          }
        return Response(create_options)
Esempio n. 6
0
 def create_options(self, request):
     selected_region, regions = get_regions(request, for_end_user=True)
     client = request.user.clients.first()
     openstack_settings = OpenstackSettings.for_client(
         client=client) if client else None
     create_options = {
         'regions':
         regions,
         'container_formats':
         [x for (x, y) in Image.IMAGE_CONTAINER_FORMAT],
         'disk_formats': [x for (x, y) in Image.IMAGE_DISK_FORMAT],
         'visibilities':
         OpenStackImageVisibility.get_user_choices(),
         'os_distros': [x for (x, y) in settings.OS_TYPES],
         'selected_region':
         selected_region,
         'hypervisor_types': [x for x in settings.OS_HYPERVISOR_TYPES],
         'statuses':
         statuses_dict_to_statuses_choices(Image.IMAGE_STATUS),
         'cleanup_enabled':
         openstack_settings.auto_cleanup_images
         if openstack_settings else False,
         'cleanup_days':
         openstack_settings.auto_cleanup_number_of_days
         if openstack_settings else False,
         'cleanup_formats':
         openstack_settings.auto_cleanup_image_types
         if openstack_settings else None,
         'allowed_formats':
         getattr(django_settings, 'OS_IMAGE_UPLOAD_FORMATS', []),
         'can_create_resource':
         check_if_enough_credit(
             client=self.request.user.clients.all().first(),
             update_uptodate_credit=False,
         ),
     }
     return Response(create_options)
Esempio n. 7
0
 def filter_options(self, request):
     return Response({
         'statuses': statuses_dict_to_statuses_choices(dictionary=TODOStatus.status_map.items()),
     })