DeltaCloud Clientを利用してみる
gem install deltacloud-clientでいけるらしいが不足しているものがあるのでインストール
libxml2パッケージインストール
# yum install libxml2 # yum install libxml2-devel # yum install libxslt # yum install libxslt-devel
nokogiri gemパッケージインストール
# gem install nokogiri -- --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib64 --with-xslt-dir=/usr/include
deltacloud-clientインストール
# gem install deltacloud-client
利用方法確認
gemのインストールディレクトリ内にdeltacloudcという実行ファイルができるのでこれを実行することでdeltacloud APIに対して操作が可能になる。
# deltacloudc --help Usage: deltacloudc collection operation [options] URL format: API_URL=http://[user]:[password]@[api_url][port][/uri] Examples: 1. To list collections for deltacloud api on port 3333 of server deltacloud.foo deltacloudc -l -u http://user:password@deltacloud.foo:3333/api 2. To list the operations for the 'images' collection: deltacloudc images -l -u http://user:password@deltacloud.foo:3333/api 3. To list all images (i.e. call the 'index' operation of 'images'): deltacloudc images index -u http://user:password@deltacloud.foo:3333/api 4. To get the details of image '5': deltacloudc images show -i 5 -u http://user:password@deltacloud.foo:3333/api Options: -i, --id ID ID for operation -d, --image-id ID Image ID -b, --bucket-id ID Bucket ID -a, --arch ARCH Architecture (x86, x86_64) -p HARDWARE_PROFILE, Hardware Profile --hardware-profile -n, --name NAME Name (for instance eg.) -s, --state STATE Instance state (RUNNING, STOPPED) -u, --url URL API url ($API_URL variable) -l, --list List collections/operations -h, --help Display this screen -v, --version Display API version -V, --verbose Print verbose messages -f, --file-path PATH local path for new blob data -m, --blob-metadata k1=v1, k2=v2 Comma seperated k=v pairs for blob metadata (for create operation)
list取得
-lオプション でとりあえず取得してみる。
deltaclouddが起動している状態でdeltacloudcコマンドを実行。
deltaclouddが起動しているサーバをdeltacloud-serverの3001番ポートとすると下記のように実行。(ここではec2ドライバでサーバを起動し、ec2のアクセスキーとシークレットキーをホスト名の前に指定)
# deltacloudc -l --url http://アクセスキー:シークレットキー@deltacloud-server:3001/api drivers storage_snapshots hardware_profiles buckets instances load_balancers images realms keys storage_volumes blob
instancesに対してできること一覧取得
# deltacloudc instances --list --url http://アクセスキー:シークレットキー@deltacloud-server:3001/api create : Create a new instance. destroy : Destroy an instance. index : List all instances. reboot : Reboot a running instance. run : Run command on instance. Either password or private key must be send in order to execute command. Authetication method should be advertised in instance. show : Show an instance identified by "id" parameter. start : Start an instance. stop : Stop a running instance.
instanceの一覧取得
# deltacloudc instances index --url http://アクセスキー:シークレットキー@deltacloud-server:3001/api
※indexは省略化
bucketsのリスト取得
# deltacloudc buckets index --url http://アクセスキー:シークレットキー@deltacloud-server:3001/api
※indexは省略化