Esempio n. 1
0
 def _get_vpp_router(self, context, router_id):
     try:
         router = model_query.get_by_id(context, Router, router_id)
     except Exception:
         raise n_exc.BadRequest("L3 Router not found for router_id: %s",
                                router_id)
     return router
Esempio n. 2
0
 def _get_gateway_device(self, context, device_id):
     try:
         return model_query.get_by_id(context,
                                      nsx_models.NetworkGatewayDevice,
                                      device_id)
     except sa_orm_exc.NoResultFound:
         raise GatewayDeviceNotFound(device_id=device_id)
Esempio n. 3
0
 def _get_port(self, context, id, lazy_fields=None):
     try:
         port = model_query.get_by_id(context, models_v2.Port, id,
                                      lazy_fields=lazy_fields)
     except exc.NoResultFound:
         raise exceptions.PortNotFound(port_id=id)
     return port
Esempio n. 4
0
 def _get_switchport_mapping(context, resource_id):
     try:
         gw_map_db = lib_model_query.get_by_id(
             context, nuage_models.NuageSwitchportMapping, resource_id)
     except sql_exc.NoResultFound:
         raise _ext.SwitchportNotFound(id=resource_id)
     return gw_map_db
Esempio n. 5
0
 def _get_gateway_device(self, context, device_id):
     try:
         return model_query.get_by_id(context,
                                      nsx_models.NetworkGatewayDevice,
                                      device_id)
     except sa_orm_exc.NoResultFound:
         raise GatewayDeviceNotFound(device_id=device_id)
 def _get_resource(self, context, model, id, for_update=False):
     resource = None
     try:
         if for_update:
             # To lock the instance for update, return a single
             # instance, instead of an instance with LEFT OUTER
             # JOINs that do not work in PostgreSQL
             query = model_query.query_with_hooks(context, model).options(
                 lazyload('*')
             ).filter(
                 model.id == id).with_lockmode('update')
             resource = query.one()
         else:
             resource = model_query.get_by_id(context, model, id)
     except exc.NoResultFound:
         with excutils.save_and_reraise_exception(reraise=False) as ctx:
             if issubclass(model, (models.LoadBalancer, models.Listener,
                                   models.L7Policy, models.L7Rule,
                                   models.PoolV2, models.MemberV2,
                                   models.HealthMonitorV2,
                                   models.LoadBalancerStatistics,
                                   models.SessionPersistenceV2)):
                 raise loadbalancerv2.EntityNotFound(name=model.NAME, id=id)
             ctx.reraise = True
     return resource
Esempio n. 7
0
 def _get_port_pair_detail(self, id):
     try:
         port = model_query.get_by_id(
             self.admin_context, PortPairDetail, id)
     except exc.NoResultFound:
         raise PortPairDetailNotFound(port_id=id)
     return port
Esempio n. 8
0
 def _get_reachabilityquicktest(self, context, id):
     try:
         reachabilityquicktest = model_query.get_by_id(
             context, ReachabilityQuickTest, id)
     except exc.NoResultFound:
         raise ReachabilityTestNotFound(id=id)
     return reachabilityquicktest
Esempio n. 9
0
 def _get_resource(self, context, resource, resource_id):
     model = resource_model_map[resource]
     try:
         return model_query.get_by_id(context, model, resource_id)
     except exc.NoResultFound:
         raise tagging.TagResourceNotFound(resource=resource,
                                           resource_id=resource_id)
 def _get_networktemplate(self, context, id):
     try:
         networktemplate = model_query.get_by_id(context, NetworkTemplate,
                                                 id)
     except exc.NoResultFound:
         raise NetworkTemplateNotFound(id=id)
     return networktemplate
Esempio n. 11
0
 def _get_resource(self, context, resource, resource_id):
     model = resource_model_map[resource]
     try:
         return model_query.get_by_id(context, model, resource_id)
     except exc.NoResultFound:
         raise tagging.TagResourceNotFound(resource=resource,
                                           resource_id=resource_id)
Esempio n. 12
0
 def _get_network_gateway(self, context, gw_id):
     try:
         gw = model_query.get_by_id(context, nsx_models.NetworkGateway,
                                    gw_id)
     except sa_orm_exc.NoResultFound:
         raise GatewayNotFound(gateway_id=gw_id)
     return gw
Esempio n. 13
0
 def _get_network_gateway(self, context, gw_id):
     try:
         gw = model_query.get_by_id(context, nsx_models.NetworkGateway,
                                    gw_id)
     except sa_orm_exc.NoResultFound:
         raise GatewayNotFound(gateway_id=gw_id)
     return gw
Esempio n. 14
0
 def get_port_detail_without_exception(self, id):
     with db_api.CONTEXT_READER.using(self.admin_context):
         try:
             port = model_query.get_by_id(
                 self.admin_context, PortPairDetail, id)
         except exc.NoResultFound:
             return None
         return self._make_port_detail_dict(port)
Esempio n. 15
0
 def _get_subnet(self, context, id):
     # TODO(slaweq): remove this method when all will be switched to use OVO
     # objects only
     try:
         subnet = model_query.get_by_id(context, models_v2.Subnet, id)
     except exc.NoResultFound:
         raise exceptions.SubnetNotFound(subnet_id=id)
     return subnet
Esempio n. 16
0
 def _get_subnet(self, context, id):
     # TODO(slaweq): remove this method when all will be switched to use OVO
     # objects only
     try:
         subnet = model_query.get_by_id(context, models_v2.Subnet, id)
     except exc.NoResultFound:
         raise exceptions.SubnetNotFound(subnet_id=id)
     return subnet
Esempio n. 17
0
    def _get_switchport_binding(context, resource_id):
        try:
            gw_bind_db = lib_model_query.get_by_id(
                context, nuage_models.NuageSwitchportBinding, resource_id)
            query = context.session.query(
                nuage_models.NuageSwitchportMapping.switch_id,
                nuage_models.NuageSwitchportMapping.port_id)
            query = query.filter(nuage_models.NuageSwitchportMapping.port_uuid
                                 == gw_bind_db['switchport_uuid']).distinct()
            switch, port = query.one()
            gw_bind_db['port_id'] = port
            gw_bind_db['switch_id'] = switch

        except sql_exc.NoResultFound:
            raise _ext.SwitchportBindingNotFound(id=resource_id)
        return gw_bind_db
Esempio n. 18
0
    def _build_bagpipe_classifier_from_fc(self, fc, reverse, source_bgpvpns):
        classifier = {}
        classifier['protocol'] = fc['protocol']

        for side in (constants.SOURCE, constants.DESTINATION):
            flow_side = constants.REVERSE_FLOW_SIDE[side] if reverse else side

            port_range_min = fc[side + '_port_range_min']
            port_range_max = fc[side + '_port_range_max']
            if port_range_min is not None:
                if (port_range_max is not None and
                        port_range_min != port_range_max):
                    classifier[flow_side + 'Port'] = ':'.join(
                        [str(port_range_min), str(port_range_max)]
                    )
                else:
                    classifier[flow_side + 'Port'] = str(port_range_min)

            if flow_side == constants.SOURCE and source_bgpvpns:
                continue

            logical_port = fc['logical_' + side + '_port']
            if logical_port is not None:
                port = model_query.get_by_id(
                    self.admin_context, models_v2.Port, logical_port
                )
                if fc[side + '_ip_prefix'] is None:
                    ips = port['fixed_ips']
                    # For now, only handle when the port has a single IP
                    if len(ips) == 1:
                        classifier[flow_side + 'Prefix'] = (
                            ips[0]['ip_address'] + '/32'
                        )
                else:
                    classifier[flow_side + 'Prefix'] = (
                        fc[side + '_ip_prefix']
                    )
            else:
                if fc[side + '_ip_prefix'] is not None:
                    classifier[flow_side + 'Prefix'] = (
                        fc[side + '_ip_prefix']
                    )

        return classifier
Esempio n. 19
0
 def _get_resource(self, context, model, v_id):
     try:
         r = model_query.get_by_id(context, model, v_id)
     except exc.NoResultFound:
         with excutils.save_and_reraise_exception(reraise=False) as ctx:
             if issubclass(model, vpn_models.IPsecSiteConnection):
                 raise vpnaas.IPsecSiteConnectionNotFound(
                     ipsec_site_conn_id=v_id)
             elif issubclass(model, vpn_models.IKEPolicy):
                 raise vpnaas.IKEPolicyNotFound(ikepolicy_id=v_id)
             elif issubclass(model, vpn_models.IPsecPolicy):
                 raise vpnaas.IPsecPolicyNotFound(ipsecpolicy_id=v_id)
             elif issubclass(model, vpn_models.VPNService):
                 raise vpnaas.VPNServiceNotFound(vpnservice_id=v_id)
             elif issubclass(model, vpn_models.VPNEndpointGroup):
                 raise vpnaas.VPNEndpointGroupNotFound(
                     endpoint_group_id=v_id)
             ctx.reraise = True
     return r
Esempio n. 20
0
 def _get_tap_service(self, context, id):
     try:
         return model_query.get_by_id(context, TapService, id)
     except exc.NoResultFound:
         raise taas.TapServiceNotFound(tap_id=id)
Esempio n. 21
0
 def _get_srv6_encap_network(self, context, encap_net_id):
     try:
         return model_query.get_by_id(context, Srv6EncapNetwork,
                                      encap_net_id)
     except exc.NoResultFound:
         raise SRv6EncapNetworkNotFound(id=encap_net_id)
Esempio n. 22
0
 def _get_path_node(self, id):
     try:
         node = model_query.get_by_id(self.admin_context, PathNode, id)
     except exc.NoResultFound:
         raise NodeNotFound(node_id=id)
     return node
Esempio n. 23
0
 def _get_tap_flow(self, context, id):
     try:
         return model_query.get_by_id(context, TapFlow, id)
     except Exception:
         raise taas.TapFlowNotFound(flow_id=id)
Esempio n. 24
0
 def _get_firewall_rule(self, context, id):
     try:
         return model_query.get_by_id(context, FirewallRuleV2, id)
     except exc.NoResultFound:
         raise f_exc.FirewallRuleNotFound(firewall_rule_id=id)
Esempio n. 25
0
def _read_classification_group(context, id):
    """Returns a classification group."""

    cg = mq.get_by_id(context, ClassificationGroup, id)
    return cg
Esempio n. 26
0
 def _get_service_graph(self, context, id):
     try:
         return model_query.get_by_id(context, ServiceGraph, id)
     except exc.NoResultFound:
         raise ext_sg.ServiceGraphNotFound(id=id)
Esempio n. 27
0
 def _get_network(self, context, id):
     try:
         network = model_query.get_by_id(context, models_v2.Network, id)
     except exc.NoResultFound:
         raise exceptions.NetworkNotFound(net_id=id)
     return network
Esempio n. 28
0
 def _get_port_pair_group(self, context, id):
     try:
         return model_query.get_by_id(context, PortPairGroup, id)
     except exc.NoResultFound:
         raise ext_sfc.PortPairGroupNotFound(id=id)
Esempio n. 29
0
 def _get_flow_classifier(self, context, id):
     try:
         return model_query.get_by_id(context, fc_db.FlowClassifier, id)
     except exc.NoResultFound:
         raise ext_fc.FlowClassifierNotFound(id=id)
Esempio n. 30
0
 def _get_port(self, context, id):
     try:
         return model_query.get_by_id(context, models_v2.Port, id)
     except exc.NoResultFound:
         raise ext_sfc.PortPairPortNotFound(id=id)
Esempio n. 31
0
 def _get_firewall_policy(self, context, id):
     try:
         return model_query.get_by_id(context, FirewallPolicy, id)
     except exc.NoResultFound:
         raise f_exc.FirewallPolicyNotFound(firewall_policy_id=id)
 def _get_flow_classifier(self, context, id):
     try:
         return model_query.get_by_id(context, FlowClassifier, id)
     except exc.NoResultFound:
         raise fc_ext.FlowClassifierNotFound(id=id)
Esempio n. 33
0
 def _get_tap_flow(self, context, id):
     try:
         return model_query.get_by_id(context, TapFlow, id)
     except Exception:
         raise taas.TapFlowNotFound(flow_id=id)
Esempio n. 34
0
 def _get_network(self, context, id):
     try:
         network = model_query.get_by_id(context, models_v2.Network, id)
     except exc.NoResultFound:
         raise exceptions.NetworkNotFound(net_id=id)
     return network
Esempio n. 35
0
 def _get_tap_service(self, context, id):
     try:
         return model_query.get_by_id(context, TapService, id)
     except exc.NoResultFound:
         raise taas.TapServiceNotFound(tap_id=id)
Esempio n. 36
0
 def _get_by_id(context, model, id):
     return model_query.get_by_id(context, model, id)
Esempio n. 37
0
 def _get_port(self, context, id):
     try:
         return model_query.get_by_id(context, models_v2.Port, id)
     except exc.NoResultFound:
         raise fc_ext.FlowClassifierPortNotFound(id=id)
Esempio n. 38
0
 def _get_port(self, context, id):
     try:
         port = model_query.get_by_id(context, models_v2.Port, id)
     except exc.NoResultFound:
         raise exceptions.PortNotFound(port_id=id)
     return port
 def _get_tenantpolicy(self, context, id):
     try:
         tenantpolicy = model_query.get_by_id(context, TenantPolicy, id)
     except exc.NoResultFound:
         raise TenantPolicyNotFound(id=id)
     return tenantpolicy
Esempio n. 40
0
 def _resource_exists(self, context, model, id):
     try:
         model_query.get_by_id(context, model, id)
     except exc.NoResultFound:
         return False
     return True
Esempio n. 41
0
 def _get_bgpvpn(self, context, id):
     try:
         return model_query.get_by_id(context, BGPVPN, id)
     except exc.NoResultFound:
         raise bgpvpn_ext.BGPVPNNotFound(id=id)
Esempio n. 42
0
 def _get_port_chain(self, context, id):
     try:
         return model_query.get_by_id(context, PortChain, id)
     except exc.NoResultFound:
         raise ext_sfc.PortChainNotFound(id=id)
 def _get_port(self, context, id):
     try:
         return model_query.get_by_id(context, models_v2.Port, id)
     except exc.NoResultFound:
         raise fc_ext.FlowClassifierPortNotFound(id=id)
Esempio n. 44
0
 def _get_firewall_group(self, context, id):
     try:
         return model_query.get_by_id(context, FirewallGroup, id)
     except exc.NoResultFound:
         raise f_exc.FirewallGroupNotFound(firewall_id=id)