Questo contenuto non è disponibile nella lingua selezionata.
Chapter 8. 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.
8.1. Attaching a network to an instance Copia collegamentoCollegamento copiato negli appunti!
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
Identify the available networks and note the name or ID of the network that you want to attach to your instance:
openstack network list
(overcloud)$ openstack network listCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the network that you need is not available,create a new network:
openstack network create <network>
(overcloud)$ openstack network create <network>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Attach the network to your instance:
openstack server add network <instance> <network>
$ openstack server add network <instance> <network>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
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.
-
Replace
Additional resources
- openstack network create command in the Command Line Interface Reference.
- Creating a network in the Networking Guide.
8.2. Detaching a network from an instance Copia collegamentoCollegamento copiato negli appunti!
You can detach a network from an instance.
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
Identify the network that is attached to the instance:
openstack server show <instance>
(overcloud)$ openstack server show <instance>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Detach the network from the instance:
openstack server remove network <instance> <network>
$ openstack server remove network <instance> <network>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
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.
-
Replace
8.3. Attaching a port to an instance Copia collegamentoCollegamento copiato negli appunti!
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.
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.
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 NovaLibvirtNumPciePorts 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.
Prerequisites
- If attaching a port with an SR-IOV vNIC to an instance, there must be a free SR-IOV device on the host on the appropriate physical network, and the instance must have a free PCIe slot.
Procedure
Create the port that you want to attach to your instance:
openstack port create --network <network> [--vnic-type <vnic-type>] <port>
$ openstack port create --network <network> [--vnic-type <vnic-type>] <port>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
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.
-
Replace
Attach the port to your instance:
openstack server add port <instance> <port>
$ openstack server add port <instance> <port>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
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.
-
Replace
Verify that the port is attached to your instance:
openstack port list --device-id <instance_UUID>
$ openstack port list --device-id <instance_UUID>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<instance_UUID>with the UUID of the instance that you attached the port to.
Additional resources
- openstack port create command in the Command Line Interface Reference.
8.4. Detaching a port from an instance Copia collegamentoCollegamento copiato negli appunti!
You can detach a port from an instance.
Procedure
Identify the port that is attached to the instance:
openstack server show <instance>
(overcloud)$ openstack server show <instance>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Detach the port from the instance:
openstack server remove port <instance> <port>
$ openstack server remove port <instance> <port>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
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.
-
Replace
8.5. Attaching a volume to an instance Copia collegamentoCollegamento copiato negli appunti!
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 multi-attach volume. For more information about creating multi-attach volumes, see Volumes that can be attached to multiple instances.
Prerequisites
-
To attach a multi-attach volume, the environment variable
OS_COMPUTE_API_VERSIONis 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
-
Procedure
Identify the available volumes and note the name or ID of the volume that you want to attach to your instance:
openstack volume list
(overcloud)$ openstack volume listCopy to Clipboard Copied! Toggle word wrap Toggle overflow Attach the volume to your instance:
openstack server add volume <instance> <volume>
$ openstack server add volume <instance> <volume>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
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.NoteIf 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)
Multiattach volumes are only supported starting with compute API version 2.60. (HTTP 400) (Request-ID: req-3a969c31-e360-4c79-a403-75cc6053c9e5)Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can either set the environment variable
OS_COMPUTE_API_VERSION=2.72, or include the--os-compute-api-versionargument when adding the volume to the instance:openstack --os-compute-api-version 2.72 server add volume <instance> <volume>
$ openstack --os-compute-api-version 2.72 server add volume <instance> <volume>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
TipSpecify
--os-compute-api-version 2.20or higher to add a volume to an instance with statusSHELVEDorSHELVED_OFFLOADED.-
Replace
Confirm that the volume is attached to the instance or instances:
openstack volume show <volume>
$ openstack volume show <volume>Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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 | +-----------------------------------------------------+----------------------+---------+-----+-----------------------------------------------------------------------------------------------+
+-----------------------------------------------------+----------------------+---------+-----+-----------------------------------------------------------------------------------------------+ | 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 | +-----------------------------------------------------+----------------------+---------+-----+-----------------------------------------------------------------------------------------------+Copy to Clipboard Copied! Toggle word wrap Toggle overflow
8.6. Viewing the volumes attached to an instance Copia collegamentoCollegamento copiato negli appunti!
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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
8.7. Detaching a volume from an instance Copia collegamentoCollegamento copiato negli appunti!
You can detach a volume from an instance.
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.
Prerequisites
- 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.
Procedure
Identify the volume that is attached to the instance:
openstack server show <instance>
(overcloud)$ openstack server show <instance>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Detach the volume from the instance:
openstack server remove volume <instance> <volume>
$ openstack server remove volume <instance> <volume>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
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.NoteSpecify
--os-compute-api-version 2.20or higher to remove a volume from an instance with statusSHELVEDorSHELVED_OFFLOADED.
-
Replace