From 8c415efd50af0d0a11e7a05f6362921619d6a39c Mon Sep 17 00:00:00 2001 From: German Germanovich Date: Sat, 8 Nov 2014 20:03:54 +0300 Subject: [PATCH] [cloudstack] Add get volumes for server --- lib/fog/cloudstack/models/compute/server.rb | 7 ++++++- lib/fog/cloudstack/models/compute/volumes.rb | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/fog/cloudstack/models/compute/server.rb b/lib/fog/cloudstack/models/compute/server.rb index 459a61ff0..49fe95b6b 100644 --- a/lib/fog/cloudstack/models/compute/server.rb +++ b/lib/fog/cloudstack/models/compute/server.rb @@ -50,7 +50,12 @@ module Fog end def ip_addresses - addresses.map{|a| a.ip_address} + addresses.map(&:ip_address) + end + + def volumes + requires :id + service.volumes.all('virtualmachineid' => id) end def public_ip_addresses diff --git a/lib/fog/cloudstack/models/compute/volumes.rb b/lib/fog/cloudstack/models/compute/volumes.rb index 5dcfa1882..b5df36d14 100644 --- a/lib/fog/cloudstack/models/compute/volumes.rb +++ b/lib/fog/cloudstack/models/compute/volumes.rb @@ -7,8 +7,9 @@ module Fog class Volumes < Fog::Collection model Fog::Compute::Cloudstack::Volume - def all - data = service.list_volumes["listvolumesresponse"]["volume"] || [] + def all(attributes = {}) + response = service.list_volumes(attributes) + data = response["listvolumesresponse"]["volume"] || [] load(data) end