Esempio n. 1
0
    def _parse_nexus_vni_range(self, tunnel_range):
        """Raise an exception for invalid tunnel range or malformed range."""
        for ident in tunnel_range:
            if not self._is_valid_nexus_vni(ident):
                raise exc.NetworkTunnelRangeError(
                    tunnel_range=tunnel_range,
                    error=_("%(id)s is not a valid Nexus VNI value.") %
                    {'id': ident})

        if tunnel_range[1] < tunnel_range[0]:
            raise exc.NetworkTunnelRangeError(
                tunnel_range=tunnel_range,
                error=_("End of tunnel range is less than start of "
                        "tunnel range."))
Esempio n. 2
0
def verify_tunnel_range(tunnel_range, tunnel_type):
    """Raise an exception for invalid tunnel range or malformed range."""
    mappings = {p_const.TYPE_GRE: is_valid_gre_id,
                p_const.TYPE_VXLAN: is_valid_vxlan_vni,
                p_const.TYPE_GENEVE: is_valid_geneve_vni}
    if tunnel_type in mappings:
        for ident in tunnel_range:
            if not mappings[tunnel_type](ident):
                raise n_exc.NetworkTunnelRangeError(
                    tunnel_range=tunnel_range,
                    error=_("%(id)s is not a valid %(type)s identifier") %
                    {'id': ident, 'type': tunnel_type})
    if tunnel_range[1] < tunnel_range[0]:
        raise n_exc.NetworkTunnelRangeError(
            tunnel_range=tunnel_range,
            error=_("End of tunnel range is less "
                    "than start of tunnel range"))
Esempio n. 3
0
 def _parse_tunnel_ranges(self, tunnel_ranges, current_range):
     for entry in tunnel_ranges:
         entry = entry.strip()
         try:
             tun_min, tun_max = entry.split(':')
             tun_min = tun_min.strip()
             tun_max = tun_max.strip()
             tunnel_range = int(tun_min), int(tun_max)
         except ValueError as ex:
             raise exc.NetworkTunnelRangeError(tunnel_range=entry, error=ex)
         plugin_utils.verify_tunnel_range(tunnel_range, self.get_type())
         current_range.append(tunnel_range)
     LOG.info(_LI("%(type)s ID ranges: %(range)s"),
              {'type': self.get_type(), 'range': current_range})
Esempio n. 4
0
    def _parse_h3c_vni_ranges(self, tunnel_ranges, current_range):
        for entry in tunnel_ranges:
            entry = entry.strip()
            try:
                tun_min, tun_max = entry.split(':')
                tun_min = tun_min.strip()
                tun_max = tun_max.strip()
                tunnel_range = int(tun_min), int(tun_max)
            except ValueError as ex:
                raise exc.NetworkTunnelRangeError(tunnel_range=entry, error=ex)

            self._parse_h3c_vni_range(tunnel_range)
            current_range.append(tunnel_range)

        LOG.info(("H3C VXLAN ID ranges: %(range)s"), {'range': current_range})