steamcannon-deltacloud-client 0.0.9.7.2
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 +183 -0
@@ -0,0 +1,105 @@
|
|
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 "images" do
|
23
|
+
|
24
|
+
it_should_behave_like "all resources"
|
25
|
+
|
26
|
+
it "should allow retrieval of all images" do
|
27
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
28
|
+
images = client.images
|
29
|
+
images.should_not be_empty
|
30
|
+
images.size.should eql( 3 )
|
31
|
+
images.each do |image|
|
32
|
+
image.uri.should_not be_nil
|
33
|
+
image.uri.should be_a(String)
|
34
|
+
image.description.should_not be_nil
|
35
|
+
image.description.should be_a(String)
|
36
|
+
image.architecture.should_not be_nil
|
37
|
+
image.architecture.should be_a(String)
|
38
|
+
image.owner_id.should_not be_nil
|
39
|
+
image.owner_id.should be_a(String)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should allow retrieval of my own images" do
|
45
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
46
|
+
images = client.images( :owner_id=>:self )
|
47
|
+
images.should_not be_empty
|
48
|
+
images.size.should eql( 1 )
|
49
|
+
images.each do |image|
|
50
|
+
image.uri.should_not be_nil
|
51
|
+
image.uri.should be_a(String)
|
52
|
+
image.description.should_not be_nil
|
53
|
+
image.description.should be_a(String)
|
54
|
+
image.architecture.should_not be_nil
|
55
|
+
image.architecture.should be_a(String)
|
56
|
+
image.owner_id.should_not be_nil
|
57
|
+
image.owner_id.should be_a(String)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should allow retrieval of a single image by ID" do
|
63
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
64
|
+
image = client.image( 'img1' )
|
65
|
+
image.should_not be_nil
|
66
|
+
image.uri.should eql( API_URL + '/images/img1' )
|
67
|
+
image.id.should eql( 'img1' )
|
68
|
+
image.architecture.should eql( 'x86_64' )
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should allow retrieval of a single image by URI" do
|
73
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
74
|
+
image = client.fetch_image( API_URL + '/images/img1' )
|
75
|
+
image.should_not be_nil
|
76
|
+
image.uri.should eql( API_URL + '/images/img1' )
|
77
|
+
image.id.should eql( 'img1' )
|
78
|
+
image.architecture.should eql( 'x86_64' )
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "filtering by architecture" do
|
83
|
+
it "return matching images" do
|
84
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
85
|
+
images = client.images( :architecture=>'x86_64' )
|
86
|
+
images.should_not be_empty
|
87
|
+
images.each do |image|
|
88
|
+
image.architecture.should eql( 'x86_64' )
|
89
|
+
end
|
90
|
+
images = client.images( :architecture=>'i386' )
|
91
|
+
images.should_not be_empty
|
92
|
+
images.each do |image|
|
93
|
+
image.architecture.should eql( 'i386' )
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should return an empty array for no matches" do
|
99
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
100
|
+
images = client.images( :architecture=>'8088' )
|
101
|
+
images.should be_empty
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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 "initializing the client" do
|
22
|
+
|
23
|
+
it "should parse valid API URIs" do
|
24
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
25
|
+
client.api_host.should eql( API_HOST )
|
26
|
+
client.api_port.should eql( API_PORT.to_i )
|
27
|
+
client.api_path.should eql( API_PATH )
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should discover entry points upon connection" do
|
31
|
+
DeltaCloud.new( "name", "password", API_URL ) do |client|
|
32
|
+
client.entry_points[:hardware_profiles].should eql( "#{API_URL}/hardware_profiles" )
|
33
|
+
client.entry_points[:images].should eql( "#{API_URL}/images" )
|
34
|
+
client.entry_points[:instances].should eql( "#{API_URL}/instances" )
|
35
|
+
client.entry_points[:storage_volumes].should eql( "#{API_URL}/storage_volumes" )
|
36
|
+
client.entry_points[:storage_snapshots].should eql( "#{API_URL}/storage_snapshots" )
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should provide the current driver name via client" do
|
41
|
+
DeltaCloud.new( "name", "password", API_URL ) do |client|
|
42
|
+
client.driver_name.should eql( 'mock' )
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should provide the current driver name without client" do
|
47
|
+
DeltaCloud.driver_name( API_URL ).should eql( 'mock' )
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "without a block" do
|
51
|
+
before( :each ) do
|
52
|
+
reload_fixtures
|
53
|
+
end
|
54
|
+
it "should connect without a block" do
|
55
|
+
client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
|
56
|
+
client.images.should_not be_nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,78 @@
|
|
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
|
+
=begin
|
23
|
+
Spec::Matchers.define :include_transition do |action,to|
|
24
|
+
match do |transitions|
|
25
|
+
found = transitions.find{|e| e.action.to_s == action.to_s && e.to.to_s == to.to_s }
|
26
|
+
! found.nil?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
=end
|
30
|
+
|
31
|
+
describe "instance-states" do
|
32
|
+
|
33
|
+
it_should_behave_like "all resources"
|
34
|
+
|
35
|
+
it "should allow retrieval of instance-state information" do
|
36
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
37
|
+
instance_states = client.instance_states
|
38
|
+
instance_states.should_not be_nil
|
39
|
+
instance_states.should_not be_empty
|
40
|
+
|
41
|
+
instance_states[0].name.should eql( 'start' )
|
42
|
+
instance_states[0].transitions.size.should eql( 1 )
|
43
|
+
instance_states[0].transitions[0].should_not be_auto
|
44
|
+
|
45
|
+
instance_states[1].name.should eql( 'pending' )
|
46
|
+
instance_states[1].transitions.size.should eql( 1 )
|
47
|
+
instance_states[1].transitions[0].should be_auto
|
48
|
+
|
49
|
+
instance_states[2].name.should eql( 'running' )
|
50
|
+
instance_states[2].transitions.size.should eql( 2 )
|
51
|
+
includes_transition( instance_states[2].transitions, :reboot, :running ).should be_true
|
52
|
+
includes_transition( instance_states[2].transitions, :stop, :stopped ).should be_true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should allow retrieval of a single instance-state blob" do
|
57
|
+
DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
|
58
|
+
instance_state = client.instance_state( :pending )
|
59
|
+
instance_state.should_not be_nil
|
60
|
+
instance_state.name.should eql( 'pending' )
|
61
|
+
instance_state.transitions.size.should eql( 1 )
|
62
|
+
instance_state.transitions[0].should be_auto
|
63
|
+
|
64
|
+
instance_state = client.instance_state( :running )
|
65
|
+
instance_state.name.should eql( 'running' )
|
66
|
+
instance_state.transitions.size.should eql( 2 )
|
67
|
+
includes_transition( instance_state.transitions, :reboot, :running ).should be_true
|
68
|
+
includes_transition( instance_state.transitions, :stop, :stopped ).should be_true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def includes_transition( transitions, action, to )
|
73
|
+
found = transitions.find{|e| e.action.to_s == action.to_s && e.to.to_s == to.to_s }
|
74
|
+
! found.nil?
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
end
|
@@ -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
|