Set DHCP port status to up automatically

In Dragonflow, the DHCP port is virtual, i.e. it does not really exist.
Therefore, no wiring is needed for it. Therefore, its status can be
automatically set to up.

Change-Id: Iba3f8a898e057ad9d1603f904731ec9582058259
Partial-Bug: #1452274
This commit is contained in:
Omer Anson 2017-12-26 17:31:41 +02:00
parent 35c9de51d9
commit 746e80df55
2 changed files with 13 additions and 1 deletions

View File

@ -83,7 +83,8 @@ class DFDHCPModule(object):
'admin_state_up': True, 'device_id': '',
'device_owner': n_const.DEVICE_OWNER_DHCP,
'mac_address': n_const.ATTR_NOT_SPECIFIED,
'fixed_ips': [{'subnet_id': subnet['id']}]}}
'fixed_ips': [{'subnet_id': subnet['id']}],
'status': n_const.PORT_STATUS_ACTIVE}}
self.core_plugin.create_port(context, port)
def _update_dhcp_port(self, context, port, subnet):

View File

@ -16,6 +16,7 @@
import mock
from neutron.plugins.ml2.plugin import Ml2Plugin
from neutron_lib import constants as n_const
from dragonflow.neutron.ml2.dhcp_module import DFDHCPModule
from dragonflow.tests.unit import test_mech_driver as test_md
@ -92,3 +93,13 @@ class TestDfDHCPModule(test_md.DFMechanismDriverTestCase):
data, subnet2['subnet']['id'])
req.get_response(self.api)
delete_mock.assert_called_once()
def test_dhcp_port_status(self):
network, _ = self._test_create_network_revision()
with self.subnet(network={'network': network}, enable_dhcp=True,
set_context=True):
filters = {'device_owner': [n_const.DEVICE_OWNER_DHCP],
'network': [network]}
ports = self.driver.get_ports(self.context, filters=filters)
port = ports[0]
self.assertEqual(n_const.PORT_STATUS_ACTIVE, port['status'])