cloud-appliance-descriptor 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/lib/cloud/appliance/descriptor/appliance.rb +5 -5
- data/lib/cloud/appliance/descriptor/version.rb +1 -1
- data/spec/cloud/appliance/descriptor/appliance_spec.rb +17 -17
- data/spec/cloud/appliance/descriptor/disk_spec.rb +2 -2
- data/spec/cloud/appliance/descriptor/os_spec.rb +2 -2
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZmMzM2M5OGE5M2I0NjA5N2I0MTBlM2Y3MzM0Mzc1N2YxZDFiNGQxNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MmRlZWQ4ZWEwZmI3MDgzNmM5M2U2MDBkYTY5OGQ5NzQxODdiNjFlZQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTRlMWM0ZmQ2NjU1NjMwYjIxMDQ0ZjFmY2Q1MjQxZmE1NDMxNjBkMjg5MTVk
|
10
|
+
NGJiZmEwNjhmZDg1NTU3NDA5Y2QzNmYwYmM1MGYxYmY5OWIyNWE0NjEyMGY1
|
11
|
+
Y2YxOTBlNzc2MWYyYTE2OWFmYmUyNzFiN2NjNzZlYjlhODdlYjQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NWQ1OGRhZTliMzNjMjVmNWE3N2MzNDVmZThlZmQyNTMxYzk1YzEyMWNiN2Zi
|
14
|
+
MzRiOTM4YzMzNmM5ZDcyMGQwOTUyODc1OGE5MDIxZTM5Y2M2ZmY1Y2U1ODRk
|
15
|
+
NDVlY2MzNDIxN2M4NTkxYjkyOTk4MzRkM2JlNDYyMjBkOWQwYjA=
|
@@ -27,22 +27,22 @@ module Cloud
|
|
27
27
|
end
|
28
28
|
|
29
29
|
variables['os'] = os.to_hash
|
30
|
-
variables['disks'] = disks.map
|
30
|
+
variables['disks'] = disks.map(&:to_hash)
|
31
31
|
|
32
|
-
|
32
|
+
JSON.pretty_generate(action => variables)
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.from_json(string)
|
36
36
|
raw = JSON.parse(string)
|
37
|
-
|
37
|
+
from_hash(raw)
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.from_hash(hash)
|
41
41
|
hash.each do |key, value|
|
42
42
|
action = key
|
43
43
|
parameters = value
|
44
|
-
os = parameters.delete
|
45
|
-
disks = parameters.delete
|
44
|
+
os = parameters.delete 'os'
|
45
|
+
disks = parameters.delete 'disks'
|
46
46
|
parameters[:action] = action
|
47
47
|
|
48
48
|
appliance = Appliance.new parameters
|
@@ -42,7 +42,7 @@ module Cloud
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'with arguments representing appliance variables' do
|
45
|
-
let(:appliance) { Appliance.new action: :create, title: 'Title', description: 'description', identifier: 'id', cpu: 5, memory: 2048, version: '548242', groups:
|
45
|
+
let(:appliance) { Appliance.new action: :create, title: 'Title', description: 'description', identifier: 'id', cpu: 5, memory: 2048, version: '548242', groups: %w(GROUP1 GROUP2) }
|
46
46
|
|
47
47
|
it 'creates appliance instance and populete its instance variables' do
|
48
48
|
is_expected.to be_an_instance_of Appliance
|
@@ -58,7 +58,7 @@ module Cloud
|
|
58
58
|
expect(subject.identifier).to eq('id')
|
59
59
|
expect(subject.title).to eq('Title')
|
60
60
|
expect(subject.action).to eq(:create)
|
61
|
-
expect(subject.groups).to eq(
|
61
|
+
expect(subject.groups).to eq(%w(GROUP1 GROUP2))
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -111,7 +111,7 @@ module Cloud
|
|
111
111
|
|
112
112
|
describe '.remove_group' do
|
113
113
|
let(:group) { double('group') }
|
114
|
-
let(:appliance) { Appliance.new groups: [group]}
|
114
|
+
let(:appliance) { Appliance.new groups: [group] }
|
115
115
|
|
116
116
|
it 'removes group from groups array' do
|
117
117
|
expect(subject.groups).to contain_exactly(group)
|
@@ -132,7 +132,7 @@ module Cloud
|
|
132
132
|
|
133
133
|
describe '.remove_disk' do
|
134
134
|
let(:disk) { double('disk') }
|
135
|
-
let(:appliance) { Appliance.new disks: [disk]}
|
135
|
+
let(:appliance) { Appliance.new disks: [disk] }
|
136
136
|
|
137
137
|
it 'removes disk from disks array' do
|
138
138
|
expect(subject.disks).to contain_exactly(disk)
|
@@ -142,7 +142,7 @@ module Cloud
|
|
142
142
|
end
|
143
143
|
|
144
144
|
describe '.add_attribute' do
|
145
|
-
let(:attribute) { { :
|
145
|
+
let(:attribute) { { key: :value } }
|
146
146
|
|
147
147
|
it 'adds attribute to attributes hash' do
|
148
148
|
expect(subject.attributes).to be_empty
|
@@ -152,7 +152,7 @@ module Cloud
|
|
152
152
|
end
|
153
153
|
|
154
154
|
describe '.remove_attribute' do
|
155
|
-
let(:attribute) { { :
|
155
|
+
let(:attribute) { { key: :value } }
|
156
156
|
let(:appliance) { Appliance.new attributes: attribute }
|
157
157
|
|
158
158
|
it 'removes attribute from attributes hash' do
|
@@ -163,13 +163,13 @@ module Cloud
|
|
163
163
|
end
|
164
164
|
|
165
165
|
describe '.to_json' do
|
166
|
-
let(:os) { Os.new distribution: 'Ubuntu', version: '14.04'}
|
166
|
+
let(:os) { Os.new distribution: 'Ubuntu', version: '14.04' }
|
167
167
|
let(:disk1) { Disk.new type: :os, format: :raw }
|
168
168
|
let(:disk2) { Disk.new type: :data, format: :qcow2 }
|
169
|
-
let(:appliance) {Appliance.new action: :create, title: 'Title', version: '548242', groups:
|
170
|
-
let(:disks) { [{
|
169
|
+
let(:appliance) { Appliance.new action: :create, title: 'Title', version: '548242', groups: %w(GROUP1 GROUP2), os: os, disks: [disk1, disk2], attributes: { 'KEY1' => 'VALUE1', 'KEY2' => 'VALUE2' } }
|
170
|
+
let(:disks) { [{ 'type' => 'data', 'format' => 'qcow2' }, { 'type' => 'os', 'format' => 'raw' }] }
|
171
171
|
|
172
|
-
let(:json) { {
|
172
|
+
let(:json) { { 'create' => { 'title' => 'Title', 'version' => '548242', 'groups' => %w(GROUP1 GROUP2), 'attributes' => { 'KEY1' => 'VALUE1', 'KEY2' => 'VALUE2' }, 'description' => '', 'memory' => 1024, 'cpu' => 1, 'os' => { 'distribution' => 'Ubuntu', 'version' => '14.04', 'arch' => 'x86_64', 'type' => 'linux' }, 'disks' => [] } } }
|
173
173
|
|
174
174
|
it 'converts appliance object into its JSON representation' do
|
175
175
|
hash = JSON.parse(subject.to_json)
|
@@ -188,11 +188,11 @@ module Cloud
|
|
188
188
|
expect(subject.action).to eq('create')
|
189
189
|
expect(subject.title).to eq('Title')
|
190
190
|
expect(subject.version).to eq('548242')
|
191
|
-
expect(subject.groups).to eq(
|
191
|
+
expect(subject.groups).to eq(%w(GROUP1 GROUP2))
|
192
192
|
expect(subject.cpu).to eq(1)
|
193
193
|
expect(subject.memory).to eq(1024)
|
194
194
|
expect(subject.description).to eq('')
|
195
|
-
expect(subject.attributes).to eq(
|
195
|
+
expect(subject.attributes).to eq('KEY1' => 'VALUE1', 'KEY2' => 'VALUE2')
|
196
196
|
expect(subject.os.distribution).to eq('Ubuntu')
|
197
197
|
expect(subject.os.version).to eq('14.04')
|
198
198
|
expect(subject.os.type).to eq('linux')
|
@@ -200,7 +200,7 @@ module Cloud
|
|
200
200
|
expect(subject.disks.size).to eq(2)
|
201
201
|
|
202
202
|
disks = subject.disks
|
203
|
-
disks.sort_by!
|
203
|
+
disks.sort_by!(&:type)
|
204
204
|
|
205
205
|
expect(disks[0].type).to eq('data')
|
206
206
|
expect(disks[0].format).to eq('qcow2')
|
@@ -210,18 +210,18 @@ module Cloud
|
|
210
210
|
end
|
211
211
|
|
212
212
|
describe '#from_hash' do
|
213
|
-
let(:hash) { {
|
213
|
+
let(:hash) { { 'create' => { 'title' => 'Title', 'version' => '548242', 'groups' => %w(GROUP1 GROUP2), 'attributes' => { 'KEY1' => 'VALUE1', 'KEY2' => 'VALUE2' }, 'description' => '', 'memory' => 1024, 'cpu' => 1, 'os' => { 'distribution' => 'Ubuntu', 'version' => '14.04', 'arch' => 'x86_64', 'type' => 'linux' }, 'disks' => [{ 'type' => 'data', 'format' => 'qcow2' }, { 'type' => 'os', 'format' => 'raw' }] } } }
|
214
214
|
let(:appliance) { Appliance.from_hash(hash) }
|
215
215
|
|
216
216
|
it 'returns appliance object from its hash representation' do
|
217
217
|
expect(subject.action).to eq('create')
|
218
218
|
expect(subject.title).to eq('Title')
|
219
219
|
expect(subject.version).to eq('548242')
|
220
|
-
expect(subject.groups).to eq(
|
220
|
+
expect(subject.groups).to eq(%w(GROUP1 GROUP2))
|
221
221
|
expect(subject.cpu).to eq(1)
|
222
222
|
expect(subject.memory).to eq(1024)
|
223
223
|
expect(subject.description).to eq('')
|
224
|
-
expect(subject.attributes).to eq(
|
224
|
+
expect(subject.attributes).to eq('KEY1' => 'VALUE1', 'KEY2' => 'VALUE2')
|
225
225
|
expect(subject.os.distribution).to eq('Ubuntu')
|
226
226
|
expect(subject.os.version).to eq('14.04')
|
227
227
|
expect(subject.os.type).to eq('linux')
|
@@ -229,7 +229,7 @@ module Cloud
|
|
229
229
|
expect(subject.disks.size).to eq(2)
|
230
230
|
|
231
231
|
disks = subject.disks
|
232
|
-
disks.sort_by!
|
232
|
+
disks.sort_by!(&:type)
|
233
233
|
|
234
234
|
expect(disks[0].type).to eq('data')
|
235
235
|
expect(disks[0].format).to eq('qcow2')
|
@@ -64,9 +64,9 @@ module Cloud
|
|
64
64
|
let(:disk) { Disk.new type: :os, format: :raw, path: '/path/to/image' }
|
65
65
|
|
66
66
|
it 'returns hash representation of disk instance - instance variables as keys with their values' do
|
67
|
-
expect(subject.to_hash).to eq(
|
67
|
+
expect(subject.to_hash).to eq('type' => :os, 'format' => :raw, 'path' => '/path/to/image')
|
68
68
|
subject.target = 'vda'
|
69
|
-
expect(subject.to_hash).to eq(
|
69
|
+
expect(subject.to_hash).to eq('type' => :os, 'format' => :raw, 'path' => '/path/to/image', 'target' => 'vda')
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -70,9 +70,9 @@ module Cloud
|
|
70
70
|
let(:os) { Os.new distribution: 'Ubuntu' }
|
71
71
|
|
72
72
|
it 'returns hash representation of os instance - instance variables as keys with their values' do
|
73
|
-
expect(subject.to_hash).to eq(
|
73
|
+
expect(subject.to_hash).to eq('arch' => :x86_64, 'type' => :linux, 'distribution' => 'Ubuntu')
|
74
74
|
subject.version = '14.04'
|
75
|
-
expect(subject.to_hash).to eq(
|
75
|
+
expect(subject.to_hash).to eq('arch' => :x86_64, 'type' => :linux, 'distribution' => 'Ubuntu', 'version' => '14.04')
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud-appliance-descriptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Kimle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.0.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.9.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.9.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubygems-tasks
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.2.4
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.2.4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0.32'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.32'
|
97
97
|
description: Helper gem to ease creation of cloud appliance descriptor.
|
@@ -101,9 +101,9 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- .travis.yml
|
107
107
|
- CODE_OF_CONDUCT.md
|
108
108
|
- Gemfile
|
109
109
|
- LICENSE.txt
|
@@ -132,17 +132,17 @@ require_paths:
|
|
132
132
|
- lib
|
133
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
|
-
- -
|
135
|
+
- - ! '>='
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
139
|
requirements:
|
140
|
-
- -
|
140
|
+
- - ! '>='
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.4.
|
145
|
+
rubygems_version: 2.4.8
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Helper gem to ease creation of cloud appliance descriptor.
|