Class: Skytap::Commands::VmExportJob
- Inherits:
-
Object
- Object
- Skytap::Commands::VmExportJob
- Defined in:
- lib/skytap/plugins/vm_download.rb
Instance Attribute Summary collapse
-
#api_token ⇒ Object
readonly
Returns the value of attribute api_token.
-
#export_dir ⇒ Object
readonly
Returns the value of attribute export_dir.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#vm ⇒ Object
readonly
Returns the value of attribute vm.
-
#vm_id ⇒ Object
readonly
Returns the value of attribute vm_id.
Instance Method Summary collapse
- #at_capacity?(exception) ⇒ Boolean
- #create_on_server ⇒ Object
- #export(force_reload = false) ⇒ Object
-
#initialize(logger, username, api_token, vm_id, dir = nil) ⇒ VmExportJob
constructor
A new instance of VmExportJob.
Constructor Details
#initialize(logger, username, api_token, vm_id, dir = nil) ⇒ VmExportJob
Returns a new instance of VmExportJob.
176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/skytap/plugins/vm_download.rb', line 176 def initialize(logger, username, api_token, vm_id, dir=nil) @logger = logger @username = username @api_token = api_token @vm_id = vm_id @vm = Skytap.invoke!(username, api_token, "vm show #{vm_id}") @export_dir = File.join(File.(dir || '.'), "vm_#{vm_id}") FileUtils.mkdir_p(export_dir) create_on_server end |
Instance Attribute Details
#api_token ⇒ Object (readonly)
Returns the value of attribute api_token.
174 175 176 |
# File 'lib/skytap/plugins/vm_download.rb', line 174 def api_token @api_token end |
#export_dir ⇒ Object (readonly)
Returns the value of attribute export_dir.
174 175 176 |
# File 'lib/skytap/plugins/vm_download.rb', line 174 def export_dir @export_dir end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
174 175 176 |
# File 'lib/skytap/plugins/vm_download.rb', line 174 def logger @logger end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
174 175 176 |
# File 'lib/skytap/plugins/vm_download.rb', line 174 def username @username end |
#vm ⇒ Object (readonly)
Returns the value of attribute vm.
174 175 176 |
# File 'lib/skytap/plugins/vm_download.rb', line 174 def vm @vm end |
#vm_id ⇒ Object (readonly)
Returns the value of attribute vm_id.
174 175 176 |
# File 'lib/skytap/plugins/vm_download.rb', line 174 def vm_id @vm_id end |
Instance Method Details
#at_capacity?(exception) ⇒ Boolean
201 202 203 |
# File 'lib/skytap/plugins/vm_download.rb', line 201 def at_capacity?(exception) exception..include?('You cannot export a VM because you may not have more than') end |
#create_on_server ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/skytap/plugins/vm_download.rb', line 189 def create_on_server begin export rescue Exception => ex if at_capacity?(ex) raise NoSlotsAvailable.new else raise end end end |
#export(force_reload = false) ⇒ Object
205 206 207 208 209 210 211 212 213 214 |
# File 'lib/skytap/plugins/vm_download.rb', line 205 def export(force_reload=false) return @export unless @export.nil? || force_reload if @export id = @export['id'] @export = Skytap.invoke!(username, api_token, "export show #{id}") else @export = Skytap.invoke!(username, api_token, "export create", {}, :param => {'vm_id' => vm_id}) end end |