Class: VagrantPlugins::Openstack::CinderClient
- Inherits:
-
Object
- Object
- VagrantPlugins::Openstack::CinderClient
- Defined in:
- lib/vagrant-openstack-provider/client/cinder.rb
Instance Method Summary collapse
- #get_all_volumes(env) ⇒ Object
-
#initialize ⇒ CinderClient
constructor
A new instance of CinderClient.
Methods included from HttpUtils
#delete, #get, #get_api_version_list, #post
Methods included from HttpUtils::RequestLogger
Constructor Details
#initialize ⇒ CinderClient
Returns a new instance of CinderClient.
14 15 16 17 |
# File 'lib/vagrant-openstack-provider/client/cinder.rb', line 14 def initialize @logger = Log4r::Logger.new('vagrant_openstack::cinder') @session = VagrantPlugins::Openstack.session end |
Instance Method Details
#get_all_volumes(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant-openstack-provider/client/cinder.rb', line 19 def get_all_volumes(env) volumes_json = get(env, "#{@session.endpoints[:volume]}/volumes/detail") JSON.parse(volumes_json)['volumes'].map do |volume| name = volume['display_name'] name = volume['name'] if name.nil? # To be compatible with cinder api v1 and v2 case volume['attachments'].size when 0 @logger.debug "No attachment found for volume #{volume['id']}" else = volume['attachments'][0] server_id = ['server_id'] device = ['device'] @logger.warn "Found #{.size} attachments for volume #{volume['id']} : " if .size > 1 @logger.debug "Attachment found for volume #{volume['id']} : #{.to_json}" end Volume.new(volume['id'], name, volume['size'], volume['status'], volume['bootable'], server_id, device) end end |