LoginSignup
3
4

More than 5 years have passed since last update.

IDCFクラウドで仮想マシンを作成する

Posted at

IDCFクラウドを使うことになりまして。
まずは仮想マシンを立ち上げてみようと思った次第です。

こちらのGetting Startedを参考にさせていただきました。

※ 使用したPCの環境は「MacOS X 10.9.5」です。
※ アカウント登録は済ませている体で進めます。

cloudstack-apiのインストール

gitもpipも我がMacにはインストール済みだったので、以下コマンドのみでインストール完了しました。

sudo pip install git+https://github.com/idcf/cloudstack-api

設定ファイル(.idcfrc)

参考ページに書かれている通りに作業しました。

仮想マシン立ち上げてみる

APIから以下のように実行しています。

実行イメージ
% cloudstack-api listZones -t id
+--------------------------------------+
|                  id                  |
+--------------------------------------+
| a117e75f-d02e-4074-806d-889c61261394 |
+--------------------------------------+
[naokienokido@Naoki-Enokido-MacBook-Pro] ~
% cloudstack-api listServiceOfferings -t id,displaytext
+--------------------------------------+------------------------------------+
|                  id                  |            displaytext             |
+--------------------------------------+------------------------------------+
| 12e39b73-3ce6-4e57-9036-3dac0c2b2b06 | highmem.M16( 2CPU / 16GB RAM )     |
| 354c62e6-b99b-42f2-b5c7-e741f1085422 | standard.XL32( 8CPU / 32 GB RAM )  |
| 435c1aab-e796-42c7-9320-22ebdc8f50aa | highcpu.L8( 4CPU / 8GB RAM )       |
| 55621f17-4d38-457c-ba34-e6199701b67b | standard.S4( 1CPU / 4GB RAM )      |
| 6a99ff4c-1a24-4aa6-b4cc-600220987ed0 | standard.L16( 4CPU / 16GB RAM )    |
| 6fda5e0c-e64d-46ea-893d-7e2ac9e128e7 | highcpu.XL16 ( 8CPU / 16GB RAM )   |
| 7ae143a6-5662-4f1d-bc4c-10defa775bcb | standard.M8( 2CPU / 8GB RAM )      |
| 7c548831-427b-437c-9c8b-80dde8031303 | highcpu.2XL32( 16 CPU / 32GB RAM ) |
| 8cf15770-c3c8-4efc-8ae5-b8327790db76 | highcpu.M4( 2CPU / 4GB RAM )       |
| d1aac6d2-bb47-4106-90d0-6a73ac3ae78e | light.S2( 1CPU / 2GB RAM )         |
| d59817bc-ed79-4083-8b71-51b26c76d311 | highmem.L32( 4CPU / 32GB RAM )     |
| e01a9f32-55c4-4c0d-9b7c-d49a3ccfd3f6 | light.S1( 1CPU / 1GB RAM )         |
| ee5ee568-76b2-46ad-9221-c695e6f2149d | highmem.XL64( 8CPU / 64GB RAM )    |
+--------------------------------------+------------------------------------+
[naokienokido@Naoki-Enokido-MacBook-Pro] ~
% cloudstack-api listTemplates --templatefilter executable -t id,ostypename
+--------------------------------------+---------------------------------------+
|                  id                  |               ostypename              |
+--------------------------------------+---------------------------------------+
| 275896bd-4f4a-429d-a3ad-4c5273978951 | Windows Server 2008 R2 (64-bit)       |
| 2e5ced0d-13cd-4848-93e6-6e6a0571ffc3 | CentOS 6.4 (64-bit)                   |
| 33134882-9eee-45f5-8520-51ff8f3b9ec9 | Ubuntu 12.04 (64-bit)                 |
| 34c8ff3d-21a9-45c3-a9c2-c69b00be7a4a | Red Hat Enterprise Linux 6.4 (64-bit) |
| 382ca26e-048f-4aae-a733-ac3d5bfaec51 | Windows Server 2012 R2 (64-bit)       |
| 3d911756-3b96-4d18-b70f-226c570556e6 | Windows Server 2008 R2 (64-bit)       |
| 47f01aad-b11c-4d00-a82f-26646bad9115 | Red Hat Enterprise Linux 5.9 (64-bit) |
| 4cdf1019-fb19-4c99-acc6-367f7a815c79 | Windows Server 2012 (64-bit)          |
| 5cd70dbe-721f-4e50-af19-12d0f1dc63dd | Ubuntu 12.04 (64-bit)                 |
| 6a0f801a-900d-4dcd-9802-e21f8602adad | Debian GNU/Linux 6(64-bit)            |
| 6ccce6a1-8c26-48cc-8ee7-316149e5b1d9 | Windows Server 2012 R2 (64-bit)       |
| 6e677875-f46b-4bce-a867-f840c96f8904 | Windows Server 2008 R2 (64-bit)       |
| 782a845c-24bc-4538-a4c9-4821290200b3 | Ubuntu 12.04 (64-bit)                 |
| 78bae077-bb64-4752-8604-36ef8a747b34 | Ubuntu 12.04 (64-bit)                 |
| 7d373b69-c27a-42dd-a2ac-c015b53e67d4 | CentOS 5.9 (64-bit)                   |
| 8c54dbd6-4fab-4500-b02f-0e3fa0bb1086 | CentOS 6.4 (64-bit)                   |
| 8f641617-0d03-459c-9736-b903654f6d35 | CentOS 5.6 (64-bit)                   |
| 9ac92eb1-810f-429e-a225-95b1e4a000a6 | CentOS 6.4 (64-bit)                   |
| 9d6249ff-e84c-4ed9-82df-c8d54c770201 | CentOS 5.9 (32-bit)                   |
| a0d20503-c040-4638-ade9-16a968728696 | Windows Server 2012 (64-bit)          |
| a6896a7d-42a7-4bd7-8534-1b809d22abb8 | CentOS 6.4 (64-bit)                   |
| b03bca79-fbe5-44e2-b73c-ceb61d0da16d | Ubuntu 10.04 (64-bit)                 |
| b2d2a4fa-d694-444b-b961-0a0f9d7fe0f3 | Ubuntu 12.04 (64-bit)                 |
| b39f9f23-6784-4161-8143-8b130df3f09f | Other Linux (64-bit)                  |
| ba03656a-6c5f-4d8f-a5fd-516616c7a125 | Windows Server 2012 (64-bit)          |
| bfc969ae-7d70-4310-9c77-cc6f89d67d3c | Windows Server 2012 R2 (64-bit)       |
| c535256e-bf28-4fc8-b9a7-545aa458ff22 | Windows Server 2008 R2 (64-bit)       |
| c6634eb6-7650-47e3-a1a6-540145ed6967 | Windows Server 2012 R2 (64-bit)       |
| d7dd6015-e940-4563-a2a0-25c8b2f58ead | Red Hat Enterprise Linux 5.9 (32-bit) |
| f1604ef7-6d56-40ee-b698-f53b39ffa2f7 | Windows Server 2012 (64-bit)          |
| f42bd2d4-6f15-49d7-b166-f2d041695925 | Ubuntu 12.04 (64-bit)                 |
+--------------------------------------+---------------------------------------+
% cloudstack-api deployVirtualMachine --serviceofferingid e01a9f32-55c4-4c0d-9b7c-d49a3ccfd3f6 --templateid 2e5ced0d-13cd-4848-93e6-6e6a0571ffc3 --zoneid a117e75f-d02e-4074-806d-889c61261394 --group neno-test --keypair neno-test --name test-instance-1
{
  "deployvirtualmachineresponse": {
    "id": "0e48581e-071b-45d3-a61e-bc0189d32135",
    "jobid": "43a1b0f0-a146-43f3-8c59-5a1ec445bd3d"
  }
}

クラウドコンソールから、バーチャルルータにファイアウォールとポートフォワードでSSHできるように設定して、ログインしてみます。
ポートはとりあえず49222としました。

ポートフォワードの設定

コメント プライベートポート パブリックポート プロトコル 仮想マシン
test-ssh 22 49222 TCP test-instance-1

ファイアウォールの設定

コメント ソースCIDR タイプ ポートレンジ
test-ssh My IPを指定 TCP 49222

ログイン後にOSのバージョンを確認してみたところ、

| 2e5ced0d-13cd-4848-93e6-6e6a0571ffc3 | CentOS 6.4 (64-bit)                   

のテンプレートを指定したつもりだったんですが、CentOS 6.5と表示されました。

[root@test-instance-1 ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)

templateのOSを判断するには、listTemplatesで取得できるnameの方がよいのかも?

% cloudstack-api listTemplates --templatefilter executable -t id,ostypename,name

+--------------------------------------+---------------------------------------+-----------------------------------------------------+
|                  id                  |               ostypename              |                         name                        |
+--------------------------------------+---------------------------------------+-----------------------------------------------------+
| 275896bd-4f4a-429d-a3ad-4c5273978951 | Windows Server 2008 R2 (64-bit)       | Windows Server 2008 R2 Ent SP1 + SQL2014 Std        |
| 2e5ced0d-13cd-4848-93e6-6e6a0571ffc3 | CentOS 6.4 (64-bit)                   | CentOS 6.5 64-bit for Vagrant                       |
| 33134882-9eee-45f5-8520-51ff8f3b9ec9 | Ubuntu 12.04 (64-bit)                 | ubuntu-1gb-opt                                      |
| 34c8ff3d-21a9-45c3-a9c2-c69b00be7a4a | Red Hat Enterprise Linux 6.4 (64-bit) | Red Hat Enterprise Linux 6.5 64-bit                 |
| 382ca26e-048f-4aae-a733-ac3d5bfaec51 | Windows Server 2012 R2 (64-bit)       | Windows Server 2012 R2 Std + SQL2014 Std            |
| 3d911756-3b96-4d18-b70f-226c570556e6 | Windows Server 2008 R2 (64-bit)       | Windows Server 2008 R2 Ent SP1 + SQL2008 R2 Std SP3 |
| 47f01aad-b11c-4d00-a82f-26646bad9115 | Red Hat Enterprise Linux 5.9 (64-bit) | Red Hat Enterprise Linux 5.10 64-bit                |
| 4cdf1019-fb19-4c99-acc6-367f7a815c79 | Windows Server 2012 (64-bit)          | Windows Server 2012 Std                             |
| 5cd70dbe-721f-4e50-af19-12d0f1dc63dd | Ubuntu 12.04 (64-bit)                 | Ubuntu-1G                                           |
| 6a0f801a-900d-4dcd-9802-e21f8602adad | Debian GNU/Linux 6(64-bit)            | VyOS 1.0.4 64-bit                                   |
| 6ccce6a1-8c26-48cc-8ee7-316149e5b1d9 | Windows Server 2012 R2 (64-bit)       | Windows Server 2012 R2 Std                          |
| 6e677875-f46b-4bce-a867-f840c96f8904 | Windows Server 2008 R2 (64-bit)       | Windows Server 2008 R2 Ent SP1 + SQL2012 Std SP2    |
| 782a845c-24bc-4538-a4c9-4821290200b3 | Ubuntu 12.04 (64-bit)                 | Ubuntu-1GB-2                                        |
| 78bae077-bb64-4752-8604-36ef8a747b34 | Ubuntu 12.04 (64-bit)                 | Ubuntu Server 12.04 LTS 64-bit                      |
| 7d373b69-c27a-42dd-a2ac-c015b53e67d4 | CentOS 5.9 (64-bit)                   | CentOS 5.10 64-bit                                  |
| 8c54dbd6-4fab-4500-b02f-0e3fa0bb1086 | CentOS 6.4 (64-bit)                   | CentOS 7.0 64-bit                                   |
| 8f641617-0d03-459c-9736-b903654f6d35 | CentOS 5.6 (64-bit)                   | AppTemplate CentOS 6.5 64-bit                       |
| 9ac92eb1-810f-429e-a225-95b1e4a000a6 | CentOS 6.4 (64-bit)                   | cl-base-centos65-08192014                           |
| 9d6249ff-e84c-4ed9-82df-c8d54c770201 | CentOS 5.9 (32-bit)                   | CentOS 5.10 32-bit                                  |
| a0d20503-c040-4638-ade9-16a968728696 | Windows Server 2012 (64-bit)          | Windows Server 2012 Std + SQL2012 Std SP2           |
| a6896a7d-42a7-4bd7-8534-1b809d22abb8 | CentOS 6.4 (64-bit)                   | CentOS 6.5 64-bit                                   |
| b03bca79-fbe5-44e2-b73c-ceb61d0da16d | Ubuntu 10.04 (64-bit)                 | Ubuntu Server 10.04 LTS 64-bit                      |
| b2d2a4fa-d694-444b-b961-0a0f9d7fe0f3 | Ubuntu 12.04 (64-bit)                 | Ubuntu Server 14.04 LTS 64-bit                      |
| b39f9f23-6784-4161-8143-8b130df3f09f | Other Linux (64-bit)                  | [Alpha] CoreOS 472.0.0 64-bit                       |
| ba03656a-6c5f-4d8f-a5fd-516616c7a125 | Windows Server 2012 (64-bit)          | Windows Server 2012 Std + SQL2008 R2 Std SP3        |
| bfc969ae-7d70-4310-9c77-cc6f89d67d3c | Windows Server 2012 R2 (64-bit)       | Windows Server 2012 R2 Std + SQL2008 R2 Std SP3     |
| c535256e-bf28-4fc8-b9a7-545aa458ff22 | Windows Server 2008 R2 (64-bit)       | Windows Server 2008 R2 Ent SP1                      |
| c6634eb6-7650-47e3-a1a6-540145ed6967 | Windows Server 2012 R2 (64-bit)       | Windows Server 2012 R2 Std + SQL2012 Std SP2        |
| d7dd6015-e940-4563-a2a0-25c8b2f58ead | Red Hat Enterprise Linux 5.9 (32-bit) | Red Hat Enterprise Linux 5.10 32-bit                |
| f1604ef7-6d56-40ee-b698-f53b39ffa2f7 | Windows Server 2012 (64-bit)          | Windows Server 2012 Std + SQL2014 Std               |
| f42bd2d4-6f15-49d7-b166-f2d041695925 | Ubuntu 12.04 (64-bit)                 | Ubuntu-1GB-op                                       |
+--------------------------------------+---------------------------------------+-----------------------------------------------------+

クラウドコンソールから仮想マシンを作成する際に「おすすめTemplate」として表示されているCentOS 6.5 64bitのtemplateは以下のもののようだったので、これを使って再度仮想マシンを作成しました。

| a6896a7d-42a7-4bd7-8534-1b809d22abb8 | CentOS 6.4 (64-bit)                   | CentOS 6.5 64-bit                                   

HTTPで通信してみる

Apacheで疎通してみました。

立ち上げた仮想マシンにSSHでログインして、
yum install httpd
でApacheインストールして起動させます。

バーチャルルータにHTTPの設定を追加します。
ポートはとりあえず49280としました。

ポートフォワード

コメント プライベートポート パブリックポート プロトコル 仮想マシン
test-http 80 49280 TCP test-instance-1

ファイアウォール

コメント ソースCIDR タイプ ポートレンジ
test-http My IPを指定 TCP 49280

これで、http://グローバルIP:49280 で該当のインスタンスに疎通できました。
簡単ですね。

まとめ

クラウドコンソールからはもちろんですが、APIツールを使用しても簡単に仮想マシンの作成ができますね。
これから色々と弄っていきたいと思います。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4