Esempio n. 1
0
 def __init__(self, request, *args, **kwargs):
     super(CreateVolumeType, self).__init__(request, *args, **kwargs)
     services = cinder.service_list(request)
     choice = []
     for service in services:
         if service.binary == 'cinder-volume':
             host = service.host
             try:
                 new_choice = host.split("@")[1]
             except Exception:
                 new_choice = []
             if new_choice:
                 choice.append((new_choice, new_choice))
     if len(choice) == 0:
         choice = (("",
                    _("No backend found.(Will not set with a backend)")),)
     else:
         choice.insert(0, ("", _("Do not set with a backend")))
     self.fields['backend'].choices = choice
     ordering = ['name', 'backend', 'vol_type_description']
     # Starting from 1.7 Django uses OrderedDict for fields and keyOrder
     # no longer works for it
     if django.VERSION >= (1, 7):
         self.fields = collections.OrderedDict(
             (key, self.fields[key]) for key in ordering)
     else:
         self.fields.keyOrder = ordering
Esempio n. 2
0
 def get_cinder_services_data(self):
     try:
         services = cinder.service_list(self.tab_group.request)
     except Exception:
         msg = _('Unable to get cinder services list.')
         exceptions.handle(self.request, msg)
         services = []
     return services
Esempio n. 3
0
 def get_cinder_services_data(self):
     try:
         services = cinder.service_list(self.tab_group.request)
     except Exception:
         msg = _("Unable to get cinder services list.")
         exceptions.check_message(["Connection", "refused"], msg)
         exceptions.handle(self.request, msg)
         services = []
     return services
Esempio n. 4
0
    def get_cinder_services_data(self):
        try:
            services = cinder.service_list(self.tab_group.request)
        except Exception:
            msg = _('Unable to get cinder services list.')
            exceptions.check_message(["Connection", "refused"], msg)
            raise

        return services