~ubuntu-branches/ubuntu/vivid/neutron/vivid-updates

« back to all changes in this revision

Viewing changes to neutron/plugins/ml2/drivers/ibm/mechanism_sdnve.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-03-30 11:17:19 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20150330111719-h0gx7233p4jkkgfh
Tags: 1:2015.1~b3-0ubuntu1
* New upstream milestone release:
  - d/control: Align version requirements with upstream.
  - d/control: Add new dependency on oslo-log.
  - d/p/*: Rebase.
  - d/control,d/neutron-plugin-hyperv*: Dropped, decomposed into
    separate project upstream.
  - d/control,d/neutron-plugin-openflow*: Dropped, decomposed into
    separate project upstream.
  - d/neutron-common.install: Add neutron-rootwrap-daemon and 
    neutron-keepalived-state-change binaries.
  - d/rules: Ignore neutron-hyperv-agent when installing; only for Windows.
  - d/neutron-plugin-cisco.install: Drop neutron-cisco-cfg-agent as
    decomposed into separate project upstream.
  - d/neutron-plugin-vmware.install: Drop neutron-check-nsx-config and
    neutron-nsx-manage as decomposed into separate project upstream.
  - d/control: Add dependency on python-neutron-fwaas to neutron-l3-agent.
* d/pydist-overrides: Add overrides for oslo packages.
* d/control: Fixup type in package description (LP: #1263539).
* d/p/fixup-driver-test-execution.patch: Cherry pick fix from upstream VCS
  to support unit test exection in out-of-tree vendor drivers.
* d/neutron-common.postinst: Allow general access to /etc/neutron but limit
  access to root/neutron to /etc/neutron/neutron.conf to support execution
  of unit tests in decomposed vendor drivers.
* d/control: Add dependency on python-neutron-fwaas to neutron-l3-agent
  package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2015 IBM Corp.
 
2
#
 
3
# All Rights Reserved.
 
4
#
 
5
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
6
#    not use this file except in compliance with the License. You may obtain
 
7
#    a copy of the License at
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
#    Unless required by applicable law or agreed to in writing, software
 
12
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
13
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
14
#    License for the specific language governing permissions and limitations
 
15
#    under the License.
 
16
 
 
17
from networking_ibm.sdnve.ml2 import sdnve_driver
 
18
from oslo_log import log as logging
 
19
 
 
20
from neutron.common import constants as n_const
 
21
from neutron.extensions import portbindings
 
22
from neutron.plugins.ml2 import driver_api as api
 
23
 
 
24
LOG = logging.getLogger(__name__)
 
25
 
 
26
 
 
27
class SdnveMechanismDriver(api.MechanismDriver):
 
28
    """Ml2 Mechanism driver for IBM SDNVE Controller"""
 
29
    def initialize(self):
 
30
        self.vif_type = portbindings.VIF_TYPE_BRIDGE
 
31
        self.vif_details = {portbindings.CAP_PORT_FILTER: False}
 
32
        self.restrict_update_subnet = ['enable_dhcp',
 
33
                                       'gateway_ip',
 
34
                                       'allocation-pool']
 
35
        self.restrict_update_network = ['router:external']
 
36
        self.sdnve_drv = sdnve_driver.SdnveDriver()
 
37
 
 
38
    # NETWORK
 
39
    def create_network_precommit(self, context):
 
40
        self.sdnve_drv._pre_create_network(context)
 
41
 
 
42
    def create_network_postcommit(self, context):
 
43
        self.sdnve_drv._create_network(context)
 
44
 
 
45
    def update_network_precommit(self, context):
 
46
        self.sdnve_drv._pre_update_network(context)
 
47
 
 
48
    def update_network_postcommit(self, context):
 
49
        self.sdnve_drv._update_network(context)
 
50
 
 
51
    def delete_network_postcommit(self, context):
 
52
        self.sdnve_drv._delete_network(context)
 
53
 
 
54
    # SUBNET
 
55
    def create_subnet_precommit(self, context):
 
56
        self.sdnve_drv._pre_create_subnet(context)
 
57
 
 
58
    def create_subnet_postcommit(self, context):
 
59
        self.sdnve_drv._create_subnet(context)
 
60
 
 
61
    def update_subnet_postcommit(self, context):
 
62
        self.sdnve_drv._update_subnet(context)
 
63
 
 
64
    def update_subnet_precommit(self, context):
 
65
        self.sdnve_drv._pre_update_subnet(context)
 
66
 
 
67
    def delete_subnet_postcommit(self, context):
 
68
        self.sdnve_drv._delete_subnet(context)
 
69
 
 
70
    # PORT
 
71
    def create_port_postcommit(self, context):
 
72
        self.sdnve_drv._create_port(context)
 
73
 
 
74
    def create_port_precommit(self, context):
 
75
        self.sdnve_drv._pre_create_port(context)
 
76
 
 
77
    def delete_port_precommit(self, context):
 
78
        self.sdnve_drv._pre_delete_port(context)
 
79
 
 
80
    def update_port_postcommit(self, context):
 
81
        self.sdnve_drv._update_port(context)
 
82
 
 
83
    def delete_port_postcommit(self, context):
 
84
        self.sdnve_drv._delete_port(context)
 
85
 
 
86
    def bind_port(self, context):
 
87
        LOG.debug("Attempting to bind port %(port)s on "
 
88
                  "network %(network)s",
 
89
                  {'port': context.current['id'],
 
90
                   'network': context.network.current['id']})
 
91
        for segment in context.network.network_segments:
 
92
            if self.sdnve_drv._check_segment(segment):
 
93
                context.set_binding(segment[api.ID],
 
94
                                    self.vif_type,
 
95
                                    self.vif_details,
 
96
                                    status=n_const.PORT_STATUS_ACTIVE)
 
97
                LOG.debug("Bound using segment: %s", segment)
 
98
                return
 
99
            else:
 
100
                LOG.debug("Refusing to bind port for segment ID %(id)s, "
 
101
                          "segment %(seg)s, phys net %(physnet)s, and "
 
102
                          "network type %(nettype)s",
 
103
                          {'id': segment[api.ID],
 
104
                           'seg': segment[api.SEGMENTATION_ID],
 
105
                           'physnet': segment[api.PHYSICAL_NETWORK],
 
106
                           'nettype': segment[api.NETWORK_TYPE]})