summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrmadapur <rmadapur@brocade.com>2016-03-07 02:35:39 -0800
committerrmadapur <rmadapur@brocade.com>2016-03-09 00:50:31 -0800
commit836a9d014893f819b5fa65c1f88da1d052cba4cd (patch)
tree7aacc59f1f28c97f94a0598dda7161ecbb99a312
parentec53ec05a4d69929a9a399dbf867698aff773e8d (diff)
Fixes netconf timeout issue
Netconf sessions were timing out on VDX devices,nos_driver in the init phase closed after the required usage Also added the db model for VDX devices which had got removed during vendor decomposition. No DB Migration scripts are required as these are the initial models. Closes-Bug:#1553868 Change-Id: Ibff5bf70b426b6f0ba471f26ca7bb8310370247d
Notes
Notes (review): Code-Review-1: Angela Smith <aallen@brocade.com> Code-Review+2: Ritesh Madapurath <rmadapur@brocade.com> Workflow+1: Ritesh Madapurath <rmadapur@brocade.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 11 Mar 2016 03:30:23 +0000 Reviewed-on: https://review.openstack.org/289253 Project: openstack/networking-brocade Branch: refs/heads/master
-rw-r--r--networking_brocade/vdx/ml2driver/mechanism_brocade.py8
-rw-r--r--networking_brocade/vdx/ml2driver/nos/db/__init__.py0
-rw-r--r--networking_brocade/vdx/ml2driver/nos/db/models.py135
3 files changed, 140 insertions, 3 deletions
diff --git a/networking_brocade/vdx/ml2driver/mechanism_brocade.py b/networking_brocade/vdx/ml2driver/mechanism_brocade.py
index 6a93d60..19daa5f 100644
--- a/networking_brocade/vdx/ml2driver/mechanism_brocade.py
+++ b/networking_brocade/vdx/ml2driver/mechanism_brocade.py
@@ -1,4 +1,4 @@
1# Copyright 2014 Brocade Communications System, Inc. 1# Copyright 2016 Brocade Communications System, Inc.
2# All rights reserved. 2# All rights reserved.
3# 3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may 4# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -19,13 +19,14 @@
19from neutron.i18n import _LE 19from neutron.i18n import _LE
20from neutron.i18n import _LI 20from neutron.i18n import _LI
21from neutron.plugins.ml2 import driver_api 21from neutron.plugins.ml2 import driver_api
22from neutron.plugins.ml2.drivers.brocade.db import models as brocade_db
23from oslo_config import cfg 22from oslo_config import cfg
24from oslo_log import log as logging 23from oslo_log import log as logging
25from oslo_utils import importutils 24from oslo_utils import importutils
26 25
26from networking_brocade.vdx.ml2driver.nos.db import models as brocade_db
27
27LOG = logging.getLogger(__name__) 28LOG = logging.getLogger(__name__)
28MECHANISM_VERSION = 0.9 29MECHANISM_VERSION = 1.0
29NOS_DRIVER = 'networking_brocade.vdx.ml2driver.nos.nosdriver.NOSdriver' 30NOS_DRIVER = 'networking_brocade.vdx.ml2driver.nos.nosdriver.NOSdriver'
30 31
31ML2_BROCADE = [cfg.StrOpt('address', default='', 32ML2_BROCADE = [cfg.StrOpt('address', default='',
@@ -96,6 +97,7 @@ class BrocadeMechanism(driver_api.MechanismDriver):
96 LOG.debug("Virtual Fabric: not enabled") 97 LOG.debug("Virtual Fabric: not enabled")
97 98
98 self.set_features_enabled(osversion, virtual_fabric_enabled) 99 self.set_features_enabled(osversion, virtual_fabric_enabled)
100 self._driver.close_session()
99 101
100 def set_features_enabled(self, nos_version, virtual_fabric_enabled): 102 def set_features_enabled(self, nos_version, virtual_fabric_enabled):
101 self._virtual_fabric_enabled = virtual_fabric_enabled 103 self._virtual_fabric_enabled = virtual_fabric_enabled
diff --git a/networking_brocade/vdx/ml2driver/nos/db/__init__.py b/networking_brocade/vdx/ml2driver/nos/db/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/networking_brocade/vdx/ml2driver/nos/db/__init__.py
diff --git a/networking_brocade/vdx/ml2driver/nos/db/models.py b/networking_brocade/vdx/ml2driver/nos/db/models.py
new file mode 100644
index 0000000..3e46c55
--- /dev/null
+++ b/networking_brocade/vdx/ml2driver/nos/db/models.py
@@ -0,0 +1,135 @@
1# Copyright 2016 Brocade Communications System, Inc.
2# All rights reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16
17"""Brocade specific database schema/model."""
18import sqlalchemy as sa
19
20from neutron.db import model_base
21from neutron.db import models_v2
22
23
24class ML2_BrocadeNetwork(model_base.BASEV2, models_v2.HasId,
25 models_v2.HasTenant):
26 """Schema for brocade network."""
27
28 vlan = sa.Column(sa.String(10))
29 segment_id = sa.Column(sa.String(36))
30 network_type = sa.Column(sa.String(10))
31
32
33class ML2_BrocadePort(model_base.BASEV2, models_v2.HasId,
34 models_v2.HasTenant):
35 """Schema for brocade port."""
36
37 network_id = sa.Column(sa.String(36),
38 sa.ForeignKey("ml2_brocadenetworks.id"),
39 nullable=False)
40 admin_state_up = sa.Column(sa.Boolean, nullable=False)
41 physical_interface = sa.Column(sa.String(36))
42 vlan_id = sa.Column(sa.String(36))
43
44
45def create_network(context, net_id, vlan, segment_id, network_type, tenant_id):
46 """Create a brocade specific network/port-profiles."""
47
48 # only network_type of vlan is supported
49 session = context.session
50 with session.begin(subtransactions=True):
51 net = get_network(context, net_id, None)
52 if not net:
53 net = ML2_BrocadeNetwork(id=net_id, vlan=vlan,
54 segment_id=segment_id,
55 network_type='vlan',
56 tenant_id=tenant_id)
57 session.add(net)
58 return net
59
60
61def delete_network(context, net_id):
62 """Delete a brocade specific network/port-profiles."""
63
64 session = context.session
65 with session.begin(subtransactions=True):
66 net = get_network(context, net_id, None)
67 if net:
68 session.delete(net)
69
70
71def get_network(context, net_id, fields=None):
72 """Get brocade specific network, with vlan extension."""
73
74 session = context.session
75 return session.query(ML2_BrocadeNetwork).filter_by(id=net_id).first()
76
77
78def get_networks(context, filters=None, fields=None):
79 """Get all brocade specific networks."""
80
81 session = context.session
82 return session.query(ML2_BrocadeNetwork).all()
83
84
85def create_port(context, port_id, network_id, physical_interface,
86 vlan_id, tenant_id, admin_state_up):
87 """Create a brocade specific port, has policy like vlan."""
88
89 session = context.session
90 with session.begin(subtransactions=True):
91 port = get_port(context, port_id)
92 if not port:
93 port = ML2_BrocadePort(id=port_id,
94 network_id=network_id,
95 physical_interface=physical_interface,
96 vlan_id=vlan_id,
97 admin_state_up=admin_state_up,
98 tenant_id=tenant_id)
99 session.add(port)
100
101 return port
102
103
104def get_port(context, port_id):
105 """get a brocade specific port."""
106
107 session = context.session
108 return session.query(ML2_BrocadePort).filter_by(id=port_id).first()
109
110
111def get_ports(context, network_id=None):
112 """get a brocade specific port."""
113
114 session = context.session
115 return session.query(ML2_BrocadePort).filter_by(
116 network_id=network_id).all()
117
118
119def delete_port(context, port_id):
120 """delete brocade specific port."""
121
122 session = context.session
123 with session.begin(subtransactions=True):
124 port = get_port(context, port_id)
125 if port:
126 session.delete(port)
127
128
129def update_port_state(context, port_id, admin_state_up):
130 """Update port attributes."""
131
132 session = context.session
133 with session.begin(subtransactions=True):
134 session.query(ML2_BrocadePort).filter_by(
135 id=port_id).update({'admin_state_up': admin_state_up})