class SubnetContext(MechanismDriverContext, api.SubnetContext):
- def __init__(self, plugin, plugin_context, subnet, original_subnet=None):
+ def __init__(self, plugin, plugin_context, subnet, network,
+ original_subnet=None):
super(SubnetContext, self).__init__(plugin, plugin_context)
self._subnet = subnet
self._original_subnet = original_subnet
+ self._network_context = NetworkContext(plugin, plugin_context,
+ network)
@property
def current(self):
def original(self):
return self._original_subnet
+ @property
+ def network(self):
+ return self._network_context
+
class PortContext(MechanismDriverContext, api.PortContext):
result = super(Ml2Plugin, self).create_subnet(context, subnet)
self.extension_manager.process_create_subnet(
context, subnet[attributes.SUBNET], result)
- mech_context = driver_context.SubnetContext(self, context, result)
+ network = self.get_network(context, result['network_id'])
+ mech_context = driver_context.SubnetContext(self, context,
+ result, network)
self.mechanism_manager.create_subnet_precommit(mech_context)
return result, mech_context
context, id, subnet)
self.extension_manager.process_update_subnet(
context, subnet[attributes.SUBNET], updated_subnet)
+ network = self.get_network(context, updated_subnet['network_id'])
mech_context = driver_context.SubnetContext(
- self, context, updated_subnet, original_subnet=original_subnet)
+ self, context, updated_subnet, network,
+ original_subnet=original_subnet)
self.mechanism_manager.update_subnet_precommit(mech_context)
# TODO(apech) - handle errors raised by update_subnet, potentially
# If allocated is None, then all the IPAllocation were
# correctly deleted during the previous pass.
if not allocated:
+ network = self.get_network(context, subnet['network_id'])
mech_context = driver_context.SubnetContext(self, context,
- subnet)
+ subnet,
+ network)
self.mechanism_manager.delete_subnet_precommit(
mech_context)
assert(context.current['id'] == context.original['id'])
else:
assert(not context.original)
+ network_context = context.network
+ assert(isinstance(network_context, api.NetworkContext))
+ self._check_network_context(network_context, False)
def create_subnet_precommit(self, context):
self._check_subnet_context(context, False)