Class: UnitHosting::Api::VmGroup

Inherits:
Base
  • Object
show all
Defined in:
lib/unit-hosting/api/vm_group.rb

Instance Attribute Summary

Attributes inherited from Base

#api_key, #instance_id, #server

Instance Method Summary collapse

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.



10
11
12
13
14
# File 'lib/unit-hosting/api/vm_group.rb', line 10

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の作成



30
31
32
33
34
# File 'lib/unit-hosting/api/vm_group.rb', line 30

def create_vm(recipe)
  r = server_call("vmGroup.createVm",recipe.params)
  return false if r["result"] != "success"
  r
end

#networksObject



36
37
38
# File 'lib/unit-hosting/api/vm_group.rb', line 36

def networks
  server_call("vmGroup.getNetworks")
end

#vm(instance_id) ⇒ Object

instance_idに紐づくvmを返す



26
27
28
# File 'lib/unit-hosting/api/vm_group.rb', line 26

def vm(instance_id)
  Vm.new(instance_id,vm_api_key(instance_id))
end

#vm_api_key(instance_id) ⇒ Object



19
20
21
22
23
24
# File 'lib/unit-hosting/api/vm_group.rb', line 19

def vm_api_key instance_id
  vms.each do |vm|
    return vm["api_key"] if vm["instance_id"] == instance_id
  end
  nil #missing
end

#vmsObject

このサーバグループに含まれるVMオブジェクトをすべて返す



16
17
18
# File 'lib/unit-hosting/api/vm_group.rb', line 16

def vms
  server_call("vmGroup.getVms")
end