deltacloud-client 1.0.0 → 1.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.
Files changed (45) hide show
  1. data/Rakefile +6 -46
  2. data/lib/base_object.rb +1 -1
  3. data/lib/client_bucket_methods.rb +2 -2
  4. data/lib/deltacloud.rb +8 -7
  5. metadata +81 -127
  6. data/bin/deltacloudc +0 -243
  7. data/lib/plain_formatter.rb +0 -145
  8. data/specs/buckets_spec.rb +0 -148
  9. data/specs/content_spec.rb +0 -137
  10. data/specs/data/images/img1.yml +0 -4
  11. data/specs/data/images/img2.yml +0 -4
  12. data/specs/data/images/img3.yml +0 -4
  13. data/specs/data/instances/inst0.yml +0 -16
  14. data/specs/data/instances/inst1.yml +0 -9
  15. data/specs/data/instances/inst2.yml +0 -9
  16. data/specs/data/storage_snapshots/snap1.yml +0 -4
  17. data/specs/data/storage_snapshots/snap2.yml +0 -4
  18. data/specs/data/storage_snapshots/snap3.yml +0 -4
  19. data/specs/data/storage_volumes/vol1.yml +0 -7
  20. data/specs/data/storage_volumes/vol2.yml +0 -7
  21. data/specs/data/storage_volumes/vol3.yml +0 -7
  22. data/specs/errors_spec.rb +0 -59
  23. data/specs/fixtures/images/img1.yml +0 -4
  24. data/specs/fixtures/images/img2.yml +0 -4
  25. data/specs/fixtures/images/img3.yml +0 -4
  26. data/specs/fixtures/instances/inst0.yml +0 -16
  27. data/specs/fixtures/instances/inst1.yml +0 -9
  28. data/specs/fixtures/instances/inst2.yml +0 -9
  29. data/specs/fixtures/storage_snapshots/snap1.yml +0 -4
  30. data/specs/fixtures/storage_snapshots/snap2.yml +0 -4
  31. data/specs/fixtures/storage_snapshots/snap3.yml +0 -4
  32. data/specs/fixtures/storage_volumes/vol1.yml +0 -7
  33. data/specs/fixtures/storage_volumes/vol2.yml +0 -7
  34. data/specs/fixtures/storage_volumes/vol3.yml +0 -7
  35. data/specs/hardware_profiles_spec.rb +0 -80
  36. data/specs/images_spec.rb +0 -107
  37. data/specs/initialization_spec.rb +0 -64
  38. data/specs/instance_states_spec.rb +0 -80
  39. data/specs/instances_spec.rb +0 -210
  40. data/specs/keys_spec.rb +0 -97
  41. data/specs/realms_spec.rb +0 -66
  42. data/specs/shared/resources.rb +0 -30
  43. data/specs/spec_helper.rb +0 -53
  44. data/specs/storage_snapshot_spec.rb +0 -81
  45. data/specs/storage_volume_spec.rb +0 -91
@@ -1,7 +0,0 @@
1
- :owner_id: mockuser
2
- :created: Thu Jul 30 14:35:11 UTC 2009
3
- :state: AVAILABLE
4
- :capacity: 1
5
- :device:
6
- :realm_id: us
7
- :instance_id:
@@ -1,7 +0,0 @@
1
- :owner_id: mockuser
2
- :created: Thu Jul 30 14:35:11 UTC 2009
3
- :state: IN-USE
4
- :capacity: 1
5
- :realm_id: us
6
- :device: /dev/sda1
7
- :instance_id: inst1
@@ -1,80 +0,0 @@
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
- def prop_check(prop, value_class)
23
- if prop.present?
24
- prop.value.should_not be_nil
25
- prop.value.should be_a(value_class)
26
- end
27
- end
28
-
29
- describe "hardware_profiles" do
30
-
31
- it_should_behave_like "all resources"
32
-
33
- it "should allow retrieval of all hardware profiles" do
34
- [API_URL, API_URL_REDIRECT].each do |entry_point|
35
- DeltaCloud.new( API_NAME, API_PASSWORD, entry_point ) do |client|
36
- hardware_profiles = client.hardware_profiles
37
- hardware_profiles.should_not be_empty
38
- hardware_profiles.each do |hwp|
39
- hwp.uri.should_not be_nil
40
- hwp.uri.should be_a(String)
41
- prop_check(hwp.architecture, String) unless hwp.name.eql?("opaque")
42
- end
43
- end
44
- end
45
- end
46
-
47
- it "should allow filtering of hardware_profiles by architecture" do
48
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
49
- hardware_profiles = client.hardware_profiles( :architecture=>'i386' )
50
- hardware_profiles.should_not be_empty
51
- hardware_profiles.size.should eql( 2 )
52
- hardware_profiles.first.architecture.value.should eql( 'i386' )
53
- end
54
- end
55
-
56
- it "should allow fetching a hardware_profile by id" do
57
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
58
- hwp = client.hardware_profile( 'm1-small' )
59
- hwp.should_not be_nil
60
- hwp.id.should eql( 'm1-small' )
61
- end
62
- end
63
-
64
- it "should allow fetching different hardware_profiles" do
65
- client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
66
- hwp1 = client.hardware_profile( 'm1-small' )
67
- hwp2 = client.hardware_profile( 'm1-large' )
68
- hwp1.storage.value.should_not eql(hwp2.storage.value)
69
- hwp1.memory.value.should_not eql(hwp2.memory.value)
70
- end
71
-
72
- it "should allow fetching a hardware_profile by URI" do
73
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
74
- hwp = client.fetch_hardware_profile( API_URL + '/hardware_profiles/m1-small' )
75
- hwp.should_not be_nil
76
- hwp.id.should eql( 'm1-small' )
77
- end
78
- end
79
-
80
- end
data/specs/images_spec.rb DELETED
@@ -1,107 +0,0 @@
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
- [API_URL, API_URL_REDIRECT].each do |entry_point|
28
- DeltaCloud.new( API_NAME, API_PASSWORD, entry_point ) do |client|
29
- images = client.images
30
- images.should_not be_empty
31
- images.size.should eql( 3 )
32
- images.each do |image|
33
- image.uri.should_not be_nil
34
- image.uri.should be_a(String)
35
- image.description.should_not be_nil
36
- image.description.should be_a(String)
37
- image.architecture.should_not be_nil
38
- image.architecture.should be_a(String)
39
- image.owner_id.should_not be_nil
40
- image.owner_id.should be_a(String)
41
- end
42
- end
43
- end
44
- end
45
-
46
- it "should allow retrieval of my own images" do
47
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
48
- images = client.images( :owner_id=>:self )
49
- images.should_not be_empty
50
- images.size.should eql( 1 )
51
- images.each do |image|
52
- image.uri.should_not be_nil
53
- image.uri.should be_a(String)
54
- image.description.should_not be_nil
55
- image.description.should be_a(String)
56
- image.architecture.should_not be_nil
57
- image.architecture.should be_a(String)
58
- image.owner_id.should_not be_nil
59
- image.owner_id.should be_a(String)
60
- end
61
- end
62
- end
63
-
64
- it "should allow retrieval of a single image by ID" do
65
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
66
- image = client.image( 'img1' )
67
- image.should_not be_nil
68
- image.uri.should eql( API_URL + '/images/img1' )
69
- image.id.should eql( 'img1' )
70
- image.architecture.should eql( 'x86_64' )
71
- end
72
- end
73
-
74
- it "should allow retrieval of a single image by URI" do
75
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
76
- image = client.fetch_image( API_URL + '/images/img1' )
77
- image.should_not be_nil
78
- image.uri.should eql( API_URL + '/images/img1' )
79
- image.id.should eql( 'img1' )
80
- image.architecture.should eql( 'x86_64' )
81
- end
82
- end
83
-
84
- describe "filtering by architecture" do
85
- it "return matching images" do
86
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
87
- images = client.images( :architecture=>'x86_64' )
88
- images.should_not be_empty
89
- images.each do |image|
90
- image.architecture.should eql( 'x86_64' )
91
- end
92
- images = client.images( :architecture=>'i386' )
93
- images.should_not be_empty
94
- images.each do |image|
95
- image.architecture.should eql( 'i386' )
96
- end
97
- end
98
- end
99
-
100
- it "should return an empty array for no matches" do
101
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
102
- images = client.images( :architecture=>'8088' )
103
- images.should be_empty
104
- end
105
- end
106
- end
107
- end
@@ -1,64 +0,0 @@
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
- [API_URL, API_URL_REDIRECT].each do |entry_point|
32
- DeltaCloud.new( "name", "password", entry_point ) do |client|
33
- client.entry_points[:hardware_profiles].should eql( "#{API_URL}/hardware_profiles" )
34
- client.entry_points[:images].should eql( "#{API_URL}/images" )
35
- client.entry_points[:instances].should eql( "#{API_URL}/instances" )
36
- client.entry_points[:storage_volumes].should eql( "#{API_URL}/storage_volumes" )
37
- client.entry_points[:storage_snapshots].should eql( "#{API_URL}/storage_snapshots" )
38
- client.entry_points[:buckets].should eql( "#{API_URL}/buckets")
39
- client.entry_points[:keys].should eql( "#{API_URL}/keys")
40
- end
41
- end
42
- end
43
-
44
- it "should provide the current driver name via client" do
45
- DeltaCloud.new( "name", "password", API_URL ) do |client|
46
- client.driver_name.should eql( 'mock' )
47
- end
48
- end
49
-
50
- it "should provide the current driver name without client" do
51
- DeltaCloud.driver_name( API_URL ).should eql( 'mock' )
52
- end
53
-
54
- describe "without a block" do
55
- before( :each ) do
56
- reload_fixtures
57
- end
58
- it "should connect without a block" do
59
- client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
60
- client.images.should_not be_nil
61
- end
62
- end
63
-
64
- end
@@ -1,80 +0,0 @@
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
- [API_URL, API_URL_REDIRECT].each do |entry_point|
37
- DeltaCloud.new( API_NAME, API_PASSWORD, entry_point ) do |client|
38
- instance_states = client.instance_states
39
- instance_states.should_not be_nil
40
- instance_states.should_not be_empty
41
-
42
- instance_states[0].name.should eql( 'start' )
43
- instance_states[0].transitions.size.should eql( 1 )
44
- instance_states[0].transitions[0].should_not be_auto
45
-
46
- instance_states[1].name.should eql( 'pending' )
47
- instance_states[1].transitions.size.should eql( 1 )
48
- instance_states[1].transitions[0].should be_auto
49
-
50
- instance_states[2].name.should eql( 'running' )
51
- instance_states[2].transitions.size.should eql( 2 )
52
- includes_transition( instance_states[2].transitions, :reboot, :running ).should be_true
53
- includes_transition( instance_states[2].transitions, :stop, :stopped ).should be_true
54
- end
55
- end
56
- end
57
-
58
- it "should allow retrieval of a single instance-state blob" do
59
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
60
- instance_state = client.instance_state( :pending )
61
- instance_state.should_not be_nil
62
- instance_state.name.should eql( 'pending' )
63
- instance_state.transitions.size.should eql( 1 )
64
- instance_state.transitions[0].should be_auto
65
-
66
- instance_state = client.instance_state( :running )
67
- instance_state.name.should eql( 'running' )
68
- instance_state.transitions.size.should eql( 2 )
69
- includes_transition( instance_state.transitions, :reboot, :running ).should be_true
70
- includes_transition( instance_state.transitions, :stop, :stopped ).should be_true
71
- end
72
- end
73
-
74
- def includes_transition( transitions, action, to )
75
- found = transitions.find{|e| e.action.to_s == action.to_s && e.to.to_s == to.to_s }
76
- ! found.nil?
77
- end
78
-
79
-
80
- end
@@ -1,210 +0,0 @@
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
- [API_URL, API_URL_REDIRECT].each do |entry_point|
28
- DeltaCloud.new( API_NAME, API_PASSWORD, entry_point ) do |client|
29
- instances = client.instances
30
- instances.should_not be_empty
31
- instances.each do |instance|
32
- instance.uri.should_not be_nil
33
- instance.uri.should be_a( String )
34
- instance.owner_id.should_not be_nil
35
- instance.owner_id.should be_a( String )
36
- instance.image.should_not be_nil
37
- instance.image.to_s.should match(/DeltaCloud::API::.*::Image/)
38
- instance.hardware_profile.should_not be_nil
39
- instance.hardware_profile.should be_a( DeltaCloud::API::Base::HardwareProfile )
40
- instance.state.should_not be_nil
41
- instance.state.should be_a( String )
42
- instance.public_addresses.should_not be_nil
43
- instance.public_addresses.should_not be_empty
44
- instance.public_addresses.should be_a( Array )
45
- instance.private_addresses.should_not be_nil
46
- instance.private_addresses.should_not be_empty
47
- instance.private_addresses.should be_a( Array )
48
- end
49
- end
50
- end
51
- end
52
-
53
- it "should allow navigation from instance to image" do
54
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
55
- instances = client.instances
56
- instances.should_not be_empty
57
- instance = instances.first
58
- instance.image.should_not be_nil
59
- instance.image.description.should_not be_nil
60
- instance.image.description.should be_a(String)
61
- end
62
- end
63
-
64
- it "should allow retrieval of a single instance" do
65
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
66
- instance = client.instance( "inst0" )
67
- instance.should_not be_nil
68
- instance.name.should_not be_nil
69
- instance.name.should eql( 'Mock Instance With Profile Change' )
70
- instance.uri.should_not be_nil
71
- instance.uri.should be_a( String )
72
- instance.owner_id.should eql( "mockuser" )
73
- instance.public_addresses.first.class.should eql(Hash)
74
- instance.public_addresses.first[:type].should eql('hostname')
75
- instance.public_addresses.first[:address].should eql('img1.inst0.public.com')
76
- instance.image.should_not be_nil
77
- instance.image.uri.should eql( API_URL + "/images/img1" )
78
- instance.hardware_profile.should_not be_nil
79
- instance.hardware_profile.should_not be_nil
80
- instance.hardware_profile.uri.should eql( API_URL + "/hardware_profiles/m1-large" )
81
- instance.hardware_profile.memory.value.should eql('10240')
82
- instance.hardware_profile.storage.value.should eql('850')
83
- instance.state.should eql( "RUNNING" )
84
- instance.actions.should_not be_nil
85
- end
86
- end
87
-
88
- it "should allow creation of new instances with reasonable defaults" do
89
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
90
- instance = client.create_instance( 'img1', :name=>'TestInstance', :hardware_profile => 'm1-large' )
91
- instance.should_not be_nil
92
- instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
93
- instance.id.should match( /inst[0-9]+/ )
94
- instance.name.should eql( 'TestInstance' )
95
- instance.image.id.should eql( 'img1' )
96
- instance.hardware_profile.id.should eql( 'm1-large' )
97
- instance.realm.id.should eql( 'us' )
98
- end
99
- end
100
-
101
- it "should allow creation of new instances with specific realm" do
102
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
103
- instance = client.create_instance( 'img1', :realm=>'eu', :hardware_profile => 'm1-large' )
104
- instance.should_not be_nil
105
- instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
106
- instance.id.should match( /inst[0-9]+/ )
107
- instance.image.id.should eql( 'img1' )
108
- instance.hardware_profile.id.should eql( 'm1-large' )
109
- instance.realm.id.should eql( 'eu' )
110
- end
111
- end
112
-
113
- it "should allow creation of new instances with specific hardware profile" do
114
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
115
- instance = client.create_instance( 'img1',
116
- :hardware_profile=>'m1-xlarge' )
117
- instance.should_not be_nil
118
- instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
119
- instance.id.should match( /inst[0-9]+/ )
120
- instance.image.id.should eql( 'img1' )
121
- instance.hardware_profile.id.should eql( 'm1-xlarge' )
122
- instance.realm.id.should eql( 'us' )
123
- end
124
- end
125
-
126
- it "should allow creation of new instances with specific hardware profile overriding memory" do
127
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
128
- hwp = { :id => 'm1-xlarge', :memory => 32768 }
129
- instance = client.create_instance( 'img1', :hardware_profile=> hwp )
130
- instance.should_not be_nil
131
- instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
132
- instance.id.should match( /inst[0-9]+/ )
133
- instance.image.id.should eql( 'img1' )
134
- instance.hardware_profile.id.should eql( 'm1-xlarge' )
135
- instance.hardware_profile.memory.value.should eql('12288')
136
- instance.realm.id.should eql( 'us' )
137
- end
138
- end
139
-
140
- it "should allow creation of new instances with specific realm and hardware profile" do
141
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
142
- instance = client.create_instance( 'img1', :realm=>'eu',
143
- :hardware_profile=>'m1-xlarge' )
144
- instance.should_not be_nil
145
- instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} )
146
- instance.id.should match( /inst[0-9]+/ )
147
- instance.image.id.should eql( 'img1' )
148
- instance.hardware_profile.id.should eql( 'm1-xlarge' )
149
- instance.realm.id.should eql( 'eu' )
150
- end
151
- end
152
-
153
- it "should allow fetching of instances by id" do
154
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
155
- instance = client.instance( 'inst1' )
156
- instance.should_not be_nil
157
- instance.uri.should_not be_nil
158
- instance.uri.should be_a( String )
159
- end
160
- end
161
-
162
- it "should allow fetching of instances by URI" do
163
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
164
- instance = client.fetch_instance( API_URL + '/instances/inst1' )
165
- instance.should_not be_nil
166
- instance.uri.should eql( API_URL + '/instances/inst1' )
167
- instance.id.should eql( 'inst1' )
168
- end
169
- end
170
-
171
- describe "performing actions on instances" do
172
- it "should allow actions that are valid" do
173
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
174
- instance = client.instance( 'inst1' )
175
- instance.should_not be_nil
176
- instance.state.should eql( "RUNNING" )
177
- instance.uri.should eql( API_URL + '/instances/inst1' )
178
- instance.id.should eql( 'inst1' )
179
- instance.stop!
180
- instance.state.should eql( "STOPPED" )
181
- instance.start!
182
- instance.state.should eql( "RUNNING" )
183
- end
184
- end
185
-
186
- it "should not allow actions that are invalid" do
187
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
188
- instance = client.instance( 'inst1' )
189
- instance.should_not be_nil
190
- unless instance.state.eql?("RUNNING")
191
- instance.start!
192
- end
193
- instance.state.should eql( "RUNNING" )
194
- lambda{instance.start!}.should raise_error
195
- end
196
- end
197
-
198
- it "should not throw exception when destroying an instance" do
199
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
200
- instance = client.create_instance( 'img1',
201
- :name=>'TestDestroyInstance',
202
- :hardware_profile => 'm1-xlarge' )
203
- instance.stop!
204
- lambda {
205
- instance.destroy!
206
- }.should_not raise_error
207
- end
208
- end
209
- end
210
- end
data/specs/keys_spec.rb DELETED
@@ -1,97 +0,0 @@
1
- #
2
- # Copyright (C) 2009-2011 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
- def check_key(the_key, key_name = "")
22
- the_key.should_not be_nil
23
- the_key.id.should be_a(String)
24
- the_key.id.should eql(key_name)
25
- the_key.actions.should_not be_nil
26
- the_key.actions.size.should eql(1)
27
- the_key.actions.first[0].should eql("destroy")
28
- the_key.actions.first[1].should eql("#{API_URL}/keys/#{key_name}")
29
- the_key.fingerprint.should_not be_nil
30
- the_key.fingerprint.should be_a(String)
31
- the_key.pem.should_not be_nil
32
- the_key.pem.first.should be_a(String)
33
- end
34
-
35
- def create_key_if_necessary(client, key_name)
36
- the_key = client.key(key_name)
37
- unless the_key
38
- client.create_key()
39
- end
40
- end
41
-
42
-
43
- describe "keys" do
44
-
45
- it_should_behave_like "all resources"
46
-
47
- it "should allow retrieval of all keys" do
48
- [API_URL, API_URL_REDIRECT].each do |entry_point|
49
- DeltaCloud.new( API_NAME, API_PASSWORD, entry_point ) do |client|
50
- lambda{
51
- client.keys
52
- }.should_not raise_error
53
- end
54
- end
55
- end
56
- end
57
-
58
- describe "operations on keys" do
59
-
60
- it "should allow successful creation of a new key" do
61
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
62
- new_key = client.create_key({:name => "my_new_key"})
63
- check_key(new_key, "my_new_key")
64
- end
65
- end
66
-
67
- it "should allow retrieval of an existing named key" do
68
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
69
- key_name = "my_new_key"
70
- create_key_if_necessary(client, key_name)
71
- the_key = client.key(key_name)
72
- check_key(the_key, key_name)
73
- end
74
- end
75
-
76
- it "should raise error if you create a key with the same name as an existing key" do
77
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
78
- name = "my_new_key"
79
- create_key_if_necessary(client, name)
80
- lambda{
81
- client.create_key({:name => name})
82
- }.should raise_error
83
- end
84
- end
85
-
86
- it "should allow successful destruction of an existing key" do
87
- DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
88
- name = "my_new_key"
89
- create_key_if_necessary(client, name)
90
- the_key = client.key(name)
91
- lambda{
92
- the_key.destroy!
93
- }.should_not raise_error
94
- end
95
- end
96
-
97
- end