studio_api 3.1.3 → 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +12 -0
- data/VERSION +1 -1
- data/lib/studio_api/appliance.rb +42 -19
- data/lib/studio_api/file.rb +5 -1
- data/lib/studio_api/rpm.rb +5 -1
- data/rubygem-studio_api.spec.template +2 -2
- metadata +62 -5
data/Rakefile
CHANGED
@@ -7,6 +7,18 @@ Bundler::GemHelper.install_tasks
|
|
7
7
|
|
8
8
|
task :default => "test"
|
9
9
|
|
10
|
+
desc "Create package directory containing all things to build RPM"
|
11
|
+
task :package => [:build] do
|
12
|
+
pkg_name = "rubygem-studio_api"
|
13
|
+
include FileUtils::Verbose
|
14
|
+
rm_rf "package"
|
15
|
+
mkdir "package"
|
16
|
+
cp "#{pkg_name}.changes","package/"
|
17
|
+
cp "#{pkg_name}.spec.template","package/#{pkg_name}.spec"
|
18
|
+
sh 'cp pkg/*.gem package/'
|
19
|
+
sh "sed -i \"s:<VERSION>:`cat VERSION`:\" package/#{pkg_name}.spec"
|
20
|
+
end
|
21
|
+
|
10
22
|
Rake::TestTask.new do |t|
|
11
23
|
t.libs << "test"
|
12
24
|
t.pattern = 'test/*_test.rb'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.4
|
data/lib/studio_api/appliance.rb
CHANGED
@@ -24,25 +24,21 @@ module StudioApi
|
|
24
24
|
self.element_name = "status"
|
25
25
|
end
|
26
26
|
|
27
|
+
# Represent appliance configuration
|
28
|
+
# @example set LVM in appliance ( require rails 3 for newly initialized variables )
|
29
|
+
# configuration = appliance.configuration
|
30
|
+
# configuration.lvm.enabled = "true"
|
31
|
+
# configuration.lvm.volume_group = "fooVG"
|
32
|
+
# configuration.lvm.volumes = [ { :path => "/test", :size => "500M" } ]
|
33
|
+
# configuration.save
|
27
34
|
class Configuration < ActiveResource::Base
|
28
35
|
extend StudioResource
|
29
36
|
self.element_name = "configuration"
|
30
37
|
|
31
|
-
def self.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
tree["eulas"] = tree["eulas"]["eula"]
|
36
|
-
tree["autostarts"] = tree["autostarts"]["autostart"] if tree["autostarts"]
|
37
|
-
if tree["databases"]
|
38
|
-
tree["databases"]= tree["databases"]["database"]
|
39
|
-
tree["databases"].each do |d|
|
40
|
-
d["users"] = d["users"]["user"] if d["users"]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
tree["lvm"]["volumes"] = tree["lvm"]["volumes"]["volume"] if tree["lvm"] && tree["lvm"]["volumes"]
|
44
|
-
Firewall.studio_connection = studio_connection
|
45
|
-
Configuration.new tree
|
38
|
+
def self.find (id, prefix_options={})
|
39
|
+
request_str = "/appliances/#{id.to_i}/configuration"
|
40
|
+
response = GenericRequest.new(studio_connection).get request_str
|
41
|
+
Configuration.parse response
|
46
42
|
end
|
47
43
|
|
48
44
|
def update
|
@@ -64,6 +60,29 @@ module StudioApi
|
|
64
60
|
end
|
65
61
|
end
|
66
62
|
end
|
63
|
+
|
64
|
+
private
|
65
|
+
def self.parse response
|
66
|
+
tree = XmlSimple.xml_in(response, "ForceArray" => ["tag","user","eula","autostart","database","volume"])
|
67
|
+
tree["tags"] = tree["tags"]["tag"].reduce({}){ |acc,t| acc.merge :tag => t} if tree["tags"]
|
68
|
+
tree["users"] = tree["users"]["user"]
|
69
|
+
tree["eulas"] = tree["eulas"]["eula"]
|
70
|
+
tree["autostarts"] = tree["autostarts"]["autostart"] if tree["autostarts"]
|
71
|
+
if tree["databases"]
|
72
|
+
tree["databases"]= tree["databases"]["database"]
|
73
|
+
tree["databases"].each do |d|
|
74
|
+
d["users"] = d["users"]["user"] if d["users"]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
tree["lvm"]["volumes"] = tree["lvm"]["volumes"]["volume"] if tree["lvm"] && tree["lvm"]["volumes"]
|
78
|
+
Firewall.studio_connection = studio_connection
|
79
|
+
if defined? ActiveModel #we are in rails3, so set model persistent
|
80
|
+
Configuration.new tree,true
|
81
|
+
else
|
82
|
+
Configuration.new tree
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
67
86
|
end
|
68
87
|
|
69
88
|
# Represents repository assigned to appliance
|
@@ -238,11 +257,11 @@ module StudioApi
|
|
238
257
|
end
|
239
258
|
end
|
240
259
|
|
260
|
+
# Shortcut to find configuration of appliance. Always ask server for new one.
|
261
|
+
# @see StudioApi::Appliance::Configuration
|
241
262
|
def configuration
|
242
|
-
request_str = "/appliances/#{id.to_i}/configuration"
|
243
|
-
response = GenericRequest.new(self.class.studio_connection).get request_str
|
244
263
|
Configuration.studio_connection = self.class.studio_connection
|
245
|
-
Configuration.
|
264
|
+
Configuration.find id
|
246
265
|
end
|
247
266
|
|
248
267
|
# clones appliance or template
|
@@ -254,7 +273,11 @@ module StudioApi
|
|
254
273
|
request_str = "/appliances?clone_from=#{source_id.to_i}"
|
255
274
|
request_str = Util.add_options request_str, options, false
|
256
275
|
response = GenericRequest.new(studio_connection).post request_str, options
|
257
|
-
|
276
|
+
if defined? ActiveModel #we are in rails3, so set model persistent
|
277
|
+
Appliance.new Hash.from_xml(response)["appliance"],true
|
278
|
+
else
|
279
|
+
Appliance.new Hash.from_xml(response)["appliance"]
|
280
|
+
end
|
258
281
|
end
|
259
282
|
|
260
283
|
# Gets all GPG keys assigned to appliance
|
data/lib/studio_api/file.rb
CHANGED
@@ -57,7 +57,11 @@ module StudioApi
|
|
57
57
|
end
|
58
58
|
rq = GenericRequest.new studio_connection
|
59
59
|
response = rq.post request_str, :file => content
|
60
|
-
|
60
|
+
if defined? ActiveModel #rails 3 and ActiveResource persistency
|
61
|
+
File.new Hash.from_xml(response)["file"],true
|
62
|
+
else
|
63
|
+
File.new Hash.from_xml(response)["file"]
|
64
|
+
end
|
61
65
|
end
|
62
66
|
|
63
67
|
private
|
data/lib/studio_api/rpm.rb
CHANGED
@@ -21,7 +21,11 @@ module StudioApi
|
|
21
21
|
# @return [StudioApi::Rpm] uploaded RPM
|
22
22
|
def self.upload content, base_system
|
23
23
|
response = GenericRequest.new(studio_connection).post "/rpms?base_system=#{CGI.escape base_system.to_s}", :file => content
|
24
|
-
|
24
|
+
if defined? ActiveModel #for rails3 we need persistent, otherwise delete method fail
|
25
|
+
self.new Hash.from_xml(response)["rpm"],true
|
26
|
+
else
|
27
|
+
self.new Hash.from_xml(response)["rpm"]
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
# Downloads file to specified path.
|
@@ -27,8 +27,8 @@ License: GPLv2 or The Ruby License
|
|
27
27
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
28
28
|
BuildRequires: rubygems_with_buildroot_patch
|
29
29
|
%rubygems_requires
|
30
|
-
BuildRequires: rubygem-activeresource >=
|
31
|
-
Requires: rubygem-activeresource >=
|
30
|
+
BuildRequires: rubygem-activeresource >= 2.3.8
|
31
|
+
Requires: rubygem-activeresource >= 2.3.8
|
32
32
|
BuildRequires: rubygem-xml-simple >= 1.0.0
|
33
33
|
Requires: rubygem-xml-simple >= 1.0.0
|
34
34
|
#
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: studio_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 11
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 3
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 3.1.
|
9
|
+
- 4
|
10
|
+
version: 3.1.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Josef Reidinger
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-11-28 00:00:00 +00:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: activeresource
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 19
|
27
30
|
segments:
|
28
31
|
- 2
|
29
32
|
- 3
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: xml-simple
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 23
|
41
46
|
segments:
|
42
47
|
- 1
|
43
48
|
- 0
|
@@ -49,9 +54,11 @@ dependencies:
|
|
49
54
|
name: yard
|
50
55
|
prerelease: false
|
51
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
52
58
|
requirements:
|
53
59
|
- - ">="
|
54
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
55
62
|
segments:
|
56
63
|
- 0
|
57
64
|
version: "0"
|
@@ -96,6 +103,52 @@ files:
|
|
96
103
|
- lib/studio_api/util.rb
|
97
104
|
- rubygem-studio_api.changes
|
98
105
|
- rubygem-studio_api.spec.template
|
106
|
+
- test/appliance_test.rb
|
107
|
+
- test/build_test.rb
|
108
|
+
- test/connection_test.rb
|
109
|
+
- test/file_test.rb
|
110
|
+
- test/gallery_test.rb
|
111
|
+
- test/generic_request_test.rb
|
112
|
+
- test/repository_test.rb
|
113
|
+
- test/resource_test.rb
|
114
|
+
- test/responses/api_version.xml
|
115
|
+
- test/responses/appliance.xml
|
116
|
+
- test/responses/appliances.xml
|
117
|
+
- test/responses/build.xml
|
118
|
+
- test/responses/builds.xml
|
119
|
+
- test/responses/configuration.xml
|
120
|
+
- test/responses/file.xml
|
121
|
+
- test/responses/files.xml
|
122
|
+
- test/responses/gallery.xml
|
123
|
+
- test/responses/gallery_appliance.xml
|
124
|
+
- test/responses/gpg_key.xml
|
125
|
+
- test/responses/gpg_keys.xml
|
126
|
+
- test/responses/manifest.xml
|
127
|
+
- test/responses/repositories.xml
|
128
|
+
- test/responses/repository.xml
|
129
|
+
- test/responses/rpm.xml
|
130
|
+
- test/responses/rpms.xml
|
131
|
+
- test/responses/running_build.xml
|
132
|
+
- test/responses/running_build_image_already_exists.xml
|
133
|
+
- test/responses/running_builds.xml
|
134
|
+
- test/responses/software.xml
|
135
|
+
- test/responses/software_fake_response.xml
|
136
|
+
- test/responses/software_installed.xml
|
137
|
+
- test/responses/software_search.xml
|
138
|
+
- test/responses/status-broken.xml
|
139
|
+
- test/responses/status.xml
|
140
|
+
- test/responses/template_sets.xml
|
141
|
+
- test/responses/testdrive.xml
|
142
|
+
- test/responses/testdrives.xml
|
143
|
+
- test/responses/users_0.xml
|
144
|
+
- test/responses/users_1.xml
|
145
|
+
- test/responses/users_2.xml
|
146
|
+
- test/responses/versions.xml
|
147
|
+
- test/rpm_test.rb
|
148
|
+
- test/running_build_test.rb
|
149
|
+
- test/template_set_test.rb
|
150
|
+
- test/test_helper.rb
|
151
|
+
- test/testdrive_test.rb
|
99
152
|
has_rdoc: true
|
100
153
|
homepage: http://github.com/jreidinger/studio_api
|
101
154
|
licenses:
|
@@ -109,16 +162,20 @@ rdoc_options:
|
|
109
162
|
require_paths:
|
110
163
|
- lib
|
111
164
|
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
none: false
|
112
166
|
requirements:
|
113
167
|
- - ">="
|
114
168
|
- !ruby/object:Gem::Version
|
169
|
+
hash: 3
|
115
170
|
segments:
|
116
171
|
- 0
|
117
172
|
version: "0"
|
118
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
|
+
none: false
|
119
175
|
requirements:
|
120
176
|
- - ">="
|
121
177
|
- !ruby/object:Gem::Version
|
178
|
+
hash: 23
|
122
179
|
segments:
|
123
180
|
- 1
|
124
181
|
- 3
|
@@ -127,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
184
|
requirements: []
|
128
185
|
|
129
186
|
rubyforge_project: studio_api
|
130
|
-
rubygems_version: 1.
|
187
|
+
rubygems_version: 1.5.2
|
131
188
|
signing_key:
|
132
189
|
specification_version: 3
|
133
190
|
summary: Intuitive ruby bindings to Studio Api Interface.
|