Skip to content

Commit

Permalink
Refactoring get
Browse files Browse the repository at this point in the history
  • Loading branch information
nledez committed Aug 28, 2013
1 parent 57cd9f4 commit 76de3fd
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/proxmox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,34 +89,38 @@ def openvz_post(ostemplate, vmid, config = {})
end
end

def openvz_delete(vmid)
@site["nodes/#{@node}/openvz/#{vmid}"].delete @auth_params do |response, request, result, &block|
check_response response
def openvz_vm_action_post(action, vmid)
@site["nodes/#{@node}/openvz/#{vmid}/status/#{action}"].post "", @auth_params do |response, request, result, &block|
JSON.parse(response.body)['data']
end
end

def openvz_vm_status(vmid)
@site["nodes/#{@node}/openvz/#{vmid}/status/current"].get @auth_params do |response, request, result, &block|
def openvz_vm_action_get(action, vmid)
@site["nodes/#{@node}/openvz/#{vmid}/status/#{action}"].get @auth_params do |response, request, result, &block|
JSON.parse(response.body)['data']
end
end

def openvz_vm_action(action, vmid)
@site["nodes/#{@node}/openvz/#{vmid}/status/#{action}"].post "", @auth_params do |response, request, result, &block|
JSON.parse(response.body)['data']
def openvz_delete(vmid)
@site["nodes/#{@node}/openvz/#{vmid}"].delete @auth_params do |response, request, result, &block|
check_response response
end
end

def openvz_vm_status(vmid)
openvz_vm_action_get("current", vmid)
end

def openvz_vm_start(vmid)
openvz_vm_action("start", vmid)
openvz_vm_action_post("start", vmid)
end

def openvz_vm_stop(vmid)
openvz_vm_action("stop", vmid)
openvz_vm_action_post("stop", vmid)
end

def openvz_vm_shutdown(vmid)
openvz_vm_action("shutdown", vmid)
openvz_vm_action_post("shutdown", vmid)
end

def openvz_vm_config(vmid)
Expand Down

0 comments on commit 76de3fd

Please sign in to comment.