def _parse_l3_vni_ranges(self): try: self.l3_vni_ranges = self.parse_l3_vni_ranges( cfg.CONF.VCFCONTROLLER.l3_vni_ranges) except Exception as e: LOG.exception( _LE("Failed to parse l3_vni_ranges. " "Service terminated!: %s"), e) sys.exit(1) LOG.info(_("L3 vni ranges: %s"), self.l3_vni_ranges)
def _add_interface_by_subnet(self, context, router, subnet_id, owner): subnet = self._core_plugin._get_subnet(context, subnet_id) if not subnet['gateway_ip']: msg = _('Subnet for router interface must have a gateway IP') raise common_exceptions.BadRequest(resource='router', msg=msg) self._check_for_dup_router_subnet(context, router, subnet['network_id'], subnet_id, subnet['cidr']) return [subnet]
def _check_for_dup_router_subnet(self, context, router, network_id, subnet_id, subnet_cidr): try: # It's possible these ports are on the same network, but # different subnets. new_ipnet = netaddr.IPNetwork(subnet_cidr) for p in (rp.port for rp in router.attached_ports): for ip in p['fixed_ips']: if ip['subnet_id'] == subnet_id: msg = (_("Router already has a port on subnet %s") % subnet_id) raise common_exceptions.BadRequest(resource='router', msg=msg) # Ignore temporary Prefix Delegation CIDRs if subnet_cidr == q_const.PROVISIONAL_IPV6_PD_PREFIX: continue sub_id = ip['subnet_id'] cidr = self._core_plugin.get_subnet( context.elevated(), sub_id)['cidr'] ipnet = netaddr.IPNetwork(cidr) match1 = netaddr.all_matching_cidrs(new_ipnet, [cidr]) match2 = netaddr.all_matching_cidrs(ipnet, [subnet_cidr]) if match1 or match2: data = { 'subnet_cidr': subnet_cidr, 'subnet_id': subnet_id, 'cidr': cidr, 'sub_id': sub_id } msg = (_("Cidr %(subnet_cidr)s of subnet " "%(subnet_id)s overlaps with cidr %(cidr)s " "of subnet %(sub_id)s") % data) raise common_exceptions.BadRequest(resource='router', msg=msg) except exc.NoResultFound: pass
def release_segment(self, session, router_id): query = (session.query(self.model).filter_by(router_id=router_id)) if query.first() is None: return vxlan_id = query.first().vxlan_vni inside = any(lo <= vxlan_id <= hi for lo, hi in self.l3_vni_ranges) info = {'type': self.get_type(), 'id': vxlan_id} with session.begin(subtransactions=True): query = (session.query(self.model).filter_by(vxlan_vni=vxlan_id)) if inside: count = query.update({"allocated": False, 'router_id': None}) if count: LOG.debug("Releasing %(type)s tunnel %(id)s to pool", info) else: count = query.delete() if count: LOG.debug("Releasing %(type)s tunnel %(id)s outside pool", info) if not count: LOG.warning(_("%(type)s tunnel %(id)s not found"), info)
class H3CSecurityGroupRuleDbNotFound(qexception.NotFound): message = _("H3CSecurityGroupRule %(h3c_security_group_rule_id)s " "could not be found")
class BindSecurityGroupOverLimit(NeutronException): message = _("Only bind one security group per instance")
class ServiceInsertionNotFound(qexception.NotFound): message = _("ServiceInsertion %(service_insertion_id)s not found")
class LoadbalancerNotFound(qexception.NotFound): message = _("The Loadbalancer %(loadbalancer_id)s could not be found")
class OperationNotSupported(NeutronException): message = _("OperationNotSupported")
class InternalError(NeutronException): message = _("VCFC internal server error.")
class H3CRouterBindFirewall(NeutronException): message = _("The router is bound to one of the tenant's firewalls.")
class RouterBindResource(NeutronException): message = _("Failed to delete the vRouter because it has " "been bound to service resources.")
class PoolSubnetNotBound(NeutronException): message = _("VCFC create pool failed, the subnet of vlan " "pool has not bound to a router.")
class IpNotSupportAssigned(NeutronException): message = _("The ip address couldn't be assigned.")
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from networking_h3c._i18n import _ from oslo_config import cfg CONTROLLER_OPTS = [ cfg.StrOpt('url', default='https://127.0.0.1:8443', help=_('The H3C vcf controller api base url')), cfg.StrOpt('username', default='sdn', help=_('Controller username')), cfg.StrOpt('password', default='skyline', help=_('Controller password')), cfg.StrOpt('domain', default='sdn', help=_('Controller domain')), cfg.StrOpt('timeout', default=1800, help=_('Controller timeout')), cfg.IntOpt('retry', default=5, help=_('The retry times for connecting controller')), cfg.StrOpt('vnic_type', default='ovs', help=_('port binding vnic_type default is ovs')), cfg.BoolOpt('hybrid_vnic', default=True, help=_('Plug-in working in hybrid_vnic mode')), cfg.BoolOpt('ip_mac_binding', default=True, help=_('ipmac binding')), cfg.IntOpt('denyflow_age', default=300, help=_('denyflow_age')),
class ForbiddenError(NeutronException): message = _("This operation is forbidden.")
class BadRequests(NeutronException): message = _("Bad Request")
class NoTunnelIdAvailable(NeutronException): message = _("Unable to allocate tunnel id " "for %(tunnel_type)s type tunnel.")
class UnknownError(NeutronException): message = _("A unknown error occurred during request.")
class RequestTimeoutError(ServiceUnavailable): message = _("%(resource)s request: VCFC timeout! URL = %(url)s")
class HttpServiceUnavailable(NeutronException): message = _("HttpServiceUnavailable")
class PoolCountExceeded(qexception.Conflict): message = _("Exceeded allowed count of Pool for tenant " "%(tenant_id)s. Only one Pool is supported per tenant.")
class ServiceContextNotFound(qexception.NotFound): message = _("ServiceContext %(service_context_id)s could not be found")
class JsonDecodingError(NeutronException): message = _("%(resource)s request: Decoding json error! ")
class ServiceNodeNotFound(qexception.NotFound): message = _("ServiceNode %(service_node_id)s not found")
class HttpNotAuthError(NeutronException): message = _("VCFC Authorization failed")
class ResourceNotFound(qexception.NotFound): message = _("Resource of Tenant %(Tenant_id)s should create first")
class HttpNotFoundError(NeutronException): message = _("The requested content not found.")
class PortIpInused(qexception.Conflict): message = _("The port ip %(port_ip)s is being used by " "floating ip %(floating_ip)s.")
class ConflictError(NeutronException): message = _("This operation leaded to conflict.")