Chapter 7. Updating an instance

You can add and remove additional resources from running instances, such as persistent volume storage, a network interface, or a public IP address. You can also update instance metadata and the security groups that the instance belongs to.

7.1. Attaching a network to an instance

You can attach a network to a running instance. When you attach a network to the instance, the Compute service creates the port on the network for the instance. Use a network to attach the network interface to an instance when you want to use the default security group and there is only one subnet on the network.

Procedure

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

    (overcloud)$ openstack network list

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

    (overcloud)$ openstack network create <network>
  2. Attach the network to your instance:

    $ openstack server add network <instance> <network>
    • 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.

Additional resources

7.2. Detaching a network from an instance

You can detach a network from an instance.

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:

    (overcloud)$ 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.

7.3. Attaching a port to an instance

You can attach a network interface to a running instance by using a port. You can attach a port to only one instance at a time. Use a port to attach the network interface to an instance when you want to use a custom security group, or when there are multiple subnets on the network.

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

You cannot attach a port with an SR-IOV vNIC to an instance, or a port with a guaranteed minimum bandwidth QoS policy.

Procedure

  1. Identify the available ports and note the name or ID of the port that you want to attach to your instance:

    (overcloud)$ openstack port list

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

    (overcloud)$ openstack port create --network <network> <port>
    • Replace <network> with the name or ID of the network to create the port on.
    • 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.

Additional resources

7.4. Detaching a port from an instance

You can detach a port from an instance.

Procedure

  1. Identify the port that is attached to the instance:

    (overcloud)$ 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.

7.5. Attaching a volume to an instance

You can attach a volume to an instance for persistent storage. You can attach a volume to only one instance at a time, unless the volume has been configured as a multiattach volume. For more information about creating multiattach-capable volumes, see Attach a volume to multiple instances.

Procedure

  1. Identify the available volumes and note the name or ID of the volume that you want to attach to your instance:

    (overcloud)$ openstack volume list
  2. Attach the volume to your instance:

    $ openstack server add volume <instance> <volume>
    • 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.

      Note

      Specify --os-compute-api-version 2.20 or higher to add a volume to an instance with status SHELVED or SHELVED_OFFLOADED.

7.6. Viewing the volumes attached to an instance

You can view the volumes attached to a particular instance.

Prerequisites

  • You are using python-openstackclient 5.5.0.

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       |
    +---------------------+----------+---------------------+-----------------------+

7.7. Detaching a volume from an instance

You can detach a volume from an instance.

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:

    (overcloud)$ 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.

7.8. Attaching a volume to multiple instances

You can attach multiple instances to the same Block Storage (cinder) volume when the volume is configured as multi-attach. Multi-attach gives multiple instances simultaneous read/write access to a single Block Storage volume. This is useful for deploying clustered database systems, such as MSSQL and Oracle. Multi-attach is supported by the Compute service (nova) libvirt driver, and the following Block Storage drivers:

  • Scaleio
  • Infinidat
  • Solidfire
  • Zfssaiscsi

Prerequisites

  • You must use Compute API version 2.60 or later. If you are using an earlier version of the API you will see the following error:

    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 run the command again using the --os-compute-api-version argument:

    $ openstack --os-compute-api-version 2.72 server add volume <instance_name> <volume_name>
  • Multi-attach volumes are supported in your project.

Procedure

  1. Identify the available volumes and note the name or ID of the volume that you want to attach to your instances:

    (overcloud)$ openstack volume list
  2. Ensure that your chosen volume is multi-attach capable:

    (overcloud)$ openstack volume show volMultiattach | grep multiattach
    | multiattach               | True       |
    | type                      | multiattach |
  3. Attach the volume to an instance:

    $ openstack server add volume <instance> <volume>
    • 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.
  4. Repeat steps 2 and 3 until all instances that you want to attach to the volume are attached.
  5. Verify the status of the volume and confirm that the instances are attached:

    $ openstack volume list
    +-----------------------------------------------------+----------------------+---------+-----+-----------------------------------------------------------------------------------------------+
    | 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  |
    +-----------------------------------------------------+----------------------+---------+-----+-----------------------------------------------------------------------------------------------+