-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
97 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
source/lib/vagrant-openstack-provider/command/volume_list.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'vagrant-openstack-provider/command/utils' | ||
require 'vagrant-openstack-provider/command/abstract_command' | ||
|
||
module VagrantPlugins | ||
module Openstack | ||
module Command | ||
class VolumeList < AbstractCommand | ||
include VagrantPlugins::Openstack::Command::Utils | ||
|
||
def self.synopsis | ||
I18n.t('vagrant_openstack.command.volume_list_synopsis') | ||
end | ||
def cmd(name, argv, env) | ||
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0 || argv == ['--'] | ||
volumes = env[:openstack_client].cinder.get_all_volumes(env) | ||
|
||
rows = [] | ||
volumes.each do |v| | ||
attachment = "#{v.instance_id} (#{v.device})" unless v.instance_id.nil? | ||
rows << [v.id, v.name, v.size, v.status, attachment] | ||
end | ||
display_table(env, ['Id', 'Name', 'Size (Go)', 'Status', 'Attachment (instance id and device)'], rows) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
source/spec/vagrant-openstack-provider/command/volume_list_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'vagrant-openstack-provider/spec_helper' | ||
|
||
describe VagrantPlugins::Openstack::Command::FloatingIpList do | ||
describe 'cmd' do | ||
|
||
let(:cinder) do | ||
double('cinder').tap do |cinder| | ||
cinder.stub(:get_all_volumes) do | ||
[Volume.new('987', 'vol-01', '2', 'available', 'true', nil, nil), | ||
Volume.new('654', 'vol-02', '4', 'in-use', 'false', 'inst-01', '/dev/vdc')] | ||
end | ||
end | ||
end | ||
|
||
let(:env) do | ||
Hash.new.tap do |env| | ||
env[:ui] = double('ui') | ||
env[:ui].stub(:info).with(anything) | ||
env[:openstack_client] = double | ||
env[:openstack_client].stub(:cinder) { cinder } | ||
end | ||
end | ||
|
||
before :each do | ||
@volume_list_cmd = VagrantPlugins::Openstack::Command::VolumeList.new(nil, env) | ||
end | ||
|
||
it 'should get volumes list from server' do | ||
cinder.should_receive(:get_all_volumes).with(env) | ||
@volume_list_cmd.cmd('volume-list', [], env) | ||
end | ||
end | ||
end |