Use constants from neutron-lib

With this we enable the deprecation warnings by default.

Related-Blueprint: neutron-lib

Change-Id: I5b9e53751dd164010e5bbeb15f534ac0fe2a5105
changes/17/299017/16
Henry Gessau 7 years ago
parent cdb47fe53a
commit 4148a347b3
  1. 7
      neutron/agent/dhcp/agent.py
  2. 7
      neutron/agent/l3/agent.py
  3. 4
      neutron/agent/l3/dvr_edge_ha_router.py
  4. 2
      neutron/agent/l3/dvr_edge_router.py
  5. 5
      neutron/agent/l3/dvr_local_router.py
  6. 2
      neutron/agent/l3/ha_router.py
  7. 3
      neutron/agent/l3/legacy_router.py
  8. 11
      neutron/agent/l3/router_info.py
  9. 19
      neutron/agent/linux/dhcp.py
  10. 17
      neutron/agent/linux/interface.py
  11. 2
      neutron/agent/linux/ip_lib.py
  12. 2
      neutron/agent/linux/iptables_firewall.py
  13. 8
      neutron/agent/linux/openvswitch_firewall/constants.py
  14. 15
      neutron/agent/linux/openvswitch_firewall/firewall.py
  15. 3
      neutron/agent/linux/openvswitch_firewall/rules.py
  16. 2
      neutron/agent/linux/utils.py
  17. 5
      neutron/agent/metadata/agent.py
  18. 5
      neutron/agent/rpc.py
  19. 5
      neutron/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py
  20. 2
      neutron/api/rpc/agentnotifiers/l3_rpc_agent_api.py
  21. 2
      neutron/api/rpc/agentnotifiers/metering_rpc_agent_api.py
  22. 10
      neutron/api/rpc/handlers/dhcp_rpc.py
  23. 5
      neutron/api/rpc/handlers/l3_rpc.py
  24. 74
      neutron/api/v2/attributes.py
  25. 7
      neutron/api/v2/base.py
  26. 4
      neutron/cmd/netns_cleanup.py
  27. 5
      neutron/cmd/sanity/checks.py
  28. 17
      neutron/common/_deprecate.py
  29. 109
      neutron/common/constants.py
  30. 3
      neutron/common/ipv6_utils.py
  31. 2
      neutron/common/utils.py
  32. 2
      neutron/db/address_scope_db.py
  33. 11
      neutron/db/agents_db.py
  34. 5
      neutron/db/agentschedulers_db.py
  35. 3
      neutron/db/bgp_db.py
  36. 5
      neutron/db/db_base_plugin_common.py
  37. 31
      neutron/db/db_base_plugin_v2.py
  38. 2
      neutron/db/dvr_mac_db.py
  39. 2
      neutron/db/external_net_db.py
  40. 7
      neutron/db/ipam_backend_mixin.py
  41. 10
      neutron/db/ipam_non_pluggable_backend.py
  42. 7
      neutron/db/ipam_pluggable_backend.py
  43. 21
      neutron/db/l3_agentschedulers_db.py
  44. 17
      neutron/db/l3_db.py
  45. 55
      neutron/db/l3_dvr_db.py
  46. 7
      neutron/db/l3_dvrscheduler_db.py
  47. 49
      neutron/db/l3_hamode_db.py
  48. 2
      neutron/db/metering/metering_rpc.py
  49. 3
      neutron/db/migration/alembic_migrations/versions/newton/contract/7bbb25278f53_device_owner_ha_replicate_int.py
  50. 13
      neutron/db/securitygroups_db.py
  51. 17
      neutron/db/securitygroups_rpc_base.py
  52. 2
      neutron/debug/debug_agent.py
  53. 3
      neutron/extensions/address_scope.py
  54. 3
      neutron/extensions/allowedaddresspairs.py
  55. 3
      neutron/extensions/default_subnetpools.py
  56. 2
      neutron/extensions/dhcpagentscheduler.py
  57. 4
      neutron/extensions/dvr.py
  58. 4
      neutron/extensions/extraroute.py
  59. 8
      neutron/extensions/l3_ext_ha_mode.py
  60. 2
      neutron/extensions/l3agentscheduler.py
  61. 9
      neutron/extensions/multiprovidernet.py
  62. 11
      neutron/extensions/portbindings.py
  63. 3
      neutron/extensions/portsecurity.py
  64. 7
      neutron/extensions/providernet.py
  65. 7
      neutron/extensions/securitygroup.py
  66. 3
      neutron/extensions/subnetallocation.py
  67. 3
      neutron/extensions/vlantransparent.py
  68. 2
      neutron/ipam/requests.py
  69. 17
      neutron/ipam/subnet_alloc.py
  70. 2
      neutron/ipam/utils.py
  71. 2
      neutron/notifiers/nova.py
  72. 3
      neutron/objects/common_types.py
  73. 2
      neutron/objects/qos/rule.py
  74. 2
      neutron/pecan_wsgi/hooks/notifier.py
  75. 2
      neutron/plugins/common/utils.py
  76. 2
      neutron/plugins/ml2/db.py
  77. 2
      neutron/plugins/ml2/driver_context.py
  78. 5
      neutron/plugins/ml2/drivers/agent/_common_agent.py
  79. 2
      neutron/plugins/ml2/drivers/l2pop/mech_driver.py
  80. 2
      neutron/plugins/ml2/drivers/l2pop/rpc_manager/l2population_rpc.py
  81. 2
      neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
  82. 3
      neutron/plugins/ml2/drivers/linuxbridge/mech_driver/mech_linuxbridge.py
  83. 2
      neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py
  84. 3
      neutron/plugins/ml2/drivers/macvtap/macvtap_common.py
  85. 2
      neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py
  86. 2
      neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py
  87. 2
      neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py
  88. 2
      neutron/plugins/ml2/drivers/openvswitch/agent/common/config.py
  89. 2
      neutron/plugins/ml2/drivers/openvswitch/agent/openflow/ovs_ofctl/br_dvr_process.py
  90. 8
      neutron/plugins/ml2/drivers/openvswitch/agent/openflow/ovs_ofctl/br_int.py
  91. 2
      neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py
  92. 7
      neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
  93. 2
      neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py
  94. 3
      neutron/plugins/ml2/managers.py
  95. 9
      neutron/plugins/ml2/plugin.py
  96. 2
      neutron/plugins/ml2/rpc.py
  97. 5
      neutron/policy.py
  98. 2
      neutron/scheduler/dhcp_agent_scheduler.py
  99. 5
      neutron/scheduler/l3_agent_scheduler.py
  100. 2
      neutron/services/bgp/bgp_plugin.py
  101. Some files were not shown because too many files have changed in this diff Show More

@ -17,6 +17,7 @@ import collections
import os
import eventlet
from neutron_lib import constants
from neutron_lib import exceptions
from oslo_config import cfg
from oslo_log import log as logging
@ -29,7 +30,7 @@ from neutron.agent.linux import dhcp
from neutron.agent.linux import external_process
from neutron.agent.metadata import driver as metadata_driver
from neutron.agent import rpc as agent_rpc
from neutron.common import constants
from neutron.common import constants as n_const
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.common import utils
@ -428,7 +429,7 @@ class DhcpPluginApi(object):
self.host = host
target = oslo_messaging.Target(
topic=topic,
namespace=constants.RPC_NAMESPACE_DHCP_PLUGIN,
namespace=n_const.RPC_NAMESPACE_DHCP_PLUGIN,
version='1.0')
self.client = n_rpc.get_client(target)
@ -580,7 +581,7 @@ class DhcpAgentWithStateReport(DhcpAgent):
ctx = context.get_admin_context_without_session()
agent_status = self.state_rpc.report_state(
ctx, self.agent_state, True)
if agent_status == constants.AGENT_REVIVED:
if agent_status == n_const.AGENT_REVIVED:
LOG.info(_LI("Agent has just been revived. "
"Scheduling full sync"))
self.schedule_resync("Agent has just been revived")

@ -15,6 +15,7 @@
import eventlet
import netaddr
from neutron_lib import constants as lib_const
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging
@ -646,7 +647,7 @@ class L3NATAgentWithStateReport(L3NATAgent):
'interface_driver': self.conf.interface_driver,
'log_agent_heartbeats': self.conf.AGENT.log_agent_heartbeats},
'start_flag': True,
'agent_type': l3_constants.AGENT_TYPE_L3}
'agent_type': lib_const.AGENT_TYPE_L3}
report_interval = self.conf.AGENT.report_interval
if report_interval:
self.heartbeat = loopingcall.FixedIntervalLoopingCall(
@ -663,9 +664,9 @@ class L3NATAgentWithStateReport(L3NATAgent):
ex_gw_port = ri.get_ex_gw_port()
if ex_gw_port:
num_ex_gw_ports += 1
num_interfaces += len(ri.router.get(l3_constants.INTERFACE_KEY,
num_interfaces += len(ri.router.get(lib_const.INTERFACE_KEY,
[]))
num_floating_ips += len(ri.router.get(l3_constants.FLOATINGIP_KEY,
num_floating_ips += len(ri.router.get(lib_const.FLOATINGIP_KEY,
[]))
configurations = self.agent_state['configurations']
configurations['routers'] = num_routers

@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants
from neutron.agent.l3.dvr_edge_router import DvrEdgeRouter
from neutron.agent.l3 import dvr_snat_ns
from neutron.agent.l3.ha_router import HaRouter
@ -75,7 +77,7 @@ class DvrEdgeHaRouter(DvrEdgeRouter, HaRouter):
snat_interface = self._get_snat_int_device_name(port['id'])
self.driver.unplug(snat_interface,
namespace=self.ha_namespace,
prefix=l3_constants.SNAT_INT_DEV_PREFIX)
prefix=constants.SNAT_INT_DEV_PREFIX)
self._clear_vips(snat_interface)
super(DvrEdgeHaRouter, self)._external_gateway_removed(
ex_gw_port, interface_name)

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants as l3_constants
from oslo_log import log as logging
from neutron._i18n import _LE
@ -20,7 +21,6 @@ from neutron.agent.l3 import dvr_snat_ns
from neutron.agent.l3 import router_info as router
from neutron.agent.linux import ip_lib
from neutron.agent.linux import iptables_manager
from neutron.common import constants as l3_constants
LOG = logging.getLogger(__name__)

@ -16,6 +16,7 @@ import binascii
import collections
import netaddr
from neutron_lib import constants as l3_constants
from oslo_log import log as logging
from oslo_utils import excutils
import six
@ -24,7 +25,7 @@ from neutron._i18n import _LE, _LW
from neutron.agent.l3 import dvr_fip_ns
from neutron.agent.l3 import dvr_router_base
from neutron.agent.linux import ip_lib
from neutron.common import constants as l3_constants
from neutron.common import constants as n_const
from neutron.common import exceptions
from neutron.common import utils as common_utils
@ -347,7 +348,7 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
def get_floating_agent_gw_interface(self, ext_net_id):
"""Filter Floating Agent GW port for the external network."""
fip_ports = self.router.get(l3_constants.FLOATINGIP_AGENT_INTF_KEY, [])
fip_ports = self.router.get(n_const.FLOATINGIP_AGENT_INTF_KEY, [])
return next(
(p for p in fip_ports if p['network_id'] == ext_net_id), None)

@ -16,6 +16,7 @@ import os
import shutil
import netaddr
from neutron_lib import constants as n_consts
from oslo_log import log as logging
from neutron._i18n import _LE
@ -23,7 +24,6 @@ from neutron.agent.l3 import router_info as router
from neutron.agent.linux import external_process
from neutron.agent.linux import ip_lib
from neutron.agent.linux import keepalived
from neutron.common import constants as n_consts
from neutron.common import utils as common_utils
from neutron.extensions import portbindings

@ -12,9 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants as l3_constants
from neutron.agent.l3 import router_info as router
from neutron.agent.linux import ip_lib
from neutron.common import constants as l3_constants
class LegacyRouter(router.RouterInfo):

@ -14,6 +14,7 @@
import collections
import netaddr
from neutron_lib import constants as l3_constants
from oslo_log import log as logging
from neutron._i18n import _, _LE, _LW
@ -21,7 +22,7 @@ from neutron.agent.l3 import namespaces
from neutron.agent.linux import ip_lib
from neutron.agent.linux import iptables_manager
from neutron.agent.linux import ra
from neutron.common import constants as l3_constants
from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc
from neutron.common import ipv6_utils
from neutron.common import utils as common_utils
@ -351,7 +352,7 @@ class RouterInfo(object):
def _internal_network_updated(self, port, subnet_id, prefix, old_prefix,
updated_cidrs):
interface_name = self.get_internal_device_name(port['id'])
if prefix != l3_constants.PROVISIONAL_IPV6_PD_PREFIX:
if prefix != n_const.PROVISIONAL_IPV6_PD_PREFIX:
fixed_ips = port['fixed_ips']
for fixed_ip in fixed_ips:
if fixed_ip['subnet_id'] == subnet_id:
@ -432,7 +433,7 @@ class RouterInfo(object):
if 'subnets' in port:
for subnet in port['subnets']:
if (netaddr.IPNetwork(subnet['cidr']).version == 6 and
subnet['cidr'] != l3_constants.PROVISIONAL_IPV6_PD_PREFIX):
subnet['cidr'] != n_const.PROVISIONAL_IPV6_PD_PREFIX):
return True
def enable_radvd(self, internal_ports=None):
@ -707,7 +708,7 @@ class RouterInfo(object):
'snat', '-m mark ! --mark %s/%s '
'-m conntrack --ctstate DNAT '
'-j SNAT --to-source %s'
% (ext_in_mark, l3_constants.ROUTER_MARK_MASK, ex_gw_ip))
% (ext_in_mark, n_const.ROUTER_MARK_MASK, ex_gw_ip))
return [dont_snat_traffic_to_internal_ports_if_not_to_floating_ip,
snat_internal_traffic_to_floating_ip]
@ -721,7 +722,7 @@ class RouterInfo(object):
mark = self.agent_conf.external_ingress_mark
mark_packets_entering_external_gateway_port = (
'mark', '-i %s -j MARK --set-xmark %s/%s' %
(interface_name, mark, l3_constants.ROUTER_MARK_MASK))
(interface_name, mark, n_const.ROUTER_MARK_MASK))
return [mark_packets_entering_external_gateway_port]
def _empty_snat_chains(self, iptables_manager):

@ -21,6 +21,7 @@ import shutil
import time
import netaddr
from neutron_lib import constants
from neutron_lib import exceptions
from oslo_config import cfg
from oslo_log import log as logging
@ -34,7 +35,7 @@ from neutron.agent.common import utils as agent_common_utils
from neutron.agent.linux import external_process
from neutron.agent.linux import ip_lib
from neutron.agent.linux import iptables_manager
from neutron.common import constants
from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc
from neutron.common import ipv6_utils
from neutron.common import utils as common_utils
@ -351,8 +352,8 @@ class Dnsmasq(DhcpLocalProcess):
# static to preserve previous behavior
addr_mode = getattr(subnet, 'ipv6_address_mode', None)
ra_mode = getattr(subnet, 'ipv6_ra_mode', None)
if (addr_mode in [constants.DHCPV6_STATEFUL,
constants.DHCPV6_STATELESS] or
if (addr_mode in [n_const.DHCPV6_STATEFUL,
n_const.DHCPV6_STATELESS] or
not addr_mode and not ra_mode):
mode = 'static'
@ -510,7 +511,7 @@ class Dnsmasq(DhcpLocalProcess):
fixed_ips,
key=lambda fip: ((fip.subnet_id in v6_nets) and (
v6_nets[fip.subnet_id].ipv6_address_mode == (
constants.DHCPV6_STATELESS))),
n_const.DHCPV6_STATELESS))),
reverse=True)
def _iter_hosts(self):
@ -545,11 +546,11 @@ class Dnsmasq(DhcpLocalProcess):
no_opts = False
if alloc.subnet_id in v6_nets:
addr_mode = v6_nets[alloc.subnet_id].ipv6_address_mode
no_dhcp = addr_mode in (constants.IPV6_SLAAC,
constants.DHCPV6_STATELESS)
no_dhcp = addr_mode in (n_const.IPV6_SLAAC,
n_const.DHCPV6_STATELESS)
# we don't setup anything for SLAAC. It doesn't make sense
# to provide options for a client that won't use DHCP
no_opts = addr_mode == constants.IPV6_SLAAC
no_opts = addr_mode == n_const.IPV6_SLAAC
# If dns_name attribute is supported by ports API, return the
# dns_assignment generated by the Neutron server. Otherwise,
@ -770,7 +771,7 @@ class Dnsmasq(DhcpLocalProcess):
addr_mode = getattr(subnet, 'ipv6_address_mode', None)
if (not subnet.enable_dhcp or
(subnet.ip_version == 6 and
addr_mode == constants.IPV6_SLAAC)):
addr_mode == n_const.IPV6_SLAAC)):
continue
if subnet.dns_nameservers:
options.append(
@ -1124,7 +1125,7 @@ class DeviceManager(object):
{'device_id': device_id, 'network_id': network.id})
for port in network.ports:
port_device_id = getattr(port, 'device_id', None)
if port_device_id == constants.DEVICE_ID_RESERVED_DHCP_PORT:
if port_device_id == n_const.DEVICE_ID_RESERVED_DHCP_PORT:
try:
port = self.plugin.update_dhcp_port(
port.id, {'port': {'network_id': network.id,

@ -16,6 +16,7 @@
import abc
import netaddr
from neutron_lib import constants
from oslo_config import cfg
from oslo_log import log as logging
from oslo_log import versionutils
@ -56,7 +57,7 @@ class LinuxInterfaceDriver(object):
# from linux IF_NAMESIZE
DEV_NAME_LEN = 14
DEV_NAME_PREFIX = n_const.TAP_DEVICE_PREFIX
DEV_NAME_PREFIX = constants.TAP_DEVICE_PREFIX
def __init__(self, conf):
self.conf = conf
@ -181,8 +182,8 @@ class LinuxInterfaceDriver(object):
# Manage on-link routes (routes without an associated address)
new_onlink_cidrs = set(s['cidr'] for s in extra_subnets or [])
v4_onlink = device.route.list_onlink_routes(n_const.IP_VERSION_4)
v6_onlink = device.route.list_onlink_routes(n_const.IP_VERSION_6)
v4_onlink = device.route.list_onlink_routes(constants.IP_VERSION_4)
v6_onlink = device.route.list_onlink_routes(constants.IP_VERSION_6)
existing_onlink_cidrs = set(r['cidr'] for r in v4_onlink + v6_onlink)
for route in new_onlink_cidrs - existing_onlink_cidrs:
@ -292,7 +293,7 @@ class NullDriver(LinuxInterfaceDriver):
class OVSInterfaceDriver(LinuxInterfaceDriver):
"""Driver for creating an internal interface on an OVS bridge."""
DEV_NAME_PREFIX = n_const.TAP_DEVICE_PREFIX
DEV_NAME_PREFIX = constants.TAP_DEVICE_PREFIX
def __init__(self, conf):
super(OVSInterfaceDriver, self).__init__(conf)
@ -302,7 +303,7 @@ class OVSInterfaceDriver(LinuxInterfaceDriver):
def _get_tap_name(self, dev_name, prefix=None):
if self.conf.ovs_use_veth:
dev_name = dev_name.replace(prefix or self.DEV_NAME_PREFIX,
n_const.TAP_DEVICE_PREFIX)
constants.TAP_DEVICE_PREFIX)
return dev_name
def _ovs_add_port(self, bridge, device_name, port_id, mac_address,
@ -381,7 +382,7 @@ class OVSInterfaceDriver(LinuxInterfaceDriver):
class IVSInterfaceDriver(LinuxInterfaceDriver):
"""Driver for creating an internal interface on an IVS bridge."""
DEV_NAME_PREFIX = n_const.TAP_DEVICE_PREFIX
DEV_NAME_PREFIX = constants.TAP_DEVICE_PREFIX
def __init__(self, conf):
super(IVSInterfaceDriver, self).__init__(conf)
@ -389,7 +390,7 @@ class IVSInterfaceDriver(LinuxInterfaceDriver):
def _get_tap_name(self, dev_name, prefix=None):
dev_name = dev_name.replace(prefix or self.DEV_NAME_PREFIX,
n_const.TAP_DEVICE_PREFIX)
constants.TAP_DEVICE_PREFIX)
return dev_name
def _ivs_add_port(self, device_name, port_id, mac_address):
@ -450,7 +451,7 @@ class BridgeInterfaceDriver(LinuxInterfaceDriver):
# Enable agent to define the prefix
tap_name = device_name.replace(prefix or self.DEV_NAME_PREFIX,
n_const.TAP_DEVICE_PREFIX)
constants.TAP_DEVICE_PREFIX)
# Create ns_veth in a namespace if one is configured.
root_veth, ns_veth = ip.add_veth(tap_name, device_name,
namespace2=namespace)

@ -18,6 +18,7 @@ import re
import eventlet
import netaddr
from neutron_lib import constants
from neutron_lib import exceptions
from oslo_config import cfg
from oslo_log import log as logging
@ -26,7 +27,6 @@ import six
from neutron._i18n import _, _LE
from neutron.agent.common import utils
from neutron.common import constants
from neutron.common import exceptions as n_exc
LOG = logging.getLogger(__name__)

@ -17,6 +17,7 @@ import collections
import re
import netaddr
from neutron_lib import constants
from oslo_config import cfg
from oslo_log import log as logging
import six
@ -28,7 +29,6 @@ from neutron.agent.linux import ipset_manager
from neutron.agent.linux import iptables_comments as ic
from neutron.agent.linux import iptables_manager
from neutron.agent.linux import utils
from neutron.common import constants
from neutron.common import exceptions as n_exc
from neutron.common import ipv6_utils
from neutron.common import utils as c_utils

@ -13,7 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.common import constants
from neutron_lib import constants
from neutron.common import constants as n_const
OF_STATE_NOT_TRACKED = "-trk"
OF_STATE_TRACKED = "+trk"
@ -42,6 +44,6 @@ protocol_to_nw_proto = {
PROTOCOLS_WITH_PORTS = (constants.PROTO_NAME_TCP, constants.PROTO_NAME_UDP)
ethertype_to_dl_type_map = {
constants.IPv4: constants.ETHERTYPE_IP,
constants.IPv6: constants.ETHERTYPE_IPV6,
constants.IPv4: n_const.ETHERTYPE_IP,
constants.IPv6: n_const.ETHERTYPE_IPV6,
}

@ -14,6 +14,7 @@
# under the License.
import netaddr
from neutron_lib import constants as lib_const
from neutron_lib import exceptions
from oslo_log import log as logging
@ -367,14 +368,14 @@ class OVSFirewallDriver(firewall.FirewallDriver):
self._initialize_ingress(port)
def _initialize_egress_ipv6_icmp(self, port):
for icmp_type in constants.ICMPV6_ALLOWED_TYPES:
for icmp_type in lib_const.ICMPV6_ALLOWED_TYPES:
self._add_flow(
table=ovs_consts.BASE_EGRESS_TABLE,
priority=95,
in_port=port.ofport,
reg_port=port.ofport,
dl_type=constants.ETHERTYPE_IPV6,
nw_proto=constants.PROTO_NUM_IPV6_ICMP,
nw_proto=lib_const.PROTO_NUM_IPV6_ICMP,
icmp_type=icmp_type,
actions='normal'
)
@ -439,7 +440,7 @@ class OVSFirewallDriver(firewall.FirewallDriver):
reg_port=port.ofport,
in_port=port.ofport,
dl_type=dl_type,
nw_proto=constants.PROTO_NUM_UDP,
nw_proto=lib_const.PROTO_NUM_UDP,
tp_src=src_port,
tp_dst=dst_port,
actions='resubmit(,{:d})'.format(
@ -455,7 +456,7 @@ class OVSFirewallDriver(firewall.FirewallDriver):
in_port=port.ofport,
reg_port=port.ofport,
dl_type=dl_type,
nw_proto=constants.PROTO_NUM_UDP,
nw_proto=lib_const.PROTO_NUM_UDP,
tp_src=src_port,
tp_dst=dst_port,
actions='drop'
@ -546,14 +547,14 @@ class OVSFirewallDriver(firewall.FirewallDriver):
)
def _initialize_ingress_ipv6_icmp(self, port):
for icmp_type in constants.ICMPV6_ALLOWED_TYPES:
for icmp_type in lib_const.ICMPV6_ALLOWED_TYPES:
self._add_flow(
table=ovs_consts.BASE_INGRESS_TABLE,
priority=100,
reg_port=port.ofport,
dl_dst=port.mac,
dl_type=constants.ETHERTYPE_IPV6,
nw_proto=constants.PROTO_NUM_IPV6_ICMP,
nw_proto=lib_const.PROTO_NUM_IPV6_ICMP,
icmp_type=icmp_type,
actions='strip_vlan,output:{:d}'.format(port.ofport),
)
@ -579,7 +580,7 @@ class OVSFirewallDriver(firewall.FirewallDriver):
priority=95,
reg_port=port.ofport,
dl_type=dl_type,
nw_proto=constants.PROTO_NUM_UDP,
nw_proto=lib_const.PROTO_NUM_UDP,
tp_src=src_port,
tp_dst=dst_port,
actions='strip_vlan,output:{:d}'.format(port.ofport),

@ -20,7 +20,6 @@ from oslo_log import log as logging
from neutron.agent import firewall
from neutron.agent.linux import ip_lib
from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts
from neutron.common import constants
from neutron.common import utils
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \
as ovs_consts
@ -83,7 +82,7 @@ def create_protocol_flows(direction, flow_template, port, rule):
try:
flow_template['nw_proto'] = ovsfw_consts.protocol_to_nw_proto[protocol]
if rule['ethertype'] == n_consts.IPv6 and protocol == 'icmp':
flow_template['nw_proto'] = constants.PROTO_NUM_IPV6_ICMP
flow_template['nw_proto'] = n_consts.PROTO_NUM_IPV6_ICMP
except KeyError:
pass

@ -26,6 +26,7 @@ import threading
import eventlet
from eventlet.green import subprocess
from eventlet import greenthread
from neutron_lib import constants
from oslo_config import cfg
from oslo_log import log as logging
from oslo_rootwrap import client
@ -35,7 +36,6 @@ from six.moves import http_client as httplib
from neutron._i18n import _, _LE
from neutron.agent.common import config
from neutron.common import constants
from neutron.common import utils
from neutron import wsgi

@ -16,6 +16,7 @@ import hashlib
import hmac
import httplib2
from neutron_lib import constants
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging
@ -112,7 +113,7 @@ class MetadataProxyHandler(object):
filters = {}
if router_id:
filters['device_id'] = [router_id]
filters['device_owner'] = n_const.ROUTER_INTERFACE_OWNERS
filters['device_owner'] = constants.ROUTER_INTERFACE_OWNERS
if ip_address:
filters['fixed_ips'] = {'ip_address': [ip_address]}
if networks:
@ -251,7 +252,7 @@ class UnixDomainMetadataProxy(object):
'log_agent_heartbeats': cfg.CONF.AGENT.log_agent_heartbeats,
},
'start_flag': True,
'agent_type': n_const.AGENT_TYPE_METADATA}
'agent_type': constants.AGENT_TYPE_METADATA}
report_interval = cfg.CONF.AGENT.report_interval
if report_interval:
self.heartbeat = loopingcall.FixedIntervalLoopingCall(

@ -16,12 +16,13 @@
from datetime import datetime
import itertools
from neutron_lib import constants
from oslo_log import log as logging
import oslo_messaging
from oslo_utils import uuidutils
from neutron._i18n import _LW
from neutron.common import constants
from neutron.common import constants as n_const
from neutron.common import rpc as n_rpc
from neutron.common import topics
@ -68,7 +69,7 @@ class PluginReportStateAPI(object):
"""
def __init__(self, topic):
target = oslo_messaging.Target(topic=topic, version='1.0',
namespace=constants.RPC_NAMESPACE_STATE)
namespace=n_const.RPC_NAMESPACE_STATE)
self.client = n_rpc.get_client(target)
def report_state(self, context, agent_state, use_call=False):

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from neutron_lib import constants
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging
@ -21,7 +22,7 @@ from neutron._i18n import _LE, _LW
from neutron.callbacks import events
from neutron.callbacks import registry
from neutron.callbacks import resources
from neutron.common import constants
from neutron.common import constants as n_const
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.common import utils
@ -118,7 +119,7 @@ class DhcpAgentNotifyAPI(object):
return enabled_agents
def _is_reserved_dhcp_port(self, port):
return port.get('device_id') == constants.DEVICE_ID_RESERVED_DHCP_PORT
return port.get('device_id') == n_const.DEVICE_ID_RESERVED_DHCP_PORT
def _notify_agents(self, context, method, payload, network_id):
"""Notify all the agents that are hosting the network."""

@ -15,11 +15,11 @@
import random
from neutron_lib import constants
from oslo_log import log as logging
import oslo_messaging
from neutron._i18n import _LE
from neutron.common import constants
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.common import utils

@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants
from oslo_log import log as logging
import oslo_messaging
import six
from neutron.common import constants
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.common import utils

@ -17,6 +17,7 @@ import copy
import itertools
import operator
from neutron_lib import constants
from neutron_lib import exceptions
from oslo_config import cfg
from oslo_db import exception as db_exc
@ -25,8 +26,7 @@ import oslo_messaging
from oslo_utils import excutils
from neutron._i18n import _, _LW
from neutron.api.v2 import attributes
from neutron.common import constants
from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc
from neutron.common import utils
from neutron.db import api as db_api
@ -65,7 +65,7 @@ class DhcpRpcCallback(object):
# DHCP agent since Juno, so similar rationale for not bumping the
# major version as above applies here too.
target = oslo_messaging.Target(
namespace=constants.RPC_NAMESPACE_DHCP_PLUGIN,
namespace=n_const.RPC_NAMESPACE_DHCP_PLUGIN,
version='1.4')
def _get_active_networks(self, context, **kwargs):
@ -203,7 +203,7 @@ class DhcpRpcCallback(object):
port['port']['device_owner'] = constants.DEVICE_OWNER_DHCP
port['port'][portbindings.HOST_ID] = host
if 'mac_address' not in port['port']:
port['port']['mac_address'] = attributes.ATTR_NOT_SPECIFIED
port['port']['mac_address'] = constants.ATTR_NOT_SPECIFIED
plugin = manager.NeutronManager.get_plugin()
return self._port_action(plugin, context, port, 'create_port')
@ -216,7 +216,7 @@ class DhcpRpcCallback(object):
port['port'][portbindings.HOST_ID] = host
plugin = manager.NeutronManager.get_plugin()
old_port = plugin.get_port(context, port['id'])
if (old_port['device_id'] != constants.DEVICE_ID_RESERVED_DHCP_PORT
if (old_port['device_id'] != n_const.DEVICE_ID_RESERVED_DHCP_PORT
and old_port['device_id'] !=
utils.get_dhcp_agent_device_id(port['port']['network_id'], host)):
raise n_exc.DhcpPortInUse(port_id=port['id'])

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from neutron_lib import constants
from neutron_lib import exceptions
from oslo_config import cfg
from oslo_log import log as logging
@ -20,7 +21,7 @@ import oslo_messaging
from oslo_serialization import jsonutils
import six
from neutron.common import constants
from neutron.common import constants as n_const
from neutron.common import utils
from neutron import context as neutron_context
from neutron.db import api as db_api
@ -119,7 +120,7 @@ class L3RpcCallback(object):
gw_port_host,
router.get('gw_port'),
router['id'])
for p in router.get(constants.SNAT_ROUTER_INTF_KEY, []):
for p in router.get(n_const.SNAT_ROUTER_INTF_KEY, []):
self._ensure_host_set_on_port(context,
gw_port_host,
p, router['id'])

@ -15,8 +15,10 @@
import functools
import re
import sys
import netaddr
from neutron_lib import constants
from neutron_lib import exceptions as n_exc
from oslo_log import log as logging
from oslo_utils import uuidutils
@ -24,12 +26,12 @@ import six
import webob.exc
from neutron._i18n import _
from neutron.common import constants
from neutron.common import _deprecate
from neutron.common import constants as n_const
LOG = logging.getLogger(__name__)
ATTR_NOT_SPECIFIED = object()
# Defining a constant to avoid repeating string literal in several modules
SHARED = 'shared'
@ -75,7 +77,7 @@ def _verify_dict_keys(expected_keys, target_dict, strict=True):
def is_attr_set(attribute):
return not (attribute is None or attribute is ATTR_NOT_SPECIFIED)
return not (attribute is None or attribute is constants.ATTR_NOT_SPECIFIED)
def _validate_list_of_items(item_validator, data, *args, **kwargs):
@ -192,8 +194,8 @@ def _validate_mac_address(data, valid_values=None):
valid_mac = False
if valid_mac:
valid_mac = not netaddr.EUI(data) in map(netaddr.EUI,
constants.INVALID_MAC_ADDRESSES)
valid_mac = not netaddr.EUI(data) in map(
netaddr.EUI, constants.INVALID_MAC_ADDRESSES)
# TODO(arosen): The code in this file should be refactored
# so it catches the correct exceptions. _validate_no_whitespace
# raises AttributeError if data is None.
@ -600,13 +602,10 @@ def convert_to_list(data):
return [data]
HEX_ELEM = '[0-9A-Fa-f]'
UUID_PATTERN = '-'.join([HEX_ELEM + '{8}', HEX_ELEM + '{4}',
HEX_ELEM + '{4}', HEX_ELEM + '{4}',
HEX_ELEM + '{12}'])
# Note: In order to ensure that the MAC address is unicast the first byte
# must be even.
MAC_PATTERN = "^%s[aceACE02468](:%s{2}){5}$" % (HEX_ELEM, HEX_ELEM)
MAC_PATTERN = "^%s[aceACE02468](:%s{2}){5}$" % (constants.HEX_ELEM,
constants.HEX_ELEM)
# Dictionary that maintains a list of validation functions
validators = {'type:dict': _validate_dict,
@ -721,12 +720,12 @@ RESOURCE_ATTRIBUTE_MAP = {
'convert_to': convert_to_boolean,
'is_visible': True},
'mac_address': {'allow_post': True, 'allow_put': True,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:mac_address': None},
'enforce_policy': True,
'is_visible': True},
'fixed_ips': {'allow_post': True, 'allow_put': True,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'convert_list_to': convert_kvp_list_to_dict,
'validate': {'type:fixed_ips': None},
'enforce_policy': True,
@ -764,7 +763,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True},
'subnetpool_id': {'allow_post': True,
'allow_put': False,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'required_by_policy': False,
'validate': {'type:subnetpool_id_or_none': None},
'is_visible': True},
@ -772,31 +771,31 @@ RESOURCE_ATTRIBUTE_MAP = {
'allow_put': False,
'validate': {'type:non_negative': None},
'convert_to': convert_to_int,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'required_by_policy': False,
'is_visible': False},
'cidr': {'allow_post': True,
'allow_put': False,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:subnet_or_none': None},
'required_by_policy': False,
'is_visible': True},
'gateway_ip': {'allow_post': True, 'allow_put': True,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:ip_address_or_none': None},
'is_visible': True},
'allocation_pools': {'allow_post': True, 'allow_put': True,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:ip_pools': None},
'is_visible': True},
'dns_nameservers': {'allow_post': True, 'allow_put': True,
'convert_to': convert_none_to_empty_list,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:nameservers': None},
'is_visible': True},
'host_routes': {'allow_post': True, 'allow_put': True,
'convert_to': convert_none_to_empty_list,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:hostroutes': None},
'is_visible': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
@ -808,13 +807,13 @@ RESOURCE_ATTRIBUTE_MAP = {
'convert_to': convert_to_boolean,
'is_visible': True},
'ipv6_ra_mode': {'allow_post': True, 'allow_put': False,
'default': ATTR_NOT_SPECIFIED,
'validate': {'type:values': constants.IPV6_MODES},
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:values': n_const.IPV6_MODES},
'is_visible': True},
'ipv6_address_mode': {'allow_post': True, 'allow_put': False,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:values':
constants.IPV6_MODES},
n_const.IPV6_MODES},
'is_visible': True},
SHARED: {'allow_post': False,
'allow_put': False,
@ -847,7 +846,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'allow_put': True,
'validate': {'type:non_negative': None},
'convert_to': convert_to_int,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'is_visible': True},
'ip_version': {'allow_post': False,
'allow_put': False,
@ -856,17 +855,17 @@ RESOURCE_ATTRIBUTE_MAP = {
'allow_put': True,
'validate': {'type:non_negative': None},
'convert_to': convert_to_int,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'is_visible': True},
'min_prefixlen': {'allow_post': True,
'allow_put': True,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:non_negative': None},
'convert_to': convert_to_int,
'is_visible': True},
'max_prefixlen': {'allow_post': True,
'allow_put': True,
'default': ATTR_NOT_SPECIFIED,
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:non_negative': None},
'convert_to': convert_to_int,
'is_visible': True},
@ -951,7 +950,7 @@ def fill_default_value(attr_info, res_dict,
def convert_value(attr_info, res_dict, exc_cls=ValueError):
for attr, attr_vals in six.iteritems(attr_info):
if (attr not in res_dict or
res_dict[attr] is ATTR_NOT_SPECIFIED):
res_dict[attr] is constants.ATTR_NOT_SPECIFIED):
continue
# Convert values if necessary
if 'convert_to' in attr_vals:
@ -990,3 +989,22 @@ def verify_attributes(res_dict, attr_info):
if extra_keys:
msg = _("Unrecognized attribute(s) '%s'") % ', '.join(extra_keys)
raise webob.exc.HTTPBadRequest(msg)
# Shim added to move the following to neutron_lib.constants:
# ATTR_NOT_SPECIFIED
# HEX_ELEM
# UUID_PATTERN
# Neutron-lib migration shim. This will wrap any constants that are moved
# to that library in a deprecation warning, until they can be updated to
# import directly from their new location.
# If you're wondering why we bother saving _OLD_REF, it is because if we
# do not, then the original module we are overwriting gets garbage collected,
# and then you will find some super strange behavior with inherited classes
# and the like. Saving a ref keeps it around.
# WARNING: THESE MUST BE THE LAST TWO LINES IN THIS MODULE
_OLD_REF = sys.modules[__name__]
sys.modules[__name__] = _deprecate._DeprecateSubset(globals(), constants)
# WARNING: THESE MUST BE THE LAST TWO LINES IN THIS MODULE

@ -17,6 +17,7 @@ import collections
import copy
import netaddr
from neutron_lib import constants
from neutron_lib import exceptions
from oslo_config import cfg
from oslo_log import log as logging
@ -30,7 +31,7 @@ from neutron.api import api_common
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
from neutron.api.v2 import attributes
from neutron.api.v2 import resource as wsgi_resource
from neutron.common import constants as const
from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc
from neutron.common import rpc as n_rpc
from neutron.db import api as db_api
@ -80,7 +81,7 @@ class Controller(object):
# use plugin's dhcp notifier, if this is already instantiated
agent_notifiers = getattr(plugin, 'agent_notifiers', {})
self._dhcp_agent_notifier = (
agent_notifiers.get(const.AGENT_TYPE_DHCP) or
agent_notifiers.get(constants.AGENT_TYPE_DHCP) or
dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
)
if cfg.CONF.notify_nova_on_port_data_changes:
@ -602,7 +603,7 @@ class Controller(object):
# Make a list of attributes to be updated to inform the policy engine
# which attributes are set explicitly so that it can distinguish them
# from the ones that are set to their default values.
orig_obj[const.ATTRIBUTES_TO_UPDATE] = body[self._resource].keys()
orig_obj[n_const.ATTRIBUTES_TO_UPDATE] = body[self._resource].keys()
try:
policy.enforce(request.context,
action,

@ -17,6 +17,7 @@ import itertools
import re
import time
from neutron_lib import constants
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
@ -32,7 +33,6 @@ from neutron.agent.linux import dhcp
from neutron.agent.linux import external_process
from neutron.agent.linux import interface
from neutron.agent.linux import ip_lib
from neutron.api.v2 import attributes
from neutron.common import config
@ -111,7 +111,7 @@ def eligible_for_deletion(conf, namespace, force=False):
else:
prefixes = itertools.chain(*NS_PREFIXES.values())
ns_mangling_pattern = '(%s%s)' % ('|'.join(prefixes),
attributes.UUID_PATTERN)
constants.UUID_PATTERN)
# filter out namespaces without UUID as the name
if not re.match(ns_mangling_pattern, namespace):

@ -18,6 +18,7 @@ import shutil
import tempfile
import netaddr
from neutron_lib import constants as n_consts
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import uuidutils
@ -31,7 +32,7 @@ from neutron.agent.linux import ip_lib
from neutron.agent.linux import ip_link_support
from neutron.agent.linux import keepalived
from neutron.agent.linux import utils as agent_utils
from neutron.common import constants as n_consts
from neutron.common import constants
from neutron.plugins.common import constants as const
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
import constants as ovs_const
@ -135,7 +136,7 @@ def icmpv6_header_match_supported():
return ofctl_arg_supported(cmd='add-flow',
table=ovs_const.ARP_SPOOF_TABLE,
priority=1,
dl_type=n_consts.ETHERTYPE_IPV6,
dl_type=constants.ETHERTYPE_IPV6,
nw_proto=n_consts.PROTO_NUM_IPV6_ICMP,
icmp_type=n_consts.ICMPV6_TYPE_NA,
nd_target='fdf8:f53b:82e4::10',

@ -14,7 +14,6 @@
import copy
import debtcollector
import inspect
import os
from neutron._i18n import _
@ -29,16 +28,12 @@ class _DeprecateSubset(object):
if (not name.startswith("__") and not inspect.ismodule(a) and
name in vars(self.other_mod)):
# These should be enabled after most have been cleaned up
# in neutron proper, which may not happen during the busy M-3.
if os.getenv('NEUTRON_SHOW_DEPRECATION_WARNINGS'):
debtcollector.deprecate(
name,
message='moved to neutron_lib',
version='mitaka',
removal_version='newton',
stacklevel=4)
debtcollector.deprecate(
name,
message='moved to neutron_lib',
version='mitaka',
removal_version='newton',
stacklevel<