mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2271 from nosborn/vcloud_director_task_progress
[vcloud_director] Fancy progress bar for async tasks.
This commit is contained in:
commit
b5761cc36b
3 changed files with 16 additions and 28 deletions
|
@ -54,14 +54,10 @@ Lazy load isn't used with `get` and `get_by_name` methods are used.
|
|||
|
||||
```ruby
|
||||
vcloud = Fog::Compute::VcloudDirector.new(
|
||||
vcloud_director_username: "<username>@<org_name>",
|
||||
vcloud_director_password: "<password>",
|
||||
vcloud_director_host: 'example.com',
|
||||
:connection_options => {
|
||||
:ssl_verify_peer => false,
|
||||
:connect_timeout => 200,
|
||||
:read_timeout => 200
|
||||
}
|
||||
:vcloud_director_username => "<username>@<org_name>",
|
||||
:vcloud_director_password => "<password>",
|
||||
:vcloud_director_host => 'api.example.com',
|
||||
:vcloud_director_show_progress => false, # task progress bar on/off
|
||||
)
|
||||
```
|
||||
|
||||
|
@ -341,7 +337,6 @@ vm = vapp.vms.get_by_name("DEVWEB")
|
|||
vm.cpu = 4
|
||||
```
|
||||
```no-highlight
|
||||
... success
|
||||
4
|
||||
```
|
||||
|
||||
|
@ -355,7 +350,6 @@ vm = vapp.vms.get_by_name("DEVWEB")
|
|||
vm.memory = 4096
|
||||
```
|
||||
```no-highlight
|
||||
... success
|
||||
4096
|
||||
```
|
||||
|
||||
|
@ -369,7 +363,6 @@ vm = vapp.vms.get_by_name("DEVWEB")
|
|||
vm.power_on
|
||||
```
|
||||
```no-highlight
|
||||
..... success
|
||||
true
|
||||
```
|
||||
|
||||
|
@ -418,7 +411,6 @@ customization.script = "new userdata script"
|
|||
customization.save
|
||||
```
|
||||
```no-highlight
|
||||
.. success
|
||||
true
|
||||
```
|
||||
|
||||
|
@ -464,7 +456,6 @@ network.ip_address_allocation_mode = "DHCP"
|
|||
network.save
|
||||
```
|
||||
```no-highlight
|
||||
.. success
|
||||
true
|
||||
```
|
||||
|
||||
|
@ -548,7 +539,6 @@ vm = vapp.vms.get_by_name("DEVWEB")
|
|||
vm.disks.create(1024)
|
||||
```
|
||||
```no-highlight
|
||||
... success
|
||||
true
|
||||
```
|
||||
|
||||
|
@ -638,7 +628,6 @@ disk = vm.disks.get_by_name("Hard disk 2")
|
|||
disk.capacity = 2048
|
||||
```
|
||||
```no-highlight
|
||||
... success
|
||||
true
|
||||
```
|
||||
|
||||
|
@ -653,7 +642,6 @@ disk = vm.disks.get_by_name("Hard disk 2")
|
|||
disk.destroy
|
||||
```
|
||||
```no-highlight
|
||||
... success
|
||||
true
|
||||
```
|
||||
|
||||
|
@ -714,7 +702,6 @@ vm = vapp.vms.get_by_name("DEVWEB")
|
|||
vm.tags.create('this_is_a_key', 'this_is_a_value')
|
||||
```
|
||||
```no-highlight
|
||||
success
|
||||
true
|
||||
```
|
||||
|
||||
|
@ -744,7 +731,6 @@ vm = vapp.vms.get_by_name("DEVWEB")
|
|||
vm.tags.get_by_name('this_is_a_key').value = 'new_value'
|
||||
```
|
||||
```no-highlight
|
||||
success
|
||||
"new_value"
|
||||
```
|
||||
|
||||
|
@ -758,7 +744,6 @@ vm = vapp.vms.get_by_name("DEVWEB")
|
|||
vm.tags.get_by_name('this_is_a_key').destroy
|
||||
```
|
||||
```no-highlight
|
||||
success
|
||||
true
|
||||
```
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ module Fog
|
|||
class TaskError < Fog::VcloudDirector::Errors::TaskError; end
|
||||
|
||||
requires :vcloud_director_username, :vcloud_director_password, :vcloud_director_host
|
||||
recognizes :vcloud_director_api_version
|
||||
recognizes :vcloud_director_api_version, :vcloud_director_show_progress
|
||||
|
||||
secrets :vcloud_director_password
|
||||
|
||||
|
@ -318,7 +318,8 @@ module Fog
|
|||
extend Fog::Deprecation
|
||||
deprecate :auth_token, :vcloud_token
|
||||
|
||||
attr_reader :end_point, :api_version
|
||||
attr_reader :end_point, :api_version, :show_progress
|
||||
alias_method :show_progress?, :show_progress
|
||||
|
||||
def initialize(options={})
|
||||
@vcloud_director_password = options[:vcloud_director_password]
|
||||
|
@ -332,6 +333,8 @@ module Fog
|
|||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
||||
@end_point = "#{@scheme}://#{@host}#{@path}/"
|
||||
@api_version = options[:vcloud_director_api_version] || Fog::Compute::VcloudDirector::Defaults::API_VERSION
|
||||
@show_progress = options[:vcloud_director_show_progress]
|
||||
@show_progress = $stdin.tty? if @show_progress.nil?
|
||||
end
|
||||
|
||||
def vcloud_token
|
||||
|
|
|
@ -36,14 +36,14 @@ module Fog
|
|||
end
|
||||
|
||||
def non_running?
|
||||
if status == 'running'
|
||||
if progress.to_i == 0
|
||||
printf '.'
|
||||
else
|
||||
print " #{progress} %\r"
|
||||
if @service.show_progress? && (@last_progress ||= 0) < 100
|
||||
if status == 'running'
|
||||
Formatador.redisplay_progressbar(progress, 100, :label => operation_name, :started_at => start_time)
|
||||
@last_progress = progress
|
||||
elsif status == 'success'
|
||||
Formatador.redisplay_progressbar(100, 100, :label => operation_name, :started_at => start_time)
|
||||
@last_progress = 100
|
||||
end
|
||||
else
|
||||
puts " #{status}"
|
||||
end
|
||||
status != 'running'
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue