from neutron.db import allowedaddresspairs_db as addr_pair_db
from neutron.db import db_base_plugin_v2
from neutron.db import external_net_db
+from neutron.db import extradhcpopt_db
from neutron.db import models_v2
from neutron.db import quota_db # noqa
from neutron.db import securitygroups_rpc_base as sg_db_rpc
from neutron.extensions import allowedaddresspairs as addr_pair
+from neutron.extensions import extra_dhcp_opt as edo_ext
from neutron.extensions import multiprovidernet as mpnet
from neutron.extensions import portbindings
from neutron.extensions import providernet as provider
external_net_db.External_net_db_mixin,
sg_db_rpc.SecurityGroupServerRpcMixin,
agentschedulers_db.DhcpAgentSchedulerDbMixin,
- addr_pair_db.AllowedAddressPairsMixin):
+ addr_pair_db.AllowedAddressPairsMixin,
+ extradhcpopt_db.ExtraDhcpOptMixin):
"""Implement the Neutron L2 abstractions using modules.
_supported_extension_aliases = ["provider", "external-net", "binding",
"quotas", "security-group", "agent",
"dhcp_agent_scheduler",
- "multi-provider", "allowed-address-pairs"]
+ "multi-provider", "allowed-address-pairs",
+ "extra_dhcp_opt"]
@property
def supported_extension_aliases(self):
with session.begin(subtransactions=True):
self._ensure_default_security_group_on_port(context, port)
sgids = self._get_security_groups_on_port(context, port)
+ dhcp_opts = port['port'].get(edo_ext.EXTRADHCPOPTS, [])
result = super(Ml2Plugin, self).create_port(context, port)
self._process_port_create_security_group(context, result, sgids)
network = self.get_network(context, result['network_id'])
self._process_create_allowed_address_pairs(
context, result,
attrs.get(addr_pair.ADDRESS_PAIRS)))
+ self._process_port_create_extra_dhcp_opts(context, result,
+ dhcp_opts)
self.mechanism_manager.create_port_precommit(mech_context)
try:
need_port_update_notify |= self.update_security_group_on_port(
context, id, port, original_port, updated_port)
network = self.get_network(context, original_port['network_id'])
+ need_port_update_notify |= self._update_extra_dhcp_opts_on_port(
+ context, id, port, updated_port)
mech_context = driver_context.PortContext(
self, context, updated_port, network,
original_port=original_port)
from neutron.plugins.ml2 import config
from neutron.tests.unit import _test_extension_portbindings as test_bindings
from neutron.tests.unit import test_db_plugin as test_plugin
+from neutron.tests.unit import test_extension_extradhcpopts as test_dhcpopts
from neutron.tests.unit import test_security_groups_rpc as test_sg_rpc
network_req = self.new_create_request('networks', data)
res = network_req.get_response(self.api)
self.assertEqual(res.status_int, 400)
+
+
+class DHCPOptsTestCase(test_dhcpopts.TestExtraDhcpOpt):
+
+ def setUp(self, plugin=None):
+ super(test_dhcpopts.ExtraDhcpOptDBTestCase, self).setUp(
+ plugin=PLUGIN_NAME)