Commit 06f5b07
committed
Make the "port forwarding create" command idempotent
The `port forwarding create` command would exit with an error
if you attempted to create a forwarding configuration that already exists.
This made it difficult to identify actual failures.
This commit updates the `port forwarding create` command so that it is not
an error if the requested forwarding already exists.
The old behavior was:
$ openstack esi port forwarding create 192.168.11.31 128.31.20.118 -p 8888
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| ID | Internal Port | External Port | Protocol | Internal IP | External IP |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| 43c96be3-861d-4818-a32a-079a93b6f9c4 | 8888 | 8888 | tcp | 192.168.11.31 | 128.31.20.118 |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
$ openstack esi port forwarding create esi-MOC-R4PAC24U35-S1B-provisioning 128.31.20.118 -p 8888 -p 8889
BadRequestException: 400: Client Error for url:
https://esi.massopen.cloud:13696/v2.0/floatingips/be4b2718-ec5f-4722-80b5-485c421e4a72/port_forwardings,
Bad port_forwarding request: A duplicate port forwarding entry with
same attributes already exists, conflicting values are
{'floatingip_id': 'be4b2718-ec5f-4722-80b5-485c421e4a72',
'external_port': 8888, 'protocol': 'tcp'}.
The new behavior looks like this:
$ openstack esi port forwarding create 192.168.11.31 128.31.20.118 -p 8888
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| ID | Internal Port | External Port | Protocol | Internal IP | External IP |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| 43c96be3-861d-4818-a32a-079a93b6f9c4 | 8888 | 8888 | tcp | 192.168.11.31 | 128.31.20.118 |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
$ openstack esi port forwarding create esi-MOC-R4PAC24U35-S1B-provisioning 128.31.20.118 -p 8888 -p 8889
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| ID | Internal Port | External Port | Protocol | Internal IP | External IP |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+
| exists | 8888 | 8888 | tcp | 192.168.11.31 | 128.31.20.118 |
| d7d56201-232a-41fe-8ae6-1f6fb88a37d3 | 8889 | 8889 | tcp | 192.168.11.31 | 128.31.20.118 |
+--------------------------------------+---------------+---------------+----------+---------------+---------------+1 parent 775476e commit 06f5b07
1 file changed
+41
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
37 | 48 | | |
38 | 49 | | |
39 | 50 | | |
| |||
73 | 84 | | |
74 | 85 | | |
75 | 86 | | |
76 | | - | |
77 | 87 | | |
78 | 88 | | |
79 | 89 | | |
| |||
233 | 243 | | |
234 | 244 | | |
235 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
236 | 258 | | |
237 | 259 | | |
238 | 260 | | |
| |||
329 | 351 | | |
330 | 352 | | |
331 | 353 | | |
| 354 | + | |
332 | 355 | | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
347 | 373 | | |
348 | 374 | | |
349 | 375 | | |
| |||
0 commit comments