def _pool_get(request, pool_id, expand_resource=False): try: pool = neutronclient(request).show_pool(pool_id).get('pool') except Exception: messages.warning(request, _("Unable to get pool detail.")) return None if expand_resource: # TODO(lyj): The expand resource(subnet, member etc.) attached # to a pool could be deleted without cleanup pool related database, # this will cause exceptions if we trying to get the deleted resources. # so we need to handle the situation by showing a warning message here. # we can safely remove the try/except once the neutron bug is fixed # https://bugs.launchpad.net/neutron/+bug/1406854 try: pool['subnet'] = neutron.subnet_get(request, pool['subnet_id']) except Exception: messages.warning(request, _("Unable to get subnet for pool " "%(pool)s.") % {"pool": pool_id}) pool['vip'] = _get_vip(request, pool, vip_dict=None, expand_name_only=False) try: pool['members'] = _member_list(request, expand_pool=False, pool_id=pool_id) except Exception: messages.warning(request, _("Unable to get members for pool " "%(pool)s.") % {"pool": pool_id}) try: pool['health_monitors'] = pool_health_monitor_list( request, id=pool['health_monitors']) except Exception: messages.warning(request, _("Unable to get health monitors " "for pool %(pool)s.") % {"pool": pool_id}) return Pool(pool)
def readable(self, request): pFormatted = {'id': self.id, 'name': self.name, 'description': self.description, 'status': self.status, 'protocol': self.protocol, 'health_monitors': self.health_monitors, 'provider': self.provider} try: pFormatted['subnet_id'] = self.subnet_id pFormatted['subnet_name'] = neutron.subnet_get( request, self.subnet_id).cidr except Exception: pFormatted['subnet_id'] = self.subnet_id pFormatted['subnet_name'] = self.subnet_id if self.vip_id is not None: try: pFormatted['vip_id'] = self.vip_id pFormatted['vip_name'] = vip_get( request, self.vip_id).name except Exception: pFormatted['vip_id'] = self.vip_id pFormatted['vip_name'] = self.vip_id else: pFormatted['vip_id'] = None pFormatted['vip_name'] = None return self.AttributeDict(pFormatted)
def _vip_get(request, vip_id, expand_resource=False): vip = neutronclient(request).show_vip(vip_id).get('vip') if expand_resource: vip['subnet'] = neutron.subnet_get(request, vip['subnet_id']) vip['port'] = neutron.port_get(request, vip['port_id']) vip['pool'] = _pool_get(request, vip['pool_id']) return Vip(vip)
def readable(self, request): pFormatted = { "id": self.id, "name": self.name, "description": self.description, "protocol": self.protocol, "health_monitors": self.health_monitors, } try: pFormatted["subnet_id"] = self.subnet_id pFormatted["subnet_name"] = neutron.subnet_get(request, self.subnet_id).cidr except Exception: pFormatted["subnet_id"] = self.subnet_id pFormatted["subnet_name"] = self.subnet_id if self.vip_id is not None: try: pFormatted["vip_id"] = self.vip_id pFormatted["vip_name"] = vip_get(request, self.vip_id).name except Exception: pFormatted["vip_id"] = self.vip_id pFormatted["vip_name"] = self.vip_id else: pFormatted["vip_id"] = None pFormatted["vip_name"] = None return self.AttributeDict(pFormatted)
def readable(self, request): pFormatted = { 'id': self.id, 'name': self.name, 'description': self.description, 'protocol': self.protocol, 'health_monitors': self.health_monitors } try: pFormatted['subnet_id'] = self.subnet_id pFormatted['subnet_name'] = subnet_get(request, self.subnet_id).cidr except: pFormatted['subnet_id'] = self.subnet_id pFormatted['subnet_name'] = self.subnet_id if self.vip_id is not None: try: pFormatted['vip_id'] = self.vip_id pFormatted['vip_name'] = vip_get(request, self.vip_id).name except: pFormatted['vip_id'] = self.vip_id pFormatted['vip_name'] = self.vip_id else: pFormatted['vip_id'] = None pFormatted['vip_name'] = None return self.AttributeDict(pFormatted)
def readable(self, request): sFormatted = { 'id': self.id, 'name': self.name, 'description': self.description, 'admin_state_up': self.admin_state_up, 'status': self.status, } try: sFormatted['subnet_id'] = self.subnet_id sFormatted['subnet_name'] = neutron.subnet_get( request, self.subnet_id).cidr except Exception: sFormatted['subnet_id'] = self.subnet_id sFormatted['subnet_name'] = self.subnet_id try: sFormatted['router_id'] = self.router_id sFormatted['router_name'] = neutron.router_get( request, self.router_id).name except Exception: sFormatted['router_id'] = self.router_id sFormatted['router_name'] = self.router_id return self.AttributeDict(sFormatted)
def _vip_get(request, vip_id, expand_resource=False): vip = neutronclient(request).show_vip(vip_id).get("vip") if expand_resource: vip["subnet"] = neutron.subnet_get(request, vip["subnet_id"]) vip["port"] = neutron.port_get(request, vip["port_id"]) vip["pool"] = _pool_get(request, vip["pool_id"]) return Vip(vip)
def _pool_get(request, pool_id, expand_subnet=False, expand_vip=False): pool = neutronclient(request).show_pool(pool_id).get('pool') if expand_subnet: pool['subnet_name'] = neutron.subnet_get(request, pool['subnet_id']).cidr if expand_vip: pool['vip_name'] = _get_vip_name(request, pool, vip_dict=False) return Pool(pool)
def _pool_get(request, pool_id, expand_resource=False): pool = neutronclient(request).show_pool(pool_id).get("pool") if expand_resource: pool["subnet"] = neutron.subnet_get(request, pool["subnet_id"]) pool["vip"] = _get_vip(request, pool, vip_dict=None, expand_name_only=False) pool["members"] = _member_list(request, expand_pool=False, pool_id=pool_id) pool["health_monitors"] = pool_health_monitor_list(request, id=pool["health_monitors"]) return Pool(pool)
def get_data(self, request, share_net_id): share_net = manila.share_network_get(request, share_net_id) neutron_enabled = base.is_service_enabled(request, 'network') if neutron_enabled: share_net.neutron_net = neutron.network_get( request, share_net.neutron_net_id).name_or_id share_net.neutron_subnet = neutron.subnet_get( request, share_net.neutron_subnet_id).name_or_id return share_net
def _pool_get(request, pool_id, expand_resource=False): pool = neutronclient(request).show_pool(pool_id).get('pool') if expand_resource: pool['subnet'] = neutron.subnet_get(request, pool['subnet_id']) pool['vip'] = _get_vip(request, pool, vip_dict=None, expand_name_only=False) pool['members'] = _member_list(request, expand_pool=False, pool_id=pool_id) pool['health_monitors'] = pool_health_monitor_list( request, id=pool['health_monitors']) return Pool(pool)
def get_data(self, request, share_net_id): share_net = manila.share_network_get(request, share_net_id) neutron_enabled = base.is_service_enabled(request, 'network') if neutron_enabled: share_net.neutron_net = neutron.network_get( request, share_net.neutron_net_id).name_or_id share_net.neutron_subnet = neutron.subnet_get( request, share_net.neutron_subnet_id).name_or_id else: share_net.nova_net = network.network_get( request, share_net.nova_net_id).name_or_id return share_net
def _pool_get(request, pool_id, expand_resource=False): try: pool = neutronclient(request).show_pool(pool_id).get('pool') except Exception: messages.warning(request, _("Unable to get pool detail.")) return None if expand_resource: # TODO(lyj): The expand resource(subnet, member etc.) attached # to a pool could be deleted without cleanup pool related database, # this will cause exceptions if we trying to get the deleted resources. # so we need to handle the situation by showing a warning message here. # we can safely remove the try/except once the neutron bug is fixed # https://bugs.launchpad.net/neutron/+bug/1406854 try: pool['subnet'] = neutron.subnet_get(request, pool['subnet_id']) except Exception: messages.warning( request, _("Unable to get subnet for pool " "%(pool)s.") % {"pool": pool_id}) pool['vip'] = _get_vip(request, pool, vip_dict=None) # Check here to reduce the additional request if pool['members'] is # empty if pool['members']: try: pool['members'] = _member_list(request, expand_pool=False, pool_id=pool_id) except Exception: messages.warning( request, _("Unable to get members for pool " "%(pool)s.") % {"pool": pool_id}) # If the filter to get health monitors list is empty, all health # monitors will be returned in the tenant. if pool['health_monitors']: monitors = [] for monitor_id in pool['health_monitors']: try: monitors.append( _pool_health_monitor_get(request, monitor_id, False)) except Exception: messages.warning( request, _("Unable to get health monitor " "%(monitor_id)s for pool %(pool)s.") % { "pool": pool_id, "monitor_id": monitor_id }) pool['health_monitors'] = monitors return Pool(pool)
def _vpnservice_get(request, vpnservice_id, expand_subnet=False, expand_router=False, expand_conns=False): vpnservice = neutronclient(request).show_vpnservice(vpnservice_id).get( 'vpnservice') if expand_subnet: vpnservice['subnet'] = neutron.subnet_get( request, vpnservice['subnet_id']) if expand_router: vpnservice['router'] = neutron.router_get( request, vpnservice['router_id']) if expand_conns: ipsecsiteconns = _ipsecsiteconnection_list(request) vpnservice['ipsecsiteconns'] = [c for c in ipsecsiteconns if c.vpnservice_id == vpnservice['id']] return VPNService(vpnservice)
def _pool_get(request, pool_id, expand_resource=False): try: pool = neutronclient(request).show_pool(pool_id).get('pool') except Exception: messages.warning(request, _("Unable to get pool detail.")) return None if expand_resource: # TODO(lyj): The expand resource(subnet, member etc.) attached # to a pool could be deleted without cleanup pool related database, # this will cause exceptions if we trying to get the deleted resources. # so we need to handle the situation by showing a warning message here. # we can safely remove the try/except once the neutron bug is fixed # https://bugs.launchpad.net/neutron/+bug/1406854 try: pool['subnet'] = neutron.subnet_get(request, pool['subnet_id']) except Exception: messages.warning(request, _("Unable to get subnet for pool " "%(pool)s.") % {"pool": pool_id}) pool['vip'] = _get_vip(request, pool, vip_dict=None) # Check here to reduce the additional request if pool['members'] is # empty if pool['members']: try: pool['members'] = _member_list(request, expand_pool=False, pool_id=pool_id) except Exception: messages.warning(request, _("Unable to get members for pool " "%(pool)s.") % {"pool": pool_id}) # If the filter to get health monitors list is empty, all health # monitors will be returned in the tenant. if pool['health_monitors']: monitors = [] for monitor_id in pool['health_monitors']: try: monitors.append(_pool_health_monitor_get(request, monitor_id, False)) except Exception: messages.warning(request, _("Unable to get health monitor " "%(monitor_id)s for pool %(pool)s.") % {"pool": pool_id, "monitor_id": monitor_id}) pool['health_monitors'] = monitors return Pool(pool)
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 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) server_search_opts = {'share_network_id': share_net_id} share_servs = manila.share_server_list( self.request, search_opts=server_search_opts) share_net.share_servers = share_servs except Exception: redirect = reverse('horizon:project:shares:index') exceptions.handle(self.request, _('Unable to retrieve share network details.'), redirect=redirect) 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) server_search_opts = {'share_network_id': share_net_id} share_servs = manila.share_server_list( self.request, search_opts=server_search_opts) share_net.share_servers = share_servs except Exception: redirect = reverse('horizon:project:shares:index') exceptions.handle(self.request, _('Unable to retrieve share network details.'), redirect=redirect) return share_net
def readable(self, request): sFormatted = {'id': self.id, 'name': self.name, 'description': self.description, 'admin_state_up': self.admin_state_up, 'status': self.status, } try: sFormatted['subnet_id'] = self.subnet_id sFormatted['subnet_name'] = neutron.subnet_get( request, self.subnet_id).cidr except Exception: sFormatted['subnet_id'] = self.subnet_id sFormatted['subnet_name'] = self.subnet_id try: sFormatted['router_id'] = self.router_id sFormatted['router_name'] = neutron.router_get( request, self.router_id).name except Exception: sFormatted['router_id'] = self.router_id sFormatted['router_name'] = self.router_id return self.AttributeDict(sFormatted)