Class: SakuraCloud::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/sakura_cloud.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_secret, api_server, server_id) ⇒ Server

Returns a new instance of Server.



20
21
22
23
24
25
# File 'lib/sakura_cloud.rb', line 20

def initialize(api_key,api_secret,api_server,server_id)
  @api_key=api_key
  @api_secret=api_secret
  @api_server=api_server
  @server_id=server_id
end

Instance Method Details

#keyboard(*keys) ⇒ Object

ex keyboard()



48
49
50
# File 'lib/sakura_cloud.rb', line 48

def keyboard(*keys) #ex keyboard(["ctrl","alt","delete"])
  response=put(@api_server,"/server/#{@server_id}/keyboard","Keys"=>keys)
end

#plan=(plan_id) ⇒ Object



30
31
32
# File 'lib/sakura_cloud.rb', line 30

def plan=(plan_id)
  response=put(@api_server,"/server/#{@server_id}/to/plan/#{plan_id}")
end

#powerObject



36
37
38
# File 'lib/sakura_cloud.rb', line 36

def power
  response=get(@api_server,"/server/#{@server_id}/power")
end

#profileObject Also known as: server



26
27
28
# File 'lib/sakura_cloud.rb', line 26

def profile
  response=get(@api_server,"/server/"+@server_id)
end

#resetObject



45
46
47
# File 'lib/sakura_cloud.rb', line 45

def reset
  response=put(@api_server,"/server/#{@server_id}/reset")
end

#statusObject



33
34
35
# File 'lib/sakura_cloud.rb', line 33

def status
  response=get(@api_server,"/server/#{@server_id}/monitor")
end

#turn_offObject



42
43
44
# File 'lib/sakura_cloud.rb', line 42

def turn_off
  response=delete(@api_server,"/server/#{@server_id}/power")
end

#turn_onObject



39
40
41
# File 'lib/sakura_cloud.rb', line 39

def turn_on
  response=put(@api_server,"/server/#{@server_id}/power")
end

#vnc_snapshotObject



51
52
53
# File 'lib/sakura_cloud.rb', line 51

def vnc_snapshot
  response=get(@api_server,"/server/#{@server_id}/vnc/snapshot.png")
end