Class: UnitHosting::Api::VmGroup
- Defined in:
- lib/unit-hosting/api/vm_group.rb
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.
- #networks ⇒ Object
-
#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.
9 10 11 12 13 |
# File 'lib/unit-hosting/api/vm_group.rb', line 9 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の作成
28 29 30 31 32 |
# File 'lib/unit-hosting/api/vm_group.rb', line 28 def create_vm(recipe) r = server_call("vmGroup.createVm",recipe.params) return false if r["result"] != "success" r end |
#networks ⇒ Object
34 35 36 |
# File 'lib/unit-hosting/api/vm_group.rb', line 34 def networks server_call("vmGroup.getNetworks") end |
#vm(instance_id) ⇒ Object
instance_idに紐づくvmを返す
24 25 26 |
# File 'lib/unit-hosting/api/vm_group.rb', line 24 def vm(instance_id) Vm.new(instance_id,vm_api_key(instance_id)) end |
#vm_api_key(instance_id) ⇒ Object
18 19 20 21 22 |
# File 'lib/unit-hosting/api/vm_group.rb', line 18 def vm_api_key instance_id vms.each do |vm| return vm["api_key"] if vm["instance_id"] == instance_id end end |
#vms ⇒ Object
このサーバグループに含まれるVMオブジェクトをすべて返す
15 16 17 |
# File 'lib/unit-hosting/api/vm_group.rb', line 15 def vms server_call("vmGroup.getVms") end |