Class: UnitHosting::VmGroup
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create_vm(recipe) ⇒ Object
vmの作成.
-
#initialize(instance_id = nil, api_key = nil) ⇒ VmGroup
constructor
A new instance of VmGroup.
-
#vm(instance_id) ⇒ Object
instance_idに紐づくvmを返す.
- #vm_api_key(instance_id) ⇒ Object
-
#vms ⇒ Object
このサーバグループに含まれるVMオブジェクトをすべて返す.
Methods inherited from Base
load, #load, #load_key, #server_call
Constructor Details
#initialize(instance_id = nil, api_key = nil) ⇒ VmGroup
Returns a new instance of VmGroup.
8 9 10 11 12 |
# File 'lib/unit_hosting/vm_group.rb', line 8 def initialize(instance_id=nil,api_key=nil) @instance_id_elm = '/server-group/instance_id' @api_key_elm = '/server-group/key' super end |
Instance Method Details
#create_vm(recipe) ⇒ Object
vmの作成
31 32 33 34 35 |
# File 'lib/unit_hosting/vm_group.rb', line 31 def create_vm(recipe) r = server_call("vmGroup.createVm",recipe.params) return false if r["result"] != "success" r end |
#vm(instance_id) ⇒ Object
instance_idに紐づくvmを返す
27 28 29 |
# File 'lib/unit_hosting/vm_group.rb', line 27 def vm(instance_id) Vm.new(instance_id,vm_api_key(instance_id)) end |
#vm_api_key(instance_id) ⇒ Object
21 22 23 24 25 |
# File 'lib/unit_hosting/vm_group.rb', line 21 def vm_api_key instance_id server_call("vmGroup.getVms").each do |vm| return vm["api_key"] if vm[instance_id] == instance_id end end |