ConoHaをOpenStackコマンドで見てみると（構築関連）

OpenStackにはPythonで書かれた[コマンドラインクライアント](https://pypi.python.org/pypi/python-openstackclient/)がある。
これでConoHaのAPIを叩くとどんな感じになるかチェックしてみた。

(確認: 2017年11月)

# イメージ

```console
% openstack image list
+--------------------------------------+--------------------------------------------+--------+
| ID                                   | Name                                       | Status |
+--------------------------------------+--------------------------------------------+--------+
| a28ad8eb-a23b-45c1-83f6-1b7b17a0ac89 | vmi-arch-amd64                             | active |
| 26ef30ba-5d04-4ffe-91eb-58c069927dc3 | vmi-arch-amd64-20gb                        | active |
| b6648f3e-d232-4e19-9cc4-89043cad55eb | vmi-basercms-4.0-centos-7.3-unified        | active |
| dbaae5d7-0393-4897-808e-27559bd2528f | vmi-basercms-4.0-centos-7.3-unified-20gb   | active |
| 49848467-c2b6-4d45-b8af-3b62dd4dbfde | vmi-centos-6.6-amd64                       | active |
| e3c65854-29e2-41ef-a37b-79db8536dfca | vmi-centos-6.6-amd64-20gb                  | active |
| da1da341-d68c-4fa7-b283-70019fba6b36 | vmi-centos-6.6-i386                        | active |
| f8ff2137-980c-4e48-85c6-6d9caea0c021 | vmi-centos-6.6-i386-20gb                   | active |
| cd13a8b9-6b57-467b-932e-eee5edcd8d6c | vmi-centos-6.7-amd64                       | active |
| 025defb8-0cbb-48de-8ffb-1b11130e4866 | vmi-centos-6.7-amd64-20gb                  | active |
| 9ef2815a-23a9-4647-97f0-4047b3a819a3 | vmi-centos-6.7-i386                        | active |
| aec25e57-d992-42b5-9824-584f0b4d7060 | vmi-centos-6.7-i386-20gb                   | active |
| 7a2de560-1bc6-42aa-8fd8-4da4978b2ec7 | vmi-centos-6.8-amd64                       | active |
| 30159dae-2a02-4e7c-ba9e-4658935ad6cf | vmi-centos-6.8-amd64-20gb                  | active |
| 2765f574-b157-4313-95dd-4baa816e1227 | vmi-centos-6.8-i386                        | active |
| 9535ed04-83ad-4694-bb2e-0759784d1689 | vmi-centos-6.8-i386-20gb                   | active |
| fdb77dff-cb7e-4f3a-9c58-2c7349cde01f | vmi-centos-6.9-amd64                       | active |
| 083e8546-b77a-4e2d-95cf-9caf4cdbcedb | vmi-centos-6.9-amd64-20gb                  | active |
| c99f70fa-40c7-4b48-b67b-e8f89676b7a5 | vmi-centos-6.9-i386                        | active |
| 0c90acd2-7825-4c39-94b0-fc68d2eb1baf | vmi-centos-6.9-i386-20gb                   | active |
| 21113ec0-3d41-499b-8733-812eb4230e7b | vmi-centos-7.1-amd64                       | active |
| 77271182-f24f-4d69-9bba-d56dc00b03d3 | vmi-centos-7.1-amd64-20gb                  | active |
| e141fc06-632e-42a9-9c2d-eec9201427ec | vmi-centos-7.2-amd64                       | active |
| 1e6bf6ca-d221-49e8-9496-c33b51f5ed58 | vmi-centos-7.2-amd64-20gb                  | active |
| 1788b029-1b7a-43eb-a89d-02abd0866458 | vmi-centos-7.3-amd64-unified               | active |
| b78cb72c-dd3e-452a-ad9a-a8860ef6fd41 | vmi-centos-7.3-amd64-unified-20gb          | active |
| 5a933dc9-c2ec-48d7-98e4-a72d408c9ffb | vmi-centos-7.4-amd64                       | active |
| 95450a81-8194-4ff2-aab6-4f2595da56bb | vmi-centos-7.4-amd64-20gb                  | active |
| efcef3d4-5db8-4ef2-ac2e-ce7130092f62 | vmi-concrete5-8.10-centos-7.3-unified      | active |
| 58f7e55b-3ee7-4b76-bdd6-4733bf6fc18d | vmi-concrete5-8.10-centos-7.3-unified-20gb | active |
| e012238a-53b6-403e-8c19-36075d6cc5f1 | vmi-debian-7.11-amd64                      | active |
| 27f791e7-2c15-4a00-8689-3131d3932e9a | vmi-debian-7.11-amd64-20gb                 | active |
| 772fa27e-adf6-424e-b6db-15089c3407ca | vmi-debian-7.11-i386                       | active |
| 9c4a6abb-0bcb-43ed-a685-0407f1176ad7 | vmi-debian-7.11-i386-20gb                  | active |
| a63a4659-3ff7-416d-9d83-931f68c820c8 | vmi-debian-8.7-amd64-unified               | active |
| 1444e96a-7455-41ac-a744-bf1150a23324 | vmi-debian-8.7-amd64-unified-20gb          | active |
| 8c9f7e23-c42e-4eeb-9672-786d80ce84aa | vmi-debian-8.7-i386-unified                | active |
| 2286b897-7eb9-4dcf-8847-6af18bae6450 | vmi-debian-8.7-i386-unified-20gb           | active |
| 86ef477d-5789-4a5a-b739-5219021252c8 | vmi-debian-9.0-amd64-unified               | active |
| efd589e6-6d6f-458b-923a-400d64924978 | vmi-debian-9.0-amd64-unified-20gb          | active |
| c57c8902-c5cd-4f45-92e8-dcfffbcb07ce | vmi-django-1.11-centos-7.3-unified         | active |
| 40707657-ec0d-4576-ac4c-946e9ac24038 | vmi-django-1.11-centos-7.3-unified-20gb    | active |
| a6dfcbc7-13e3-4146-81e5-cfb51266135a | vmi-docker-17.06-ubuntu-16.04-unified      | active |
| cb9174eb-c25b-4762-8db2-6a2c0d102c43 | vmi-docker-17.06-ubuntu-16.04-unified-20gb | active |
| b3effc36-da5b-4fee-b51c-43aabcb87861 | vmi-drupal-8.2-centos-7.3-unified          | active |
| 4060dd0a-a042-431a-b7f5-dc50022aa3a0 | vmi-drupal-8.2-centos-7.3-unified-20gb     | active |
| e743e81b-fbee-42aa-bd8f-c84dc990bb0a | vmi-fedora-26-amd64                        | active |
| 28a0e1ca-e4d2-4bb0-a290-bc51a0ca34a5 | vmi-fedora-26-amd64-20gb                   | active |
| ac2fd4ab-cc87-4b86-bf6a-73f2d3f23e8a | vmi-freebsd-10.3-amd64-20gb                | active |
| 23effbeb-dd21-45e4-a0db-bea595e990d0 | vmi-freebsd-10.3-x86_64                    | active |
| c0e04c75-62af-43ee-aaf5-665ab8730032 | vmi-freebsd-10.3-zfs-amd64-20gb            | active |
| e4b459c0-c850-4416-a6e9-79a933240c8c | vmi-freebsd-10.3-zfs-x86_64                | active |
| 4cc9cf05-3113-437b-95d7-c5912423c585 | vmi-gitlab-10.0-centos-7.3                 | active |
| 391d1b9f-5f16-443e-a8bd-dd46fb744a2e | vmi-gitlab-10.0-centos-7.3-20gb            | active |
| a8275afd-1a23-4c2d-86e2-ea315f576c58 | vmi-hinemos-6.0-centos-7.3-unified         | active |
| ccc8b06b-7ee4-4d70-b410-34662e607bbd | vmi-hinemos-6.0-centos-7.3-unified-20gb    | active |
| f3fd7d12-03af-46ac-b53a-ee04dec23d38 | vmi-jenkins-2.60-centos-7.3-unified        | active |
| 6c9adc89-d1af-4eea-8bdb-47fe0057b6fa | vmi-jenkins-2.60-centos-7.3-unified-20gb   | active |
| 927e415e-1f27-45f6-96ee-59bdc144fec2 | vmi-joomla-3.7-centos-7.3-unified          | active |
| befddd69-8c6a-466a-836b-d512e68d070a | vmi-joomla-3.7-centos-7.3-unified-20gb     | active |
| f608392b-fe8f-42f1-b10b-cdae2729026e | vmi-lamp-centos-7.3-unified                | active |
| 3dea6146-0046-41a8-80b0-eb01522b99d4 | vmi-lamp-centos-7.3-unified-20gb           | active |
| 3718c231-2d85-43dc-a87a-830f6ed6b674 | vmi-lemp-centos-7.3-unified                | active |
| 726d1f6a-8af0-4fd3-854a-05fb74391224 | vmi-lemp-centos-7.3-unified-20gb           | active |
| 18720683-728d-425b-8607-5d9c9533822f | vmi-mastodon-1.2-ubuntu-16.04-unified      | active |
| c27521b1-8c9a-4591-913e-397620593042 | vmi-mastodon-1.2-ubuntu-16.04-unified-20gb | active |
| 38723d3e-d5b0-4f29-88b9-3d1d6ee1fd92 | vmi-mediawiki-1.28-centos-7.3-unified      | active |
| 7c88cf7b-4548-4deb-a46c-609c2f4fd3ce | vmi-mediawiki-1.28-centos-7.3-unified-20gb | active |
| 9b70032f-c486-4fd9-9e00-e7899d336406 | vmi-minecraft-1.12.2-centos-7.4            | active |
| 89890ae4-9330-4ed5-a522-d1bfb716ef5d | vmi-mongodb-3.4-centos-7.3-unified         | active |
| 5e4dbea8-db3f-4675-b789-0b4ccfcab83c | vmi-mongodb-3.4-centos-7.3-unified-20gb    | active |
| a030c166-6e67-4a28-bf9d-af7e096e4591 | vmi-netbsd-7.1-amd64                       | active |
| c52d0b83-c2ef-4661-be0e-5e2cbb0bf744 | vmi-netbsd-7.1-amd64-20gb                  | active |
| 0ed01013-93b9-454d-af05-ab421d5a0b3f | vmi-openbsd-6.0-amd64                      | active |
| 222b39bd-91c8-420e-a39e-1ec67d151997 | vmi-openbsd-6.0-amd64-20gb                 | active |
| 776039c7-50ed-4f5e-b98f-8a94e39aa304 | vmi-opensuse-42.2-amd64-unified            | active |
| 24897046-a9f8-436a-9d69-b9432422932f | vmi-opensuse-42.2-amd64-unified-20gb       | active |
| 2e4d8079-abbd-45bd-ad6d-7435d78f711f | vmi-owncloud-10.0-centos-7.3-unified       | active |
| e354b6d1-aa29-4eac-bdc4-a4aa48f2a4d6 | vmi-owncloud-10.0-centos-7.3-unified-20gb  | active |
| 9abad71b-5530-437c-9211-6fd27cd1b314 | vmi-piwik-3.0-centos-7.3-unified           | active |
| 89be042d-c2c1-4702-9ea5-bafc6fa3218c | vmi-piwik-3.0-centos-7.3-unified-20gb      | active |
| ffdf2454-38cc-424b-8b6b-199df7574b13 | vmi-rails-5.1-centos-7.3-unified           | active |
| 3bb9c09d-d58a-4469-af73-c79c0bc2d8b9 | vmi-rails-5.1-centos-7.3-unified-20gb      | active |
| 460819d9-25de-44e0-a239-b0e0b33eb91d | vmi-redis-3.2-centos-7.2                   | active |
| b9ccf65f-cdd5-4fce-bb16-679985020a5f | vmi-redis-3.2-centos-7.2-20gb              | active |
| 08847571-a260-4af3-a13d-16fe68162016 | vmi-redmine-3.4-centos-7.3-unified         | active |
| 0c25f6d8-f706-44de-8032-a3d7dfe30541 | vmi-redmine-3.4-centos-7.3-unified-20gb    | active |
| c50d92b9-f9c8-4fb0-868c-5601f8c9195e | vmi-ubuntu-14.04-amd64-unified             | active |
| c171aae7-d3b7-4776-b3df-9b4130d48019 | vmi-ubuntu-14.04-amd64-unified-20gb        | active |
| 9155c52d-81dd-4a65-a234-8feaa403ac6f | vmi-ubuntu-14.04-i386-unified              | active |
| fc199af0-9f7e-4d39-9219-fe74cfbd9ac2 | vmi-ubuntu-14.04-i386-unified-20gb         | active |
| b9e54c41-cda9-4d84-8248-808bfaf6c793 | vmi-ubuntu-16.04-amd64-unified             | active |
| fdedd7ed-2a4b-4de6-88ba-364deb25e193 | vmi-ubuntu-16.04-amd64-unified-20gb        | active |
| ec2bfd27-7793-4f53-8ab6-936c79a06213 | vmi-ubuntu-16.04-i386-unified              | active |
| 65cfff0d-baac-4e5b-8263-f949c9ed7ed3 | vmi-ubuntu-16.04-i386-unified-20gb         | active |
| 88503ca6-5d0f-454e-9b51-2e42d72d7d09 | vmi-wordpress-kusanagi-centos-7.2          | active |
| c03ec927-88d0-41c1-8e64-e9e7029d7e59 | vmi-wordpress-kusanagi-centos-7.2-20gb     | active |
| ac965a99-7318-44e2-b61c-60788213e9bc | vmi-zabbix-2.4-centos-7.2                  | active |
| a1229749-a3e1-4098-88dc-9b19e7aad22e | vmi-zabbix-2.4-centos-7.2-20gb             | active |
| ff75715d-551a-4ea9-97fd-14eea8e11b08 | vmi-zbx-3.0-centos-7.3                     | active |
+--------------------------------------+--------------------------------------------+--------+
```

20gb 版があるのは、ConoHaは512MBのフレーバーだけSSDの容量が20GBだから。
比べるとこんな感じ。

```console
% openstack image show vmi-arch-amd64
+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                                                                                             |
+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum         | 9c3da95fa44884cfd1de8ef2193f18e1                                                                                                                                                                                  |
| container_format | ovf                                                                                                                                                                                                               |
| created_at       | 2017-07-19T05:30:40Z                                                                                                                                                                                              |
| disk_format      | qcow2                                                                                                                                                                                                             |
| file             | /v2/images/a28ad8eb-a23b-45c1-83f6-1b7b17a0ac89/file                                                                                                                                                              |
| id               | a28ad8eb-a23b-45c1-83f6-1b7b17a0ac89                                                                                                                                                                              |
| min_disk         | 50                                                                                                                                                                                                                |
| min_ram          | 0                                                                                                                                                                                                                 |
| name             | vmi-arch-amd64                                                                                                                                                                                                    |
| owner            | 50c9f8c6b6d3488bad75196708a2a438                                                                                                                                                                                  |
| properties       | direct_url='file:///var/lib/glance5/images/50c9f8c6b6d3488bad75196708a2a438/a28ad8eb-a23b-45c1-83f6-1b7b17a0ac89', display_order='290', dst='Arch_Linux-20170710-64bit', hw_qemu_guest_agent='yes', os_type='lin' |
| protected        | False                                                                                                                                                                                                             |
| schema           | /v2/schemas/image                                                                                                                                                                                                 |
| size             | 2252013568                                                                                                                                                                                                        |
| status           | active                                                                                                                                                                                                            |
| tags             |                                                                                                                                                                                                                   |
| updated_at       | 2017-10-04T03:46:11Z                                                                                                                                                                                              |
| visibility       | public                                                                                                                                                                                                            |
+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
% openstack image show vmi-arch-amd64-20gb
+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                                                                                             |
+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum         | 2d7f0526f871404028d2153c1493607d                                                                                                                                                                                  |
| container_format | ovf                                                                                                                                                                                                               |
| created_at       | 2017-07-19T04:04:30Z                                                                                                                                                                                              |
| disk_format      | qcow2                                                                                                                                                                                                             |
| file             | /v2/images/26ef30ba-5d04-4ffe-91eb-58c069927dc3/file                                                                                                                                                              |
| id               | 26ef30ba-5d04-4ffe-91eb-58c069927dc3                                                                                                                                                                              |
| min_disk         | 20                                                                                                                                                                                                                |
| min_ram          | 0                                                                                                                                                                                                                 |
| name             | vmi-arch-amd64-20gb                                                                                                                                                                                               |
| owner            | 50c9f8c6b6d3488bad75196708a2a438                                                                                                                                                                                  |
| properties       | direct_url='file:///var/lib/glance5/images/50c9f8c6b6d3488bad75196708a2a438/26ef30ba-5d04-4ffe-91eb-58c069927dc3', display_order='290', dst='Arch_Linux-20170710-64bit', hw_qemu_guest_agent='yes', os_type='lin' |
| protected        | False                                                                                                                                                                                                             |
| schema           | /v2/schemas/image                                                                                                                                                                                                 |
| size             | 2821783552                                                                                                                                                                                                        |
| status           | active                                                                                                                                                                                                            |
| tags             |                                                                                                                                                                                                                   |
| updated_at       | 2017-10-04T03:46:12Z                                                                                                                                                                                              |
| visibility       | public                                                                                                                                                                                                            |
+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
```

# フレーバー

```console
% openstack flavor list
+--------------------------------------+---------+-------+------+-----------+-------+-----------+
| ID                                   | Name    |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+---------+-------+------+-----------+-------+-----------+
| 294639c7-72ba-43a5-8ff2-513c8995b869 | g-2gb   |  2048 |   50 |         0 |     3 | True      |
| 3aa001cd-95b6-46c9-a91e-e62d6f7f06a3 | g-16gb  | 16384 |   50 |         0 |     8 | True      |
| 62e8fb4b-6a26-46cd-be13-e5bbf5614d15 | g-4gb   |  4096 |   50 |         0 |     4 | True      |
| 7eea7469-0d85-4f82-8050-6ae742394681 | g-1gb   |  1024 |   50 |         0 |     2 | True      |
| 965affd4-d9e8-4ffb-b9a9-624d63e2d83f | g-8gb   |  8192 |   50 |         0 |     6 | True      |
| a20905c6-3733-46c4-81cc-458c7dca1bae | g-32gb  | 32768 |   50 |         0 |    12 | True      |
| c2a97b05-1b4b-4038-bbcb-343201659279 | g-64gb  | 65536 |   50 |         0 |    24 | True      |
| d92b02ce-9a4f-4544-8d7f-ae8380bc08e7 | g-512mb |   512 |   20 |         0 |     1 | True      |
+--------------------------------------+---------+-------+------+-----------+-------+-----------+
```

[料金表](https://www.conoha.jp/pricing/)のとおり512MBのみが20GBで他は50GBで統一されている。

プロパティは色々あるが、 `instance_name_tag` でタグの名前を付ける程度？

# イメージ追加

ConoHaのImage API v2にはイメージの追加（Glance）が定義されていない。

https://www.conoha.jp/docs/

なんとなく叩いてみると404で怒られる。

```console
% openstack image create Gentoo
404 Not Found: nginx/1.6.2 (HTTP 404)
```

よって、外部で作ったqcow2などを流し込むことは現状不可能。

# ボリューム

ボリュームタイプはSSDのみ。

```console
% openstack volume type list
+--------------------------------------+---------+-----------+
| ID                                   | Name    | Is Public |
+--------------------------------------+---------+-----------+
| a91ff1b3-f87d-4368-8419-4fc75ba3b791 | gnc_ssd | N/A       |
+--------------------------------------+---------+-----------+
```

試しに適当なサイズを指定すると怒られる。

```console
% openstack volume create --type gnc_ssd --bootable --read-write --size 20 Gentoo
Volume size must be an integer and 200, 500, 1000, 2000 or 3000. (HTTP 400)
```

# VPS追加

　これまで取ってきた情報を組み合わせると、こんな感じで新しいインスタンスを追加できる。

```console
% openstack server create test4 --flavor g-1gb --image vmi-debian-9.0-amd64-unified-20gb --property instance_name_tag=test4 --block-device-mapping /dev/vdb=aae41df3-faa5-4b37-b28c-696baf6caee6:::0
```

ちなみに、叩いてVPSが作られるとその時点から1時間単位で課金されるので注意。

なお、これもAPIに定義されていないのだがボリュームを指定してのインスタンス追加は出来ない。
つまり、適当なインスタンス上にボリュームをマウントした後、OSやブートローダーを設定したとしてもそのボリュームから起動することは出来ない。