def get_data(self): try: sec_service_id = self.kwargs['sec_service_id'] sec_service = manila.security_service_get( self.request, sec_service_id) sec_service.type = utils.get_nice_security_service_type( sec_service) except Exception: message = _("Unable to retrieve security service " "'%s' details.") % sec_service_id exceptions.handle( self.request, message, redirect=self.redirect_url) return sec_service
def get_data(self): try: sec_service_id = self.kwargs['sec_service_id'] sec_service = manila.security_service_get( self.request, sec_service_id) sec_service.type = utils.get_nice_security_service_type( sec_service) except Exception: message = _("Unable to retrieve security service " "'%s' details.") % sec_service_id exceptions.handle( self.request, message, redirect=self.redirect_url) return sec_service
def get_data(self): try: share_net_id = self.kwargs['share_network_id'] share_net = manila.share_network_get(self.request, share_net_id) if base.is_service_enabled(self.request, 'network'): try: share_net.neutron_net = neutron.network_get( self.request, share_net.neutron_net_id).name_or_id except ( neutron.neutron_client.exceptions.NeutronClientException): share_net.neutron_net = _("Unknown") try: share_net.neutron_subnet = neutron.subnet_get( self.request, share_net.neutron_subnet_id).name_or_id except ( neutron.neutron_client.exceptions.NeutronClientException): share_net.neutron_subnet = _("Unknown") else: try: share_net.nova_net = network.network_get( self.request, share_net.nova_net_id).name_or_id except Exception: share_net.nova_net = _("Unknown") share_net.sec_services = ( manila.share_network_security_service_list( self.request, share_net_id)) for ss in share_net.sec_services: ss.type = utils.get_nice_security_service_type(ss) server_search_opts = {'share_network_id': share_net_id} try: share_servs = manila.share_server_list( self.request, search_opts=server_search_opts) # Non admins won't be able to get share servers except Exception: share_servs = [] if share_servs: share_net.share_servers = share_servs except Exception: exceptions.handle(self.request, _('Unable to retrieve share network details.'), redirect=self.redirect_url) return share_net
def get_data(self): try: share_net_id = self.kwargs['share_network_id'] share_net = manila.share_network_get(self.request, share_net_id) if base.is_service_enabled(self.request, 'network'): try: share_net.neutron_net = neutron.network_get( self.request, share_net.neutron_net_id).name_or_id except (neutron.neutron_client.exceptions. NeutronClientException): share_net.neutron_net = _("Unknown") try: share_net.neutron_subnet = neutron.subnet_get( self.request, share_net.neutron_subnet_id).name_or_id except (neutron.neutron_client.exceptions. NeutronClientException): share_net.neutron_subnet = _("Unknown") else: try: share_net.nova_net = network.network_get( self.request, share_net.nova_net_id).name_or_id except Exception: share_net.nova_net = _("Unknown") share_net.sec_services = ( manila.share_network_security_service_list( self.request, share_net_id)) for ss in share_net.sec_services: ss.type = utils.get_nice_security_service_type(ss) server_search_opts = {'share_network_id': share_net_id} try: share_servs = manila.share_server_list( self.request, search_opts=server_search_opts) # Non admins won't be able to get share servers except Exception: share_servs = [] if share_servs: share_net.share_servers = share_servs except Exception: exceptions.handle(self.request, _('Unable to retrieve share network details.'), redirect=self.redirect_url) return share_net
def test_get_nice_security_service_type(self, input_value, expected_value): security_service = type("FakeSS", (object, ), {"type": input_value})() result = utils.get_nice_security_service_type(security_service) self.assertEqual(expected_value, result)
def test_get_nice_security_service_type(self, input_value, expected_value): security_service = type("FakeSS", (object, ), {"type": input_value})() result = utils.get_nice_security_service_type(security_service) self.assertEqual(expected_value, result)