akanda->astara 3rd step: Rename + modify code

Renames the module and updates imports, references and deprecates
config in favor of newly named equivs.

Change-Id: I56d1770182ca1f3fa4bf2401e7532b181ed1c23a
Partially-Implements: blueprint convert-to-astara
This commit is contained in:
Adam Gandelman 2015-12-02 14:54:29 -08:00
parent 761255264c
commit aa029dec8e
21 changed files with 69 additions and 54 deletions

View File

@ -13,4 +13,4 @@
# License for the specific language governing permissions and limitations
# under the License.
from akanda_neutron.extensions._authzbase import * # noqa
from astara_neutron.extensions._authzbase import * # noqa

View File

@ -13,4 +13,4 @@
# License for the specific language governing permissions and limitations
# under the License.
from akanda_neutron.extensions.loadbalancerstatus import * # noqa
from astara_neutron.extensions.loadbalancerstatus import * # noqa

View File

@ -13,4 +13,4 @@
# License for the specific language governing permissions and limitations
# under the License.
from akanda_neutron.extensions.routerstatus import * # noqa
from astara_neutron.extensions.routerstatus import * # noqa

View File

@ -13,4 +13,4 @@
# License for the specific language governing permissions and limitations
# under the License.
from akanda_neutron.plugins.decorators import * # noqa
from astara_neutron.plugins.decorators import * # noqa

View File

@ -13,4 +13,4 @@
# License for the specific language governing permissions and limitations
# under the License.
from akanda_neutron.plugins.floatingip import * # noqa
from astara_neutron.plugins.floatingip import * # noqa

View File

@ -13,4 +13,4 @@
# License for the specific language governing permissions and limitations
# under the License.
from akanda_neutron.plugins.lbaas_neutron_plugin import * # noqa
from astara_neutron.plugins.lbaas_neutron_plugin import * # noqa

View File

@ -13,4 +13,4 @@
# License for the specific language governing permissions and limitations
# under the License.
from akanda_neutron.plugins.ml2_neutron_plugin import * # noqa
from astara_neutron.plugins.ml2_neutron_plugin import * # noqa

View File

@ -13,4 +13,4 @@
# License for the specific language governing permissions and limitations
# under the License.
from akanda_neutron.plugins.nsx_neutron_plugin import * # noqa
from astara_neutron.plugins.nsx_neutron_plugin import * # noqa

View File

@ -17,7 +17,7 @@
from neutron.api import extensions
from neutron_lbaas.db.loadbalancer import models
from akanda.neutron.extensions import _authzbase
from astara_neutron.extensions import _authzbase
class LoadbalancerstatusResource(_authzbase.ResourceDelegate):

View File

@ -17,7 +17,7 @@
from neutron.api import extensions
from neutron.db.l3_db import Router
from akanda.neutron.extensions import _authzbase
from astara_neutron.extensions import _authzbase
class RouterstatusResource(_authzbase.ResourceDelegate):

View File

@ -34,20 +34,32 @@ from neutron.plugins.common import constants
IPV6_ASSIGNMENT_ATTEMPTS = 1000
LOG = logging.getLogger(__name__)
akanda_opts = [
cfg.StrOpt('akanda_ipv6_tenant_range',
default='fdd6:a1fa:cfa8::/48',
help='IPv6 address prefix'),
cfg.IntOpt('akanda_ipv6_prefix_length',
default=64,
help='Default length of prefix to pre-assign'),
astara_opts = [
cfg.StrOpt(
'astara_ipv6_tenant_range',
default='fdd6:a1fa:cfa8::/48',
help='IPv6 address prefix',
deprecated_opts=[
cfg.DeprecatedOpt('akanda_ipv6_tenant_range')
]),
cfg.IntOpt(
'astara_ipv6_prefix_length',
default=64,
help='Default length of prefix to pre-assign',
deprecated_opts=[
cfg.DeprecatedOpt('akanda_ipv6_prefix_length')
]),
cfg.ListOpt(
'akanda_allowed_cidr_ranges',
'astara_allowed_cidr_ranges',
default=['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fc00::/7'],
help='List of allowed subnet cidrs for non-admin users')
help='List of allowed subnet cidrs for non-admin users',
deprecated_opts=[
cfg.DeprecatedOpt('akanda_allowed_cidr_ranges')
])
]
cfg.CONF.register_opts(akanda_opts)
cfg.CONF.register_opts(astara_opts)
SUPPORTED_EXTENSIONS = [
'dhrouterstatus',
@ -90,19 +102,19 @@ def sync_subnet_gateway_port(f):
def check_subnet_cidr_meets_policy(context, subnet):
if context.is_admin:
return
elif getattr(context, '_akanda_auto_add', None):
elif getattr(context, '_astara_auto_add', None):
return
net = netaddr.IPNetwork(subnet['subnet']['cidr'])
for allowed_cidr in cfg.CONF.akanda_allowed_cidr_ranges:
for allowed_cidr in cfg.CONF.astara_allowed_cidr_ranges:
if net in netaddr.IPNetwork(allowed_cidr):
return
else:
reason = _('Cannot create a subnet that is not within the '
'allowed address ranges [%s].' %
cfg.CONF.akanda_allowed_cidr_ranges)
cfg.CONF.astara_allowed_cidr_ranges)
raise q_exc.AdminRequired(reason=reason)
@ -110,20 +122,20 @@ def get_special_ipv6_addrs(ips, mac_address):
current_ips = set(ips)
special_ips = set([_generate_ipv6_address('fe80::/64', mac_address)])
akanda_ipv6_cidr = netaddr.IPNetwork(cfg.CONF.akanda_ipv6_tenant_range)
astara_ipv6_cidr = netaddr.IPNetwork(cfg.CONF.astara_ipv6_tenant_range)
for ip in current_ips:
if '/' not in ip and netaddr.IPAddress(ip) in akanda_ipv6_cidr:
if '/' not in ip and netaddr.IPAddress(ip) in astara_ipv6_cidr:
# Calculate the cidr here because the caller does not have access
# to request context, subnet or port_id.
special_ips.add(
'%s/%s' % (
netaddr.IPAddress(
netaddr.IPNetwork(
'%s/%d' % (ip, cfg.CONF.akanda_ipv6_prefix_length)
'%s/%d' % (ip, cfg.CONF.astara_ipv6_prefix_length)
).first
),
cfg.CONF.akanda_ipv6_prefix_length
cfg.CONF.astara_ipv6_prefix_length
)
)
return special_ips - current_ips
@ -244,8 +256,8 @@ def _add_ipv6_subnet(context, network):
try:
subnet_generator = _ipv6_subnet_generator(
cfg.CONF.akanda_ipv6_tenant_range,
cfg.CONF.akanda_ipv6_prefix_length)
cfg.CONF.astara_ipv6_tenant_range,
cfg.CONF.astara_ipv6_prefix_length)
except:
LOG.exception('Unable able to add tenant IPv6 subnet.')
return
@ -276,9 +288,9 @@ def _add_ipv6_subnet(context, network):
'host_routes': attributes.ATTR_NOT_SPECIFIED,
'allocation_pools': attributes.ATTR_NOT_SPECIFIED
}
context._akanda_auto_add = True
context._astara_auto_add = True
plugin.create_subnet(context, {'subnet': create_args})
del context._akanda_auto_add
del context._astara_auto_add
break
else:
LOG.error('Unable to generate a unique tenant subnet cidr')

View File

@ -32,6 +32,9 @@ explicit_floating_ip_opts = [
default=[],
help='UUID(s) of subnet(s) from which floating IPs can be allocated',
required=True,
deprecated_opts=[
cfg.DeprecatedOpt('floatingip_subnet', group='akanda')
]
),
]
@ -45,17 +48,17 @@ class ExplicitFloatingIPAllocationMixin(object):
"""
def _allocate_floatingip_from_configured_subnets(self, context):
cfg.CONF.register_opts(explicit_floating_ip_opts, group='akanda')
cfg.CONF.register_opts(explicit_floating_ip_opts, group='astara')
# NOTE(dhellmann): There may be a better way to do this, but
# the "filter" argument to get_subnets() is not documented so
# who knows.
e_context = context.elevated()
subnets = [
self._get_subnet(e_context, unicode(s))
for s in cfg.CONF.akanda.floatingip_subnet
for s in cfg.CONF.astara.floatingip_subnet
]
if not subnets:
LOG.error('config setting akanda.floatingip_subnet missing')
LOG.error('config setting astara.floatingip_subnet missing')
raise q_exc.IpAddressGenerationFailure(net_id='UNKNOWN')
# The base class method _generate_ip() handles the allocation
# ranges and going from one subnet to the next when a network

View File

@ -19,7 +19,7 @@ class LoadBalancerPluginv2(plugin.LoadBalancerPluginv2):
"""
This is allows loadbalancer status to be updated from Akanda.
To enable, add the full python path to this class to the service_plugin
list in neutron.conf Ensure both the path to akanda/neutron/extensions
list in neutron.conf Ensure both the path to astara_neutron/extensions
has been added to api_extensions_path *as well as* the path to
neutron-lbaas/neutron_lbaas/extensions.
"""

View File

@ -22,8 +22,8 @@ from neutron.db import l3_db
from neutron.plugins.ml2 import plugin
from neutron.services.l3_router import l3_router_plugin
from akanda.neutron.plugins import decorators as akanda
from akanda.neutron.plugins import floatingip
from astara_neutron.plugins import decorators as astara
from astara_neutron.plugins import floatingip
AKANDA_PORT_NAME_RE = re.compile(
@ -50,15 +50,15 @@ class Ml2Plugin(floatingip.ExplicitFloatingIPAllocationMixin,
except ValueError:
pass
@akanda.auto_add_ipv6_subnet
@astara.auto_add_ipv6_subnet
def create_network(self, context, network):
return super(Ml2Plugin, self).create_network(context, network)
@akanda.auto_add_subnet_to_router
@astara.auto_add_subnet_to_router
def create_subnet(self, context, subnet):
return super(Ml2Plugin, self).create_subnet(context, subnet)
@akanda.sync_subnet_gateway_port
@astara.sync_subnet_gateway_port
def update_subnet(self, context, id, subnet):
return super(Ml2Plugin, self).update_subnet(
context, id, subnet)

View File

@ -36,13 +36,13 @@ from neutron.plugins.vmware.nsxlib import switch as switchlib
from neutron.plugins.vmware.plugins import base
from neutron.plugins.vmware.plugins.base import cfg as n_cfg
from akanda.neutron.plugins import decorators as akanda
from akanda.neutron.plugins import floatingip
from astara_neutron.plugins import decorators as astara
from astara_neutron.plugins import floatingip
LOG = logging.getLogger("NeutronPlugin")
def akanda_nvp_ipv6_port_security_wrapper(f):
def astara_nvp_ipv6_port_security_wrapper(f):
@functools.wraps(f)
def wrapper(lport_obj, mac_address, fixed_ips, port_security_enabled,
security_profiles, queue_id, mac_learning_enabled,
@ -61,7 +61,7 @@ def akanda_nvp_ipv6_port_security_wrapper(f):
# TODO(mark): investigate moving away from this an wrapping
# (create|update)_port
# add link-local and subnet cidr for IPv6 temp addresses
special_ipv6_addrs = akanda.get_special_ipv6_addrs(
special_ipv6_addrs = astara.get_special_ipv6_addrs(
(p['ip_address'] for p in lport_obj['allowed_address_pairs']),
mac_address
)
@ -74,12 +74,12 @@ def akanda_nvp_ipv6_port_security_wrapper(f):
return wrapper
base.switchlib._configure_extensions = akanda_nvp_ipv6_port_security_wrapper(
base.switchlib._configure_extensions = astara_nvp_ipv6_port_security_wrapper(
base.switchlib._configure_extensions
)
class AkandaNsxSynchronizer(nsx_sync.NsxSynchronizer):
class AstaraNsxSynchronizer(nsx_sync.NsxSynchronizer):
"""
The NsxSynchronizer class in Neutron runs a synchronization thread to
sync nvp objects with neutron objects. Since we don't use nvp's routers
@ -135,7 +135,7 @@ class NsxPluginV2(floatingip.ExplicitFloatingIPAllocationMixin,
"""
supported_extension_aliases = (
base.NsxPluginV2.supported_extension_aliases +
akanda.SUPPORTED_EXTENSIONS
astara.SUPPORTED_EXTENSIONS
)
def __init__(self):
@ -210,7 +210,7 @@ class NsxPluginV2(floatingip.ExplicitFloatingIPAllocationMixin,
# self.nsx_sync_opts.min_chunk_size,
# self.nsx_sync_opts.max_random_sync_delay)
self._synchronizer = AkandaNsxSynchronizer(
self._synchronizer = AstaraNsxSynchronizer(
self, self.cluster,
self.nsx_sync_opts.state_sync_interval,
self.nsx_sync_opts.min_sync_req_delay,
@ -241,11 +241,11 @@ class NsxPluginV2(floatingip.ExplicitFloatingIPAllocationMixin,
self.handle_port_metadata_access_delegate = noop
self.handle_metadata_access_delegate = noop
@akanda.auto_add_ipv6_subnet
@astara.auto_add_ipv6_subnet
def create_network(self, context, network):
return super(NsxPluginV2, self).create_network(context, network)
@akanda.auto_add_subnet_to_router
@astara.auto_add_subnet_to_router
def create_subnet(self, context, subnet):
return super(NsxPluginV2, self).create_subnet(context, subnet)
@ -269,7 +269,7 @@ class NsxPluginV2(floatingip.ExplicitFloatingIPAllocationMixin,
get_sync_data = l3_db.L3_NAT_db_mixin.get_sync_data
def _ensure_metadata_host_route(self, *args, **kwargs):
""" Akanda metadata services are provided by router so make no-op/"""
""" Astara metadata services are provided by router so make no-op/"""
pass
def _nsx_create_port(self, context, port_data):
@ -281,7 +281,7 @@ class NsxPluginV2(floatingip.ExplicitFloatingIPAllocationMixin,
# the DB object and return success
# NOTE(rods): Reporting mark's comment on havana version of this patch.
# Akanda does want ports for external networks so this method is
# Astara does want ports for external networks so this method is
# basically same with external check removed and the auto plugging of
# router ports
@ -354,7 +354,7 @@ class NsxPluginV2(floatingip.ExplicitFloatingIPAllocationMixin,
# unit tests.
# NOTE(rods): reporting mark's comment on havana version of this patch.
# Akanda does want ports for external networks so this method is
# Astara does want ports for external networks so this method is
# basically same with external check removed
# ---------------------------------------------------------------------

View File

@ -24,7 +24,7 @@ classifier =
packages =
akanda
akanda.neutron
akanda_neutron
astara_neutron
namespace_packages =
akanda