[DigitalOcean] Helper methods for flavor,image,region,ips

This commit is contained in:
Daniel Lobato 2014-11-28 01:02:31 +01:00
Родитель 418fd8fdc1
Коммит c974e8f88c
1 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -174,6 +174,29 @@ module Fog
msg = 'DigitalOcean servers do not support updates'
raise NotImplementedError.new(msg)
end
# Helper method to get the flavor name
def flavor
requires :flavor_id
@flavor ||= service.flavors.get(flavor_id.to_i)
end
# Helper method to get the image name
def image
requires :image_id
@image ||= service.images.get(image_id.to_i)
end
# Helper method to get the region name
def region
requires :region_id
@region ||= service.regions.get(region_id.to_i)
end
# Helper method to get an array with all available IP addresses
def ip_addresses
[public_ip_address, private_ip_address].flatten.select(&:present?)
end
end
end
end