Browse Source

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
tags/kilo-eol
rmadapur 3 years ago
parent
commit
836a9d0148

+ 5
- 3
networking_brocade/vdx/ml2driver/mechanism_brocade.py View File

@@ -1,4 +1,4 @@
1
-# Copyright 2014 Brocade Communications System, Inc.
1
+# Copyright 2016 Brocade Communications System, Inc.
2 2
 # All rights reserved.
3 3
 #
4 4
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -19,13 +19,14 @@
19 19
 from neutron.i18n import _LE
20 20
 from neutron.i18n import _LI
21 21
 from neutron.plugins.ml2 import driver_api
22
-from neutron.plugins.ml2.drivers.brocade.db import models as brocade_db
23 22
 from oslo_config import cfg
24 23
 from oslo_log import log as logging
25 24
 from oslo_utils import importutils
26 25
 
26
+from networking_brocade.vdx.ml2driver.nos.db import models as brocade_db
27
+
27 28
 LOG = logging.getLogger(__name__)
28
-MECHANISM_VERSION = 0.9
29
+MECHANISM_VERSION = 1.0
29 30
 NOS_DRIVER = 'networking_brocade.vdx.ml2driver.nos.nosdriver.NOSdriver'
30 31
 
31 32
 ML2_BROCADE = [cfg.StrOpt('address', default='',
@@ -96,6 +97,7 @@ class BrocadeMechanism(driver_api.MechanismDriver):
96 97
             LOG.debug("Virtual Fabric: not enabled")
97 98
 
98 99
         self.set_features_enabled(osversion, virtual_fabric_enabled)
100
+        self._driver.close_session()
99 101
 
100 102
     def set_features_enabled(self, nos_version, virtual_fabric_enabled):
101 103
         self._virtual_fabric_enabled = virtual_fabric_enabled

+ 0
- 0
networking_brocade/vdx/ml2driver/nos/db/__init__.py View File


+ 135
- 0
networking_brocade/vdx/ml2driver/nos/db/models.py View File

@@ -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."""
18
+import sqlalchemy as sa
19
+
20
+from neutron.db import model_base
21
+from neutron.db import models_v2
22
+
23
+
24
+class 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
+
33
+class 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
+
45
+def 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
+
61
+def 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
+
71
+def 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
+
78
+def 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
+
85
+def 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
+
104
+def 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
+
111
+def 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
+
119
+def 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
+
129
+def 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})

Loading…
Cancel
Save