summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYushiro FURUKAWA <y.furukawa_2@jp.fujitsu.com>2018-07-29 20:40:44 +0900
committerYushiro FURUKAWA <y.furukawa_2@jp.fujitsu.com>2018-07-29 20:44:13 +0900
commit25c19efb5dc97a3922db8c1436a3dd98506aa3f3 (patch)
treeef01d260581cdf7e91c6ac62a4dd0178dd4a8ea2
parent0c61ebef0399392459cbe8b2d1eaf5316b9c8c8f (diff)
Fix updating Ucast_Macs_Remote entry in removing portHEAD8.0.07.0.0stable/steinstable/rockymaster
In case of VM/router/DHCP ports, Ucast_Macs_Remote entory should be removed on deleting these ports. In addition, this commit includes some refactor. Change-Id: Ief913c7605657e03f9d297cf5839e73d3c0fff42
Notes
Notes (review): Code-Review+2: Yushiro FURUKAWA <y.furukawa_2@jp.fujitsu.com> Workflow+1: Yushiro FURUKAWA <y.furukawa_2@jp.fujitsu.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 31 Jul 2018 12:14:00 +0000 Reviewed-on: https://review.openstack.org/586871 Project: openstack/networking-fujitsu Branch: refs/heads/master
-rw-r--r--networking_fujitsu/ml2/cfab/mech_cfab.py3
-rw-r--r--networking_fujitsu/ml2/common/ovsdb/ovsdb_writer.py18
-rw-r--r--networking_fujitsu/ml2/common/tunnel_caller.py3
-rw-r--r--networking_fujitsu/ml2/common/utils.py17
-rw-r--r--networking_fujitsu/ml2/fossw/client.py50
-rw-r--r--networking_fujitsu/ml2/fossw/fossw_vlandriver.py34
-rw-r--r--networking_fujitsu/ml2/fossw/fossw_vxlandriver.py24
-rw-r--r--networking_fujitsu/ml2/fossw/mech_fossw.py90
-rw-r--r--networking_fujitsu/tests/unit/ml2/fossw/test_mech_fossw.py32
9 files changed, 118 insertions, 153 deletions
diff --git a/networking_fujitsu/ml2/cfab/mech_cfab.py b/networking_fujitsu/ml2/cfab/mech_cfab.py
index 1769025..24f8640 100644
--- a/networking_fujitsu/ml2/cfab/mech_cfab.py
+++ b/networking_fujitsu/ml2/cfab/mech_cfab.py
@@ -1,4 +1,4 @@
1# Copyright 2015-2017 FUJITSU LIMITED 1# Copyright 2015-2018 FUJITSU LIMITED
2# 2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may 3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain 4# not use this file except in compliance with the License. You may obtain
@@ -127,6 +127,7 @@ class CFABMechanismDriver(api.MechanismDriver):
127 Case2: Otherwise 127 Case2: Otherwise
128 Associate the assigned MAC address to the portprofile. 128 Associate the assigned MAC address to the portprofile.
129 """ 129 """
130
130 port = mech_context.current 131 port = mech_context.current
131 network = mech_context.network 132 network = mech_context.network
132 if utils.is_baremetal(port): 133 if utils.is_baremetal(port):
diff --git a/networking_fujitsu/ml2/common/ovsdb/ovsdb_writer.py b/networking_fujitsu/ml2/common/ovsdb/ovsdb_writer.py
index 7a9f3d4..aab6300 100644
--- a/networking_fujitsu/ml2/common/ovsdb/ovsdb_writer.py
+++ b/networking_fujitsu/ml2/common/ovsdb/ovsdb_writer.py
@@ -1,4 +1,4 @@
1# Copyright 2017 FUJITSU LIMITED 1# Copyright 2017-2018 FUJITSU LIMITED
2# 2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may 3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain 4# not use this file except in compliance with the License. You may obtain
@@ -28,6 +28,7 @@ LOG = logging.getLogger(__name__)
28 28
29class OVSDBWriter(base_connection.BaseConnection): 29class OVSDBWriter(base_connection.BaseConnection):
30 """Performs transactions to OVSDB server tables.""" 30 """Performs transactions to OVSDB server tables."""
31
31 def __init__(self, ovsdb_ip, ovsdb_port): 32 def __init__(self, ovsdb_ip, ovsdb_port):
32 super(OVSDBWriter, self).__init__(ovsdb_ip, ovsdb_port) 33 super(OVSDBWriter, self).__init__(ovsdb_ip, ovsdb_port)
33 34
@@ -160,7 +161,6 @@ class OVSDBWriter(base_connection.BaseConnection):
160 :param logical_switch_name: Neutron network uuid, but delete all '-' 161 :param logical_switch_name: Neutron network uuid, but delete all '-'
161 to make sure the length is within 32. 162 to make sure the length is within 32.
162 :type logical_switch_name: string 163 :type logical_switch_name: string
163
164 :returns: None 164 :returns: None
165 """ 165 """
166 166
@@ -182,7 +182,6 @@ class OVSDBWriter(base_connection.BaseConnection):
182 :param logical_switch_name: Neutron network uuid, but delete all '-' 182 :param logical_switch_name: Neutron network uuid, but delete all '-'
183 to make sure the length is within 32. 183 to make sure the length is within 32.
184 :type logical_switch_name: string 184 :type logical_switch_name: string
185
186 :returns: UUID of ROW in Logical_Switch table. 185 :returns: UUID of ROW in Logical_Switch table.
187 :rtype: uuid 186 :rtype: uuid
188 """ 187 """
@@ -212,7 +211,6 @@ class OVSDBWriter(base_connection.BaseConnection):
212 211
213 :param logical_switch_uuid: UUID of ROW in Logical_Switch table. 212 :param logical_switch_uuid: UUID of ROW in Logical_Switch table.
214 :type logical_switch_uuid: uuid 213 :type logical_switch_uuid: uuid
215
216 :returns: None 214 :returns: None
217 """ 215 """
218 216
@@ -240,7 +238,6 @@ class OVSDBWriter(base_connection.BaseConnection):
240 :param logical_switch_uuid: UUID of logical_switch in the binding-pair 238 :param logical_switch_uuid: UUID of logical_switch in the binding-pair
241 mapping. 239 mapping.
242 :type logical_switch_uuid: uuid 240 :type logical_switch_uuid: uuid
243
244 :returns: vlanid in the binding-pair mapping. 241 :returns: vlanid in the binding-pair mapping.
245 :rtype: integer 242 :rtype: integer
246 """ 243 """
@@ -290,7 +287,6 @@ class OVSDBWriter(base_connection.BaseConnection):
290 :param logical_switch_uuid: UUID of logical_switch in the binding-pair 287 :param logical_switch_uuid: UUID of logical_switch in the binding-pair
291 mapping. 288 mapping.
292 :type logical_switch_uuid: uuid 289 :type logical_switch_uuid: uuid
293
294 :returns: None 290 :returns: None
295 """ 291 """
296 292
@@ -315,7 +311,6 @@ class OVSDBWriter(base_connection.BaseConnection):
315 311
316 :param port_mac: MAC address of physical port. 312 :param port_mac: MAC address of physical port.
317 :type port_mac: string 313 :type port_mac: string
318
319 :returns: list of ROWs information of the given port_mac in 314 :returns: list of ROWs information of the given port_mac in
320 Ucast_Macs_Local table. 315 Ucast_Macs_Local table.
321 :rtype: list 316 :rtype: list
@@ -345,7 +340,6 @@ class OVSDBWriter(base_connection.BaseConnection):
345 340
346 :param port_mac: MAC address of physical port. 341 :param port_mac: MAC address of physical port.
347 :type port_mac: string 342 :type port_mac: string
348
349 :returns: None 343 :returns: None
350 """ 344 """
351 345
@@ -365,7 +359,6 @@ class OVSDBWriter(base_connection.BaseConnection):
365 359
366 :param dst_ip: IP address of physical locator. 360 :param dst_ip: IP address of physical locator.
367 :type dst_ip: string 361 :type dst_ip: string
368
369 :returns: uuid of ROW of the given dst_ip in Physical_Locator table. 362 :returns: uuid of ROW of the given dst_ip in Physical_Locator table.
370 :rtype: uuid 363 :rtype: uuid
371 """ 364 """
@@ -399,7 +392,6 @@ class OVSDBWriter(base_connection.BaseConnection):
399 :type locator_uuid: uuid 392 :type locator_uuid: uuid
400 :param MAC_value: MAC address of NIC of baremetal server. 393 :param MAC_value: MAC address of NIC of baremetal server.
401 :type MAC_value: string 394 :type MAC_value: string
402
403 :returns: None 395 :returns: None
404 """ 396 """
405 397
@@ -429,7 +421,6 @@ class OVSDBWriter(base_connection.BaseConnection):
429 :type locator_ip: string 421 :type locator_ip: string
430 :param MAC_value: MAC address of NIC of baremetal server. 422 :param MAC_value: MAC address of NIC of baremetal server.
431 :type MAC_value: string 423 :type MAC_value: string
432
433 :returns: None 424 :returns: None
434 """ 425 """
435 426
@@ -457,7 +448,6 @@ class OVSDBWriter(base_connection.BaseConnection):
457 448
458 :param port_mac: MAC address of VM port. 449 :param port_mac: MAC address of VM port.
459 :type port_mac: string 450 :type port_mac: string
460
461 :returns: list of ROWs information of the given port_mac in 451 :returns: list of ROWs information of the given port_mac in
462 Ucast_Macs_Remote table. 452 Ucast_Macs_Remote table.
463 :rtype: list 453 :rtype: list
@@ -487,7 +477,6 @@ class OVSDBWriter(base_connection.BaseConnection):
487 477
488 :param port_mac: MAC address of VM port. 478 :param port_mac: MAC address of VM port.
489 :type port_mac: string 479 :type port_mac: string
490
491 :returns: None 480 :returns: None
492 """ 481 """
493 482
@@ -521,7 +510,6 @@ class OVSDBWriter(base_connection.BaseConnection):
521 :param locator_uuid: uuid of physical locator (remote VTEP) where 510 :param locator_uuid: uuid of physical locator (remote VTEP) where
522 the port is binding to. 511 the port is binding to.
523 :type locator_uuid: uuid 512 :type locator_uuid: uuid
524
525 :returns: None 513 :returns: None
526 """ 514 """
527 515
@@ -563,7 +551,6 @@ class OVSDBWriter(base_connection.BaseConnection):
563 :param locator_IP: IP address of physical locator (remote VTEP) where 551 :param locator_IP: IP address of physical locator (remote VTEP) where
564 the port is binding to. 552 the port is binding to.
565 :type locator_uuid: string 553 :type locator_uuid: string
566
567 :returns: None 554 :returns: None
568 """ 555 """
569 556
@@ -596,7 +583,6 @@ class OVSDBWriter(base_connection.BaseConnection):
596 format: <slot/port> 583 format: <slot/port>
597 example: 0/2 584 example: 0/2
598 :type port_name: string 585 :type port_name: string
599
600 :returns: None 586 :returns: None
601 """ 587 """
602 588
diff --git a/networking_fujitsu/ml2/common/tunnel_caller.py b/networking_fujitsu/ml2/common/tunnel_caller.py
index 6fff172..dfb08dd 100644
--- a/networking_fujitsu/ml2/common/tunnel_caller.py
+++ b/networking_fujitsu/ml2/common/tunnel_caller.py
@@ -1,4 +1,4 @@
1# Copyright 2017 FUJITSU LIMITED 1# Copyright 2017-2018 FUJITSU LIMITED
2# 2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may 3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain 4# not use this file except in compliance with the License. You may obtain
@@ -34,7 +34,6 @@ class TunnelCaller(object):
34 :type context: A Neutron context object. 34 :type context: A Neutron context object.
35 :param tunnel_ip: An endpoint IP address of vxlan. 35 :param tunnel_ip: An endpoint IP address of vxlan.
36 :type tunnel_ip: string 36 :type tunnel_ip: string
37
38 :returns: None 37 :returns: None
39 """ 38 """
40 39
diff --git a/networking_fujitsu/ml2/common/utils.py b/networking_fujitsu/ml2/common/utils.py
index 41cbfa4..60a1e83 100644
--- a/networking_fujitsu/ml2/common/utils.py
+++ b/networking_fujitsu/ml2/common/utils.py
@@ -1,4 +1,4 @@
1# Copyright 2015-2017 FUJITSU LIMITED 1# Copyright 2015-2018 FUJITSU LIMITED
2# 2#
3# Licensed under the Apache License, Version 2.0 (the "License"); 3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License. 4# you may not use this file except in compliance with the License.
@@ -32,7 +32,6 @@ def eliminate_val(source, reject):
32 :type source: string 32 :type source: string
33 :param reject: a list of integer to reject. ex. [1, 2] 33 :param reject: a list of integer to reject. ex. [1, 2]
34 :type reject: list of integer 34 :type reject: list of integer
35
36 :returns: a string separated with "," like an example 35 :returns: a string separated with "," like an example
37 :rtype: string 36 :rtype: string
38 """ 37 """
@@ -120,10 +119,10 @@ def get_network_type(network):
120 119
121 :param network: NetworkContext or network dict 120 :param network: NetworkContext or network dict
122 :type network: NetworkContext or dict 121 :type network: NetworkContext or dict
123
124 :returns network_type: 'vlan', 'vxlan', 'local', 'flat' and 'geneve' 122 :returns network_type: 'vlan', 'vxlan', 'local', 'flat' and 'geneve'
125 :rtype: string 123 :rtype: string
126 """ 124 """
125
127 return _get_provider_attribute(network, 'NETWORK_TYPE') 126 return _get_provider_attribute(network, 'NETWORK_TYPE')
128 127
129 128
@@ -132,10 +131,10 @@ def get_segmentation_id(network):
132 131
133 :param network: NetworkContext or network dict 132 :param network: NetworkContext or network dict
134 :type network: NetworkContext or dict 133 :type network: NetworkContext or dict
135
136 :returns segmentation_id: VLANID('vlan') or VNI('vxlan') 134 :returns segmentation_id: VLANID('vlan') or VNI('vxlan')
137 :rtype: integer 135 :rtype: integer
138 """ 136 """
137
139 return _get_provider_attribute(network, 'SEGMENTATION_ID') 138 return _get_provider_attribute(network, 'SEGMENTATION_ID')
140 139
141 140
@@ -144,10 +143,10 @@ def get_physical_network(network):
144 143
145 :param network: NetworkContext or network dict 144 :param network: NetworkContext or network dict
146 :type network: NetworkContext or dict 145 :type network: NetworkContext or dict
147
148 :returns physical_network: physical network name for the network 146 :returns physical_network: physical network name for the network
149 :rtype: string 147 :rtype: string
150 """ 148 """
149
151 return _get_provider_attribute(network, 'PHYSICAL_NETWORK') 150 return _get_provider_attribute(network, 'PHYSICAL_NETWORK')
152 151
153 152
@@ -156,7 +155,6 @@ def get_physical_connectivity(port):
156 155
157 :param port: a dictionary of neutron port 156 :param port: a dictionary of neutron port
158 :type port: dictionary 157 :type port: dictionary
159
160 :returns lli: "local_link_information" as follows 158 :returns lli: "local_link_information" as follows
161 [{"switch_id": "MAC_of_switch", "port_id": "1/1/0/1", 159 [{"switch_id": "MAC_of_switch", "port_id": "1/1/0/1",
162 "switch_info": "switch_name"}] 160 "switch_info": "switch_name"}]
@@ -180,7 +178,6 @@ def has_lli(port):
180 178
181 :param port: a port dictionary 179 :param port: a port dictionary
182 :type port: dictionary 180 :type port: dictionary
183
184 :returns True(a port has 'local_link_information') or False(otherwise) 181 :returns True(a port has 'local_link_information') or False(otherwise)
185 :rtype: boolean 182 :rtype: boolean
186 """ 183 """
@@ -193,7 +190,6 @@ def is_baremetal(port):
193 190
194 :param port: a dictionary of neutron port 191 :param port: a dictionary of neutron port
195 :type port: dictionary 192 :type port: dictionary
196
197 :returns: True(vnic_type is baremetal) or False(otherwise) 193 :returns: True(vnic_type is baremetal) or False(otherwise)
198 :rtype: boolean 194 :rtype: boolean
199 """ 195 """
@@ -207,7 +203,6 @@ def is_lag(local_link_information):
207 203
208 :param local_link_information: physical connectivity information 204 :param local_link_information: physical connectivity information
209 :type local_link_information: list of dict 205 :type local_link_information: list of dict
210
211 :returns: True(mode is LAG) or False(otherwise) 206 :returns: True(mode is LAG) or False(otherwise)
212 :rtype: boolean 207 :rtype: boolean
213 """ 208 """
@@ -216,13 +211,13 @@ def is_lag(local_link_information):
216 211
217 212
218def is_unbound(context): 213def is_unbound(context):
219 """Judge current port object is unbound or not. 214 """Judge current port object is changed into 'unbound' status or not.
220 215
221 :param context: port context 216 :param context: port context
222 :type context: PortContext object 217 :type context: PortContext object
223
224 :returns: True(port is unbound) or False(otherwise) 218 :returns: True(port is unbound) or False(otherwise)
225 :rtype: boolean 219 :rtype: boolean
226 """ 220 """
221
227 return (context.current[pb_def.VIF_TYPE] == pb_def.VIF_TYPE_UNBOUND and 222 return (context.current[pb_def.VIF_TYPE] == pb_def.VIF_TYPE_UNBOUND and
228 context.original[pb_def.VIF_TYPE] == pb_def.VIF_TYPE_OTHER) 223 context.original[pb_def.VIF_TYPE] == pb_def.VIF_TYPE_OTHER)
diff --git a/networking_fujitsu/ml2/fossw/client.py b/networking_fujitsu/ml2/fossw/client.py
index 2e064f7..de262ed 100644
--- a/networking_fujitsu/ml2/fossw/client.py
+++ b/networking_fujitsu/ml2/fossw/client.py
@@ -1,4 +1,4 @@
1# Copyright 2017 FUJITSU LIMITED 1# Copyright 2017-2018 FUJITSU LIMITED
2# 2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may 3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain 4# not use this file except in compliance with the License. You may obtain
@@ -50,13 +50,13 @@ class FOSSWClient(object):
50 If exists session for specified target, reuse it otherwise reconnect. 50 If exists session for specified target, reuse it otherwise reconnect.
51 In order to get command result correctly, execute 'terminal length 0' 51 In order to get command result correctly, execute 'terminal length 0'
52 at the beginning of the session. 52 at the beginning of the session.
53
53 :param ip: a ip address of FOS switch 54 :param ip: a ip address of FOS switch
54 :type ip: string 55 :type ip: string
55 :returns: None 56 :returns: None
56 :rtype: None 57 :rtype: None
57
58 """ 58 """
59 if not self.lookup(ip): 59 if not self._lookup(ip):
60 self._reconnect(ip) 60 self._reconnect(ip)
61 self._exec_command(TERMINAL_LENGTH_0) 61 self._exec_command(TERMINAL_LENGTH_0)
62 62
@@ -67,8 +67,8 @@ class FOSSWClient(object):
67 :type ip: string 67 :type ip: string
68 :returns: None 68 :returns: None
69 :rtypes: None 69 :rtypes: None
70
71 """ 70 """
71
72 self.disconnect() 72 self.disconnect()
73 method = "connect" 73 method = "connect"
74 retry_count = 0 74 retry_count = 0
@@ -112,8 +112,8 @@ class FOSSWClient(object):
112 112
113 :returns: None 113 :returns: None
114 :rtypes: None 114 :rtypes: None
115
116 """ 115 """
116
117 if self.ssh: 117 if self.ssh:
118 self.ssh.close() 118 self.ssh.close()
119 self.ssh = None 119 self.ssh = None
@@ -159,15 +159,13 @@ class FOSSWClient(object):
159 raise FOSSWClientException(method) 159 raise FOSSWClientException(method)
160 return formatted 160 return formatted
161 161
162 def lookup(self, target): 162 def _lookup(self, target):
163 """Check exist session for specified IP. 163 """Check exist session for specified IP.
164 164
165 :param target: IP address of a target host 165 :param target: IP address of a target host
166 :type target: string 166 :type target: string
167
168 :returns: exist(True) or not exist(False) 167 :returns: exist(True) or not exist(False)
169 :rtype: bool 168 :rtype: bool
170
171 """ 169 """
172 if self.ssh: 170 if self.ssh:
173 if self.ssh._host_keys: 171 if self.ssh._host_keys:
@@ -181,10 +179,8 @@ class FOSSWClient(object):
181 179
182 :param segmentation_id: id of VLAN to be created. 180 :param segmentation_id: id of VLAN to be created.
183 :type segmentation_id: string 181 :type segmentation_id: string
184
185 :returns: received message from FOS switch 182 :returns: received message from FOS switch
186 :rtype: string 183 :rtype: string
187
188 """ 184 """
189 self.change_mode(MODE_VLAN) 185 self.change_mode(MODE_VLAN)
190 cmd = self._format_command("vlan {vlanid}", vlanid=segmentation_id) 186 cmd = self._format_command("vlan {vlanid}", vlanid=segmentation_id)
@@ -195,11 +191,10 @@ class FOSSWClient(object):
195 191
196 :param segmentation_id: id of VLAN to be deleted. 192 :param segmentation_id: id of VLAN to be deleted.
197 :type segmentation_id: string 193 :type segmentation_id: string
198
199 :returns: None 194 :returns: None
200 :rtype: None 195 :rtype: None
201
202 """ 196 """
197
203 self.change_mode(MODE_VLAN) 198 self.change_mode(MODE_VLAN)
204 cmd = self._format_command("no vlan {vlanid}", vlanid=segmentation_id) 199 cmd = self._format_command("no vlan {vlanid}", vlanid=segmentation_id)
205 if "Failed to delete" in self._exec_command(cmd): 200 if "Failed to delete" in self._exec_command(cmd):
@@ -212,11 +207,10 @@ class FOSSWClient(object):
212 :type segmentation_id: string 207 :type segmentation_id: string
213 :param port_id: the number of physical port on FOS switch 208 :param port_id: the number of physical port on FOS switch
214 :type port_id: string 209 :type port_id: string
215
216 :returns: None 210 :returns: None
217 :rtype: None 211 :rtype: None
218
219 """ 212 """
213
220 method = "set_vlan" 214 method = "set_vlan"
221 self.change_mode(MODE_INTERFACE, port_id) 215 self.change_mode(MODE_INTERFACE, port_id)
222 self._exec_command("switchport mode access") 216 self._exec_command("switchport mode access")
@@ -232,11 +226,10 @@ class FOSSWClient(object):
232 226
233 :param port_id: the number of physical port on FOS switch 227 :param port_id: the number of physical port on FOS switch
234 :type port_id: string 228 :type port_id: string
235
236 :returns: None 229 :returns: None
237 :rtype: None 230 :rtype: None
238
239 """ 231 """
232
240 self.change_mode(MODE_INTERFACE, port_id) 233 self.change_mode(MODE_INTERFACE, port_id)
241 self._exec_command("no switchport access vlan") 234 self._exec_command("no switchport access vlan")
242 self._exec_command("no switchport mode") 235 self._exec_command("no switchport mode")
@@ -248,11 +241,10 @@ class FOSSWClient(object):
248 :type port: string 241 :type port: string
249 :param logicalport: the number of logical port on FOS switch 242 :param logicalport: the number of logical port on FOS switch
250 :type logicalport: string 243 :type logicalport: string
251
252 :returns: None 244 :returns: None
253 :rtype: None 245 :rtype: None
254
255 """ 246 """
247
256 self.change_mode(MODE_INTERFACE, ifname=logicalport) 248 self.change_mode(MODE_INTERFACE, ifname=logicalport)
257 self._exec_command("no port-channel static") 249 self._exec_command("no port-channel static")
258 250
@@ -268,10 +260,10 @@ class FOSSWClient(object):
268 :param logicalport: the number of logicalport 260 :param logicalport: the number of logicalport
269 (optional, default: "none") 261 (optional, default: "none")
270 :type logicalport: string 262 :type logicalport: string
271
272 :returns: the ID of VPC or None. 263 :returns: the ID of VPC or None.
273 :rtype: string 264 :rtype: string
274 """ 265 """
266
275 # TODO(yushiro): Replace regexp 267 # TODO(yushiro): Replace regexp
276 for i in iter(range(1, MAX_VPC_ID + 1)): 268 for i in iter(range(1, MAX_VPC_ID + 1)):
277 cmd = 'show vpc {vid} | include "Port channel"'.format(vid=str(i)) 269 cmd = 'show vpc {vid} | include "Port channel"'.format(vid=str(i))
@@ -297,11 +289,10 @@ class FOSSWClient(object):
297 :type logicalport: string 289 :type logicalport: string
298 :param vpcid: id of VPC 290 :param vpcid: id of VPC
299 :type vpcid: string 291 :type vpcid: string
300
301 :returns: None 292 :returns: None
302 :rtype: None 293 :rtype: None
303
304 """ 294 """
295
305 self.change_mode(MODE_INTERFACE, ifname=logicalport) 296 self.change_mode(MODE_INTERFACE, ifname=logicalport)
306 self._exec_command("vpc {vpcid}".format(vpcid=vpcid)) 297 self._exec_command("vpc {vpcid}".format(vpcid=vpcid))
307 298
@@ -310,8 +301,8 @@ class FOSSWClient(object):
310 301
311 :returns: IP address of peerlink partner 302 :returns: IP address of peerlink partner
312 :rtype: string 303 :rtype: string
313
314 """ 304 """
305
315 # TODO(yushiro): Replace regexp 306 # TODO(yushiro): Replace regexp
316 ret = self._exec_command('show vpc peer-keepalive | include "Peer ' 307 ret = self._exec_command('show vpc peer-keepalive | include "Peer '
317 'IP address"') 308 'IP address"')
@@ -331,8 +322,8 @@ class FOSSWClient(object):
331 :returns: the number of logical port which associated with specified 322 :returns: the number of logical port which associated with specified
332 physical port 323 physical port
333 :rtype: string 324 :rtype: string
334
335 """ 325 """
326
336 # Find related lag_port with specified portname 327 # Find related lag_port with specified portname
337 if portname: 328 if portname:
338 cmd = "show running-config interface %s" % portname 329 cmd = "show running-config interface %s" % portname
@@ -349,8 +340,8 @@ class FOSSWClient(object):
349 340
350 :returns: MAC address of FOS switch 341 :returns: MAC address of FOS switch
351 :rtype: string 342 :rtype: string
352
353 """ 343 """
344
354 cmd = 'show hardware eeprom | include "Base MAC Address"' 345 cmd = 'show hardware eeprom | include "Base MAC Address"'
355 res = self._exec_command(cmd) 346 res = self._exec_command(cmd)
356 if res: 347 if res:
@@ -364,11 +355,10 @@ class FOSSWClient(object):
364 :type port: string 355 :type port: string
365 :param logicalport: the number of logical port on FOS switch 356 :param logicalport: the number of logical port on FOS switch
366 :type logicalport: string 357 :type logicalport: string
367
368 :returns: None 358 :returns: None
369 :rtype: None 359 :rtype: None
370
371 """ 360 """
361
372 self.change_mode(MODE_INTERFACE, ifname=port) 362 self.change_mode(MODE_INTERFACE, ifname=port)
373 res = self._exec_command( 363 res = self._exec_command(
374 "deleteport {lo_port}".format(lo_port=logicalport)) 364 "deleteport {lo_port}".format(lo_port=logicalport))
@@ -386,11 +376,10 @@ class FOSSWClient(object):
386 :type logicalport: string 376 :type logicalport: string
387 :param vpcid: id of VPC 377 :param vpcid: id of VPC
388 :type vpcid: string 378 :type vpcid: string
389
390 :returns: None 379 :returns: None
391 :rtype: None 380 :rtype: None
392
393 """ 381 """
382
394 self.change_mode(MODE_INTERFACE, ifname=logicalport) 383 self.change_mode(MODE_INTERFACE, ifname=logicalport)
395 res = self._exec_command("no vpc {vpcid}".format(vpcid=vpcid)) 384 res = self._exec_command("no vpc {vpcid}".format(vpcid=vpcid))
396 if "Failed to remove" in res: 385 if "Failed to remove" in res:
@@ -403,8 +392,8 @@ class FOSSWClient(object):
403 392
404 :returns: None 393 :returns: None
405 :rtypes: None 394 :rtypes: None
406
407 """ 395 """
396
408 self._exec_command("copy system:running-config nvram:startup-config") 397 self._exec_command("copy system:running-config nvram:startup-config")
409 self._exec_command("y") 398 self._exec_command("y")
410 self._exec_command("") 399 self._exec_command("")
@@ -417,11 +406,10 @@ class FOSSWClient(object):
417 :param ifname: the number of physical port on FOS switch 406 :param ifname: the number of physical port on FOS switch
418 (optional, default: None) 407 (optional, default: None)
419 :type ifname: string 408 :type ifname: string
420
421 :returns: None 409 :returns: None
422 :rtype: None 410 :rtype: None
423
424 """ 411 """
412
425 # Move to Privileged EXEC mode. 413 # Move to Privileged EXEC mode.
426 prompt = self._exec_command(END) 414 prompt = self._exec_command(END)
427 if ") >" in prompt: 415 if ") >" in prompt:
diff --git a/networking_fujitsu/ml2/fossw/fossw_vlandriver.py b/networking_fujitsu/ml2/fossw/fossw_vlandriver.py
index a3289fa..213ad9a 100644
--- a/networking_fujitsu/ml2/fossw/fossw_vlandriver.py
+++ b/networking_fujitsu/ml2/fossw/fossw_vlandriver.py
@@ -1,4 +1,4 @@
1# Copyright 2017 FUJITSU LIMITED 1# Copyright 2017-2018 FUJITSU LIMITED
2# 2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may 3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain 4# not use this file except in compliance with the License. You may obtain
@@ -46,14 +46,13 @@ class FOSSWVlanDriver(object):
46 def get_switch_mac_ip_pair(self, ips): 46 def get_switch_mac_ip_pair(self, ips):
47 """Get and create pair of switch's MAC address and IP address. 47 """Get and create pair of switch's MAC address and IP address.
48 48
49 :param ips: list of IP address of FOS switch 49 :param ips: List of IP address of FOS switch
50 :type ips: list of IP address strings 50 :type ips: List of IP address strings
51 51 :returns: A dictionary which stores pair of MAC address and IP
52 :returns: the dictionary which stores pair of MAC address and IP 52 address like {'fe:54:00:23:33:9a': '192.168.50.1'}
53 address 53 :rtype: A dictionary of MAC address and IP address
54 :rtype: dictionary of MAC address and IP address
55
56 """ 54 """
55
57 switches_mac_ip_pair = {} 56 switches_mac_ip_pair = {}
58 for ip in ips: 57 for ip in ips:
59 self.client.connect(ip) 58 self.client.connect(ip)
@@ -73,11 +72,10 @@ class FOSSWVlanDriver(object):
73 :type ip: string 72 :type ip: string
74 :param vlanid: ID of VLAN to be created 73 :param vlanid: ID of VLAN to be created
75 :type vlanid: string 74 :type vlanid: string
76
77 :returns: None 75 :returns: None
78 :rtype: None 76 :rtype: None
79
80 """ 77 """
78
81 method = 'create_vlan' 79 method = 'create_vlan'
82 try: 80 try:
83 self.client.connect(ip) 81 self.client.connect(ip)
@@ -96,11 +94,10 @@ class FOSSWVlanDriver(object):
96 :type ip: string 94 :type ip: string
97 :param vlanid: ID of VLAN to be deleted 95 :param vlanid: ID of VLAN to be deleted
98 :type vlanid: string 96 :type vlanid: string
99
100 :returns: None 97 :returns: None
101 :rtype: None 98 :rtype: None
102
103 """ 99 """
100
104 method = 'delete_vlan' 101 method = 'delete_vlan'
105 try: 102 try:
106 self.client.connect(ip) 103 self.client.connect(ip)
@@ -122,11 +119,10 @@ class FOSSWVlanDriver(object):
122 :param ip_mac_pairs: the pair of MAC address and IP address of FOS 119 :param ip_mac_pairs: the pair of MAC address and IP address of FOS
123 switch 120 switch
124 :type ip_mac_pairs: dictionary 121 :type ip_mac_pairs: dictionary
125
126 :returns: None 122 :returns: None
127 :rtype: None 123 :rtype: None
128
129 """ 124 """
125
130 method = "setup_vlan" 126 method = "setup_vlan"
131 sw_mac = lli[0]['switch_id'] 127 sw_mac = lli[0]['switch_id']
132 port_id = lli[0]['port_id'] 128 port_id = lli[0]['port_id']
@@ -158,11 +154,10 @@ class FOSSWVlanDriver(object):
158 :param vlanid: the VLANID to configure. If it is not set, it will skip 154 :param vlanid: the VLANID to configure. If it is not set, it will skip
159 VLAN configuration. 155 VLAN configuration.
160 :type vlanid: Integer 156 :type vlanid: Integer
161
162 :returns: mac_lag_map MAC address and LAG port ID pair 157 :returns: mac_lag_map MAC address and LAG port ID pair
163 :rtype: dictionary 158 :rtype: dictionary
164
165 """ 159 """
160
166 method = "setup_lag" 161 method = "setup_lag"
167 mlag = False 162 mlag = False
168 unique_mac_list = sorted(list(set([lli['switch_id'] for lli in llis]))) 163 unique_mac_list = sorted(list(set([lli['switch_id'] for lli in llis])))
@@ -238,11 +233,10 @@ class FOSSWVlanDriver(object):
238 :param ip_mac_pairs: the pair of MAC address and IP address of FOS 233 :param ip_mac_pairs: the pair of MAC address and IP address of FOS
239 switches 234 switches
240 :type ip_mac_pairs: dictionary 235 :type ip_mac_pairs: dictionary
241
242 :returns: Result of validation 236 :returns: Result of validation
243 :rtype: Boolean 237 :rtype: Boolean
244
245 """ 238 """
239
246 try: 240 try:
247 ips = self._validate_lli_macs_with_config(macs, ip_mac_pairs) 241 ips = self._validate_lli_macs_with_config(macs, ip_mac_pairs)
248 self.client.connect(ips[0]) 242 self.client.connect(ips[0])
@@ -264,6 +258,7 @@ class FOSSWVlanDriver(object):
264 switches 258 switches
265 :type ip_mac_pairs: dictionary 259 :type ip_mac_pairs: dictionary
266 """ 260 """
261
267 method = "clear_vlan" 262 method = "clear_vlan"
268 sw_mac = lli[0]['switch_id'] 263 sw_mac = lli[0]['switch_id']
269 port_id = lli[0]['port_id'] 264 port_id = lli[0]['port_id']
@@ -292,11 +287,10 @@ class FOSSWVlanDriver(object):
292 :param ip_mac_pairs: the pair of MAC address and IP address of FOS 287 :param ip_mac_pairs: the pair of MAC address and IP address of FOS
293 switches 288 switches
294 :type ip_mac_pairs: dictionary 289 :type ip_mac_pairs: dictionary
295
296 :returns: None 290 :returns: None
297 :rtype: None 291 :rtype: None
298
299 """ 292 """
293
300 method = "clear_lag" 294 method = "clear_lag"
301 mlag = None 295 mlag = None
302 unique_mac_list = sorted(list(set([lli['switch_id'] for lli in llis]))) 296 unique_mac_list = sorted(list(set([lli['switch_id'] for lli in llis])))
diff --git a/networking_fujitsu/ml2/fossw/fossw_vxlandriver.py b/networking_fujitsu/ml2/fossw/fossw_vxlandriver.py
index a2e6f9a..b6f84bf 100644
--- a/networking_fujitsu/ml2/fossw/fossw_vxlandriver.py
+++ b/networking_fujitsu/ml2/fossw/fossw_vxlandriver.py
@@ -1,4 +1,4 @@
1# Copyright 2017 FUJITSU LIMITED 1# Copyright 2017-2018 FUJITSU LIMITED
2# 2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may 3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain 4# not use this file except in compliance with the License. You may obtain
@@ -66,6 +66,7 @@ class FOSSWVxlanDriver(object):
66 66
67 def save_all_fossw(self): 67 def save_all_fossw(self):
68 """Save running-config to startup-config in all FOS switches.""" 68 """Save running-config to startup-config in all FOS switches."""
69
69 for fossw_ip in self.fossw_ips: 70 for fossw_ip in self.fossw_ips:
70 self.client.connect(fossw_ip) 71 self.client.connect(fossw_ip)
71 self.client.save_running_config() 72 self.client.save_running_config()
@@ -75,6 +76,7 @@ class FOSSWVxlanDriver(object):
75 """Update Neutron DB ml2_vxlan_endpoints table 76 """Update Neutron DB ml2_vxlan_endpoints table
76 77
77 Update with VTEPs of all FOS switches. 78 Update with VTEPs of all FOS switches.
79
78 :returns: None 80 :returns: None
79 """ 81 """
80 82
@@ -125,11 +127,11 @@ class FOSSWVxlanDriver(object):
125 127
126 We consider net_uuid is always unique, and both vni and net_uuid 128 We consider net_uuid is always unique, and both vni and net_uuid
127 must be immutable. So there is not a update case. 129 must be immutable. So there is not a update case.
130
128 :param net_uuid: The uuid of Neutron network. 131 :param net_uuid: The uuid of Neutron network.
129 :type net_uuid: string 132 :type net_uuid: string
130 :param vni: The segment ID of Neutron network. 133 :param vni: The segment ID of Neutron network.
131 :type vni: integer 134 :type vni: integer
132
133 :returns: None 135 :returns: None
134 """ 136 """
135 137
@@ -145,9 +147,9 @@ class FOSSWVxlanDriver(object):
145 147
146 We only consider deleting the existing Logical_Switch ROW. 148 We only consider deleting the existing Logical_Switch ROW.
147 Also note that even it does not exit, the jsonrpc returns no error. 149 Also note that even it does not exit, the jsonrpc returns no error.
150
148 :param net_uuid: The uuid of Neutron network. 151 :param net_uuid: The uuid of Neutron network.
149 :type: string 152 :type: string
150
151 :returns: None 153 :returns: None
152 """ 154 """
153 155
@@ -182,14 +184,13 @@ class FOSSWVxlanDriver(object):
182 to. 184 to.
183 :type vni: integer 185 :type vni: integer
184 :param lli: The local_link_information of the port. 186 :param lli: The local_link_information of the port.
185 If it is a VM port, then [{}] should be given. 187 If it is a VM port, then [] should be given.
186 :type lli: list 188 :type lli: list
187 :param port: Dictionary of a port 189 :param port: Dictionary of a port
188 :type port: dictionary 190 :type port: dictionary
189 :param ip_mac_pairs: List of MAC(key) - IP(value) pairs of all FOS 191 :param ip_mac_pairs: List of MAC(key) - IP(value) pairs of all FOS
190 switches. 192 switches.
191 :type ip_mac_pairs: dictionary 193 :type ip_mac_pairs: dictionary
192
193 :returns: None 194 :returns: None
194 """ 195 """
195 196
@@ -247,6 +248,7 @@ class FOSSWVxlanDriver(object):
247 def _update_ucast_macs_remote(self, logical_switch_name, mac, tunnel_ip, 248 def _update_ucast_macs_remote(self, logical_switch_name, mac, tunnel_ip,
248 port_ips, ignore=None): 249 port_ips, ignore=None):
249 """Update Ucast_Macs_Remote table in all FOS switches OVSDB.""" 250 """Update Ucast_Macs_Remote table in all FOS switches OVSDB."""
251
250 for fossw_ip in self.fossw_ips: 252 for fossw_ip in self.fossw_ips:
251 if ignore == fossw_ip: 253 if ignore == fossw_ip:
252 continue 254 continue
@@ -263,7 +265,7 @@ class FOSSWVxlanDriver(object):
263 ls_uuid, mac, port_ips, tunnel_ip) 265 ls_uuid, mac, port_ips, tunnel_ip)
264 266
265 def reset_physical_port(self, lli, port, ip_mac_pairs, save=True): 267 def reset_physical_port(self, lli, port, ip_mac_pairs, save=True):
266 """Remove setting of raw of Physical_Port table in FOS switch OVSDB. 268 """Remove setting of row of Physical_Port table in FOS switch OVSDB.
267 269
268 ROWs with the same MAC address in Ucast_Macs_Local table and 270 ROWs with the same MAC address in Ucast_Macs_Local table and
269 Ucast_Macs_Remote table are the target to extinct. 271 Ucast_Macs_Remote table are the target to extinct.
@@ -275,16 +277,16 @@ class FOSSWVxlanDriver(object):
275 :param ip_mac_pairs: List of MAC(key) - IP(value) pairs of all FOS 277 :param ip_mac_pairs: List of MAC(key) - IP(value) pairs of all FOS
276 switches. 278 switches.
277 :type ip_mac_pairs: dictionary 279 :type ip_mac_pairs: dictionary
278
279 :returns: None 280 :returns: None
280 """ 281 """
281 282
282 if lli: 283 if lli:
283 target = ip_mac_pairs[lli[0]['switch_id']] 284 target = ip_mac_pairs[lli[0]['switch_id']]
284 port_id = lli[0]['port_id'] 285 # If this method is callef from reset_physical_port_with_lag,
286 # sw_port_id should be logical port(for LAG)
287 sw_port_id = lli[0]['port_id']
285 ovsdb_cli = ovsdb_writer.OVSDBWriter(target, self.ovsdb_port) 288 ovsdb_cli = ovsdb_writer.OVSDBWriter(target, self.ovsdb_port)
286 # TODO(yushiro): Need to send lag port in case of LAG 289 ovsdb_cli.reset_physical_port(sw_port_id)
287 ovsdb_cli.reset_physical_port(port_id)
288 290
289 mac = port["mac_address"] 291 mac = port["mac_address"]
290 292
@@ -316,7 +318,6 @@ class FOSSWVxlanDriver(object):
316 :param req_id: A request ID of network context which use for generate 318 :param req_id: A request ID of network context which use for generate
317 new context. 319 new context.
318 :type req_id: string 320 :type req_id: string
319
320 :returns: None 321 :returns: None
321 """ 322 """
322 323
@@ -338,7 +339,6 @@ class FOSSWVxlanDriver(object):
338 :param ip_mac_pairs: List of MAC(key) - IP(value) pairs of all FOS 339 :param ip_mac_pairs: List of MAC(key) - IP(value) pairs of all FOS
339 switches. 340 switches.
340 :type ip_mac_pairs: dictionary 341 :type ip_mac_pairs: dictionary
341
342 :returns: None 342 :returns: None
343 """ 343 """
344 344
diff --git a/networking_fujitsu/ml2/fossw/mech_fossw.py b/networking_fujitsu/ml2/fossw/mech_fossw.py
index aabe339..3a621b4 100644
--- a/networking_fujitsu/ml2/fossw/mech_fossw.py
+++ b/networking_fujitsu/ml2/fossw/mech_fossw.py
@@ -1,4 +1,4 @@
1# Copyright 2017 FUJITSU LIMITED 1# Copyright 2017-2018 FUJITSU LIMITED
2# 2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may 3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain 4# not use this file except in compliance with the License. You may obtain
@@ -115,10 +115,8 @@ class FOSSWMechanismDriver(api.MechanismDriver):
115 115
116 :param mech_context: context of network 116 :param mech_context: context of network
117 :type mech_context: NetworkContext 117 :type mech_context: NetworkContext
118
119 :returns: None 118 :returns: None
120 :rtype: None 119 :rtype: None
121
122 """ 120 """
123 121
124 network = net_context.current 122 network = net_context.current
@@ -143,11 +141,10 @@ class FOSSWMechanismDriver(api.MechanismDriver):
143 141
144 :param vlanid: the ID of VLAN to be created 142 :param vlanid: the ID of VLAN to be created
145 :type vlanid: string 143 :type vlanid: string
146
147 :returns: None 144 :returns: None
148 :rtype: None 145 :rtype: None
149
150 """ 146 """
147
151 method = 'create_network_postcommit' 148 method = 'create_network_postcommit'
152 for ip in self.ips: 149 for ip in self.ips:
153 try: 150 try:
@@ -159,6 +156,7 @@ class FOSSWMechanismDriver(api.MechanismDriver):
159 156
160 @log_helpers.log_method_call 157 @log_helpers.log_method_call
161 def create_network_postcommit_vxlan(self, net_uuid, seg_id): 158 def create_network_postcommit_vxlan(self, net_uuid, seg_id):
159
162 method = 'create_network_postcommit' 160 method = 'create_network_postcommit'
163 try: 161 try:
164 self._vxlan_driver.create_logical_switch(net_uuid, seg_id) 162 self._vxlan_driver.create_logical_switch(net_uuid, seg_id)
@@ -181,7 +179,6 @@ class FOSSWMechanismDriver(api.MechanismDriver):
181 179
182 :param net_context: context of network 180 :param net_context: context of network
183 :type net_context: NetworkContext 181 :type net_context: NetworkContext
184
185 :returns: None 182 :returns: None
186 :rtype: None 183 :rtype: None
187 """ 184 """
@@ -206,11 +203,10 @@ class FOSSWMechanismDriver(api.MechanismDriver):
206 203
207 :param vlanid: the ID of VLAN to be deleted 204 :param vlanid: the ID of VLAN to be deleted
208 :type vlanid: string 205 :type vlanid: string
209
210 :returns: None 206 :returns: None
211 :rtypes: None 207 :rtypes: None
212
213 """ 208 """
209
214 method = 'delete_network_postcommit' 210 method = 'delete_network_postcommit'
215 for ip in self.ips: 211 for ip in self.ips:
216 try: 212 try:
@@ -234,16 +230,17 @@ class FOSSWMechanismDriver(api.MechanismDriver):
234 def delete_port_postcommit(self, mech_context): 230 def delete_port_postcommit(self, mech_context):
235 """Calls cleanup process for FOS switch. 231 """Calls cleanup process for FOS switch.
236 232
237 Case1: Baremetal deploy with VLAN 233 Case1: 'network_type' is 'vlan' and the port is for baremetal
238 Clear VLAN/LAG for specified physical port. 234 Call clear VLAN/LAG for specified physical port.
239 Case2: 235 Case2: 'network_type' is 'vxlan' and the port is for baremetal
240 Clear VXLAN/LAG for specified physical port. 236 Call clear VXLAN/LAG for specified physical port.
241 Case3: Otherwise 237 Case3: 'network_type' is 'vxlan' and the port is for VM/DHCP/router
242 Do nothing. 238 Call clear VXLAN/LAG for specified physical port.
239 Case4: Otherwise
240 Ignore
243 241
244 :param mech_context: context of port 242 :param mech_context: context of port
245 :type mech_context: PortContext 243 :type mech_context: PortContext
246
247 :returns: None 244 :returns: None
248 :rtype: None 245 :rtype: None
249 """ 246 """
@@ -266,6 +263,7 @@ class FOSSWMechanismDriver(api.MechanismDriver):
266 @log_helpers.log_method_call 263 @log_helpers.log_method_call
267 def update_port_postcommit(self, context): 264 def update_port_postcommit(self, context):
268 """Update specified physical port on switch.""" 265 """Update specified physical port on switch."""
266
269 method = 'update_port_postcommit' 267 method = 'update_port_postcommit'
270 port = context.current 268 port = context.current
271 network = context.network 269 network = context.network
@@ -291,7 +289,7 @@ class FOSSWMechanismDriver(api.MechanismDriver):
291 if (network_type != nl_const.TYPE_VXLAN or 289 if (network_type != nl_const.TYPE_VXLAN or
292 vif_type == pb_def.VIF_TYPE_UNBOUND): 290 vif_type == pb_def.VIF_TYPE_UNBOUND):
293 return 291 return
294 # currently supports only one segment per network 292 # Currently this driver supports only one segment per network.
295 # Setup VXLAN for port which bound with DHCP, router, and vms. 293 # Setup VXLAN for port which bound with DHCP, router, and vms.
296 try: 294 try:
297 self._vxlan_driver.update_physical_port( 295 self._vxlan_driver.update_physical_port(
@@ -313,7 +311,6 @@ class FOSSWMechanismDriver(api.MechanismDriver):
313 :param params: a dictionary of the return value for 311 :param params: a dictionary of the return value for
314 get_physical_net_params 312 get_physical_net_params
315 :type params: dictionary 313 :type params: dictionary
316
317 :returns: None 314 :returns: None
318 :rtype: None 315 :rtype: None
319 """ 316 """
@@ -363,8 +360,6 @@ class FOSSWMechanismDriver(api.MechanismDriver):
363 try: 360 try:
364 call_target = target if params['lag'] else 'clear_vlan' 361 call_target = target if params['lag'] else 'clear_vlan'
365 clear_method = getattr(self._vlan_driver, call_target) 362 clear_method = getattr(self._vlan_driver, call_target)
366 LOG.info("call %(target)s. params: %(params)s",
367 {'target': call_target, 'params': params})
368 clear_method(params['local_link_info'], self.switches_mac_ip_pair) 363 clear_method(params['local_link_info'], self.switches_mac_ip_pair)
369 except Exception: 364 except Exception:
370 LOG.exception("Failed to clear vlan(%s)", params['vlanid']) 365 LOG.exception("Failed to clear vlan(%s)", params['vlanid'])
@@ -378,18 +373,20 @@ class FOSSWMechanismDriver(api.MechanismDriver):
378 network = context.network 373 network = context.network
379 if port[pb_def.VIF_TYPE] == pb_def.VIF_TYPE_UNBOUND: 374 if port[pb_def.VIF_TYPE] == pb_def.VIF_TYPE_UNBOUND:
380 return 375 return
381 if not utils.has_lli(port): 376 # Returns empty list if port doesn't include 'local_link_information'
382 LOG.warning('local_link_information not found in port %s', port)
383 return
384 lli = utils.get_physical_connectivity(port) 377 lli = utils.get_physical_connectivity(port)
385 try: 378 try:
386 if utils.is_lag(lli): 379 if utils.is_lag(lli):
387 mac_lag_map = self._vlan_driver.clear_lag( 380 ret = self._vlan_driver.clear_lag(
388 lli, self.switches_mac_ip_pair) 381 lli, self.switches_mac_ip_pair)
389 self._vxlan_driver.reset_physical_port_with_lag( 382 self._vxlan_driver.reset_physical_port_with_lag(
390 lli, port, self.switches_mac_ip_pair, 383 lli, port, self.switches_mac_ip_pair, mac_lag_map=ret)
391 mac_lag_map=mac_lag_map)
392 else: 384 else:
385 # In case of baremetal port
386 # - 'lli' exists and 'vnic_type' is 'baremetal'
387 # In case of router/DHCP/VM port
388 # - 'lli' is [](empty list)
389 # - This method only removes Ucast_macs_Remote entry
393 self._vxlan_driver.reset_physical_port( 390 self._vxlan_driver.reset_physical_port(
394 lli, port, self.switches_mac_ip_pair) 391 lli, port, self.switches_mac_ip_pair)
395 except Exception: 392 except Exception:
@@ -415,10 +412,10 @@ class FOSSWMechanismDriver(api.MechanismDriver):
415 :type port: dictionary 412 :type port: dictionary
416 :param network: a network object 413 :param network: a network object
417 :type network: NetworkContext 414 :type network: NetworkContext
418
419 :returns: A dictionary parameters for baremetal deploy 415 :returns: A dictionary parameters for baremetal deploy
420 :rtype: dictionary 416 :rtype: dictionary
421 """ 417 """
418
422 port = context.original if use_original else context.current 419 port = context.original if use_original else context.current
423 network = context.network 420 network = context.network
424 vlanid = utils.get_segmentation_id(network) 421 vlanid = utils.get_segmentation_id(network)
@@ -437,31 +434,22 @@ class FOSSWMechanismDriver(api.MechanismDriver):
437 network = context.network 434 network = context.network
438 if not is_supported(network): 435 if not is_supported(network):
439 return 436 return
440 LOG.debug("Attempting to bind port %(port)s with vnic_type "
441 "%(vnic_type)s on network %(network)s",
442 {'port': port['id'], 'vnic_type': port[pb_def.VNIC_TYPE],
443 'network': port['network_id']})
444 437
445 network_type = utils.get_network_type(network) 438 network_type = utils.get_network_type(network)
446 to_bind = False
447
448 if network_type == nl_const.TYPE_VXLAN: 439 if network_type == nl_const.TYPE_VXLAN:
449 # vxlan driver handles not only baremetal port, but vm, dhcp, 440 # VXLAN driver handles not only baremetal port, but VM/DHCP/router
450 # router ports.
451 self.setup_vxlan(context) 441 self.setup_vxlan(context)
452 to_bind = True 442 if network_type == nl_const.TYPE_VLAN and utils.is_baremetal(port):
453 if utils.is_baremetal(port) and network_type == nl_const.TYPE_VLAN:
454 self.setup_vlan(self.get_physical_net_params(context)) 443 self.setup_vlan(self.get_physical_net_params(context))
455 to_bind = True 444
456 if to_bind: 445 context.set_binding(context.segments_to_bind[0][api.ID],
457 context.set_binding(context.segments_to_bind[0][api.ID], 446 pb_def.VIF_TYPE_OTHER, {},
458 pb_def.VIF_TYPE_OTHER, {}, 447 status=nl_const.PORT_STATUS_ACTIVE)
459 status=nl_const.PORT_STATUS_ACTIVE)
460 448
461 @log_helpers.log_method_call 449 @log_helpers.log_method_call
462 def setup_vxlan(self, context): 450 def setup_vxlan(self, context):
463 """Update VXLAN from specified physical port on switch.""" 451 """Update VXLAN from specified physical port on switch."""
464 # currently supports only one segment per network 452
465 port = context.current 453 port = context.current
466 seg_id = utils.get_segmentation_id(context.network) 454 seg_id = utils.get_segmentation_id(context.network)
467 lli = utils.get_physical_connectivity(port) 455 lli = utils.get_physical_connectivity(port)
@@ -486,8 +474,7 @@ def is_supported(network):
486 474
487 :param network: a network object 475 :param network: a network object
488 :type network: NetworkContext 476 :type network: NetworkContext
489 477 :returns: True if network_type is supported and segmentation_id exists
490 :returns: True if network_type is supported and segmentation_id is included
491 otherwise False 478 otherwise False
492 :rtype: boolean 479 :rtype: boolean
493 """ 480 """
@@ -497,18 +484,3 @@ def is_supported(network):
497 LOG.warning("Network type(%s) is not supported. Skip it.", net_type) 484 LOG.warning("Network type(%s) is not supported. Skip it.", net_type)
498 return False 485 return False
499 return True if utils.get_segmentation_id(network) else False 486 return True if utils.get_segmentation_id(network) else False
500
501
502def validate_baremetal_deploy(port_context, use_original=False):
503 """Validate baremetal deploy.
504
505 :param port_context: a PortContext object
506 :type port_context: PortContext
507
508 :returns: True if enable to baremetal deploy otherwise False
509 :rtype: boolean
510 """
511
512 port = port_context.original if use_original else port_context.current
513 network = port_context.network
514 return utils.is_baremetal(port) and is_supported(network)
diff --git a/networking_fujitsu/tests/unit/ml2/fossw/test_mech_fossw.py b/networking_fujitsu/tests/unit/ml2/fossw/test_mech_fossw.py
index bd1dd89..a48b2cc 100644
--- a/networking_fujitsu/tests/unit/ml2/fossw/test_mech_fossw.py
+++ b/networking_fujitsu/tests/unit/ml2/fossw/test_mech_fossw.py
@@ -1,4 +1,4 @@
1# Copyright 2017 FUJITSU LIMITED 1# Copyright 2017-2018 FUJITSU LIMITED
2# 2#
3# Licensed under the Apache License, Version 2.0 (the "License"); 3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License. 4# you may not use this file except in compliance with the License.
@@ -507,6 +507,26 @@ class TestFOSSWBaremetalPortsVxlan(TestFujitsuMechDriverV2):
507 ml2_exc.MechanismDriverError, 507 ml2_exc.MechanismDriverError,
508 self.mech.update_port_postcommit, ctx) 508 self.mech.update_port_postcommit, ctx)
509 509
510 def test_update_port_raises_setup_vlan(self):
511 ctx = self.prepare_dummy_context(net_type='vxlan',
512 vif_type='unbound',
513 set_original=True)
514 # Raise in setup_vlan method
515 self.mech._vxlan_driver.reset_physical_port.side_effect = Exception
516 self.assertRaises(
517 ml2_exc.MechanismDriverError,
518 self.mech.update_port_postcommit, ctx)
519
520 def test_update_port_raises_setup_vxlan(self):
521 ctx = self.prepare_dummy_context(net_type='vxlan',
522 vif_type='unbound',
523 set_original=True)
524 # Raise in setup_vxlan method
525 self.mech._vxlan_driver.reset_physical_port.side_effect = Exception
526 self.assertRaises(
527 ml2_exc.MechanismDriverError,
528 self.mech.update_port_postcommit, ctx)
529
510 def test_delete_port(self): 530 def test_delete_port(self):
511 ctx = self.prepare_dummy_context(net_type='vxlan') 531 ctx = self.prepare_dummy_context(net_type='vxlan')
512 self.mech.delete_port_postcommit(ctx) 532 self.mech.delete_port_postcommit(ctx)
@@ -528,6 +548,16 @@ class TestFOSSWBaremetalPortsVxlan(TestFujitsuMechDriverV2):
528 self.mech.switches_mac_ip_pair 548 self.mech.switches_mac_ip_pair
529 ) 549 )
530 550
551 def test_delete_port_with_bound_not_baremetal(self):
552 ctx = self.prepare_dummy_context(net_type='vxlan', vif_type='ovs')
553 ctx.current['binding:profile'] = {}
554 self.mech.delete_port_postcommit(ctx)
555 self.mech._vxlan_driver.reset_physical_port.assert_called_once_with(
556 [],
557 ctx.current,
558 self.mech.switches_mac_ip_pair
559 )
560
531 def test_delete_port_raises_reset_physical_port(self): 561 def test_delete_port_raises_reset_physical_port(self):
532 ctx = self.prepare_dummy_context(net_type='vxlan', vif_type='normal') 562 ctx = self.prepare_dummy_context(net_type='vxlan', vif_type='normal')
533 self.mech._vxlan_driver.reset_physical_port.side_effect = Exception 563 self.mech._vxlan_driver.reset_physical_port.side_effect = Exception