def __init__(self, request, *args, **kwargs): super(AddSecurityServiceAction, self).__init__(request, *args, **kwargs) err_msg = _('Unable to get the security services hosts') default_role_field_name = self.get_default_role_field_name() self.fields[default_role_field_name] = forms.CharField(required=False) self.fields[default_role_field_name].initial = 'member' field_name = self.get_member_field_name('member') self.fields[field_name] = forms.MultipleChoiceField(required=False) share_network_id = self.initial['id'] security_services = manila.share_network_security_service_list( request, share_network_id) sec_services_initial = [sec_service.id for sec_service in security_services] sec_services = [] try: sec_services = manila.security_service_list(request) except Exception: exceptions.handle(request, err_msg) sec_services_choices = [(sec_service.id, sec_service.name or sec_service.id) for sec_service in sec_services] self.fields[field_name].choices = sec_services_choices self.fields[field_name].initial = sec_services_initial
def __init__(self, request, *args, **kwargs): super(AddSecurityServiceAction, self).__init__(request, *args, **kwargs) err_msg = _('Unable to get the security services hosts') default_role_field_name = self.get_default_role_field_name() self.fields[default_role_field_name] = forms.CharField(required=False) self.fields[default_role_field_name].initial = 'member' field_name = self.get_member_field_name('member') self.fields[field_name] = forms.MultipleChoiceField(required=False) share_network_id = self.initial['id'] security_services = manila.share_network_security_service_list( request, share_network_id) sec_services_initial = [ sec_service.id for sec_service in security_services ] sec_services = [] try: sec_services = manila.security_service_list(request) except Exception: exceptions.handle(request, err_msg) sec_services_choices = [(sec_service.id, sec_service.name or sec_service.id) for sec_service in sec_services] self.fields[field_name].choices = sec_services_choices self.fields[field_name].initial = sec_services_initial
def __init__(self, request, *args, **kwargs): super(AddSecurityServiceForm, self).__init__(request, *args, **kwargs) sec_services_choices = manila.security_service_list(request) self.fields['sec_service'].choices = [(' ', ' ')] + \ [(choice.id, choice.name or choice.id) for choice in sec_services_choices]
def __init__(self, request, *args, **kwargs): super(AddSecurityServiceForm, self).__init__( request, *args, **kwargs) sec_services_choices = manila.security_service_list(request) self.fields['sec_service'].choices = [(' ', ' ')] + \ [(choice.id, choice.name or choice.id) for choice in sec_services_choices]
def get_security_services_data(self): try: security_services = manila.security_service_list(self.request) except Exception: security_services = [] exceptions.handle(self.request, _("Unable to retrieve security services")) return security_services
def get_security_services_data(self): try: security_services = manila.security_service_list( self.request, search_opts={'all_tenants': True}) utils.set_project_name_to_objects(self.request, security_services) except Exception: security_services = [] exceptions.handle( self.request, _("Unable to retrieve security services")) return security_services
def get_security_services_data(self): try: security_services = manila.security_service_list( self.request, search_opts={'all_tenants': True}) utils.set_project_name_to_objects(self.request, security_services) except Exception: security_services = [] exceptions.handle(self.request, _("Unable to retrieve security services")) return security_services
def handle(self, request, context): try: manila.share_network_update(request, context['id'], description=context['description'], name=context['name']) sec_services = manila.security_service_list( request, search_opts={'share_network_id': context['id']}) sec_services_old = set( [sec_service.id for sec_service in sec_services]) sec_services_new = set(context['security_service']) for sec_service in sec_services_new - sec_services_old: manila.share_network_security_service_add( request, context['id'], sec_service) for sec_service in sec_services_old - sec_services_new: manila.share_network_security_service_remove( request, context['id'], sec_service) return True except Exception: exceptions.handle(request, _('Unable to update share network.')) return False
def handle(self, request, context): try: manila.share_network_update(request, context['id'], description=context['description'], name=context['name']) sec_services = manila.security_service_list(request, search_opts={ 'share_network_id': context['id']}) sec_services_old = set([sec_service.id for sec_service in sec_services]) sec_services_new = set(context['security_service']) for sec_service in sec_services_new - sec_services_old: manila.share_network_security_service_add(request, context['id'], sec_service) for sec_service in sec_services_old - sec_services_new: manila.share_network_security_service_remove(request, context['id'], sec_service) return True except Exception: exceptions.handle(request, _('Unable to update share network.')) return False
def test_security_service_list(self, kwargs): api.security_service_list(self.request, **kwargs) self.manilaclient.security_services.list.assert_called_once_with( detailed=True, search_opts=kwargs.get("search_opts", None))