Merge "Allow default network and policy profiles"
This commit is contained in:
commit
ee023ba698
@ -97,10 +97,33 @@
|
|||||||
# password=mySecretPassword
|
# password=mySecretPassword
|
||||||
|
|
||||||
[cisco_n1k]
|
[cisco_n1k]
|
||||||
# integration_bridge=br-int
|
|
||||||
# enable_tunneling=True
|
# (StrOpt) Specify the name of the integration bridge to which the VIFs are
|
||||||
# tunnel_bridge=br-tun
|
# attached.
|
||||||
# local_ip=10.0.0.3
|
#
|
||||||
# tenant_network_type=local
|
# integration_bridge = br-int
|
||||||
# default_policy_profile=<my default dhcp/router policy profile name>
|
|
||||||
# poll_duration=<Time in seconds>
|
# (StrOpt) Name of the policy profile to be associated with a port when no
|
||||||
|
# policy profile is specified during port creates.
|
||||||
|
#
|
||||||
|
# default_policy_profile =
|
||||||
|
# Example: default_policy_profile = service_profile
|
||||||
|
|
||||||
|
# (StrOpt) Name of the policy profile to be associated with a port owned by
|
||||||
|
# network node (dhcp, router).
|
||||||
|
#
|
||||||
|
# network_node_policy_profile =
|
||||||
|
# Example: network_node_policy_profile = dhcp_pp
|
||||||
|
|
||||||
|
# (StrOpt) Name of the network profile to be associated with a network when no
|
||||||
|
# network profile is specified during network creates. Admin should pre-create
|
||||||
|
# a network profile with this name.
|
||||||
|
#
|
||||||
|
# default_network_profile =
|
||||||
|
# Example: default_network_profile = network_pool
|
||||||
|
|
||||||
|
# (StrOpt) Time in seconds for which the plugin polls the VSM for updates in
|
||||||
|
# policy profiles.
|
||||||
|
#
|
||||||
|
# poll_duration =
|
||||||
|
# Example: poll_duration = 180
|
||||||
|
@ -164,9 +164,9 @@ class NetworkProfileAlreadyExists(exceptions.NeutronException):
|
|||||||
"already exists.")
|
"already exists.")
|
||||||
|
|
||||||
|
|
||||||
class NetworkProfileIdNotFound(exceptions.NotFound):
|
class NetworkProfileNotFound(exceptions.NotFound):
|
||||||
"""Network Profile with the given UUID cannot be found."""
|
"""Network Profile with the given UUID/name cannot be found."""
|
||||||
message = _("Network Profile %(profile_id)s could not be found.")
|
message = _("Network Profile %(profile)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class NoMoreNetworkSegments(exceptions.NoNetworkAvailable):
|
class NoMoreNetworkSegments(exceptions.NoNetworkAvailable):
|
||||||
|
@ -70,8 +70,12 @@ cisco_n1k_opts = [
|
|||||||
help=_("N1K VXLAN ID Ranges")),
|
help=_("N1K VXLAN ID Ranges")),
|
||||||
cfg.StrOpt('network_vlan_ranges', default='vlan:1:4095',
|
cfg.StrOpt('network_vlan_ranges', default='vlan:1:4095',
|
||||||
help=_("N1K Network VLAN Ranges")),
|
help=_("N1K Network VLAN Ranges")),
|
||||||
|
cfg.StrOpt('default_network_profile', default='default_network_profile',
|
||||||
|
help=_("N1K default network profile")),
|
||||||
cfg.StrOpt('default_policy_profile', default='service_profile',
|
cfg.StrOpt('default_policy_profile', default='service_profile',
|
||||||
help=_("N1K default policy profile")),
|
help=_("N1K default policy profile")),
|
||||||
|
cfg.StrOpt('network_node_policy_profile', default='dhcp_pp',
|
||||||
|
help=_("N1K policy profile for network node")),
|
||||||
cfg.StrOpt('poll_duration', default='10',
|
cfg.StrOpt('poll_duration', default='10',
|
||||||
help=_("N1K Policy profile polling duration in seconds")),
|
help=_("N1K Policy profile polling duration in seconds")),
|
||||||
]
|
]
|
||||||
|
@ -886,7 +886,7 @@ def get_network_profile(db_session, id):
|
|||||||
return db_session.query(
|
return db_session.query(
|
||||||
n1kv_models_v2.NetworkProfile).filter_by(id=id).one()
|
n1kv_models_v2.NetworkProfile).filter_by(id=id).one()
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.NetworkProfileIdNotFound(profile_id=id)
|
raise c_exc.NetworkProfileNotFound(profile=id)
|
||||||
|
|
||||||
|
|
||||||
def _get_network_profiles(**kwargs):
|
def _get_network_profiles(**kwargs):
|
||||||
@ -1197,7 +1197,7 @@ class NetworkProfile_db_mixin(object):
|
|||||||
try:
|
try:
|
||||||
get_network_profile(context.session, id)
|
get_network_profile(context.session, id)
|
||||||
return True
|
return True
|
||||||
except c_exc.NetworkProfileIdNotFound(profile_id=id):
|
except c_exc.NetworkProfileNotFound(profile=id):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _get_segment_range(self, data):
|
def _get_segment_range(self, data):
|
||||||
@ -1310,6 +1310,21 @@ class NetworkProfile_db_mixin(object):
|
|||||||
LOG.exception(msg)
|
LOG.exception(msg)
|
||||||
raise q_exc.InvalidInput(error_message=msg)
|
raise q_exc.InvalidInput(error_message=msg)
|
||||||
|
|
||||||
|
def _get_network_profile_by_name(self, db_session, name):
|
||||||
|
"""
|
||||||
|
Retrieve network profile based on name.
|
||||||
|
|
||||||
|
:param db_session: database session
|
||||||
|
:param name: string representing the name for the network profile
|
||||||
|
:returns: network profile object
|
||||||
|
"""
|
||||||
|
with db_session.begin(subtransactions=True):
|
||||||
|
try:
|
||||||
|
return (db_session.query(n1kv_models_v2.NetworkProfile).
|
||||||
|
filter_by(name=name).one())
|
||||||
|
except exc.NoResultFound:
|
||||||
|
raise c_exc.NetworkProfileNotFound(profile=name)
|
||||||
|
|
||||||
|
|
||||||
class PolicyProfile_db_mixin(object):
|
class PolicyProfile_db_mixin(object):
|
||||||
|
|
||||||
@ -1460,7 +1475,7 @@ class PolicyProfile_db_mixin(object):
|
|||||||
db_session = db.get_session()
|
db_session = db.get_session()
|
||||||
with db_session.begin(subtransactions=True):
|
with db_session.begin(subtransactions=True):
|
||||||
return (db_session.query(n1kv_models_v2.PolicyProfile).
|
return (db_session.query(n1kv_models_v2.PolicyProfile).
|
||||||
filter_by(name=name).first())
|
filter_by(name=name).one())
|
||||||
|
|
||||||
def _remove_all_fake_policy_profiles(self):
|
def _remove_all_fake_policy_profiles(self):
|
||||||
"""
|
"""
|
||||||
|
@ -204,6 +204,7 @@ class Client(object):
|
|||||||
"""
|
"""
|
||||||
body = {'name': network['name'],
|
body = {'name': network['name'],
|
||||||
'id': network['id'],
|
'id': network['id'],
|
||||||
|
'mode': 'access',
|
||||||
'networkSegmentPool': network_profile['name'], }
|
'networkSegmentPool': network_profile['name'], }
|
||||||
if network[providernet.NETWORK_TYPE] == c_const.NETWORK_TYPE_VLAN:
|
if network[providernet.NETWORK_TYPE] == c_const.NETWORK_TYPE_VLAN:
|
||||||
body['vlan'] = network[providernet.SEGMENTATION_ID]
|
body['vlan'] = network[providernet.SEGMENTATION_ID]
|
||||||
|
@ -667,16 +667,16 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
port['id'])
|
port['id'])
|
||||||
port[n1kv_profile.PROFILE_ID] = binding.profile_id
|
port[n1kv_profile.PROFILE_ID] = binding.profile_id
|
||||||
|
|
||||||
def _process_network_profile(self, context, attrs):
|
def _process_network_profile(self, context, network):
|
||||||
"""Validate network profile exists."""
|
"""Validate network profile exists."""
|
||||||
profile_id = attrs.get(n1kv_profile.PROFILE_ID)
|
profile_id = network.get(n1kv_profile.PROFILE_ID)
|
||||||
profile_id_set = attributes.is_attr_set(profile_id)
|
profile_id_set = attributes.is_attr_set(profile_id)
|
||||||
if not profile_id_set:
|
if not profile_id_set:
|
||||||
raise cisco_exceptions.NetworkProfileIdNotFound(
|
profile_name = c_conf.CISCO_N1K.default_network_profile
|
||||||
profile_id=profile_id)
|
net_p = self._get_network_profile_by_name(context.session,
|
||||||
if not self.network_profile_exists(context, profile_id):
|
profile_name)
|
||||||
raise cisco_exceptions.NetworkProfileIdNotFound(
|
profile_id = net_p['id']
|
||||||
profile_id=profile_id)
|
network['n1kv:profile_id'] = profile_id
|
||||||
return profile_id
|
return profile_id
|
||||||
|
|
||||||
def _process_policy_profile(self, context, attrs):
|
def _process_policy_profile(self, context, attrs):
|
||||||
@ -1218,7 +1218,7 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
|
|
||||||
if ('device_id' in port['port'] and port['port']['device_owner'] in
|
if ('device_id' in port['port'] and port['port']['device_owner'] in
|
||||||
['network:dhcp', 'network:router_interface']):
|
['network:dhcp', 'network:router_interface']):
|
||||||
p_profile_name = c_conf.CISCO_N1K.default_policy_profile
|
p_profile_name = c_conf.CISCO_N1K.network_node_policy_profile
|
||||||
p_profile = self._get_policy_profile_by_name(p_profile_name)
|
p_profile = self._get_policy_profile_by_name(p_profile_name)
|
||||||
if p_profile:
|
if p_profile:
|
||||||
port['port']['n1kv:profile_id'] = p_profile['id']
|
port['port']['n1kv:profile_id'] = p_profile['id']
|
||||||
@ -1228,6 +1228,13 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
profile_id = port['port'].get(n1kv_profile.PROFILE_ID)
|
profile_id = port['port'].get(n1kv_profile.PROFILE_ID)
|
||||||
profile_id_set = attributes.is_attr_set(profile_id)
|
profile_id_set = attributes.is_attr_set(profile_id)
|
||||||
|
|
||||||
|
if not profile_id_set:
|
||||||
|
p_profile_name = c_conf.CISCO_N1K.default_policy_profile
|
||||||
|
p_profile = self._get_policy_profile_by_name(p_profile_name)
|
||||||
|
if p_profile:
|
||||||
|
port['port']['n1kv:profile_id'] = p_profile['id']
|
||||||
|
profile_id_set = True
|
||||||
|
|
||||||
if profile_id_set:
|
if profile_id_set:
|
||||||
profile_id = self._process_policy_profile(context,
|
profile_id = self._process_policy_profile(context,
|
||||||
port['port'])
|
port['port'])
|
||||||
|
Loading…
Reference in New Issue
Block a user