DeltaCloudの管理画面を使ってEC2(Tokyo Region)の操作をするには
DeltaCloud0.3のソースコード内を見ているとどうもリージョンは直接指定している模様。
チェックする箇所は以下。
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/deltacloud-core-0.3.0/lib/deltacloud/drivers/ec2/ec2_driver.rb
このコード内に
DEFAULT_REGION = 'us-east-1'
という指定箇所があります。
この部分をとりあえず東京リージョン用に書き換えます。
DEFAULT_REGION = 'ap-northeast-1' #DEFAULT_REGION = 'us-east-1'
そして、このap-northeast-1という値がどこで効いてくるかをチェックしてみると、endpointを決めるとこでした。
def endpoint_for_service(service) endpoint = (Thread.current[:provider] || ENV['API_PROVIDER'] || DEFAULT_REGION) # return the endpoint if it does not map to a default endpoint, allowing # the endpoint to be a full hostname instead of a region. Deltacloud::Drivers::driver_config[:ec2][:entrypoints][service.to_s][endpoint] || endpoint end
どうやらconfig内にendpointのURLが記載されているようなのでconfigをチェック。
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/deltacloud-core-0.3.0/config/drivers.yml
・・略
- ec2
そのままだとこういう感じになっているので、ap-northeast-1の記載は全くなし。
ということで下記一行をec2の設定内に追加。
ap-northeast-1: ec2.ap-northeast-1.amazonaws.com
これでdeltaclouddを起動するとTokyo Regionのサーバが管理可能になります。
リージョンの指定を動的にやるにはどうすればいいんだろう。