# Testing VM Connectivity

Connectivity to a specific VM instance can be tested by ping from DHCP server
using either the GUI or CLI.

## Test Connectivity with GUI

1. Navigate to the **Compute** > **Instances** view.
2. Select a specific instance and select **More** from the top menu.

   ![test-connectivity](media/test-connectivity.png)
3. Select **Test Connectivity**. The Test Connectivity window is displayed.

   ![test-connectivity-window](media/test-connectivity-window.png)
4. Select either **arping** or **ping** for the connectivity test.
5. Click **OK**. A message is displayed that the connectivity test is taking place.
6. A few seconds later, the test results will be displayed indicting success
   or failure as well as other relevant details. This status report is also
   available in the right-hand sidebar.

## Test Connectivity with CLI

1. The ‘guestnet-admin-tool ping-vm create’ command which tests the VMs
   connectivity requires the ID of the given VM.
   Note: ‘–command-type’ is either ‘ping’ (default) or ‘arping’
   ```default
   guestnet-admin-tool ping-vm create [-h]
                                      [-f {adaptive_table,json,shell,table,value,yaml}]
                                      [-c COLUMN] [--max-width <integer>]
                                      [--noindent] [--prefix PREFIX]
                                      [-m [NAME=VALUE [NAME=VALUE ...]]]
                                      [--command-type COMMAND_TYPE]
                                      [--name NAME]
                                      vm_id
   ```
2. Run the ‘vm list’ command to locate the ID of  VM-1.
   ```default
   vm list -c id -c name
   ```
3. This returns a list of VMs and their IDs.
   ```default
   +--------------------------------------+-----------------------------------------------------+
   | id                                   | name                                                |
   +======================================+=====================================================+
   | cfdb1753-f8e6-4d32-8ec8-e22d76fbc11e | VM-1                                                |
   +--------------------------------------+-----------------------------------------------------+
   ```
4. Test connectivity for VM-1.
   ```default
   guestnet-admin-tool ping-vm create cfdb1753-f8e6-4d32-8ec8-e22d76fbc11e
   ```
5. This returns a temporary, pending status of the VM’s connectivity.
   ```default
   +--------------+--------------------------------------+
   | id           | a8c3ee99-8966-4f7c-b127-6ce31c397b2d |
   | name         | none                                 |
   | status       | pending                              |
   | command_type | ping                                 |
   | created_at   | 2019-05-07T13:40:02.132361           |
   | output       | -                                    |
   | project_id   | bd616bd0a58f467cb0e96eeb5af6b53c     |
   | updated_at   | 2019-05-07T13:40:02.132369           |
   | user_id      | admin                                |
   | vm_id        | cfdb1753-f8e6-4d32-8ec8-e22d76fbc11e |
   +--------------+--------------------------------------+
   ```
6. Wait a few seconds and then request the final status of this VM connectivity
   test using the ‘guestnet-admin-tool ping-vm get ping_vm_id‘.
   ```default
   guestnet-admin-tool ping-vm get a8c3ee99-8966-4f7c-b127-6ce31c397b2d
   ```
7. This returns the final, succeeded/failed status of the VM connectivity
   test with relevant output details.
   ```default
   +--------------+----------------------------------------------------------------+
   | id           | a8c3ee99-8966-4f7c-b127-6ce31c397b2d                           |
   | name         | none                                                           |
   | status       | succeeded                                                      |
   | command_type | ping                                                           |
   | created_at   | 2019-05-07T13:40:02                                            |
   |              +----------------------------------------------------------------+
   | output       | PING 10.11.12.10 (10.11.12.10) 56(84) bytes of data.           |
   |              | 64 bytes from 10.11.12.10: icmp_seq=1 ttl=64 time=2.33 ms      |
   |              | 64 bytes from 10.11.12.10: icmp_seq=2 ttl=64 time=0.369 ms     |
   |              |                                                                |
   |              | --- 10.11.12.10 ping statistics ---                            |
   |              | 2 packets transmitted, 2 received, 0% packet loss, time 1001ms |
   |              | rtt min/avg/max/mdev = 0.369/1.350/2.332/0.982 ms              |
   |              |                                                                |
   |              +----------------------------------------------------------------+
   | project_id   | bd616bd0a58f467cb0e96eeb5af6b53c                               |
   | updated_at   | 2019-05-07T13:40:04                                            |
   | user_id      | admin                                                          |
   | vm_id        | cfdb1753-f8e6-4d32-8ec8-e22d76fbc11e                           |
   +--------------+----------------------------------------------------------------+
   ```

## Additional Commands for VM Connectivity Testing

1. Delete a specific VM connectivity test
   ```default
   guestnet-admin-tool ping-vm delete ping_vm_id
   ```
2. List all VM connectivity tests for a specific VM
   ```default
   guestnet-admin-tool ping-vm list --vm-id VM_ID
   ```
3. List all VM connectivity tests for all VMs
   ```default
   guestnet-admin-tool ping-vm list
   ```
