skytapify 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ require 'active_support/concern'
2
+ require 'zip/zip'
3
+
1
4
  module Skytapify
2
5
  module ActsAsSkytapConfig
3
6
  extend ActiveSupport::Concern
@@ -63,13 +66,28 @@ module Skytapify
63
66
  end
64
67
  handle_asynchronously :regenerate_schedules if defined? self.handle_asynchronously
65
68
 
66
-
69
+ def rdp_archive
70
+ Struct.new("ZipContents", :filename, :contents) unless defined? Struct::ZipContents
71
+ files_to_zip = []
72
+ get_config['vms'].each do |vm|
73
+ rdp = rdp_by_vm_id(vm['id'])
74
+ files_to_zip << Struct::ZipContents.new("#{vm['name'].gsub(/[^0-9A-Za-z\-]/, '_')}.rdp", rdp)
75
+ end
76
+ zip = Zip::ZipOutputStream::write_buffer do |z|
77
+ files_to_zip.each do |zc|
78
+ z.put_next_entry(zc.filename)
79
+ z.write(zc.contents)
80
+ end
81
+ end
82
+ zip.rewind
83
+ zip.sysread
84
+ end
67
85
 
68
86
  private
69
87
 
70
88
  def rename_configuration_vms
71
89
  get_config['vms'].each do |vm|
72
- api_call(organization, "vm update #{vm['id']}", {name: user.last_name + ' - ' + vm['name'] }) if user.first_name.present?
90
+ api_call(organization, "vm update #{vm['id']}", {name: user.last_name + ' - ' + vm['name'] }) if user.last_name.present?
73
91
  end
74
92
  end
75
93
 
@@ -167,6 +185,10 @@ module Skytapify
167
185
  api_call(organization, "configuration update #{configuration_id}", {owner: skytap_id})
168
186
  end
169
187
 
188
+ def rdp_by_vm_id(id)
189
+ api_call(organization, "vm show #{id}.rdp")
190
+ end
191
+
170
192
  end
171
193
 
172
194
  end
@@ -1,3 +1,3 @@
1
1
  module Skytapify
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skytapify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: