Update an instance

Add and remove resources from running instances, such as persistent volume storage, network interfaces, or public IP addresses. Update instance metadata and the security groups that the instance belongs to.

Note

To run openstack client commands on the cloud, you must specify the name of the cloud detailed in your clouds.yaml file. You can specify the name of the cloud by using one of the following methods:

  • Use the --os-cloud option with each command, for example:
    $ openstack flavor list --os-cloud <cloud_name>

    Use this option if you access more than one cloud.

  • Create an environment variable for the cloud name in your bashrc file:
    `export OS_CLOUD=<cloud_name>`

Attach a network to an instance

Attach a network to a running instance to add a network interface. The Compute service (nova) creates the port automatically. Use this method when you want the default security group and there is only one subnet.

Before you begin

  • The administrator has created a project for you and they have provided you with a clouds.yaml file for you to access the cloud.
  • You have installed the python-openstackclient package.

Procedure

  1. Identify the available networks and note the name or ID of the network that you want to attach to your instance:
    $ openstack network list

    If the network that you need is not available, create a new network:

    $ openstack network create <network>
  2. Attach the network to your instance:
    $ openstack server add network [--tag <tag_name>] <instance> <network>
    • Optional: Include the --tag option and replace <tag_name> with the name of a tag for your virtual NIC device.
    • Replace <instance> with the name or ID of the instance that you want to attach the network to.
    • Replace <network> with the name or ID of the network that you want to attach to the instance. Tip
      To tag a virtual device at server creation time, see Tag virtual devices.

Detach a network from an instance

Detach a network from an instance to remove all its ports. To detach only a specific port while keeping other ports on the same network, detach the port instead.

Before you begin

  • The administrator has created a project for you and they have provided you with a clouds.yaml file for you to access the cloud.
  • You have installed the python-openstackclient package.

About this task

Note
Detaching the network detaches all network ports. If the instance has multiple ports on a network and you want to detach only one of those ports, follow the Detaching a port from an instance procedure to detach the port.

Procedure

  1. Identify the network that is attached to the instance:
    $ openstack server show <instance>
  2. Detach the network from the instance:
    $ openstack server remove network <instance> <network>
    • Replace <instance> with the name or ID of the instance that you want to remove the network from.
    • Replace <network> with the name or ID of the network that you want to remove from the instance.

Attach a port to an instance

Attach a network interface to a running instance by using a port. A port can be attached to only one instance at a time. Use a port instead of a network when you need a custom security group or there are multiple subnets.

Before you begin

  • If you are attaching a port with an SR-IOV vNIC to an instance, you have a free SR-IOV device on the host on the appropriate physical network, and the instance has a free PCIe slot.
  • The administrator has created a project for you and they have provided you with a clouds.yaml file for you to access the cloud.
  • You have installed the python-openstackclient package.

About this task

Tip
If you attach the network interface by using a network, the port is created automatically. For more information, see Attaching a network to an instance.
Note
Red Hat OpenStack Platform (RHOSP) provides up to 24 interfaces for each instance. By default, you can add up to 16 PCIe devices to an instance before you must reboot the instance to add more. The RHOSP administrator can use the num_pcie_ports parameter to configure the number of PCIe devices that can be added to an instance, before a reboot of the instance is required to add more devices.

Procedure

  1. Create the port that you want to attach to your instance:
    $ openstack port create --network <network> [--vnic-type <vnic-type>] <port>
    • Replace <network> with the name or ID of the network to create the port on.
    • Optional: To create an SR-IOV port, replace <vnic-type> with one of the following values:
      • direct: Creates a direct mode SR-IOV virtual function (VF) port.
      • direct-physical: Creates a direct mode SR-IOV physical function (PF) port.
      • macvtap: Creates an SR-IOV port that is attached to the instance through a MacVTap device.
    • Replace <port> with the name or ID of the port that you want to attach to the instance.
  2. Attach the port to your instance:
    $ openstack server add port <instance> <port>
    • Replace <instance> with the name or ID of the instance that you want to attach the port to.
    • Replace <port> with the name or ID of the port that you want to attach to the instance.
  3. Verify that the port is attached to your instance:
    $ openstack port list --device-id <instance_UUID>

    Replace <instance_UUID> with the UUID of the instance that you attached the port to.

Detach a port from an instance

Detach a specific port from an instance to remove a single network interface without affecting other ports on the same network.

Before you begin

  • The administrator has created a project for you and they have provided you with a clouds.yaml file for you to access the cloud.
  • You have installed the python-openstackclient package.

Procedure

  1. Identify the port that is attached to the instance:
    $ openstack server show <instance>
  2. Detach the port from the instance:
    $ openstack server remove port <instance> <port>
    • Replace <instance> with the name or ID of the instance that you want to remove the port from.
    • Replace <port> with the name or ID of the port that you want to remove from the instance.

Attach a volume to an instance

Attach a volume to an instance for persistent storage. A volume can be attached to only one instance at a time, unless it is configured as a multi-attach volume.

Before you begin

  • To attach a multi-attach volume, the environment variable OS_COMPUTE_API_VERSION is set to 2.60 or later.
  • The instance is fully operational, or fully stopped. You cannot attach a volume to an instance when the instance is in the process of booting up or shutting down.
  • To attach more than 26 volumes to your instance, the image you used to create the instance must have the following properties:
    • hw_scsi_model=virtio-scsi
    • hw_disk_bus=scsi
  • The administrator has created a project for you and they have provided you with a clouds.yaml file for you to access the cloud.
  • You have installed the python-openstackclient package.

Procedure

  1. Identify the available volumes and note the name or ID of the volume that you want to attach to your instance:
    $ openstack volume list
  2. Attach the volume to your instance:
    $ openstack server add volume [--tag <tag_name>] <instance> <volume>
    • Optional: Include the --tag option and replace <tag_name> with the name of a tag for your virtual storage device.
    • Replace <instance> with the name or ID of the instance that you want to attach the volume to.
    • Replace <volume> with the name or ID of the volume that you want to attach to the instance. Tip
      To tag a virtual device at server creation time, see Tagging virtual devices.
      Note

      If the command returns the following error, the volume you chose to attach to the instance is a multi-attach volume, therefore you must use Compute API version 2.60 or later:

      Multiattach volumes are only supported starting with compute API version 2.60. (HTTP 400) (Request-ID: req-3a969c31-e360-4c79-a403-75cc6053c9e5)

      You can either set the environment variable OS_COMPUTE_API_VERSION=2.72, or include the --os-compute-api-version argument when adding the volume to the instance:

      $ openstack --os-compute-api-version 2.72 server add volume <instance> <volume>
    Tip
    Specify --os-compute-api-version 2.20 or higher to add a volume to an instance with status SHELVED or SHELVED_OFFLOADED.
  3. Confirm that the volume is attached to the instance or instances:
    $ openstack volume show <volume>

    Replace <volume> with the name or ID of the volume to display.

    Example output:

    +-----------------------------------------------------+----------------------+---------+-----+-----------------------------------------------------------------------------------------------+
    | ID                                                             | Name                | Status | Size| Attached to
    +-----------------------------------------------------+---------------------+---------+------+---------------------------------------------------------------------------------------------+
    | f3fb92f6-c77b-429f-871d-65b1e3afa750 | volMultiattach | in-use |   50 | Attached to instance1 on /dev/vdb Attached to instance2 on /dev/vdb  |
    +-----------------------------------------------------+----------------------+---------+-----+-----------------------------------------------------------------------------------------------+

View the volumes attached to an instance

View the volumes attached to an instance to verify storage assignments before performing operations.

Before you begin

  • You are using python-openstackclient 5.5.0.
  • The administrator has created a project for you and they have provided you with a clouds.yaml file for you to access the cloud.
  • You have installed the python-openstackclient package. * .Procedure
  • List the volumes attached to an instance:
    $ openstack server volume list <instance>
    +---------------------+----------+---------------------+-----------------------+
    | ID                  | Device   | Server ID           | Volume ID             |
    +---------------------+----------+---------------------+-----------------------+
    | 1f9dcb02-9a20-4a4b- | /dev/vda | ab96b635-1e63-4487- | 1f9dcb02-9a20-4a4b-9f |
    | 9f25-c7846a1ce9e8   |          | a85c-854197cd537b   | 25-c7846a1ce9e8       |
    +---------------------+----------+---------------------+-----------------------+

Detach a volume from an instance

Detach a volume from an instance to release the persistent storage. The volume data is preserved and can be reattached to another instance.

Before you begin

  • The instance is fully operational, or fully stopped. You cannot detach a volume from an instance when the instance is in the process of booting up or shutting down.
  • The administrator has created a project for you and they have provided you with a clouds.yaml file for you to access the cloud.
  • You have installed the python-openstackclient package.

About this task

Note
Detaching the network detaches all network ports. If the instance has multiple ports on a network and you want to detach only one of those ports, follow the Detaching a port from an instance procedure to detach the port.

Procedure

  1. Identify the volume that is attached to the instance:
    $ openstack server show <instance>
  2. Detach the volume from the instance:
    $ openstack server remove volume <instance> <volume>
    • Replace <instance> with the name or ID of the instance that you want to remove the volume from.
    • Replace <volume> with the name or ID of the volume that you want to remove from the instance. Note
      Specify --os-compute-api-version 2.20 or higher to remove a volume from an instance with status SHELVED or SHELVED_OFFLOADED.