ChefのKnifeでCloudStackを操作する方法CloudStackによるプライベートクラウド構築術(8)(2/3 ページ)

» 2012年10月23日 17時20分 公開
[堀田直孝,クリエーションライン株式会社]

knife-cloudstackのコマンド操作

ゾーンを表示する(knife cs zone list)

 knife cs zone listは、アカウントに結び付けられている全ての有効なゾーンを表示します。

$ knife cs zone list
 Name             Network Type     Security Groups
 TestZone         Advanced         false

ネットワークを表示する(knife cs network list)

 アカウントに結び付けられている全ての有効なネットワークを表示します。

$ knife cs network list
 Name           Type           Default        Shared         Gateway        Netmask
 public         Isolated                                     10.1.1.1       255.255.255.0

全ての有効なサービスオファリングを表示する(knife cs service list)

 アカウントに結び付けられている全ての有効なサービスオファリングを表示します。

$ knife cs service list
 Name                      Memory                    CPUs                      CPU Speed                 Created
 Medium Instance           1.00GB                    1                         1000 Mhz                  2012-09-04T10:11:07+0900
 Small Instance            512.00MB                  1                         500 Mhz                   2012-09-04T10:11:07+0900

アカウントに結び付いているテンプレートを表示する(knife cs template list)

 アカウントに結び付けられているテンプレートを表示します。デフォルトでは「おすすめ」テンプレートが表示されます。-F (--filter) オプションを用いて表示するテンプレートの種類を指定できます。

$ knife cs template list -F community
 Name                             Size                             Zone          Public                           Created
 CentOS 5.5(64-bit) no GUI (KVM)  8.00GB                           TestZone      true                             2012-09-04T14:15:41+0900

アカウントに結び付いている全ての有効なサーバを表示(knife cs server list)

 アカウントに結び付けられている全ての有効なサーバを表示します。

 なお、表示されるサーバはCloudStack上のもので、Chefによって管理されているかどうかは無関係です。

$ knife cs server list
 Name                             Public IP                        Service        Template                         State
 test-by-hand-0910-2              192.168.122.162                  Small Instance CentOS 5.5(64-bit) no GUI (KVM)  Stopped
 ubuntu-0909-1                    192.168.122.160                  Small Instance ubuntu-10.04.4-server-amd64.iso  Stopped

全てのサーバを/etc/hosts形式で表示する(knife cs hosts)

 /etc/hosts形式で全てのサーバを表示します。

$ knife cs hosts
 #Public IP                             Host                                   FQDN
 192.168.122.162                        test-by-hand-0910-2                    test-by-hand-0910-2.cs1cloud.internal
 192.168.122.160                        ubuntu-0909-1                          ubuntu-0909-1.cs1cloud.internal

仮想マシンの起動(knife cs server start)

 指定した仮想マシンを起動します。下の例では「test-by-hand-0910-2」を起動しています。

 $ knife cs server start test-by-hand-0910-2
 Name: test-by-hand-0910-2
 Public IP: 192.168.122.162
 Service: Small Instance
 Template: CentOS 5.5(64-bit) no GUI (KVM)
 Domain: ROOT
 Zone: TestZone
 State: Stopped
 Do you really want to start this server? (Y/N) y
 Waiting for startup......
 Started server test-by-hand-0910-2

仮想マシンの再起動(knife cs server reboot)

 指定した仮想マシンを再起動します。下の例では「test-by-hand-0910-2」を再起動しています。

$ knife cs server reboot test-by-hand-0910-2
 Name: test-by-hand-0910-2
 Public IP: 192.168.122.162
 Service: Small Instance
 Template: CentOS 5.5(64-bit) no GUI (KVM)
 Domain: ROOT
 Zone: TestZone
 State: Running
 Do you really want to reboot this server? (Y/N) y
 Rebooting.............
 Rebooted server test-by-hand-0910-2

仮想マシンの停止(knife cs server stop)

 指定した仮想マシンを停止します。下の例では、先ほど起動した「test-by-hand-0910-2」を停止しています。

$ knife cs server stop test-by-hand-0910-2
 Name: test-by-hand-0910-2
 Public IP: 192.168.122.162
 Service: Small Instance
 Template: CentOS 5.5(64-bit) no GUI (KVM)
 Domain: ROOT
 Zone: TestZone
 State: Running
 Do you really want to stop this server? (Y/N) y
 Stopping............................................................
 Stopped server test-by-hand-0910-2

仮想マシンの削除(knife cs server delete)

 指定した仮想マシンを削除します。Chefの登録情報を同時に削除することもできます。

$ knife cs server delete test-by-hand-0910-2
 Name: test-by-hand-0910-2
 Public IP: 192.168.122.162
 Service: Small Instance
 Template: CentOS 5.5(64-bit) no GUI (KVM)
 Domain: ROOT
 Zone: TestZone
 State: Stopped
 Do you really want to delete this server? (Y/N) y
 Waiting for deletion..
 Deleted server test-by-hand-0910-2
 Do you want to delete the chef node and client
'test-by-hand-0910-2.cs1cloud.internal? (Y/N) y
 Deleted node test-by-hand-0910-2

 Chefの登録情報を削除しないで残しておくには、

Do you want to delete the chef node and client
'test-by-hand-0910-2.cs1cloud.internal? n
You said no, so I'm done here.

 とします。ここで削除を行わなくても、別途Chef側で管理情報の削除を行えます。

Copyright © ITmedia, Inc. All Rights Reserved.

RSSについて

アイティメディアIDについて

メールマガジン登録

@ITのメールマガジンは、 もちろん、すべて無料です。ぜひメールマガジンをご購読ください。