Neutron integration with OVN
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
6.0KB

  1. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  2. # not use this file except in compliance with the License. You may obtain
  3. # a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  10. # License for the specific language governing permissions and limitations
  11. # under the License.
  12. from neutron_lib.api.definitions import portbindings
  13. from neutron_lib import constants as const
  14. import six
  15. # TODO(lucasagomes): Remove OVN_SG_NAME_EXT_ID_KEY in the Rocky release
  16. OVN_SG_NAME_EXT_ID_KEY = 'neutron:security_group_name'
  17. OVN_SG_EXT_ID_KEY = 'neutron:security_group_id'
  18. OVN_SG_RULE_EXT_ID_KEY = 'neutron:security_group_rule_id'
  19. OVN_ML2_MECH_DRIVER_NAME = 'ovn'
  20. OVN_NETWORK_NAME_EXT_ID_KEY = 'neutron:network_name'
  21. OVN_NETWORK_MTU_EXT_ID_KEY = 'neutron:mtu'
  22. OVN_PORT_NAME_EXT_ID_KEY = 'neutron:port_name'
  23. OVN_ROUTER_NAME_EXT_ID_KEY = 'neutron:router_name'
  24. OVN_ROUTER_IS_EXT_GW = 'neutron:is_ext_gw'
  25. OVN_GW_PORT_EXT_ID_KEY = 'neutron:gw_port_id'
  26. OVN_SUBNET_EXT_ID_KEY = 'neutron:subnet_id'
  27. OVN_SUBNET_EXT_IDS_KEY = 'neutron:subnet_ids'
  28. OVN_PHYSNET_EXT_ID_KEY = 'neutron:provnet-physical-network'
  29. OVN_NETTYPE_EXT_ID_KEY = 'neutron:provnet-network-type'
  30. OVN_SEGID_EXT_ID_KEY = 'neutron:provnet-segmentation-id'
  31. OVN_PROJID_EXT_ID_KEY = 'neutron:project_id'
  32. OVN_DEVID_EXT_ID_KEY = 'neutron:device_id'
  33. OVN_CIDRS_EXT_ID_KEY = 'neutron:cidrs'
  34. OVN_FIP_EXT_ID_KEY = 'neutron:fip_id'
  35. OVN_FIP_PORT_EXT_ID_KEY = 'neutron:fip_port_id'
  36. OVN_FIP_EXT_MAC_KEY = 'neutron:fip_external_mac'
  37. OVN_REV_NUM_EXT_ID_KEY = 'neutron:revision_number'
  38. OVN_QOS_POLICY_EXT_ID_KEY = 'neutron:qos_policy_id'
  39. OVN_SG_IDS_EXT_ID_KEY = 'neutron:security_group_ids'
  40. OVN_DEVICE_OWNER_EXT_ID_KEY = 'neutron:device_owner'
  41. OVN_LIVENESS_CHECK_EXT_ID_KEY = 'neutron:liveness_check_at'
  42. OVN_PORT_BINDING_PROFILE = portbindings.PROFILE
  43. OVN_PORT_BINDING_PROFILE_PARAMS = [{'parent_name': six.string_types,
  44. 'tag': six.integer_types},
  45. {'vtep-physical-switch': six.string_types,
  46. 'vtep-logical-switch': six.string_types}]
  47. MIGRATING_ATTR = 'migrating_to'
  48. OVN_ROUTER_PORT_OPTION_KEYS = ['router-port', 'nat-addresses']
  49. OVN_GATEWAY_CHASSIS_KEY = 'redirect-chassis'
  50. OVN_GATEWAY_NAT_ADDRESSES_KEY = 'nat-addresses'
  51. OVN_DROP_PORT_GROUP_NAME = 'neutron_pg_drop'
  52. OVN_PROVNET_PORT_NAME_PREFIX = 'provnet-'
  53. # Agent extension constants
  54. OVN_AGENT_DESC_KEY = 'neutron:description'
  55. OVN_AGENT_METADATA_SB_CFG_KEY = 'neutron:ovn-metadata-sb-cfg'
  56. OVN_AGENT_METADATA_DESC_KEY = 'neutron:description-metadata'
  57. OVN_AGENT_METADATA_ID_KEY = 'neutron:ovn-metadata-id'
  58. OVN_CONTROLLER_AGENT = 'OVN Controller agent'
  59. OVN_CONTROLLER_GW_AGENT = 'OVN Controller Gateway agent'
  60. OVN_METADATA_AGENT = 'OVN Metadata agent'
  61. # OVN ACLs have priorities. The highest priority ACL that matches is the one
  62. # that takes effect. Our choice of priority numbers is arbitrary, but it
  63. # leaves room above and below the ACLs we create. We only need two priorities.
  64. # The first is for all the things we allow. The second is for dropping traffic
  65. # by default.
  66. ACL_PRIORITY_ALLOW = 1002
  67. ACL_PRIORITY_DROP = 1001
  68. ACL_ACTION_DROP = 'drop'
  69. ACL_ACTION_ALLOW_RELATED = 'allow-related'
  70. ACL_ACTION_ALLOW = 'allow'
  71. # When a OVN L3 gateway is created, it needs to be bound to a chassis. In
  72. # case a chassis is not found OVN_GATEWAY_INVALID_CHASSIS will be set in
  73. # the options column of the Logical Router. This value is used to detect
  74. # unhosted router gateways to schedule.
  75. OVN_GATEWAY_INVALID_CHASSIS = 'neutron-ovn-invalid-chassis'
  76. SUPPORTED_DHCP_OPTS = {
  77. 4: ['netmask', 'router', 'dns-server', 'log-server',
  78. 'lpr-server', 'swap-server', 'ip-forward-enable',
  79. 'policy-filter', 'default-ttl', 'mtu', 'router-discovery',
  80. 'router-solicitation', 'arp-timeout', 'ethernet-encap',
  81. 'tcp-ttl', 'tcp-keepalive', 'nis-server', 'ntp-server',
  82. 'tftp-server'],
  83. 6: ['server-id', 'dns-server', 'domain-search']}
  84. DHCPV6_STATELESS_OPT = 'dhcpv6_stateless'
  85. CHASSIS_DATAPATH_NETDEV = 'netdev'
  86. CHASSIS_IFACE_DPDKVHOSTUSER = 'dpdkvhostuser'
  87. OVN_IPV6_ADDRESS_MODES = {
  88. const.IPV6_SLAAC: const.IPV6_SLAAC,
  89. const.DHCPV6_STATEFUL: const.DHCPV6_STATEFUL.replace('-', '_'),
  90. const.DHCPV6_STATELESS: const.DHCPV6_STATELESS.replace('-', '_')
  91. }
  92. DB_MAX_RETRIES = 60
  93. DB_INITIAL_RETRY_INTERVAL = 0.5
  94. DB_MAX_RETRY_INTERVAL = 1
  95. TXN_COMMITTED = 'committed'
  96. INITIAL_REV_NUM = -1
  97. ACL_EXPECTED_COLUMNS_NBDB = (
  98. 'external_ids', 'direction', 'log', 'priority',
  99. 'name', 'action', 'severity', 'match')
  100. # Resource types
  101. TYPE_NETWORKS = 'networks'
  102. TYPE_PORTS = 'ports'
  103. TYPE_SECURITY_GROUP_RULES = 'security_group_rules'
  104. TYPE_ROUTERS = 'routers'
  105. TYPE_ROUTER_PORTS = 'router_ports'
  106. TYPE_SECURITY_GROUPS = 'security_groups'
  107. TYPE_FLOATINGIPS = 'floatingips'
  108. TYPE_SUBNETS = 'subnets'
  109. _TYPES_PRIORITY_ORDER = (
  110. TYPE_NETWORKS,
  111. TYPE_SECURITY_GROUPS,
  112. TYPE_SUBNETS,
  113. TYPE_ROUTERS,
  114. TYPE_PORTS,
  115. TYPE_ROUTER_PORTS,
  116. TYPE_FLOATINGIPS,
  117. TYPE_SECURITY_GROUP_RULES)
  118. # The order in which the resources should be created or updated by the
  119. # maintenance task: Root ones first and leafs at the end.
  120. MAINTENANCE_CREATE_UPDATE_TYPE_ORDER = {
  121. t: n for n, t in enumerate(_TYPES_PRIORITY_ORDER, 1)}
  122. # The order in which the resources should be deleted by the maintenance
  123. # task: Leaf ones first and roots at the end.
  124. MAINTENANCE_DELETE_TYPE_ORDER = {
  125. t: n for n, t in enumerate(reversed(_TYPES_PRIORITY_ORDER), 1)}
  126. # The addresses field to set in the logical switch port which has a
  127. # peer router port (connecting to the logical router).
  128. DEFAULT_ADDR_FOR_LSP_WITH_PEER = 'router'
  129. # Maximum chassis count where a gateway port can be hosted
  130. MAX_GW_CHASSIS = 5
  131. UNKNOWN_ADDR = 'unknown'
  132. # TODO(lucasagomes): Create constants for other LSP types
  133. LSP_TYPE_LOCALNET = 'localnet'