**** CubicPower OpenStack Study ****
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# (c) Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# @author: Swaminathan Vasudevan, Hewlett-Packard.
import abc
import six
from neutron.api import extensions
from neutron.api.v2 import attributes as attr
from neutron.api.v2 import resource_helper
from neutron.common import exceptions as qexception
from neutron.plugins.common import constants
from neutron.services.service_base import ServicePluginBase
**** CubicPower OpenStack Study ****
class VPNServiceNotFound(qexception.NotFound):
message = _("VPNService %(vpnservice_id)s could not be found")
**** CubicPower OpenStack Study ****
class IPsecSiteConnectionNotFound(qexception.NotFound):
message = _("ipsec_site_connection %(ipsecsite_conn_id)s not found")
**** CubicPower OpenStack Study ****
class IPsecSiteConnectionDpdIntervalValueError(qexception.InvalidInput):
message = _("ipsec_site_connection %(attr)s is "
"equal to or less than dpd_interval")
**** CubicPower OpenStack Study ****
class IPsecSiteConnectionMtuError(qexception.InvalidInput):
message = _("ipsec_site_connection MTU %(mtu)d is too small "
"for ipv%(version)s")
**** CubicPower OpenStack Study ****
class IKEPolicyNotFound(qexception.NotFound):
message = _("IKEPolicy %(ikepolicy_id)s could not be found")
**** CubicPower OpenStack Study ****
class IPsecPolicyNotFound(qexception.NotFound):
message = _("IPsecPolicy %(ipsecpolicy_id)s could not be found")
**** CubicPower OpenStack Study ****
class IKEPolicyInUse(qexception.InUse):
message = _("IKEPolicy %(ikepolicy_id)s is still in use")
**** CubicPower OpenStack Study ****
class VPNServiceInUse(qexception.InUse):
message = _("VPNService %(vpnservice_id)s is still in use")
**** CubicPower OpenStack Study ****
class RouterInUseByVPNService(qexception.InUse):
message = _("Router %(router_id)s is used by VPNService %(vpnservice_id)s")
**** CubicPower OpenStack Study ****
class VPNStateInvalidToUpdate(qexception.BadRequest):
message = _("Invalid state %(state)s of vpnaas resource %(id)s"
" for updating")
**** CubicPower OpenStack Study ****
class IPsecPolicyInUse(qexception.InUse):
message = _("IPsecPolicy %(ipsecpolicy_id)s is still in use")
**** CubicPower OpenStack Study ****
class DeviceDriverImportError(qexception.NeutronException):
message = _("Can not load driver :%(device_driver)s")
**** CubicPower OpenStack Study ****
class SubnetIsNotConnectedToRouter(qexception.BadRequest):
message = _("Subnet %(subnet_id)s is not "
"connected to Router %(router_id)s")
**** CubicPower OpenStack Study ****
class RouterIsNotExternal(qexception.BadRequest):
message = _("Router %(router_id)s has no external network gateway set")
vpn_supported_initiators = ['bi-directional', 'response-only']
vpn_supported_encryption_algorithms = ['3des', 'aes-128',
'aes-192', 'aes-256']
vpn_dpd_supported_actions = [
'hold', 'clear', 'restart', 'restart-by-peer', 'disabled'
]
vpn_supported_transform_protocols = ['esp', 'ah', 'ah-esp']
vpn_supported_encapsulation_mode = ['tunnel', 'transport']
#TODO(nati) add kilobytes when we support it
vpn_supported_lifetime_units = ['seconds']
vpn_supported_pfs = ['group2', 'group5', 'group14']
vpn_supported_ike_versions = ['v1', 'v2']
vpn_supported_auth_mode = ['psk']
vpn_supported_auth_algorithms = ['sha1']
vpn_supported_phase1_negotiation_mode = ['main']
vpn_lifetime_limits = (60, attr.UNLIMITED)
positive_int = (0, attr.UNLIMITED)
RESOURCE_ATTRIBUTE_MAP = {
'vpnservices': {
'id': {'allow_post': False, 'allow_put': False,
'validate': {'type:uuid': None},
'is_visible': True,
'primary_key': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'required_by_policy': True,
'is_visible': True},
'name': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None},
'is_visible': True, '
**** CubicPower OpenStack Study ****
class Vpnaas(extensions.ExtensionDescriptor):
@classmethod
**** CubicPower OpenStack Study ****
def get_name(cls):
return "VPN service"
@classmethod
**** CubicPower OpenStack Study ****
def get_alias(cls):
return "vpnaas"
@classmethod
**** CubicPower OpenStack Study ****
def get_description(cls):
return "Extension for VPN service"
@classmethod
**** CubicPower OpenStack Study ****
def get_namespace(cls):
return "https://wiki.openstack.org/Neutron/VPNaaS"
@classmethod
**** CubicPower OpenStack Study ****
def get_updated(cls):
return "2013-05-29T10:00:00-00:00"
@classmethod
**** CubicPower OpenStack Study ****
def get_resources(cls):
special_mappings = {'ikepolicies': 'ikepolicy',
'ipsecpolicies': 'ipsecpolicy'}
plural_mappings = resource_helper.build_plural_mappings(
special_mappings, RESOURCE_ATTRIBUTE_MAP)
plural_mappings['peer_cidrs'] = 'peer_cidr'
attr.PLURALS.update(plural_mappings)
return resource_helper.build_resource_info(plural_mappings,
RESOURCE_ATTRIBUTE_MAP,
constants.VPN,
register_quota=True,
translate_name=True)
@classmethod
**** CubicPower OpenStack Study ****
def get_plugin_interface(cls):
return VPNPluginBase
**** CubicPower OpenStack Study ****
def update_attributes_map(self, attributes):
super(Vpnaas, self).update_attributes_map(
attributes, extension_attrs_map=RESOURCE_ATTRIBUTE_MAP)
**** CubicPower OpenStack Study ****
def get_extended_resources(self, version):
if version == "2.0":
return RESOURCE_ATTRIBUTE_MAP
else:
return {}
@six.add_metaclass(abc.ABCMeta)
**** CubicPower OpenStack Study ****
class VPNPluginBase(ServicePluginBase):
**** CubicPower OpenStack Study ****
def get_plugin_name(self):
return constants.VPN
**** CubicPower OpenStack Study ****
def get_plugin_type(self):
return constants.VPN
**** CubicPower OpenStack Study ****
def get_plugin_description(self):
return 'VPN service plugin'
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def get_vpnservices(self, context, filters=None, fields=None):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def get_vpnservice(self, context, vpnservice_id, fields=None):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def create_vpnservice(self, context, vpnservice):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def update_vpnservice(self, context, vpnservice_id, vpnservice):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def delete_vpnservice(self, context, vpnservice_id):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def get_ipsec_site_connections(self, context, filters=None, fields=None):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def get_ipsec_site_connection(self, context,
ipsecsite_conn_id, fields=None):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def create_ipsec_site_connection(self, context, ipsec_site_connection):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def update_ipsec_site_connection(self, context,
ipsecsite_conn_id, ipsec_site_connection):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def delete_ipsec_site_connection(self, context, ipsecsite_conn_id):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def get_ikepolicy(self, context, ikepolicy_id, fields=None):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def get_ikepolicies(self, context, filters=None, fields=None):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def create_ikepolicy(self, context, ikepolicy):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def update_ikepolicy(self, context, ikepolicy_id, ikepolicy):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def delete_ikepolicy(self, context, ikepolicy_id):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def get_ipsecpolicies(self, context, filters=None, fields=None):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def get_ipsecpolicy(self, context, ipsecpolicy_id, fields=None):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def create_ipsecpolicy(self, context, ipsecpolicy):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def update_ipsecpolicy(self, context, ipsecpolicy_id, ipsecpolicy):
pass
@abc.abstractmethod
**** CubicPower OpenStack Study ****
def delete_ipsecpolicy(self, context, ipsecpolicy_id):
pass