Openstack / Create New Volume
Create New Volume
Creates a new volume in OpenStack with specified characteristics.
openstack volume create --size <size_in_GB> --image <image_id> --snapshot <snapshot_id> --bootable <volume_name> openstack volume create --size <size_in_GB> --image <image_id> --snapshot <snapshot_id> --bootable <volume_name> #!/bin/bash
# Create New Volume
openstack volume create --size {{size_in_GB}} --image {{image_id}} --snapshot {{snapshot_id}} {{--bootable|--non-bootable}} {{volume_name}} import subprocess
# Create New Volume
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"openstack",
"volume",
"create",
"--size",
"<size_in_GB>",
"--image",
"<image_id>",
"--snapshot",
"<snapshot_id>",
"--bootable",
"<volume_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
During the provisioning phase for an application requiring dedicated storage solutions.
Pro Tip
Setting `--snapshot` can reduce provisioning time by creating a volume from a snapshot; verify snapshot status is 'available' before use.
Command Builder
Tune the command before you copy it
openstack volume create --size <size_in_GB> --image <image_id> --snapshot <snapshot_id> --bootable <volume_name> Anatomy of Output
Understanding the result
+--------------------------------------+---------+ Header: Volume Creation Result Indicates the results of the volume creation operation.
| id | abcdef01-1234-5678-90ab-cdef01234567 | Volume ID Unique identifier provided for the newly created volume.
| status | creating | Creation Status Describes the current creation status of the volume.
Troubleshooting
Common pitfalls
ERROR: InvalidInput: Required parameters missing.
Solution: Double-check that all mandatory parameters, such as size and image, are supplied.
ERROR: Snapshot not found or not available.
Solution: Ensure the specified snapshot exists and is in 'available' status for cloning.
ERROR: Image 'img-xyz' not found.
Solution: Confirm the image ID is valid and accessible to the project.
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.
-
<size_in_GB> - size in GB
- The value supplied for size in GB.
-
<image_id> - image id
- The value supplied for image id.
-
<snapshot_id> - snapshot id
- The value supplied for snapshot id.
-
--bootable - bootable| non bootable
- The value supplied for bootable| non bootable.
-
<volume_name> - volume name
- The value supplied for volume name.
-
--size - Command Option
- Tool-specific option used by this command invocation.
-
--image - Command Option
- Tool-specific option used by this command invocation.
-
--snapshot - Command Option
- Tool-specific option used by this command invocation.
-
--bootable - Command Option
- Tool-specific option used by this command invocation.
Alternative Approaches
Comparable commands in other tools
Alternative cloud infrastructure tools for the same job.
gcloud compute ssh <user>@<instance> Flyctl / View Status Of Specific Application flyctl status --app <app_name> Aws / Delete Eks Cluster 1608 aws eks delete-cluster --name <cluster_name> Gh / Create Codespace Github Interactively gh cs create Cradle / Submit Elasticsearch Schema cradle elastic map