Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should port forwarding create be idempotent? #82

Open
larsks opened this issue Jan 21, 2025 · 1 comment
Open

Should port forwarding create be idempotent? #82

larsks opened this issue Jan 21, 2025 · 1 comment
Assignees

Comments

@larsks
Copy link
Member

larsks commented Jan 21, 2025

Current, it's an error to attempt to create a port forwarding that already exists:

$ openstack esi port forwarding create 192.168.79.222 128.31.20.133 -p 22
+--------------------------------------+---------------+---------------+----------+----------------+---------------+
| ID                                   | Internal Port | External Port | Protocol | Internal IP    | External IP   |
+--------------------------------------+---------------+---------------+----------+----------------+---------------+
| 42dad77d-64bc-4f1d-8cb8-d711d558f975 |            22 |            22 | tcp      | 192.168.79.222 | 128.31.20.133 |
+--------------------------------------+---------------+---------------+----------+----------------+---------------+
$ openstack esi port forwarding create 192.168.79.222 128.31.20.133 -p 22
BadRequestException: 400: Client Error for url: https://esi.massopen.cloud:13696/v2.0/floatingips/90fa9d72-90f7-44f1-9374-ade83cb9868b/port_forwardings, Bad port_forwarding request: A duplicate port forwarding entry with same attributes already exists, conflicting values are {'floatingip_id': '90fa9d72-90f7-44f1-9374-ade83cb9868b', 'external_port': 22, 'protocol': 'tcp'}.
[lars@mushu python-esiclient]  (master)$

Should calling port forwarding create with a port that already exists succeed instead without making any changes? This might make it easier when you want to add additional port forwardings; e.g., if after running the first command, above, I realized I also wanted to add ports 80 and 443, I could just run:

$ openstack esi port forwarding create 192.168.79.222 128.31.20.133 -p 22 -p 80 -p 443

And the output would be something like:

+--------------------------------------+---------------+---------------+----------+----------------+---------------+
| ID                                   | Internal Port | External Port | Protocol | Internal IP    | External IP   |
+--------------------------------------+---------------+---------------+----------+----------------+---------------+
| 42dad77d-64bc-4f1d-8cb8-d711d558f975 |            22 |            22 | tcp      | 192.168.79.222 | 128.31.20.133 |
| df0afa25-777a-4e72-bbc9-e0bc24f49a01 |            80 |            80 | tcp      | 192.168.79.222 | 128.31.20.133 |
| ff10fdf7-d73d-4e19-8672-25e1c4758e33 |           443 |           443 | tcp      | 192.168.79.222 | 128.31.20.133 |
+--------------------------------------+---------------+---------------+----------+----------------+---------------+
@tzumainn
Copy link
Contributor

sure, why not!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants