components/openstack/neutron/files/evs/plugin.py
author Xiangning Yu<xiangning.yu@oracle.com>
Thu, 24 Sep 2015 13:24:02 -0700
changeset 4902 d852c9504ffb
parent 4507 76c2e35382f6
child 4975 6445e44cfccd
permissions -rw-r--r--
21630128 Neutron needs to support updating subnet DNS configuration
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     2
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
     3
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     4
#
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     5
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     6
#    not use this file except in compliance with the License. You may obtain
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     7
#    a copy of the License at
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     8
#
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     9
#         http://www.apache.org/licenses/LICENSE-2.0
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    10
#
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    11
#    Unless required by applicable law or agreed to in writing, software
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    12
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    13
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    14
#    License for the specific language governing permissions and limitations
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    15
#    under the License.
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    16
#
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    17
# @author: Girish Moodalbail, Oracle, Inc.
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    18
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    19
import rad.client as radcli
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    20
import rad.connect as radcon
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    21
import rad.bindings.com.oracle.solaris.rad.evscntl_1 as evsbind
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    22
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    23
from oslo.config import cfg
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    24
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    25
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    26
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    27
from neutron.api.rpc.handlers import dhcp_rpc
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    28
from neutron.api.rpc.handlers import l3_rpc
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    29
from neutron.api.v2 import attributes
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    30
from neutron.common import constants
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    31
from neutron.common import exceptions
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    32
from neutron.common import rpc as n_rpc
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    33
from neutron.common import topics
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    34
from neutron.db import agents_db
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    35
from neutron.db import agentschedulers_db
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    36
from neutron.db import api as db
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    37
from neutron.db import db_base_plugin_v2
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    38
from neutron.db import external_net_db
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    39
from neutron.db import l3_gwmode_db
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    40
from neutron.db import model_base
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    41
from neutron.db import quota_db
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    42
from neutron.extensions import external_net
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    43
from neutron.extensions import providernet
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    44
from neutron.openstack.common import importutils
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    45
from neutron.openstack.common import lockutils
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    46
from neutron.openstack.common import log as logging
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    47
from neutron.plugins.common import constants as svc_constants
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    48
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    49
LOG = logging.getLogger(__name__)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    50
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    51
evs_controller_opts = [
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    52
    cfg.StrOpt('evs_controller', default='ssh://[email protected]',
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    53
               help=_("An URI that specifies an EVS controller"))
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    54
]
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    55
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    56
cfg.CONF.register_opts(evs_controller_opts, "EVS")
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    57
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    58
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    59
class EVSControllerError(exceptions.NeutronException):
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    60
    message = _("EVS controller: %(errmsg)s")
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    61
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    62
    def __init__(self, evs_errmsg):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    63
        super(EVSControllerError, self).__init__(errmsg=evs_errmsg)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    64
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    65
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    66
class EVSOpNotSupported(exceptions.NeutronException):
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    67
    message = _("Operation not supported by EVS plugin: %(opname)s")
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    68
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    69
    def __init__(self, evs_errmsg):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    70
        super(EVSOpNotSupported, self).__init__(opname=evs_errmsg)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    71
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    72
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    73
class EVSNotFound(exceptions.NeutronException):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    74
    message = _("Network %(net_id)s could not be found in EVS")
2065
1c1b527dcee1 19510667 fix allocation-pool issue while creating neutron subnets
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1966
diff changeset
    75
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    76
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    77
class EVSNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    78
                         agentschedulers_db.DhcpAgentSchedulerDbMixin,
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    79
                         external_net_db.External_net_db_mixin,
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
    80
                         l3_gwmode_db.L3_NAT_db_mixin):
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    81
    """Implements v2 Neutron Plug-in API specification.
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    82
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
    83
    All the neutron API calls to create/delete/retrieve Network/Subnet/Port
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    84
    are forwarded to EVS controller through Solaris RAD. The RAD connection
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    85
    to EVS Controller is over SSH. In order that this plugin can communicate
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    86
    with EVS Controller non-interactively and securely, one should setup SSH
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    87
    authentication with pre-shared keys between the host running neutron-server
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    88
    and the host running EVS controller.
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    89
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    90
    The following table maps OpenStack Neutron resources and attributes to
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    91
    Solaris Elastic Virtual Switch resources and attributes
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    92
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    93
    |---------------------+------------------+------------------------------|
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    94
    | OpenStack Neutron   | Solaris EVS      | Comments                     |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    95
    |---------------------+------------------+------------------------------|
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    96
    | Network             | EVS              | Represents an isolated L2    |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    97
    | -- name             | -- name          | segment; implemented either  |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    98
    | -- id               | -- uuid          | through VLANs or VXLANs      |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    99
    | -- tenant_id        | -- tenant        |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   100
    | -- shared           | Always False     |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   101
    | -- admin_state_up   | Always True      |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   102
    | -- status           | Always ACTIVE    |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   103
    | -- provider:        |                  |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   104
    |    network_type     |  -- l2-type      | (either VLAN or VXLAN)       |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   105
    | -- provider:        |                  |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   106
    |    segmentation_id  |  -- vlanid/vni   |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   107
    |                     |                  |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   108
    |                     |                  |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   109
    | Subnet              | IPnet            | An IP network represents     |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   110
    | -- name             | -- name          | a block of either IPv4       |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   111
    | -- id               | -- uuid          | or IPv6 addresses (subnet)   |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   112
    | -- network_id       | -- evs           | along with a default router  |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   113
    | -- tenant_id        | -- tenant        | for the block                |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   114
    | -- cidr             | -- subnet        |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   115
    | -- gateway_ip       | -- defrouter     |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   116
    | -- allocation_pools | -- start/stop    |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   117
    | -- dns_nameservers  | -- OpenStack:\   |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   118
    |                     | dns_nameservers  |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   119
    | -- host_routes      | -- OpenStack:\   |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   120
    |                     | host_routes      |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   121
    | -- enable_dhcp      | -- OpenStack:\   |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   122
    |                     | enable_dhcp      |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   123
    | -- shared           | Always False     |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   124
    |                     |                  |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   125
    | Port                | VPort            | A VPort represents the point |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   126
    | -- name             | -- name          | of attachment between the    |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   127
    | -- id               | -- uuid          | VNIC and an EVS. It          |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   128
    | -- network_id       | -- evs           | encapsulates various network |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   129
    | -- tenant_id        | -- tenant        | configuration parameters (   |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   130
    | -- status           | -- status        | MAC addresses, IP addresses, |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   131
    | -- mac_address      | -- macaddr       | and SLAs)                    |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   132
    | -- fixed_ips        | -- ipaddr        |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   133
    | -- device_id        | -- OpenStack:\   |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   134
    |                     |    device_id     |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   135
    | -- device_owner     | -- OpenStack:\   |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   136
    |                     |    device_owner  |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   137
    | -- security_groups  | -- Not Supported |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   138
    | -- admin_state_up   | Always UP        |                              |
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   139
    |---------------------+------------------+------------------------------|
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   140
    """
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   141
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   142
    _supported_extension_aliases = ["provider", "external-net", "router",
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   143
                                    "ext-gw-mode", "quotas", "agent",
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   144
                                    "dhcp_agent_scheduler"]
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   145
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   146
    def __init__(self):
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   147
        engine = db.get_engine()
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   148
        model_base.BASEV2.metadata.create_all(engine)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   149
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   150
        self.network_scheduler = importutils.import_object(
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   151
            cfg.CONF.network_scheduler_driver
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   152
        )
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   153
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   154
        self._setup_rpc()
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   155
        self._rad_connection = None
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   156
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   157
    @property
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   158
    def rad_connection(self):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   159
        # Since there is no connect_uri() yet, we need to do
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   160
        # parsing of ssh://[email protected] ourselves
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   161
        suh = cfg.CONF.EVS.evs_controller.split('://')
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   162
        if len(suh) != 2 or suh[0] != 'ssh' or not suh[1].strip():
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   163
            raise SystemExit(_("Specified evs_controller is invalid"))
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   164
        uh = suh[1].split('@')
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   165
        if len(uh) != 2 or not uh[0].strip() or not uh[1].strip():
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   166
            raise SystemExit(_("'user' and 'hostname' need to be specified "
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   167
                               "for evs_controller"))
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   168
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   169
        if (self._rad_connection is not None and
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   170
                self._rad_connection._closed is None):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   171
            return self._rad_connection
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   172
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   173
        LOG.debug(_("Connecting to EVS Controller at %s as %s") %
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   174
                  (uh[1], uh[0]))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   175
        self._rad_connection = radcon.connect_ssh(uh[1], user=uh[0])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   176
        return self._rad_connection
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   177
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   178
    def _setup_rpc(self):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   179
        # RPC support
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   180
        self.service_topics = {svc_constants.CORE: topics.PLUGIN,
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   181
                               svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   182
        self.conn = n_rpc.create_connection(new=True)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   183
        self.endpoints = [dhcp_rpc.DhcpRpcCallback(),
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   184
                          l3_rpc.L3RpcCallback(),
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   185
                          agents_db.AgentExtRpcCallback()]
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   186
        for svc_topic in self.service_topics.values():
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   187
            self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   188
        # Consume from all consumers in a thread
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   189
        self.conn.consume_in_threads()
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   190
        self.dhcp_agent_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   191
        self.l3_agent_notifier = l3_rpc_agent_api.L3AgentNotifyAPI()
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   192
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   193
        # needed by AgentSchedulerDbMixin()
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   194
        self.agent_notifiers[constants.AGENT_TYPE_DHCP] = \
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   195
            self.dhcp_agent_notifier
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   196
        self.agent_notifiers[constants.AGENT_TYPE_L3] = \
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   197
            self.l3_agent_notifier
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   198
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   199
    @property
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   200
    def supported_extension_aliases(self):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   201
        return self._supported_extension_aliases
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   202
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   203
    @lockutils.synchronized('evs-plugin', 'neutron-')
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   204
    def _evs_controller_addIPnet(self, tenantname, evsname, ipnetname,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   205
                                 propstr):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   206
        LOG.debug(_("Adding IPnet: %s with properties: %s for tenant: %s "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   207
                    "and for evs: %s") %
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   208
                  (ipnetname, propstr, tenantname, evsname))
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   209
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   210
        pat = radcli.ADRGlobPattern({'name': evsname,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   211
                                     'tenant': tenantname})
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   212
        try:
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   213
            evs = self.rad_connection.get_object(evsbind.EVS(), pat)
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   214
            ipnet = evs.addIPnet(propstr, ipnetname)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   215
        except radcli.ObjectError as oe:
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   216
            raise EVSControllerError(oe.get_payload().errmsg)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   217
        return ipnet
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   218
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   219
    @lockutils.synchronized('evs-plugin', 'neutron-')
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   220
    def _evs_controller_updateIPnet(self, ipnetuuid, propstr):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   221
        LOG.debug(_("Updating IPnet with id: %s with property string: %s") %
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   222
                  (ipnetuuid, propstr))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   223
        pat = radcli.ADRGlobPattern({'uuid': ipnetuuid})
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   224
        try:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   225
            ipnetlist = self.rad_connection.list_objects(evsbind.IPnet(), pat)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   226
            if not ipnetlist:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   227
                return
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   228
            assert len(ipnetlist) == 1
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   229
            ipnet = self.rad_connection.get_object(ipnetlist[0])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   230
            ipnet.setProperty(propstr)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   231
        except radcli.ObjectError as oe:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   232
            raise EVSControllerError(oe.get_payload().errmsg)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   233
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   234
    def _subnet_pool_to_evs_pool(self, subnet):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   235
        poolstr = ""
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   236
        # obtain the optional allocation pool
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   237
        pools = subnet.get('allocation_pools')
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   238
        if not pools or pools is attributes.ATTR_NOT_SPECIFIED:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   239
            return poolstr
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   240
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   241
        for pool in pools:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   242
            if poolstr:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   243
                poolstr += ","
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   244
            # if start and end address is same, EVS expects the address
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   245
            # to be provided as-is instead of x.x.x.x-x.x.x.x
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   246
            if pool['start'] == pool['end']:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   247
                poolstr += pool['start']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   248
            else:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   249
                poolstr += "%s-%s" % (pool['start'], pool['end'])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   250
        return poolstr
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   251
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   252
    def create_subnet(self, context, subnet):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   253
        """Creates a subnet(IPnet) for a given network(EVS).
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   254
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   255
         An IP network represents a block of either IPv4 or IPv6 addresses
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   256
         (i.e., subnet) along with a default router for the block. Only one
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   257
         IPnet can be associated with an EVS. All the zones/VNICs that
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   258
         connect to the EVS, through a VPort, will get an IP address from the
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   259
         IPnet associated with the EVS.
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   260
        """
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   261
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   262
        if (subnet['subnet']['host_routes'] is not
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   263
                attributes.ATTR_NOT_SPECIFIED):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   264
            raise EVSOpNotSupported(_("setting --host-route for a subnet "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   265
                                      "not supported"))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   266
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   267
        poolstr = self._subnet_pool_to_evs_pool(subnet['subnet'])
2065
1c1b527dcee1 19510667 fix allocation-pool issue while creating neutron subnets
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1966
diff changeset
   268
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   269
        with context.session.begin(subtransactions=True):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   270
            # create the subnet in the DB
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   271
            db_subnet = super(EVSNeutronPluginV2, self).create_subnet(context,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   272
                                                                      subnet)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   273
            ipnetname = db_subnet['name']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   274
            if not ipnetname:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   275
                ipnetname = None
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   276
            evsname = db_subnet['network_id']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   277
            tenantname = db_subnet['tenant_id']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   278
            proplist = ['subnet=%s' % db_subnet['cidr']]
4507
76c2e35382f6 21135855 Enable gateway-less external networks
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 3998
diff changeset
   279
            defrouter = db_subnet['gateway_ip']
76c2e35382f6 21135855 Enable gateway-less external networks
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 3998
diff changeset
   280
            if not defrouter:
76c2e35382f6 21135855 Enable gateway-less external networks
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 3998
diff changeset
   281
                defrouter = '0.0.0.0' if db_subnet['ip_version'] == 4 else '::'
76c2e35382f6 21135855 Enable gateway-less external networks
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 3998
diff changeset
   282
            proplist.append('defrouter=%s' % defrouter)
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   283
            proplist.append('uuid=%s' % db_subnet['id'])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   284
            if poolstr:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   285
                proplist.append('pool=%s' % (poolstr))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   286
            self._evs_controller_addIPnet(tenantname, evsname, ipnetname,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   287
                                          ",".join(proplist))
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   288
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   289
        # notify dhcp agent of subnet creation
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   290
        self.dhcp_agent_notifier.notify(context, {'subnet': db_subnet},
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   291
                                        'subnet.create.end')
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   292
        return db_subnet
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   293
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   294
    def update_subnet(self, context, id, subnet):
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   295
        LOG.debug(_("Updating Subnet: %s with %s") % (id, subnet))
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   296
        evs_rpccall_sync = subnet.pop('evs_rpccall_sync', False)
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   297
        if (set(subnet['subnet'].keys()) - set(('enable_dhcp',
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   298
                                                'allocation_pools',
4902
d852c9504ffb 21630128 Neutron needs to support updating subnet DNS configuration
Xiangning Yu<xiangning.yu@oracle.com>
parents: 4507
diff changeset
   299
                                                'dns_nameservers',
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   300
                                                'ipv6_address_mode',
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   301
                                                'ipv6_ra_mode'))):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   302
                raise EVSOpNotSupported(_("only following subnet attributes "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   303
                                          "enable-dhcp, allocation-pool, "
4902
d852c9504ffb 21630128 Neutron needs to support updating subnet DNS configuration
Xiangning Yu<xiangning.yu@oracle.com>
parents: 4507
diff changeset
   304
                                          "dns-nameserver, ipv6-address-mode, "
d852c9504ffb 21630128 Neutron needs to support updating subnet DNS configuration
Xiangning Yu<xiangning.yu@oracle.com>
parents: 4507
diff changeset
   305
                                          "and ipv6-ra-mode can be updated"))
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   306
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   307
        poolstr = self._subnet_pool_to_evs_pool(subnet['subnet'])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   308
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   309
        with context.session.begin(subtransactions=True):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   310
            # update subnet in DB
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   311
            retval = super(EVSNeutronPluginV2, self).\
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   312
                update_subnet(context, id, subnet)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   313
            # update EVS IPnet with allocation pool info
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   314
            if poolstr:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   315
                self._evs_controller_updateIPnet(id, "pool=%s" % poolstr)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   316
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   317
        # notify dhcp agent of subnet update
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   318
        methodname = 'subnet.update.end'
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   319
        payload = {'subnet': retval}
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   320
        if not evs_rpccall_sync:
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   321
            self.dhcp_agent_notifier.notify(context, payload, methodname)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   322
        else:
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   323
            msg = self.dhcp_agent_notifier.make_msg(
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   324
                methodname.replace(".", "_"), payload=payload)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   325
            self.dhcp_agent_notifier.call(context, msg,
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   326
                                          topic=topics.DHCP_AGENT)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   327
        return retval
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   328
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   329
    def get_subnet(self, context, id, fields=None):
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   330
        LOG.debug(_("Getting subnet: %s"), id)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   331
        subnet = super(EVSNeutronPluginV2, self).get_subnet(context, id, None)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   332
        return self._fields(subnet, fields)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   333
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   334
    def get_subnets(self, context, filters=None, fields=None,
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   335
                    sorts=None, limit=None, marker=None, page_reverse=False):
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   336
        subnets = super(EVSNeutronPluginV2, self).\
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   337
            get_subnets(context, filters, None, sorts, limit, marker,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   338
                        page_reverse)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   339
        return [self._fields(subnet, fields) for subnet in subnets]
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   340
1792
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   341
    def _release_subnet_dhcp_port(self, context, subnet, delete_network):
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   342
        """Release any dhcp port associated with the subnet"""
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   343
        filters = dict(network_id=[subnet['network_id']])
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   344
        portlist = self.get_ports(context, filters)
1792
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   345
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   346
        if delete_network:
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   347
            # One can delete a network if there is only one port that has a
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   348
            # VNIC attached to it and that port happens to be a DHCP port.
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   349
            ports_with_deviceid = [port for port in portlist
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   350
                                   if port['device_id'] != '']
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   351
            update_subnet = len(ports_with_deviceid) == 1
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   352
        else:
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   353
            # One can delete a subnet if there is only one port and that
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   354
            # port happens to be a DHCP port.
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   355
            update_subnet = len(portlist) == 1
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   356
        if update_subnet:
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   357
            # For IPv6 we need to first reset the IPv6 attributes
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   358
            if subnet['ip_version'] == 6:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   359
                if (attributes.is_attr_set(subnet.get('ipv6_address_mode'))):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   360
                    subnet_update = {'subnet':
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   361
                                     {'ipv6_address_mode': None,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   362
                                      'ipv6_ra_mode': None
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   363
                                      },
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   364
                                     'evs_rpccall_sync': True
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   365
                                     }
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   366
                    self.update_subnet(context, subnet['id'], subnet_update)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   367
            # the lone port is a dhcp port created by dhcp agent
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   368
            # it must be released before we can delete the subnet
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   369
            subnet_update = {'subnet': {'enable_dhcp': False},
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   370
                             'evs_rpccall_sync': True}
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   371
            self.update_subnet(context, subnet['id'], subnet_update)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   372
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   373
    @lockutils.synchronized('evs-plugin', 'neutron-')
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   374
    def _evs_controller_removeIPnet(self, tenantname, evsname, ipnetuuid):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   375
        LOG.debug(_("Removing IPnet with id: %s for tenant: %s for evs: %s") %
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   376
                  (ipnetuuid, tenantname, evsname))
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   377
        pat = radcli.ADRGlobPattern({'name': evsname, 'tenant': tenantname})
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   378
        try:
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   379
            evs = self.rad_connection.get_object(evsbind.EVS(), pat)
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   380
            evs.removeIPnet(ipnetuuid)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   381
        except radcli.ObjectError as oe:
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   382
            # '42' corresponds to EVS' EVS_ENOENT_IPNET error code
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   383
            if oe.get_payload().err == 42:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   384
                # EVS doesn't have that IPnet, return success to delete
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   385
                # the IPnet from Neutron DB.
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   386
                LOG.debug(_("IPnet could not be found in EVS."))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   387
                return
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   388
            raise EVSControllerError(oe.get_payload().errmsg)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   389
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   390
    def delete_subnet(self, context, id):
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   391
        subnet = self.get_subnet(context, id)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   392
        if not subnet:
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   393
            return
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   394
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   395
        # If the subnet is dhcp_enabled, then the dhcp agent would have
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   396
        # created a port connected to this subnet. We need to remove
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   397
        # that port before we can proceed with subnet delete operation.
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   398
        # Since, there is no subnet.delete.start event, we use an another
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   399
        # approach of updating the subnet's enable_dhcp attribute to
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   400
        # False that in turn sends a subnet.udpate notification. This
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   401
        # results in DHCP agent releasing the port.
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   402
        if subnet['enable_dhcp']:
1792
5cea652172c6 18416129 neutron-l3-agent should include dependency on ipfilter service
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1760
diff changeset
   403
                self._release_subnet_dhcp_port(context, subnet, False)
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   404
        with context.session.begin(subtransactions=True):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   405
            # delete subnet in DB
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   406
            super(EVSNeutronPluginV2, self).delete_subnet(context, id)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   407
            self._evs_controller_removeIPnet(subnet['tenant_id'],
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   408
                                             subnet['network_id'], id)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   409
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   410
        # notify dhcp agent
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   411
        payload = {
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   412
            'subnet': {
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   413
                'network_id': subnet['network_id'],
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   414
                'id': id,
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   415
            }
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   416
        }
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   417
        self.dhcp_agent_notifier.notify(context, payload, 'subnet.delete.end')
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   418
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   419
    @lockutils.synchronized('evs-plugin', 'neutron-')
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   420
    def _evs_controller_createEVS(self, tenantname, evsname, propstr):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   421
        LOG.debug(_("Adding EVS: %s with properties: %s for tenant: %s") %
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   422
                  (evsname, propstr, tenantname))
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   423
        try:
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   424
            evs = self.rad_connection.\
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   425
                get_object(evsbind.EVSController()).\
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   426
                createEVS(propstr, tenantname, evsname)
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   427
        except radcli.ObjectError as oe:
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   428
            raise EVSControllerError(oe.get_payload().errmsg)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   429
        return evs
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   430
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   431
    def _extend_network_dict(self, network, evs):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   432
        for prop in evs.props:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   433
            if prop.name == 'l2-type':
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   434
                network[providernet.NETWORK_TYPE] = prop.value
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   435
            elif prop.name == 'vlanid' or prop.name == 'vni':
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   436
                network[providernet.SEGMENTATION_ID] = int(prop.value)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   437
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   438
    def create_network(self, context, network):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   439
        """Creates a network(EVS) for a given tenant.
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   440
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   441
        An Elastic Virtual Switch (EVS) is a virtual switch that spans
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   442
        one or more servers (physical machines). It represents an isolated L2
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   443
        segment, and the isolation is implemented either through VLANs or
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   444
        VXLANs. An EVS provides network connectivity between the Virtual
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   445
        Machines connected to it. There are two main resources associated with
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   446
        an EVS: IPnet and VPort.
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   447
        """
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   448
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   449
        if network['network']['admin_state_up'] is False:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   450
            raise EVSOpNotSupported(_("setting admin_state_up=False for a "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   451
                                      "network not supported"))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   452
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   453
        if network['network']['shared'] is True:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   454
            raise EVSOpNotSupported(_("setting shared=True for a "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   455
                                      "network not supported"))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   456
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   457
        evsname = network['network']['name']
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   458
        if not evsname:
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   459
            evsname = None
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   460
1959
ba86b21a837b 19026240 Extract tenantid using the framework provided function
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1944
diff changeset
   461
        tenantname = self._get_tenant_id_for_create(context,
ba86b21a837b 19026240 Extract tenantid using the framework provided function
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1944
diff changeset
   462
                                                    network['network'])
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   463
        proplist = []
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   464
        network_type = network['network'][providernet.NETWORK_TYPE]
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   465
        if attributes.is_attr_set(network_type):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   466
            proplist.append('l2-type=%s' % network_type)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   467
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   468
        segment_id = network['network'][providernet.SEGMENTATION_ID]
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   469
        if attributes.is_attr_set(segment_id):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   470
            if (not attributes.is_attr_set(network_type) or
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   471
                    len(network_type) == 0):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   472
                raise EVSControllerError(_("provider:network_type must be "
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   473
                                           "specified when provider:"
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   474
                                           "segmentation_id is provided"))
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   475
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   476
            if network_type == 'vxlan':
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   477
                proplist.append('vni=%d' % segment_id)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   478
            elif network_type == 'vlan':
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   479
                proplist.append('vlanid=%d' % segment_id)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   480
            else:
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   481
                raise EVSControllerError(_("specified "
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   482
                                           "provider:network_type '%s' not "
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   483
                                           "supported") % network_type)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   484
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   485
        propstr = None
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   486
        if proplist:
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   487
            propstr = ",".join(proplist)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   488
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   489
        with context.session.begin(subtransactions=True):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   490
            # create the network in DB
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   491
            net = super(EVSNeutronPluginV2, self).create_network(context,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   492
                                                                 network)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   493
            self._process_l3_create(context, net, network['network'])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   494
            # if --router:external is not set, the above function does
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   495
            # not update net with router:external set to False
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   496
            if net.get(external_net.EXTERNAL) is None:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   497
                net[external_net.EXTERNAL] = False
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   498
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   499
            # create EVS on the EVS controller
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   500
            if propstr:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   501
                propstr += ",uuid=%s" % net['id']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   502
            else:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   503
                propstr = "uuid=%s" % net['id']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   504
            evs = self._evs_controller_createEVS(tenantname, evsname, propstr)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   505
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   506
            # add provider information into net
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   507
            self._extend_network_dict(net, evs)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   508
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   509
        return net
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   510
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   511
    def update_network(self, context, id, network):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   512
        raise EVSOpNotSupported(_("net-update"))
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   513
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   514
    @lockutils.synchronized('evs-plugin', 'neutron-')
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   515
    def _evs_controller_getEVS(self, evsuuid):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   516
        LOG.debug(_("Getting EVS: %s"), evsuuid)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   517
        try:
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   518
            evslist = self.rad_connection.\
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   519
                get_object(evsbind.EVSController()).\
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   520
                getEVSInfo('evs=%s' % evsuuid)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   521
        except radcli.ObjectError as oe:
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   522
            raise EVSControllerError(oe.getpayload().errmsg)
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   523
        if not evslist:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   524
            LOG.error(_("EVS framework does not have Neutron network "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   525
                        "'%s' defined"), evsuuid)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   526
            return None
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   527
        return evslist[0]
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   528
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   529
    def get_network(self, context, id, fields=None):
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   530
        with context.session.begin(subtransactions=True):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   531
            net = super(EVSNeutronPluginV2, self).get_network(context,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   532
                                                              id, None)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   533
            # call EVS controller to get provider network information
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   534
            evs = self._evs_controller_getEVS(net['id'])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   535
            if evs:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   536
                self._extend_network_dict(net, evs)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   537
        return self._fields(net, fields)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   538
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   539
    def get_networks(self, context, filters=None, fields=None,
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   540
                     sorts=None, limit=None, marker=None, page_reverse=False):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   541
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   542
        with context.session.begin(subtransactions=True):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   543
            nets = super(EVSNeutronPluginV2, self).\
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   544
                get_networks(context, filters, None, sorts, limit, marker,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   545
                             page_reverse)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   546
            for net in nets:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   547
                evs = self._evs_controller_getEVS(net['id'])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   548
                if evs:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   549
                    self._extend_network_dict(net, evs)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   550
        return [self._fields(net, fields) for net in nets]
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   551
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   552
    @lockutils.synchronized('evs-plugin', 'neutron-')
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   553
    def _evs_controller_deleteEVS(self, tenantname, evsuuid):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   554
        LOG.debug(_("Removing EVS with id: %s for tenant: %s") %
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   555
                  (evsuuid, tenantname))
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   556
        try:
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   557
            self.rad_connection.\
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   558
                get_object(evsbind.EVSController()).\
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   559
                deleteEVS(evsuuid, tenantname)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   560
        except radcli.ObjectError as oe:
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   561
            # '41' corresponds to EVS' EVS_ENOENT_EVS error code
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   562
            if oe.get_payload().err == 41:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   563
                # EVS doesn't have that EVS, return success to delete
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   564
                # the EVS from Neutron DB.
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   565
                LOG.debug(_("EVS could not be found in EVS backend."))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   566
                return
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   567
            raise EVSControllerError(oe.get_payload().errmsg)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   568
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   569
    def delete_network(self, context, id):
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   570
        # Check if it is an external network and whether addresses in that
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   571
        # network are being used for floating ips
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   572
        net = self.get_network(context, id)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   573
        if net[external_net.EXTERNAL]:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   574
            filters = dict(network_id=[id])
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   575
            portlist = self.get_ports(context, filters)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   576
            ports_with_deviceid = [port for port in portlist
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   577
                                   if port['device_id'] != '']
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   578
            if ports_with_deviceid:
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   579
                raise exceptions.NetworkInUse(net_id=id)
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   580
        filters = dict(network_id=[id])
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   581
        subnets = self.get_subnets(context, filters=filters)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   582
        dhcp_subnets = [s for s in subnets if s['enable_dhcp']]
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   583
        for subnet in dhcp_subnets:
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   584
            self._release_subnet_dhcp_port(context, subnet, True)
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   585
        with context.session.begin(subtransactions=True):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   586
            super(EVSNeutronPluginV2, self).delete_network(context, id)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   587
            self._evs_controller_deleteEVS(net['tenant_id'], id)
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   588
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   589
        # notify dhcp agent of network deletion
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   590
        self.dhcp_agent_notifier.notify(context, {'network': {'id': id}},
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   591
                                        'network.delete.end')
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   592
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   593
    @lockutils.synchronized('evs-plugin', 'neutron-')
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   594
    def _evs_controller_addVPort(self, tenantname, evsname, vportname,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   595
                                 propstr):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   596
        LOG.debug(_("Adding VPort: %s with properties: %s for tenant: %s "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   597
                    "and for evs: %s") %
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   598
                  (vportname, propstr, tenantname, evsname))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   599
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   600
        try:
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   601
            pat = radcli.ADRGlobPattern({'name': evsname,
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   602
                                         'tenant': tenantname})
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   603
            evs = self.rad_connection.get_object(evsbind.EVS(), pat)
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   604
            vport = evs.addVPort(propstr, vportname)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   605
        except radcli.ObjectError as oe:
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   606
            raise EVSControllerError(oe.get_payload().errmsg)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   607
        return vport
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   608
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   609
    def create_port(self, context, port):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   610
        """Creates a port(VPort) for a given network(EVS).
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   611
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   612
         A VPort represents the point of attachment between the VNIC and an
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   613
         EVS. It encapsulates various network configuration parameters such as
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   614
             -- SLAs (maxbw, cos, and priority)
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   615
             -- IP address and
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   616
             -- MAC address, et al
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   617
         This configuration is inherited by the VNIC when it connects to the
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   618
         VPort.
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   619
        """
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   620
        if port['port']['admin_state_up'] is False:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   621
            raise EVSOpNotSupported(_("setting admin_state_up=False for a "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   622
                                      "port not supported"))
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   623
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   624
        with context.session.begin(subtransactions=True):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   625
            # for external gateway ports and floating ips, tenant_id
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   626
            # is not set, but EVS does not like it.
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   627
            tenant_id = self._get_tenant_id_for_create(context, port['port'])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   628
            if not tenant_id:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   629
                network = self.get_network(context, port['port']['network_id'])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   630
                port['port']['tenant_id'] = network['tenant_id']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   631
            # create the port in the DB
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   632
            db_port = super(EVSNeutronPluginV2, self).create_port(context,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   633
                                                                  port)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   634
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   635
            tenantname = db_port['tenant_id']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   636
            vportname = db_port['name']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   637
            if not vportname:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   638
                vportname = None
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   639
            evs_id = db_port['network_id']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   640
            proplist = ['macaddr=%s' % db_port['mac_address']]
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   641
            proplist.append('ipaddr=%s' %
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   642
                            db_port['fixed_ips'][0].get('ip_address'))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   643
            proplist.append('uuid=%s' % db_port['id'])
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   644
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   645
            self._evs_controller_addVPort(tenantname, evs_id, vportname,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   646
                                          ",".join(proplist))
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   647
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   648
        # notify dhcp agent of port creation
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   649
        self.dhcp_agent_notifier.notify(context, {'port': db_port},
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   650
                                        'port.create.end')
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   651
        return db_port
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   652
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   653
    def update_port(self, context, id, port):
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   654
        # EVS does not allow updating certain attributes, so check for it
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   655
        state = port['port'].get('admin_state_up')
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   656
        if state and state is False:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   657
            raise EVSOpNotSupported(_("updating port's admin_state_up to "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   658
                                      "False is not supported"))
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   659
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   660
        # Get the original port and fail if any attempt is being made
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   661
        # to change fixed_ips of the port since EVS doesn't support it
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   662
        original_port = super(EVSNeutronPluginV2, self).get_port(context, id)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   663
        original_ips = original_port['fixed_ips']
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   664
        update_ips = port['port'].get('fixed_ips')
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   665
        if (update_ips and
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   666
            (len(update_ips) != 1 or
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   667
             update_ips[0]['subnet_id'] != original_ips[0]['subnet_id'] or
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   668
             update_ips[0]['ip_address'] != original_ips[0]['ip_address'])):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   669
            raise EVSOpNotSupported(_("updating port's fixed_ips "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   670
                                      "is not supported"))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   671
        LOG.debug(_("Updating port %s with %s") % (id, port))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   672
        db_port = super(EVSNeutronPluginV2, self).update_port(context,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   673
                                                              id, port)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   674
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   675
        # notify dhcp agent of port update
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   676
        self.dhcp_agent_notifier.notify(context, {'port': db_port},
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   677
                                        'port.update.end')
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   678
        return db_port
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   679
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   680
    def get_port(self, context, id, fields=None):
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   681
        LOG.debug(_("Getting port: %s"), id)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   682
        port = super(EVSNeutronPluginV2, self).get_port(context, id, None)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   683
        return self._fields(port, fields)
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   684
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   685
    def get_ports(self, context, filters=None, fields=None,
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   686
                  sorts=None, limit=None, marker=None, page_reverse=False):
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   687
        ports = super(EVSNeutronPluginV2, self).\
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   688
            get_ports(context, filters, None, sorts, limit, marker,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   689
                      page_reverse)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   690
        return [self._fields(port, fields) for port in ports]
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   691
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   692
    def notify_l3agent(self, context, port):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   693
        """ If an L3 agent is using this port, then we need to send
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   694
        a notification to the L3 agent so that it can remove the EVS VPort
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   695
        associated with the Neutron Port. In that case, the EVS Plugin will
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   696
        only remove the Neutron port from the DB, so return False.
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   697
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   698
        If the port is not used by the L3 agent, then the EVS plugin
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   699
        will remove both the Neutron port and EVS VPort, so return True.
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   700
        """
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   701
1959
ba86b21a837b 19026240 Extract tenantid using the framework provided function
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 1944
diff changeset
   702
        device_owner = port['device_owner']
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   703
        if device_owner not in [constants.DEVICE_OWNER_ROUTER_INTF,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   704
                                constants.DEVICE_OWNER_ROUTER_GW,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   705
                                constants.DEVICE_OWNER_FLOATINGIP]:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   706
            return True
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   707
        router_id = port['device_id']
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   708
        port_update = {
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   709
            'port': {
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   710
                'device_id': '',
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   711
                'device_owner': ''
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   712
            }
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   713
        }
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   714
        self.update_port(context, port['id'], port_update)
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   715
        if device_owner in [constants.DEVICE_OWNER_ROUTER_INTF,
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   716
                            constants.DEVICE_OWNER_ROUTER_GW]:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   717
            self.l3_agent_notifier.routers_updated(context, [router_id])
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   718
            return False
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   719
        return True
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   720
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   721
    @lockutils.synchronized('evs-plugin', 'neutron-')
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   722
    def _evs_controller_removeVPort(self, tenantname, evsname, vportuuid):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   723
        LOG.debug(_("Removing VPort with id: %s for tenant: %s for evs: %s") %
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   724
                  (vportuuid, tenantname, evsname))
3524
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   725
        pat = radcli.ADRGlobPattern({'name': evsname,
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   726
                                     'tenant': tenantname})
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   727
        try:
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   728
            evs = self.rad_connection.get_object(evsbind.EVS(), pat)
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   729
            evs.removeVPort(vportuuid)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   730
        except radcli.ObjectError as oe:
3524
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   731
            # '7' corresponds to EVS' EVS_EBUSY_VPORT error code
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   732
            if oe.get_payload().err == 7:
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   733
                # It is possible that the VM is destroyed, but EVS is unaware
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   734
                # of it. So, try to reset the vport. If it succeeds, then call
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   735
                # removeVPort() again.
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   736
                LOG.debug(_("EVS VPort is busy. We will need to reset "
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   737
                            "and then remove"))
3524
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   738
                try:
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   739
                    evs.resetVPort(vportuuid)
3524
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   740
                    evs.removeVPort(vportuuid)
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   741
                except:
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   742
                    # we failed one of the above operations, just return
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   743
                    # the original exception.
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   744
                    pass
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   745
                else:
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   746
                    # the reset and remove succeeded, just return.
ad6a9e0880b9 20089330 Horizon reports "Error: Unable to contact Neutron" on large data set
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents: 2065
diff changeset
   747
                    return
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   748
            # '43' corresponds to EVS' EVS_ENOENT_VPORT error code
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   749
            elif oe.get_payload().err == 43:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   750
                # EVS doesn't have that VPort, return success to delete
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   751
                # the VPort from Neutron DB.
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   752
                LOG.debug(_("VPort could not be found in EVS."))
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   753
                return
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   754
            raise EVSControllerError(oe.get_payload().errmsg)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   755
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   756
    def delete_port(self, context, id, l3_port_check=True):
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   757
        if l3_port_check:
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   758
            self.prevent_l3_port_deletion(context, id)
1944
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   759
        self.disassociate_floatingips(context, id)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   760
        port = self.get_port(context, id)
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   761
        if not port:
56ac2df1785b PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 1832
diff changeset
   762
            return
3998
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   763
        del_vport = l3_port_check or self.notify_l3agent(context, port)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   764
        with context.session.begin(subtransactions=True):
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   765
            super(EVSNeutronPluginV2, self).delete_port(context, id)
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   766
            if del_vport:
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   767
                self._evs_controller_removeVPort(port['tenant_id'],
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   768
                                                 port['network_id'],
5bd484384122 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3524
diff changeset
   769
                                                 port['id'])
1760
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   770
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   771
        # notify dhcp agent of port deletion
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   772
        payload = {
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   773
            'port': {
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   774
                'network_id': port['network_id'],
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   775
                'id': id,
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   776
            }
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   777
        }
353323c7bdc1 PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   778
        self.dhcp_agent_notifier.notify(context, payload, 'port.delete.end')