Skip to content

Commit 1b33822

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Set result when lswitch port exist" into stable/yoga
2 parents 0e7cc8b + 6af9f70 commit 1b33822

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/commands.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def run_idl(self, txn):
124124
'Logical_Switch_Port', 'name',
125125
self.lport, None)
126126
if port:
127+
self.result = port.uuid
127128
return
128129

129130
port = txn.insert(self.api._tables['Logical_Switch_Port'])

neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_client.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,21 @@ def check_metadata_port(enable_dhcp):
6666
# because it checks first if the metadata port exists.
6767
ovn_client.create_metadata_port(self.context, network)
6868
check_metadata_port(enable_dhcp)
69+
70+
def test_create_port(self):
71+
with self.network('test-ovn-client') as net:
72+
with self.subnet(net) as subnet:
73+
with self.port(subnet) as port:
74+
port_data = port['port']
75+
nb_ovn = self.mech_driver.nb_ovn
76+
lsp = nb_ovn.lsp_get(port_data['id']).execute()
77+
# The logical switch port has been created during the
78+
# port creation.
79+
self.assertIsNotNone(lsp)
80+
ovn_client = self.mech_driver._ovn_client
81+
port_data = self.plugin.get_port(self.context,
82+
port_data['id'])
83+
# Call the create_port again to ensure that the create
84+
# command automatically checks for existing logical
85+
# switch ports
86+
ovn_client.create_port(self.context, port_data)

neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_lswitch_not_found(self):
105105

106106
def test_lswitch_port_exists(self):
107107
with mock.patch.object(idlutils, 'row_by_value',
108-
return_value=mock.ANY):
108+
return_value=mock.Mock()):
109109
cmd = commands.AddLSwitchPortCommand(
110110
self.ovn_api, 'fake-lsp', 'fake-lswitch', may_exist=True)
111111
cmd.run_idl(self.transaction)

0 commit comments

Comments
 (0)