# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# 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
#
#
# 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: Girish Moodalbail, Oracle, Inc.
# Only import the vpn server code if it exists.
try:
try:
except ImportError:
pass
else:
except:
pass
]
"""Implements v2 Neutron Plug-in API specification.
are forwarded to EVS controller through Solaris RAD. The RAD connection
to EVS Controller is over SSH. In order that this plugin can communicate
with EVS Controller non-interactively and securely, one should setup SSH
authentication with pre-shared keys between the host running neutron-server
and the host running EVS controller.
The following table maps OpenStack Neutron resources and attributes to
Solaris Elastic Virtual Switch resources and attributes
|---------------------+------------------+------------------------------|
| OpenStack Neutron | Solaris EVS | Comments |
|---------------------+------------------+------------------------------|
| Network | EVS | Represents an isolated L2 |
| -- name | -- name | segment; implemented either |
| -- id | -- uuid | through VLANs or VXLANs |
| -- tenant_id | -- tenant | |
| -- shared | Always False | |
| -- admin_state_up | Always True | |
| -- status | Always ACTIVE | |
| -- provider: | | |
| network_type | -- l2-type | (either VLAN or VXLAN) |
| -- provider: | | |
| | | |
| | | |
| Subnet | IPnet | An IP network represents |
| -- name | -- name | a block of either IPv4 |
| -- id | -- uuid | or IPv6 addresses (subnet) |
| -- network_id | -- evs | along with a default router |
| -- tenant_id | -- tenant | for the block |
| -- cidr | -- subnet | |
| -- gateway_ip | -- defrouter | |
| -- dns_nameservers | -- OpenStack:\ | |
| | dns_nameservers | |
| -- host_routes | -- OpenStack:\ | |
| | host_routes | |
| -- enable_dhcp | -- OpenStack:\ | |
| | enable_dhcp | |
| -- shared | Always False | |
| | | |
| Port | VPort | A VPort represents the point |
| -- name | -- name | of attachment between the |
| -- id | -- uuid | VNIC and an EVS. It |
| -- network_id | -- evs | encapsulates various network |
| -- tenant_id | -- tenant | configuration parameters ( |
| -- status | -- status | MAC addresses, IP addresses, |
| -- mac_address | -- macaddr | and SLAs) |
| -- fixed_ips | -- ipaddr | |
| -- device_id | -- OpenStack:\ | |
| | device_id | |
| -- device_owner | -- OpenStack:\ | |
| | device_owner | |
| -- security_groups | -- Not Supported | |
| -- admin_state_up | Always UP | |
|---------------------+------------------+------------------------------|
"""
"ext-gw-mode", "quotas", "agent",
"l3_agent_scheduler",
"dhcp_agent_scheduler"]
)
)
self._rad_connection = None
# Since there is no connect_uri() yet, we need to do
# parsing of ssh://user@hostname ourselves
raise SystemExit(_("Specified evs_controller is invalid"))
raise SystemExit(_("'user' and 'hostname' need to be specified "
"for evs_controller"))
if (self._rad_connection is not None and
return self._rad_connection
return self._rad_connection
# RPC support
# Consume from all consumers in a thread
# needed by AgentSchedulerDbMixin()
return self._supported_extension_aliases
propstr):
"and for evs: %s") %
'tenant': tenantname})
try:
return ipnet
try:
if not ipnetlist:
return
poolstr = ""
# obtain the optional allocation pool
return poolstr
if poolstr:
poolstr += ","
# if start and end address is same, EVS expects the address
# to be provided as-is instead of x.x.x.x-x.x.x.x
else:
return poolstr
"""Creates a subnet(IPnet) for a given network(EVS).
An IP network represents a block of either IPv4 or IPv6 addresses
(i.e., subnet) along with a default router for the block. Only one
connect to the EVS, through a VPort, will get an IP address from the
IPnet associated with the EVS.
"""
raise EVSOpNotSupported(_("setting --host-route for a subnet "
"not supported"))
# create the subnet in the DB
if not ipnetname:
ipnetname = None
if not defrouter:
if poolstr:
return db_subnet
'allocation_pools',
'dns_nameservers',
'ipv6_address_mode',
'ipv6_ra_mode'))):
raise EVSOpNotSupported(_("only following subnet attributes "
"enable-dhcp, allocation-pool, "
"dns-nameserver, ipv6-address-mode, "
"and ipv6-ra-mode can be updated"))
# update subnet in DB
# update EVS IPnet with allocation pool info
if poolstr:
return retval
try:
"removing the IPnet") % (auto_created_ports))
for port in auto_created_ports:
try:
# '43' corresponds to EVS' EVS_ENOENT_VPORT error code
(port['id']))
# '42' corresponds to EVS' EVS_ENOENT_IPNET error code
# EVS doesn't have that IPnet, return success to delete
# the IPnet from Neutron DB.
return
if not subnet:
return
# get a list of ports automatically created by Neutron
# delete subnet in DB
try:
return evs
"""Creates a network(EVS) for a given tenant.
An Elastic Virtual Switch (EVS) is a virtual switch that spans
one or more servers (physical machines). It represents an isolated L2
segment, and the isolation is implemented either through VLANs or
VXLANs. An EVS provides network connectivity between the Virtual
Machines connected to it. There are two main resources associated with
an EVS: IPnet and VPort.
"""
raise EVSOpNotSupported(_("setting admin_state_up=False for a "
"network not supported"))
raise EVSOpNotSupported(_("setting shared=True for a "
"network not supported"))
if not evsname:
evsname = None
network['network'])
proplist = []
raise EVSControllerError(_("provider:network_type must be "
"specified when provider:"
"segmentation_id is provided"))
if network_type == 'vxlan':
elif network_type == 'vlan':
else:
raise EVSControllerError(_("specified "
"provider:network_type '%s' not "
"supported") % network_type)
propstr = None
if proplist:
# create the network in DB
# if --router:external is not set, the above function does
# not update net with router:external set to False
# create EVS on the EVS controller
if propstr:
else:
# add provider information into net
return net
raise EVSOpNotSupported(_("net-update"))
try:
if not evslist:
"'%s' defined"), evsuuid)
return None
return evslist[0]
id, None)
# call EVS controller to get provider network information
if evs:
if evs:
(evsuuid, tenantname))
try:
# '41' corresponds to EVS' EVS_ENOENT_EVS error code
# EVS doesn't have that EVS, return success to delete
# the EVS from Neutron DB.
return
if port_in_use:
# clean up subnets
subnet['id'])
subnet['network_id'],
subnet['id'],
propstr):
"and for evs: %s") %
try:
'tenant': tenantname})
return vport
"""Creates a port(VPort) for a given network(EVS).
A VPort represents the point of attachment between the VNIC and an
EVS. It encapsulates various network configuration parameters such as
-- SLAs (maxbw, cos, and priority)
-- IP address and
-- MAC address, et al
This configuration is inherited by the VNIC when it connects to the
VPort.
"""
raise EVSOpNotSupported(_("setting admin_state_up=False for a "
"port not supported"))
# for external gateway ports and floating ips, tenant_id
# is not set, but EVS does not like it.
if not tenant_id:
# create the port in the DB
port)
# Neutron allows to create a port on a network that doesn't
# yet have subnet associated with it, however EVS doesn't
# support this.
if not db_port['fixed_ips']:
raise EVSOpNotSupported(_("creating a port on a network that "
"does not yet have subnet "
"associated with it is not "
"supported"))
if not vportname:
vportname = None
return db_port
# EVS does not allow updating certain attributes, so check for it
raise EVSOpNotSupported(_("updating port's admin_state_up to "
"False is not supported"))
# Get the original port and fail if any attempt is being made
# to change fixed_ips of the port since EVS doesn't support it
if (update_ips and
raise EVSOpNotSupported(_("updating port's fixed_ips "
"is not supported"))
return db_port
'tenant': tenantname})
try:
# '43' corresponds to EVS' EVS_ENOENT_VPORT error code
# EVS doesn't have that VPort, return success to delete
# the VPort from Neutron DB.
else:
if l3_port_check:
if not port:
return
port['network_id'],
port['id'])