skytapify 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/skytapify/acts_as_skytap_config.rb +24 -2
- data/lib/skytapify/version.rb +1 -1
- metadata +1 -1
@@ -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.
|
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
|
data/lib/skytapify/version.rb
CHANGED