Commandes de base#
FIXME: Basic Openstack commands and usage
Understanding the Openstack command-line client#
- Overview of the
openstack
command-line client and its usage - Understanding the structure and syntax of openstack commands
- Exploring the various openstack commands and options available
Basic usage of the openstack client to interact with Openstack services#
- Using the openstack client to authenticate and connect to an Openstack cloud
- Performing basic operations on Openstack services such as creating, listing, and deleting resources
- Understanding the openstack output format and how to interpret it
Virtual machines and instances#
Using the openstack client to create, start, stop, and delete virtual machines and instances#
openstack server create \
--image Ubuntu-20.04 \
--flavor m1.medium \
--network my_network \
--security-group my_security_group my_vm
openstack server start my_vm
openstack server stop my_vm
openstack server reboot --hard my_vm
openstack server delete my_vm
Managing virtual machine metadata and user data#
openstack server set \
--property user_data="#!/bin/bash\necho 'Hello World'\n" my_vm
Attaching and detaching volumes to instances#
openstack server add volume my_vm my_volume
openstack server remove volume my_vm my_volume
Using the openstack client to connect to instances using ssh#
Use the openstack server list command to find the IP address of an instance:
openstack server list
Use the ssh command to connect to the instance
Flavors and images#
Configuring flavors#
- To list all existing flavors, use the command openstack flavor list
- To create a new flavor, use the command
openstack flavor create --ram <ram_size> --vcpus <vcpu_count> --disk <disk_size> <flavor_name>
- To show details for a specific flavor, use the command
openstack flavor show <flavor_name>
- To delete a flavor, use the command
openstack flavor delete <flavor_name>
Managing images#
- To list all existing images, use the command
openstack image list
- To upload a new image, use the command
openstack image create \ --container-format <container_format> \ --disk-format <disk_format> \ --file <image_file> <image_name>
- To show details for a specific image, use the command
openstack image show <image_name>
- To delete an image, use the command
openstack image delete <image_name>
Note:
- In order to create an image using "openstack server image create" command, the instance should be in shutdown state
- Make sure you are providing the right container-format and disk-format when uploading an image
Creating a new image from an existing instance#
- To create an image from an existing instance, use the command
openstack server image create --name <image_name> <instance_name> (--wait)
- When you create a new image from an existing instance, you are essentially taking a snapshot of the instance's current state and creating a new image from it.
- When you create an image from an existing instance, a copy of the root file system of the instance will be captured and stored as an image. This image will include all data, configurations and settings from the moment the image is created. This image can be used to create new instances later on, with identical or similar configuration as the original instance.
Understanding the concept of public and private images#
Public images
- are accessible to all users and projects within an OpenStack cloud.
- They are typically used for common operating systems and application images that are intended to be shared and reused across an organization.
Private images
- Only accessible to the user or project that created or owns the image.
- They are typically used for custom images or images that contain sensitive data and are intended to be used by specific users or projects only.
- By default, images are set to private
To make an image public, use the command
openstack image set --public <image_name>
To make an image private, use the command
openstack image set --private <image_name>
Lab session:#
- Authentication to OpenStack using openstack command
- Creating virtual machines, instances and managing them
- Managing flavor and images and related operations
- Adding metadata and user data
- Attaching and Detaching Volumes to instances
- Connecting instances using ssh