1 # Copyright (c) 2013 OpenStack Foundation
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
16 from oslo_log import log
19 from neutron._i18n import _, _LI
20 from neutron.common import exceptions as exc
21 from neutron.plugins.common import constants as p_const
22 from neutron.plugins.ml2 import driver_api as api
24 LOG = log.getLogger(__name__)
27 class LocalTypeDriver(api.TypeDriver):
28 """Manage state for local networks with ML2.
30 The LocalTypeDriver implements the 'local' network_type. Local
31 network segments provide connectivity between VMs and other
32 devices running on the same node, provided that a common local
33 network bridging technology is available to those devices. Local
34 network segments do not provide any connectivity between nodes.
38 LOG.info(_LI("ML2 LocalTypeDriver initialization complete"))
41 return p_const.TYPE_LOCAL
46 def is_partial_segment(self, segment):
49 def validate_provider_segment(self, segment):
50 for key, value in six.iteritems(segment):
51 if value and key != api.NETWORK_TYPE:
52 msg = _("%s prohibited for local provider network") % key
53 raise exc.InvalidInput(error_message=msg)
55 def reserve_provider_segment(self, session, segment):
56 # No resources to reserve
59 def allocate_tenant_segment(self, session):
60 # No resources to allocate
61 return {api.NETWORK_TYPE: p_const.TYPE_LOCAL}
63 def release_segment(self, session, segment):
64 # No resources to release
67 def get_mtu(self, physical_network=None):