Openstack / Delete Port
Delete Port
Delete a specified port from OpenStack.
openstack port delete <port_id_or_name> openstack port delete <port_id_or_name> #!/bin/bash
# Delete Port
openstack port delete {{port_id_or_name}} import subprocess
# Delete Port
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"openstack",
"port",
"delete",
"<port_id_or_name>"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: openstack not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
When decommissioning compute resources to reclaim network capacity.
Pro Tip
Ensure the port is not active or in use by a device, or the deletion will fail.
Warning
Destructive operation. Confirm the target path and keep a backup before executing.
Anatomy of Output
Understanding the result
+--------------------------------+ Output Header Confirms deletion of the specified port.
| Deleted port: 12345678-abcd-ef00-1111-223344556677 | Confirmation Indicates successful deletion of the port.
Troubleshooting
Common pitfalls
Port is in use (HTTP 409)
Solution: Detach the port from any connected device before deletion.
Not found (HTTP 404)
Solution: Ensure the port ID or name is correct.
Unauthorized (HTTP 401)
Solution: Check user permissions and project's context.
Command Breakdown
What each part is doing
-
openstack - Base Command
- The executable that performs this operation. Here it runs Openstack before the shell applies any redirect operators.
-
<port_id_or_name> - port id or name
- The port value supplied to this command.
Alternative Approaches
Comparable commands in other tools
Alternative networking tools for the same job.
dnsmasq --version Curl / Send Form Encoded Data curl -X POST -d '<name=bob>' {http://example.com/form} Openvpn / Connect To Host With Same Static Key sudo openvpn --remote <bob.example.com> --dev <tun1> --ifconfig <10.4.0.2> <10.4.0.1> --secret <path/to/key> Ifconfig / Convert Command Output To Json Via Pipe <ifconfig> | jc <--ifconfig> Jc / Convert Command Output To Json Via Magic Syntax jc <ifconfig>