steamcannon-deltacloud-client 0.0.9.7.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +176 -0
- data/Rakefile +61 -0
- data/bin/deltacloudc +158 -0
- data/init.rb +20 -0
- data/lib/deltacloud.rb +586 -0
- data/lib/documentation.rb +98 -0
- data/lib/plain_formatter.rb +86 -0
- data/specs/data/images/img1.yml +4 -0
- data/specs/data/images/img2.yml +4 -0
- data/specs/data/images/img3.yml +4 -0
- data/specs/data/instances/inst0.yml +16 -0
- data/specs/data/instances/inst1.yml +9 -0
- data/specs/data/instances/inst2.yml +9 -0
- data/specs/data/storage_snapshots/snap1.yml +4 -0
- data/specs/data/storage_snapshots/snap2.yml +4 -0
- data/specs/data/storage_snapshots/snap3.yml +4 -0
- data/specs/data/storage_volumes/vol1.yml +6 -0
- data/specs/data/storage_volumes/vol2.yml +6 -0
- data/specs/data/storage_volumes/vol3.yml +6 -0
- data/specs/fixtures/images/img1.yml +4 -0
- data/specs/fixtures/images/img2.yml +4 -0
- data/specs/fixtures/images/img3.yml +4 -0
- data/specs/fixtures/instances/inst0.yml +16 -0
- data/specs/fixtures/instances/inst1.yml +9 -0
- data/specs/fixtures/instances/inst2.yml +9 -0
- data/specs/fixtures/storage_snapshots/snap1.yml +4 -0
- data/specs/fixtures/storage_snapshots/snap2.yml +4 -0
- data/specs/fixtures/storage_snapshots/snap3.yml +4 -0
- data/specs/fixtures/storage_volumes/vol1.yml +6 -0
- data/specs/fixtures/storage_volumes/vol2.yml +6 -0
- data/specs/fixtures/storage_volumes/vol3.yml +6 -0
- data/specs/hardware_profiles_spec.rb +78 -0
- data/specs/images_spec.rb +105 -0
- data/specs/initialization_spec.rb +60 -0
- data/specs/instance_states_spec.rb +78 -0
- data/specs/instances_spec.rb +191 -0
- data/specs/realms_spec.rb +64 -0
- data/specs/shared/resources.rb +30 -0
- data/specs/spec_helper.rb +52 -0
- data/specs/storage_snapshot_spec.rb +77 -0
- data/specs/storage_volume_spec.rb +89 -0
- metadata +191 -0
@@ -0,0 +1,191 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2009 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
|
19
|
+
|
20
|
+
require 'specs/spec_helper'
|
21
|
+
|
22
|
+
describe "instances" do
|
23
|
+
|
24
|
+
it_should_behave_like "all resources"
|
25
|
+
|
26
|
+
it "should allow retrieval of all instances" do
|
27
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
28
|
+
instances = client.instances
|
29
|
+
instances.should_not be_empty
|
30
|
+
instances.each do |instance|
|
31
|
+
instance.uri.should_not be_nil
|
32
|
+
instance.uri.should be_a( String )
|
33
|
+
instance.owner_id.should_not be_nil
|
34
|
+
instance.owner_id.should be_a( String )
|
35
|
+
instance.image.should_not be_nil
|
36
|
+
instance.image.should be_a( DeltaCloud::API::Image )
|
37
|
+
instance.hardware_profile.should_not be_nil
|
38
|
+
instance.hardware_profile.should be_a( DeltaCloud::API::HardwareProfile )
|
39
|
+
instance.state.should_not be_nil
|
40
|
+
instance.state.should be_a( String )
|
41
|
+
instance.public_addresses.should_not be_nil
|
42
|
+
instance.public_addresses.should_not be_empty
|
43
|
+
instance.public_addresses.should be_a( Array )
|
44
|
+
instance.private_addresses.should_not be_nil
|
45
|
+
instance.private_addresses.should_not be_empty
|
46
|
+
instance.private_addresses.should be_a( Array )
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should allow navigation from instance to image" do
|
52
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
53
|
+
instances = client.instances
|
54
|
+
instances.should_not be_empty
|
55
|
+
instance = instances.first
|
56
|
+
instance.image.should_not be_nil
|
57
|
+
instance.image.description.should_not be_nil
|
58
|
+
instance.image.description.should be_a(String)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should allow retrieval of a single instance" do
|
63
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
64
|
+
instance = client.instance( "inst0" )
|
65
|
+
instance.should_not be_nil
|
66
|
+
instance.name.should_not be_nil
|
67
|
+
instance.name.should eql( 'Mock Instance With Profile Change' )
|
68
|
+
instance.uri.should_not be_nil
|
69
|
+
instance.uri.should be_a( String )
|
70
|
+
instance.owner_id.should eql( "mockuser" )
|
71
|
+
instance.public_addresses.first.should eql( "img1.inst0.public.com" )
|
72
|
+
instance.image.should_not be_nil
|
73
|
+
instance.image.uri.should eql( API_URL + "/images/img1" )
|
74
|
+
instance.hardware_profile.should_not be_nil
|
75
|
+
instance.hardware_profile.should_not be_nil
|
76
|
+
instance.hardware_profile.uri.should eql( API_URL + "/hardware_profiles/m1-large" )
|
77
|
+
instance.hardware_profile.memory.value.should eql(10240.0)
|
78
|
+
instance.hardware_profile.storage.value.should eql(850.0)
|
79
|
+
instance.state.should eql( "RUNNING" )
|
80
|
+
instance.actions.should_not be_nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should allow creation of new instances with reasonable defaults" do
|
85
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
86
|
+
instance = client.create_instance( 'img1', :name=>'TestInstance' )
|
87
|
+
instance.should_not be_nil
|
88
|
+
instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
|
89
|
+
instance.id.should match( /inst[0-9]+/ )
|
90
|
+
instance.name.should eql( 'TestInstance' )
|
91
|
+
instance.image.id.should eql( 'img1' )
|
92
|
+
instance.hardware_profile.id.should eql( 'm1-large' )
|
93
|
+
instance.realm.id.should eql( 'us' )
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should allow creation of new instances with specific realm" do
|
98
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
99
|
+
instance = client.create_instance( 'img1', :realm=>'eu' )
|
100
|
+
instance.should_not be_nil
|
101
|
+
instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
|
102
|
+
instance.id.should match( /inst[0-9]+/ )
|
103
|
+
instance.image.id.should eql( 'img1' )
|
104
|
+
instance.hardware_profile.id.should eql( 'm1-large' )
|
105
|
+
instance.realm.id.should eql( 'eu' )
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should allow creation of new instances with specific hardware profile" do
|
110
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
111
|
+
instance = client.create_instance( 'img1',
|
112
|
+
:hardware_profile=>'m1-xlarge' )
|
113
|
+
instance.should_not be_nil
|
114
|
+
instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
|
115
|
+
instance.id.should match( /inst[0-9]+/ )
|
116
|
+
instance.image.id.should eql( 'img1' )
|
117
|
+
instance.hardware_profile.id.should eql( 'm1-xlarge' )
|
118
|
+
instance.realm.id.should eql( 'us' )
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should allow creation of new instances with specific hardware profile overriding memory" do
|
123
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
124
|
+
hwp = { :id => 'm1-xlarge', :memory => 32768 }
|
125
|
+
instance = client.create_instance( 'img1', :hardware_profile=> hwp )
|
126
|
+
instance.should_not be_nil
|
127
|
+
instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
|
128
|
+
instance.id.should match( /inst[0-9]+/ )
|
129
|
+
instance.image.id.should eql( 'img1' )
|
130
|
+
instance.hardware_profile.id.should eql( 'm1-xlarge' )
|
131
|
+
instance.hardware_profile.memory.value.should eql(12288.0)
|
132
|
+
instance.realm.id.should eql( 'us' )
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should allow creation of new instances with specific realm and hardware profile" do
|
137
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
138
|
+
instance = client.create_instance( 'img1', :realm=>'eu',
|
139
|
+
:hardware_profile=>'m1-xlarge' )
|
140
|
+
instance.should_not be_nil
|
141
|
+
instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
|
142
|
+
instance.id.should match( /inst[0-9]+/ )
|
143
|
+
instance.image.id.should eql( 'img1' )
|
144
|
+
instance.hardware_profile.id.should eql( 'm1-xlarge' )
|
145
|
+
instance.realm.id.should eql( 'eu' )
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should allow fetching of instances by id" do
|
150
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
151
|
+
instance = client.instance( 'inst1' )
|
152
|
+
instance.should_not be_nil
|
153
|
+
instance.uri.should_not be_nil
|
154
|
+
instance.uri.should be_a( String )
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should allow fetching of instances by URI" do
|
159
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
160
|
+
instance = client.fetch_instance( API_URL + '/instances/inst1' )
|
161
|
+
instance.should_not be_nil
|
162
|
+
instance.uri.should eql( API_URL + '/instances/inst1' )
|
163
|
+
instance.id.should eql( 'inst1' )
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "performing actions on instances" do
|
168
|
+
it "should allow actions that are valid" do
|
169
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
170
|
+
instance = client.instance( 'inst1' )
|
171
|
+
instance.should_not be_nil
|
172
|
+
instance.state.should eql( "RUNNING" )
|
173
|
+
instance.uri.should eql( API_URL + '/instances/inst1' )
|
174
|
+
instance.id.should eql( 'inst1' )
|
175
|
+
instance.stop!
|
176
|
+
instance.state.should eql( "STOPPED" )
|
177
|
+
instance.start!
|
178
|
+
instance.state.should eql( "RUNNING" )
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should not allow actions that are invalid" do
|
183
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
184
|
+
instance = client.instance( 'inst1' )
|
185
|
+
instance.should_not be_nil
|
186
|
+
instance.state.should eql( "RUNNING" )
|
187
|
+
lambda{instance.start}.should raise_error
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2009 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
|
19
|
+
require 'specs/spec_helper'
|
20
|
+
|
21
|
+
describe "realms" do
|
22
|
+
|
23
|
+
it_should_behave_like "all resources"
|
24
|
+
|
25
|
+
it "should allow retrieval of all realms" do
|
26
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
27
|
+
realms = client.realms
|
28
|
+
realms.should_not be_empty
|
29
|
+
realms.each do |realm|
|
30
|
+
realm.uri.should_not be_nil
|
31
|
+
realm.uri.should be_a(String)
|
32
|
+
realm.id.should_not be_nil
|
33
|
+
realm.id.should be_a(String)
|
34
|
+
realm.name.should_not be_nil
|
35
|
+
realm.name.should be_a(String)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
it "should allow fetching a realm by id" do
|
42
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
43
|
+
realm = client.realm( 'us' )
|
44
|
+
realm.should_not be_nil
|
45
|
+
realm.id.should eql( 'us' )
|
46
|
+
realm.name.should eql( 'United States' )
|
47
|
+
realm.state.should eql( 'AVAILABLE' )
|
48
|
+
realm = client.realm( 'eu' )
|
49
|
+
realm.should_not be_nil
|
50
|
+
realm.id.should eql( 'eu' )
|
51
|
+
realm.name.should eql( 'Europe' )
|
52
|
+
realm.state.should eql( 'AVAILABLE' )
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should allow fetching a realm by URI" do
|
57
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
58
|
+
realm = client.fetch_realm( API_URL + '/realms/us' )
|
59
|
+
realm.should_not be_nil
|
60
|
+
realm.id.should eql( 'us' )
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2009 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
|
19
|
+
|
20
|
+
shared_examples_for "all resources" do
|
21
|
+
|
22
|
+
before(:each) do
|
23
|
+
reload_fixtures
|
24
|
+
end
|
25
|
+
|
26
|
+
after(:each) do
|
27
|
+
#clean_fixtures
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2009 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
|
19
|
+
require 'rubygems'
|
20
|
+
require 'yaml'
|
21
|
+
require 'fileutils'
|
22
|
+
|
23
|
+
api_host = ENV['API_HOST']
|
24
|
+
( api_host = 'localhost' ) if api_host.nil?
|
25
|
+
( api_host = 'localhost' ) if api_host == ''
|
26
|
+
|
27
|
+
api_port = ENV['API_PORT']
|
28
|
+
( api_port = 3001 ) if api_port.nil?
|
29
|
+
( api_port = 3001 ) if api_port == ''
|
30
|
+
|
31
|
+
API_HOST = api_host
|
32
|
+
API_PORT = api_port
|
33
|
+
API_PATH = '/api'
|
34
|
+
|
35
|
+
API_URL = "http://#{API_HOST}:#{API_PORT}#{API_PATH}"
|
36
|
+
API_NAME = 'mockuser'
|
37
|
+
API_PASSWORD = 'mockpassword'
|
38
|
+
|
39
|
+
$: << File.dirname( __FILE__ ) + '/../lib'
|
40
|
+
require 'deltacloud'
|
41
|
+
|
42
|
+
def clean_fixtures
|
43
|
+
FileUtils.rm_rf( File.dirname( __FILE__ ) + '/data' )
|
44
|
+
end
|
45
|
+
|
46
|
+
def reload_fixtures
|
47
|
+
clean_fixtures
|
48
|
+
FileUtils.cp_r( File.dirname( __FILE__) + '/fixtures', File.dirname( __FILE__ ) + '/data' )
|
49
|
+
end
|
50
|
+
|
51
|
+
$: << File.dirname( __FILE__ )
|
52
|
+
require 'shared/resources'
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2009 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
|
19
|
+
|
20
|
+
require 'specs/spec_helper'
|
21
|
+
|
22
|
+
describe "storage snapshot" do
|
23
|
+
|
24
|
+
it_should_behave_like "all resources"
|
25
|
+
|
26
|
+
it "allow retrieval of all storage volumes owned by the current user" do
|
27
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
28
|
+
client.connect do |client|
|
29
|
+
storage_snapshots = client.storage_snapshots
|
30
|
+
storage_snapshots.should_not be_nil
|
31
|
+
storage_snapshots.should_not be_empty
|
32
|
+
ids = storage_snapshots.collect{|e| e.id}
|
33
|
+
ids.size.should eql( 2 )
|
34
|
+
ids.should include( 'snap2' )
|
35
|
+
ids.should include( 'snap3' )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should allow fetching of storage volume by id" do
|
40
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
41
|
+
client.connect do |client|
|
42
|
+
storage_snapshot = client.storage_snapshot( 'snap2' )
|
43
|
+
storage_snapshot.should_not be_nil
|
44
|
+
storage_snapshot.id.should eql( 'snap2' )
|
45
|
+
storage_snapshot.storage_volume.capacity.should eql( 1.0 )
|
46
|
+
storage_snapshot.storage_volume.id.should eql( 'vol2' )
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should allow fetching of storage volume by URI" do
|
51
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
52
|
+
client.connect do |client|
|
53
|
+
storage_snapshot = client.fetch_storage_snapshot( API_URL + '/storage_snapshots/snap2' )
|
54
|
+
storage_snapshot.should_not be_nil
|
55
|
+
storage_snapshot.id.should eql( 'snap2' )
|
56
|
+
storage_snapshot.storage_volume.capacity.should eql( 1.0 )
|
57
|
+
storage_snapshot.storage_volume.id.should eql( 'vol2' )
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return nil for unknown storage volume by ID" do
|
62
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
63
|
+
client.connect do |client|
|
64
|
+
storage_snapshot = client.storage_snapshot( "bogus" )
|
65
|
+
storage_snapshot.should be_nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should return nil for unknown storage volume by URI" do
|
70
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
71
|
+
client.connect do |client|
|
72
|
+
storage_snapshot = client.fetch_storage_snapshot( API_URL + '/storage_snapshots/bogus' )
|
73
|
+
storage_snapshot.should be_nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2009 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
+
# contributor license agreements. See the NOTICE file distributed with
|
6
|
+
# this work for additional information regarding copyright ownership. The
|
7
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance with the
|
9
|
+
# License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
+
# License for the specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
|
19
|
+
|
20
|
+
require 'specs/spec_helper'
|
21
|
+
|
22
|
+
describe "storage volumes" do
|
23
|
+
|
24
|
+
it_should_behave_like "all resources"
|
25
|
+
|
26
|
+
it "allow retrieval of all storage volumes owned by the current user" do
|
27
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
28
|
+
client.connect do |client|
|
29
|
+
storage_volumes = client.storage_volumes
|
30
|
+
storage_volumes.should_not be_nil
|
31
|
+
storage_volumes.should_not be_empty
|
32
|
+
ids = storage_volumes.collect{|e| e.id}
|
33
|
+
ids.size.should eql( 2 )
|
34
|
+
ids.should include( 'vol2' )
|
35
|
+
ids.should include( 'vol3' )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should allow fetching of storage volume by id" do
|
40
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
41
|
+
client.connect do |client|
|
42
|
+
storage_volume = client.storage_volume( 'vol3' )
|
43
|
+
storage_volume.id.should eql( 'vol3' )
|
44
|
+
storage_volume.uri.should eql( API_URL + '/storage_volumes/vol3' )
|
45
|
+
storage_volume.state.should eql( 'IN-USE' )
|
46
|
+
storage_volume.capacity.should eql( 1.0 )
|
47
|
+
storage_volume.device.should eql( '/dev/sda1' )
|
48
|
+
storage_volume.instance.should_not be_nil
|
49
|
+
storage_volume.instance.id.should eql( 'inst1' )
|
50
|
+
ip = storage_volume.instance
|
51
|
+
ip.hardware_profile.architecture.value.should eql( 'i386' )
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should allow fetching of storage volume by URI" do
|
56
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
57
|
+
client.connect do |client|
|
58
|
+
storage_volume = client.fetch_storage_volume( API_URL + '/storage_volumes/vol3' )
|
59
|
+
storage_volume.should_not be_nil
|
60
|
+
storage_volume.id.should eql( 'vol3' )
|
61
|
+
storage_volume.uri.should eql( API_URL + '/storage_volumes/vol3' )
|
62
|
+
storage_volume.state.should eql( 'IN-USE' )
|
63
|
+
storage_volume.capacity.should eql( 1.0 )
|
64
|
+
storage_volume.device.should eql( '/dev/sda1' )
|
65
|
+
storage_volume.instance.should_not be_nil
|
66
|
+
storage_volume.instance.id.should eql( 'inst1' )
|
67
|
+
ip = storage_volume.instance
|
68
|
+
ip.hardware_profile.architecture.value.should eql( 'i386' )
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should return nil for unknown storage volume by ID" do
|
73
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
74
|
+
client.connect do |client|
|
75
|
+
storage_volume = client.storage_volume( 'bogus' )
|
76
|
+
storage_volume.should be_nil
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should return nil for unknown storage volume by URI" do
|
81
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
82
|
+
client.connect do |client|
|
83
|
+
storage_volume = client.fetch_storage_volume( API_URL + '/storage_volumes/bogus' )
|
84
|
+
storage_volume.should be_nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: steamcannon-deltacloud-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 233
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 9
|
10
|
+
- 7
|
11
|
+
- 1
|
12
|
+
version: 0.0.9.7.1
|
13
|
+
platform: java
|
14
|
+
authors:
|
15
|
+
- Red Hat, Inc.
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2010-10-07 00:00:00 -04:00
|
21
|
+
default_executable: deltacloudc
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
name: rest-client
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
hash: 3
|
32
|
+
segments:
|
33
|
+
- 1
|
34
|
+
- 4
|
35
|
+
- 2
|
36
|
+
version: 1.4.2
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id001
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: nokogiri
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 62196439
|
48
|
+
segments:
|
49
|
+
- 1
|
50
|
+
- 5
|
51
|
+
- 0
|
52
|
+
- beta
|
53
|
+
- 2
|
54
|
+
version: 1.5.0.beta.2
|
55
|
+
type: :runtime
|
56
|
+
version_requirements: *id002
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rspec
|
59
|
+
prerelease: false
|
60
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 27
|
66
|
+
segments:
|
67
|
+
- 1
|
68
|
+
- 3
|
69
|
+
- 0
|
70
|
+
version: 1.3.0
|
71
|
+
type: :development
|
72
|
+
version_requirements: *id003
|
73
|
+
description: Deltacloud REST Client for API
|
74
|
+
email: deltacloud-users@lists.fedorahosted.org
|
75
|
+
executables:
|
76
|
+
- deltacloudc
|
77
|
+
extensions: []
|
78
|
+
|
79
|
+
extra_rdoc_files:
|
80
|
+
- COPYING
|
81
|
+
files:
|
82
|
+
- Rakefile
|
83
|
+
- lib/plain_formatter.rb
|
84
|
+
- lib/deltacloud.rb
|
85
|
+
- lib/documentation.rb
|
86
|
+
- init.rb
|
87
|
+
- bin/deltacloudc
|
88
|
+
- specs/data/storage_volumes/vol3.yml
|
89
|
+
- specs/data/storage_volumes/vol1.yml
|
90
|
+
- specs/data/storage_volumes/vol2.yml
|
91
|
+
- specs/data/images/img2.yml
|
92
|
+
- specs/data/images/img3.yml
|
93
|
+
- specs/data/images/img1.yml
|
94
|
+
- specs/data/instances/inst2.yml
|
95
|
+
- specs/data/instances/inst1.yml
|
96
|
+
- specs/data/instances/inst0.yml
|
97
|
+
- specs/data/storage_snapshots/snap3.yml
|
98
|
+
- specs/data/storage_snapshots/snap1.yml
|
99
|
+
- specs/data/storage_snapshots/snap2.yml
|
100
|
+
- specs/fixtures/storage_volumes/vol3.yml
|
101
|
+
- specs/fixtures/storage_volumes/vol1.yml
|
102
|
+
- specs/fixtures/storage_volumes/vol2.yml
|
103
|
+
- specs/fixtures/images/img2.yml
|
104
|
+
- specs/fixtures/images/img3.yml
|
105
|
+
- specs/fixtures/images/img1.yml
|
106
|
+
- specs/fixtures/instances/inst2.yml
|
107
|
+
- specs/fixtures/instances/inst1.yml
|
108
|
+
- specs/fixtures/instances/inst0.yml
|
109
|
+
- specs/fixtures/storage_snapshots/snap3.yml
|
110
|
+
- specs/fixtures/storage_snapshots/snap1.yml
|
111
|
+
- specs/fixtures/storage_snapshots/snap2.yml
|
112
|
+
- specs/storage_snapshot_spec.rb
|
113
|
+
- specs/hardware_profiles_spec.rb
|
114
|
+
- specs/images_spec.rb
|
115
|
+
- specs/realms_spec.rb
|
116
|
+
- specs/instances_spec.rb
|
117
|
+
- specs/storage_volume_spec.rb
|
118
|
+
- specs/spec_helper.rb
|
119
|
+
- specs/instance_states_spec.rb
|
120
|
+
- specs/shared/resources.rb
|
121
|
+
- specs/initialization_spec.rb
|
122
|
+
- COPYING
|
123
|
+
has_rdoc: true
|
124
|
+
homepage: http://www.deltacloud.org
|
125
|
+
licenses: []
|
126
|
+
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
hash: 3
|
138
|
+
segments:
|
139
|
+
- 0
|
140
|
+
version: "0"
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
requirements: []
|
151
|
+
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 1.3.7
|
154
|
+
signing_key:
|
155
|
+
specification_version: 3
|
156
|
+
summary: Deltacloud REST Client
|
157
|
+
test_files:
|
158
|
+
- specs/data/storage_volumes/vol3.yml
|
159
|
+
- specs/data/storage_volumes/vol1.yml
|
160
|
+
- specs/data/storage_volumes/vol2.yml
|
161
|
+
- specs/data/images/img2.yml
|
162
|
+
- specs/data/images/img3.yml
|
163
|
+
- specs/data/images/img1.yml
|
164
|
+
- specs/data/instances/inst2.yml
|
165
|
+
- specs/data/instances/inst1.yml
|
166
|
+
- specs/data/instances/inst0.yml
|
167
|
+
- specs/data/storage_snapshots/snap3.yml
|
168
|
+
- specs/data/storage_snapshots/snap1.yml
|
169
|
+
- specs/data/storage_snapshots/snap2.yml
|
170
|
+
- specs/fixtures/storage_volumes/vol3.yml
|
171
|
+
- specs/fixtures/storage_volumes/vol1.yml
|
172
|
+
- specs/fixtures/storage_volumes/vol2.yml
|
173
|
+
- specs/fixtures/images/img2.yml
|
174
|
+
- specs/fixtures/images/img3.yml
|
175
|
+
- specs/fixtures/images/img1.yml
|
176
|
+
- specs/fixtures/instances/inst2.yml
|
177
|
+
- specs/fixtures/instances/inst1.yml
|
178
|
+
- specs/fixtures/instances/inst0.yml
|
179
|
+
- specs/fixtures/storage_snapshots/snap3.yml
|
180
|
+
- specs/fixtures/storage_snapshots/snap1.yml
|
181
|
+
- specs/fixtures/storage_snapshots/snap2.yml
|
182
|
+
- specs/storage_snapshot_spec.rb
|
183
|
+
- specs/hardware_profiles_spec.rb
|
184
|
+
- specs/images_spec.rb
|
185
|
+
- specs/realms_spec.rb
|
186
|
+
- specs/instances_spec.rb
|
187
|
+
- specs/storage_volume_spec.rb
|
188
|
+
- specs/spec_helper.rb
|
189
|
+
- specs/instance_states_spec.rb
|
190
|
+
- specs/shared/resources.rb
|
191
|
+
- specs/initialization_spec.rb
|