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

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.



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

#networksObject



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

#vmsObject

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



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

def vms
  server_call("vmGroup.getVms")
end