3.10. Managing Virtual Machines

3.10.1. Creating Virtual Machines

3.10.1.1. Syntax

usage: vinfra service compute server create [-h] [-f {json,table,value,yaml}]
                                            [-c COLUMN] [--wait]
                                            [--timeout <seconds>]
                                            [--description <description>]
                                            [--metadata <metadata>]
                                            [--user-data <user-data>]
                                            [--key-name <key-name>]
                                            [--config-drive] [--count <count>]
                                            --network
                                            <id=id[,mac=mac,fixed-ip=ip-addr,spoofing-protection=on|off]>|id
                                            --volume
                                            <source=source[,id=id,key1=value1,key2=value2...]>
                                            --flavor <flavor>
                                            <server-name>

Create a new compute server.

positional arguments:
  <server-name>         A new name for the compute server

optional arguments:
  -h, --help            show this help message and exit
  --description <description>
                        Server description
  --metadata <metadata>
                        Server metadata
  --user-data <user-data>
                        User data file
  --key-name <key-name>
                        Key pair to inject
  --config-drive        Use an ephemeral drive
  --count <count>       If count is specified and greater than 1, the 'name'
                        argument is treated as a naming pattern.
  --network <id=id[,mac=mac,fixed-ip=ip-addr,spoofing-protection=on|off]>|id
                        Create a compute server with a specified network.
                        Specify this option multiple times to create multiple
                        networks.
                        id: attach network interface to a specified network
                        (ID or name);
                        mac: MAC address for network interface (optional);
                        fixed-ip: fixed IP address for network interface
                        (optional);
                        spoofing-protection: enable or disable spoofing
                        protection for network interface ('on' or 'off')
                        (optional).
  --volume <source=source[,id=id,key1=value1,key2=value2...]>
                        Create a compute server with a specified volume.
                        Specify this option multiple times to create multiple
                        volumes.
                        source: source type ('volume', 'image', 'snapshot', or
                        'blank');
                        id: resource ID or name for the specified source type
                        (required for source types 'volume', 'image', and
                        'snapshot');
                        size: block device size, in gigabytes (required for
                        source types 'image' and 'blank');
                        boot-index: block device boot index (required for
                        multiple volumes with source type 'volume');
                        bus: block device controller type ('ide', 'usb',
                        'virtio', 'scsi, or 'sata') (optional);
                        type: block device type (disk or cdrom) (optional);
                        rm: remove block device on compute server termination
                        ('yes' or 'no') (optional);
                        storage-policy: block device storage policy
                        (optional).
  --flavor <flavor>     Flavor ID or name
...

3.10.1.2. Sample Output

This command creates a virtual machine `myvm based on the default Cirros image and the flavor tiny and connects it to the network private with the fixed IP address 192.168.128.100.

# vinfra service compute server create myvm \
--network id=private,fixed-ip=192.168.0.100 \
--volume source=image,id=cirros,size=1 --flavor tiny
+--------------+--------------------------------------+
| Field        | Value                                |
+--------------+--------------------------------------+
| config_drive |                                      |
| created      | 2018-09-12T13:25:02Z                 |
| description  |                                      |
| flavor       | 100                                  |
| host         |                                      |
| id           | f6656fb5-e165-4afa-a119-45882acc6af1 |
| key_name     |                                      |
| metadata     | {}                                   |
| name         | myvm                                 |
| networks     | []                                   |
| power_state  | NOSTATE                              |
| project_id   | 72a5db3a033c403a86756021e601ef34     |
| status       | BUILD                                |
| task_state   | scheduling                           |
| updated      | 2018-09-12T13:25:03Z                 |
| user_data    |                                      |
| volumes      | []                                   |
+--------------+--------------------------------------+

3.10.2. Listing Virtual Machines

3.10.2.1. Syntax

usage: vinfra service compute server list [-h] [-f {json,table,value,yaml}]
                                          [-c COLUMN]

List compute servers.
...

3.10.2.2. Sample Output

This command lists all virtual machines in the compute cluster.

# vinfra service compute server list
+--------------------------------------+------+--------+-----------------------------------+
| id                                   | name | status | host                              |
+--------------------------------------+------+--------+-----------------------------------+
| 8cd29296-8bee-4efb-828d-0e522d816c6e | myvm | ACTIVE | stor-4.example.com.vstoragedomain |
+--------------------------------------+------+--------+-----------------------------------+

3.10.3. Showing Virtual Machine Details

3.10.3.1. Syntax

usage: vinfra service compute server show [-h] [-f {json,table,value,yaml}]
                                          [-c COLUMN]
                                          <server>

Display compute server details.

positional arguments:
  <server>              Compute server ID or name
...

3.10.3.2. Sample Output

This command shows the details of the virtual machine myvm.

# vinfra service compute server show myvm
+--------------+--------------------------------------------+
| Field        | Value                                      |
+--------------+--------------------------------------------+
| config_drive |                                            |
| created      | 2018-09-12T13:30:02Z                       |
| description  |                                            |
| flavor       | 100                                        |
| host         | stor-4.example.com.vstoragedomain          |
| id           | 8cd29296-8bee-4efb-828d-0e522d816c6e       |
| key_name     |                                            |
| metadata     | {}                                         |
| name         | myvm                                       |
| networks     | - id: 1bf2c9da-e324-49f0-8d41-20410615f905 |
|              |   ipam_enabled: true                       |
|              |   ips:                                     |
|              |   - 192.168.128.100                        |
|              |   mac_addr: fa:16:3e:54:04:f0              |
|              |   name: private                            |
|              |   spoofing_protection: false               |
| power_state  | RUNNING                                    |
| project_id   | 72a5db3a033c403a86756021e601ef34           |
| status       | ACTIVE                                     |
| task_state   |                                            |
| updated      | 2018-09-12T13:30:53Z                       |
| user_data    |                                            |
| volumes      | - 30092d44-3bdd-46d8-a360-a5bc6434cbf8     |
+--------------+--------------------------------------------+

3.10.4. Showing Virtual Machine Statistics

3.10.4.1. Syntax

usage: vinfra service compute server stat [-h] [-f {json,table,value,yaml}]
                                          [-c COLUMN]
                                          <server>

Display compute server statistics.

positional arguments:
  <server>              Compute server ID or name
...

3.10.4.2. Sample Output

This command shows the statistics for the virtual machine myvm.

# vinfra service compute server stat myvm
+----------+----------------------------------+
| Field    | Value                            |
+----------+----------------------------------+
| datetime | 2018-09-12T13:37:46.803999+00:00 |
| metrics  | block_capacity: 1073741824       |
|          | block_usage: 134549504           |
|          | cpu_usage: 0                     |
|          | mem_total: 536870912             |
|          | mem_usage: 130412544             |
|          | vcpus: 1                         |
+----------+----------------------------------+

3.10.5. Attaching Networks to Virtual Machines

3.10.5.1. Syntax

usage: vinfra service compute server iface attach [-h]
                                                  [-f {json,table,value,yaml}]
                                                  [-c COLUMN] [--mac <mac>]
                                                  [--ip <ip-address>]
                                                  [--spoofing-protection {on,off}]
                                                  --server <server> --network
                                                  <network>

Attach a network to a compute server.

optional arguments:
  -h, --help            show this help message and exit
  --mac <mac>           MAC address
  --ip <ip-address>     IP address
  --spoofing-protection {on,off}
                        Enable spoofing protection for the network interface.
  --server <server>     Compute server ID or name
  --network <network>   Network ID or name
...

3.10.5.2. Sample Output

This command attaches the private network myprivnet to the virtual machine myvm.

# vinfra service compute server iface attach myprivnet --server myvm
+---------------+--------------------------------------+
| Field         | Value                                |
+---------------+--------------------------------------+
| fixed_ip      | 192.168.129.8                        |
| id            | 690ed3f2-2301-40e2-879a-126db2ecb57b |
| mac_address   | fa:16:3e:54:59:08                    |
| network_id    | 0710372e-2bdf-4dfe-b413-eb763da37e68 |
| spoofing<...> | False                                |
+---------------+--------------------------------------+

3.10.6. Listing Virtual Machine Networks

3.10.6.1. Syntax

usage: vinfra service compute server iface list [-h]
                                                [-f {json,table,value,yaml}]
                                                [-c COLUMN] --server <server>

List compute server networks.

optional arguments:
  -h, --help            show this help message and exit
  --server <server>     Compute server ID or name
...

3.10.6.2. Sample Output

This command lists the virtual networks that the virtual machine myvm is attached to. It also shows VM’s IP address in each network.

# vinfra service compute server iface list --server myvm
+----------------+----------------+-------------------+-----------------+
| id             | network_id     | mac_address       | fixed_ip        |
+----------------+----------------+-------------------+-----------------+
| 690ed3f2-<...> | 0710372e-<...> | fa:16:3e:54:59:08 | 192.168.129.8   |
| a5b13bf3-<...> | 1bf2c9da-<...> | fa:16:3e:b9:33:bb | 192.168.128.100 |
+----------------+----------------+-------------------+-----------------+

3.10.7. Detaching Networks from Virtual Machines

3.10.7.1. Syntax

usage: vinfra service compute server iface detach [-h] --server <server>
                                                  <interface>

Detach a network interface from a compute server.

positional arguments:
  <interface>        Network interface ID

optional arguments:
  -h, --help         show this help message and exit
  --server <server>  Compute server ID or name

3.10.7.2. Sample Output

This command detaches the network interface with the ID 471e37fd-13ae-4b8f-b70c-90ac02cc4386 from the VM with the ID 6c80b07f-da46-4a8a-89a4-eecb8faceb27.

# vinfra service compute server iface detach 471e37fd-13ae-4b8f-b70c-90ac02cc4386 \
--server 6c80b07f-da46-4a8a-89a4-eecb8faceb27
Operation successful

3.10.8. Accessing Virtual Machine Log

3.10.8.1. Syntax

usage: vinfra service compute server log [-h] <server>

Display compute server log.

positional arguments:
  <server>    Compute server ID or name
...

3.10.8.2. Sample Output

This command prints the log of the virtual machine myvm to the file myvm.log.

# vinfra service compute server log myvm > myvm.log

3.10.9. Migrating Virtual Machines

3.10.9.1. Syntax

usage: vinfra service compute server migrate [-h] [--cold] [--node NODE]
                                             <server>

Migrate a compute server to another host.

positional arguments:
  <server>     Compute server ID or name

optional arguments:
  -h, --help   show this help message and exit
  --cold       Perform cold migration. If not set, try to determine migration
               type automatically.
  --node NODE  Destination node ID or hostname

3.10.9.2. Sample Output

This command starts migration of the VM with the ID 6c80b07f-da46-4a8a-89a4-eecb8faceb27 to the compute node with the ID e6255aed-d6e7-41b2-ba90-86164c1cd9a6.

# vinfra service compute server migrate 6c80b07f-da46-4a8a-89a4-eecb8faceb27 \
--node e6255aed-d6e7-41b2-ba90-86164c1cd9a6
Operation successful

3.10.10. Changing Virtual Machine Flavors

3.10.10.1. Syntax

usage: vinfra service compute server resize [-h] [-f {json,table,value,yaml}]
                                            [-c COLUMN] [--wait]
                                            [--timeout <seconds>] --flavor
                                            <flavor>
                                            <server>

Resize a compute server.

positional arguments:
  <server>              Compute server ID or name

optional arguments:
  -h, --help            show this help message and exit
  --flavor <flavor>     Apply flavor with ID or name.
...

3.10.10.2. Sample Output

This command changes the flavor of the virtual machine myvm to small.

# vinfra service compute server resize myvm --flavor small
Operation successful

3.10.11. Starting Virtual Machines

3.10.11.1. Syntax

usage: vinfra service compute server start [-h] [-f {json,table,value,yaml}]
                                           [-c COLUMN] [--wait]
                                           [--timeout <seconds>]
                                           <server>

Start a compute server.

positional arguments:
  <server>              Compute server ID or name
...

3.10.11.2. Sample Output

This command starts the virtual machine myvm.

# vinfra service compute server start myvm
Operation successful

3.10.12. Pausing Virtual Machines

3.10.12.1. Syntax

usage: vinfra service compute server pause [-h] [-f {json,table,value,yaml}]
                                           [-c COLUMN] [--wait]
                                           [--timeout <seconds>]
                                           <server>

Pause a compute server.

positional arguments:
  <server>              Compute server ID or name
...

3.10.12.2. Sample Output

This command pauses the running virtual machine myvm.

# vinfra service compute server pause myvm

3.10.13. Unpausing Virtual Machines

3.10.13.1. Syntax

usage: vinfra service compute server unpause [-h] [-f {json,table,value,yaml}]
                                             [-c COLUMN] [--wait]
                                             [--timeout <seconds>]
                                             <server>

Unpause a compute server.

positional arguments:
  <server>              Compute server ID or name
...

3.10.13.2. Sample Output

This command unpauses the paused virtual machine myvm.

# vinfra service compute server unpause myvm

3.10.14. Suspending Virtual Machines

3.10.14.1. Syntax

usage: vinfra service compute server suspend [-h] [-f {json,table,value,yaml}]
                                             [-c COLUMN] [--wait]
                                             [--timeout <seconds>]
                                             <server>

Suspend a compute server.

positional arguments:
  <server>              Compute server ID or name
...

3.10.14.2. Sample Output

This command suspends the running virtual machine myvm.

# vinfra service compute server suspend myvm
Operation successful

3.10.15. Resuming Virtual Machines

3.10.15.1. Syntax

usage: vinfra service compute server resume [-h] [-f {json,table,value,yaml}]
                                            [-c COLUMN] [--wait]
                                            [--timeout <seconds>]
                                            <server>

Resume a compute server.

positional arguments:
  <server>              Compute server ID or name
...

3.10.15.2. Sample Output

This command resumes the suspended virtual machine myvm.

# vinfra service compute server resume myvm
Operation successful

3.10.16. Rebooting Virtual Machines

3.10.16.1. Syntax

usage: vinfra service compute server reboot [-h] [-f {json,table,value,yaml}]
                                            [-c COLUMN] [--wait]
                                            [--timeout <seconds>] [--hard]
                                            <server>

Reboot a compute server.

positional arguments:
  <server>              Compute server ID or name

optional arguments:
  -h, --help            show this help message and exit
  --hard                Perform hard reboot.
...

3.10.16.2. Sample Output

This command reboots the virtual machine myvm.

# vinfra service compute server reboot myvm
Operation successful

3.10.17. Resetting Virtual Machines

3.10.17.1. Syntax

usage: vinfra service compute server reset-state [-h]
                                                 [-f {json,table,value,yaml}]
                                                 [-c COLUMN] [--wait]
                                                 [--timeout <seconds>]
                                                 [--state-error]
                                                 <server>

Reset compute server state.

positional arguments:
  <server>              Compute server ID or name

...

3.10.17.2. Sample Output

This command resets the state of the virtual machine myvm.

# vinfra service compute server reset-state myvm
Operation successful

3.10.18. Stopping Virtual Machines

3.10.18.1. Syntax

usage: vinfra service compute server stop [-h] [-f {json,table,value,yaml}]
                                          [-c COLUMN] [--wait]
                                          [--timeout <seconds>] [--hard]
                                          <server>

Shut down a compute server.

positional arguments:
  <server>              Compute server ID or name

optional arguments:
  -h, --help            show this help message and exit
  --hard                Power off a compute server.
...

3.10.18.2. Sample Output

This command stops the virtual machine myvm.

# vinfra service compute server stop myvm
Operation successful

3.10.19. Evacuating Virtual Machines

3.10.19.1. Syntax

usage: vinfra service compute server evacuate [-h] <server>

Evacuate a stopped compute server from a failed host.

positional arguments:
  <server>    Compute server ID or name
...

3.10.19.2. Sample Output

This command evacuates the stopped VM myvm from its node to another, healthy compute node.

# vinfra service compute server evacuate ``myvm``
Operation successful

3.10.20. Deleting Virtual Machines

3.10.20.1. Syntax

usage: vinfra service compute server delete [-h] [-f {json,table,value,yaml}]
                                            [-c COLUMN] [--wait]
                                            [--timeout <seconds>]
                                            <server>

Delete a compute server.

positional arguments:
  <server>              Compute server ID or name
...

3.10.20.2. Sample Output

This command deletes the virtual machine myvm.

# vinfra service compute server delete myvm
Operation successful