in order for firewall logic to be able to poke a hole allowing traffic to/from a DHCP server,
we need to expose the IP being used for DHCP in a subnet to external entities.
This commit adds device_owner attribute, then dhcp-agent will update the device_owner value
of port to dhcp-agent.
Implement blueprint expose-dhcp-server-ip
Change-Id: I11283485bff8a3a3cf0b1a2716763ad32e43028a
driver = self.dhcp_driver_cls(self.conf,
network,
self.conf.root_helper,
- DeviceManager(self.conf, self.db))
+ DeviceManager(self.conf,
+ self.db,
+ 'network:dhcp'))
getattr(driver, action)()
except Exception, e:
help="The driver used to manage the virtual interface.")
]
- def __init__(self, conf, db):
+ def __init__(self, conf, db, device_owner=''):
self.conf = conf
self.db = db
+ self.device_owner = device_owner
if not conf.interface_driver:
LOG.error(_('You must specify an interface driver'))
self.driver = importutils.import_object(conf.interface_driver, conf)
body = dict(port=dict(
admin_state_up=True,
device_id=self.get_device_id(network),
+ device_owner=self.device_owner,
network_id=network.id,
tenant_id=network.tenant_id,
fixed_ips=[dict(subnet_id=s.id) for s in network.subnets]))
'device_id': {'allow_post': True, 'allow_put': True,
'default': '',
'is_visible': True},
+ 'device_owner': {'allow_post': True, 'allow_put': True,
+ 'default': '',
+ 'is_visible': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'required_by_policy': True,
'is_visible': True},
"fixed_ips": [{'subnet_id': ip["subnet_id"],
'ip_address': ip["ip_address"]}
for ip in port["fixed_ips"]],
- "device_id": port["device_id"]}
+ "device_id": port["device_id"],
+ "device_owner": port["device_owner"]}
return self._fields(res, fields)
def _create_bulk(self, resource, context, request_items):
mac_address=p['mac_address'],
admin_state_up=p['admin_state_up'],
status="ACTIVE",
- device_id=p['device_id'])
+ device_id=p['device_id'],
+ device_owner=p['device_owner'])
context.session.add(port)
# Update the allocated IP's
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
status = sa.Column(sa.String(16), nullable=False)
device_id = sa.Column(sa.String(255), nullable=False)
+ device_owner = sa.Column(sa.String(255), nullable=False)
class Subnet(model_base.BASEV2, HasId, HasTenant):
full_input = {'port': {'admin_state_up': True,
'mac_address': attributes.ATTR_NOT_SPECIFIED,
'fixed_ips': attributes.ATTR_NOT_SPECIFIED,
+ 'device_owner': '',
'host_routes': attributes.ATTR_NOT_SPECIFIED}}
full_input['port'].update(initial_input['port'])
return_value = {'id': _uuid(), 'status': 'ACTIVE',
'admin_state_up': True,
'mac_address': 'ca:fe:de:ad:be:ef',
'host_routes': [],
- 'device_id': device_id}
+ 'device_id': device_id,
+ 'device_owner': ''}
return_value.update(initial_input['port'])
instance = self.plugin.return_value
content_type = 'application/' + fmt
data = {'port': {'network_id': net_id,
'tenant_id': self._tenant_id}}
+
for arg in ('admin_state_up', 'device_id',
- 'mac_address', 'fixed_ips',
- 'name', 'tenant_id'):
+ 'mac_address', 'name', 'fixed_ips',
+ 'tenant_id', 'device_owner'):
# Arg must be present and not empty
if arg in kwargs and kwargs[arg]:
data['port'][arg] = kwargs[arg]
'tenant_id': 'bad_tenant_id',
'admin_state_up': True,
'device_id': 'fake_device',
+ 'device_owner': 'fake_owner',
'fixed_ips': []}}
port_req = self.new_create_request('ports', data)