Class: Skytap::Commands::CopyToRegion
- Inherits:
-
Base
- Object
- Base
- Skytap::Commands::CopyToRegion
show all
- Defined in:
- lib/skytap/plugins/vm_copy_to_region.rb
Constant Summary
collapse
- CHECK_PERIOD =
20
Instance Attribute Summary collapse
Attributes inherited from Base
#args, #command_options, #error, #global_options, #invoker, #logger
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#api_token, #ask, #ask_param, #command_line_params, #composed_params, #file_params, #find_id, #initialize, #interactive_params, #invoke, make_from, #noninteractive_params, #programmatic?, #solicit_user_input?, #username
Methods included from Help
#description, #help!, #help?, included, #parameters, #synopsis, #version?
Instance Attribute Details
#copiers ⇒ Object
Returns the value of attribute copiers.
36
37
38
|
# File 'lib/skytap/plugins/vm_copy_to_region.rb', line 36
def copiers
@copiers
end
|
Class Method Details
.command_name ⇒ Object
9
10
11
|
# File 'lib/skytap/plugins/vm_copy_to_region.rb', line 9
def self.command_name
'copytoregion'
end
|
.description ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/skytap/plugins/vm_copy_to_region.rb', line 13
def self.description
<<-"EOF"
Copy one or more VMs to a new region
This process involves exporting the VMs to the local filesystem,
importing them into the new region, then deleting them from the local
filesystem. Ensure you have sufficient disk space.
EOF
end
|
Instance Method Details
#expected_args ⇒ Object
23
24
25
26
27
28
|
# File 'lib/skytap/plugins/vm_copy_to_region.rb', line 23
def expected_args
ActiveSupport::OrderedHash[
'region', 'Name of target region',
'vm_id*', 'One or more IDs of template VMs to copy to the region'
]
end
|
#expected_options ⇒ Object
30
31
32
33
34
|
# File 'lib/skytap/plugins/vm_copy_to_region.rb', line 30
def expected_options
ActiveSupport::OrderedHash[
:tmpdir, {:flag_arg => 'TMPDIR', :desc => 'Temporary directory into which to download VMs'},
]
end
|
#run! ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/skytap/plugins/vm_copy_to_region.rb', line 38
def run!
@copiers = []
region = args.shift
vm_ids = args.collect {|a| find_id(a)}
until vm_ids.empty? && concurrency == 0
if vm_ids.present?
cop = Copier.new(logger, username, api_token, vm_ids.shift, region, command_options[:tmpdir])
copiers << cop
if (line = cop.status_line).present?
logger.info "#{line}\n---"
end
else
sleep CHECK_PERIOD
if (lines = status_lines).present?
logger.info "#{lines}\n---"
end
end
end
response.tap do |res|
logger.info "#{'Summary:'.bright}\n#{res.payload}" unless res.error?
end
end
|
#status_lines ⇒ Object
63
64
65
|
# File 'lib/skytap/plugins/vm_copy_to_region.rb', line 63
def status_lines
copiers.reject(&:finished?).collect(&:status_line).reject(&:blank?).join("\n")
end
|