ようへいの日々精進XP

よかろうもん

XenServer で CLI から VM のテンプレートを作成してみた一部始終

概要

  • XenServer のコマンドラインから VM のテンプレートを作成してみる
  • XenCenter を使えないような環境で利用出来る

手順

基本的な設定を OS に施す

とりあえず SELinux の設定を修正する。

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

OS をシャットダウン

shutdown -h now

VM をテンプレート化する

VM の UUID を取得する。

xe vm-list

以下のように出力される。

uuid ( RO)           : 51491a70-6177-437d-9aa9-285a7a9d14af
     name-label ( RW): Control domain on host: xenserver.inokara.com
    power-state ( RO): running


uuid ( RO)           : 76e31f28-0a5a-8cc8-f484-ecd589667a8e
     name-label ( RW): centos6.x
    power-state ( RO): halted

UUID を指定してテンプレート化してみる。

xe vm-param-set uuid=76e31f28-0a5a-8cc8-f484-ecd589667a8e is-a-template=true

テンプレートとして登録されていることを確認する

xe template-list | grep 76e31f28-0a5a-8cc8-f484-ecd589667a8e -A2 -B2

以下の通りに登録されている。

uuid ( RO)                : 76e31f28-0a5a-8cc8-f484-ecd589667a8e
          name-label ( RW): centos6.x
    name-description ( RW): Installed via xe CLI -A2 -B2

まとめ

  • こっちも意外に簡単に出来た
  • 次はやっとこさ knife xenserver の出番!