The public cloud at OVH is based upon OpenStack. Whilst we can create our instances from a control panel with an graphical user interface, we can also look to make our instances directly from the command line. We can look to use the Openstack API commands to create as many instances as we need.
To create the instances, we need to prepare some parameters as they are needed for the instance to be created, we need to specify the instance type along with the operating system.
Flavor
The flavor is the instance characteristic, this defines the VCPU, RAM and the storage disk capacity.
root@mysuperweb.co.uk:~# nova flavor-list
+--------------------------------------+---------------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+---------------------+-----------+------+-----------+------+-------+-------------+-----------+
| 008f75de-c467-4d15-8f70-79c8fbe19538 | flavor1 | 120000 | 800 | 0 | | 32 | 1.0 | True |
| 0297d7ac-fe6f-4ff1-b6e7-0b8b0908c94f | flavor2 | 60000 | 1600 | 0 | | 16 | 1.0 | True |
| 039e31f2-6541-46c8-85cf-7f47fab7ad78 | flavor3 | 120000 | 50 | 0 | | 8 | 1.0 | True |
| 0417a0e6-f68a-4b8b-a642-ca5ecb9652f7 | flavor4 | 60000 | 400 | 0 | | 4 | 1.0 | True |
+--------------------------------------+---------------------+-----------+------+-----------+------+-------+-------------+-----------+
Image
Images are the operating system template which our instance will have. They will be used during the instance creation.
root@mysuperweb.co.uk:~# nova image-list
+--------------------------------------+-------------------------------+--------+--------------------------------------+
| ID | Name | Status | Server |
+--------------------------------------+-------------------------------+--------+--------------------------------------+
| 9f00f55b-8023-4d61-abe4-46bd7c182f22 | Debian 9 | ACTIVE | |
| 99727ff9-ec04-4775-a7ce-f9952b226e7d | Ubuntu 16.04 | ACTIVE | |
| 6b31e09c-b919-4a8d-ac9f-0db5d6418568 | Centos 7 | ACTIVE | |
| 4d384eee-86ee-44f3-bf03-df811de1350f | Windows 2016 Standard Server | ACTIVE | |
+--------------------------------------+-------------------------------+--------+--------------------------------------+
Network
All instances would need an network adapter for it to communicate with other services. During the instance creation we can look to assign an network adapter.
root@mysuperweb.co.uk:~# nova net-list
Our instance will have an network called “Ext-net”, this is the external network for our instance to communicate.
+--------------------------------------+--------------------------------------+------+
| ID | Label | CIDR |
+--------------------------------------+--------------------------------------+------+
| 3f4e3b19-4a46-4672-aade-5654d1fc0704 | Ext-Net | None |
+--------------------------------------+--------------------------------------+------+
Security groups
This is to define advance security groups for the instance, in our case we will use the default one.
The default one would simply be known as “default”.
Key name
The key is an SSH key, typically it would be an RSA type SSH key with 2048 bits as an minimum.
root@mysuperweb.co.uk:~# openstack keypair list
+--------------+-------------------------------------------------+
| Name | Fingerprint |
+--------------+-------------------------------------------------+
| openstackKey | 72:1f:ff:d1:d3:d9:64:12:b9:cc:15:95:c5:da:b6:08 |
+--------------+-------------------------------------------------+
Creating the instance
We now have all the details we need, we can start to create the instance with the full command of:
nova boot --flavor 008f75de-c467-4d15-8f70-79c8fbe19538 --image 9f00f55b-8023-4d61-abe4-46bd7c182f22 --nic net-id=3f4e3b19-4a46-4672-aade-5654d1fc0704 --security-group default --key-name openstackKey firstInstance