fog-profitbricks 0.0.5 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1465 -4
- data/Rakefile +3 -0
- data/examples/pb_demo.rb +83 -35
- data/fog-profitbricks.gemspec +10 -10
- data/gemfiles/Gemfile.1.8.7 +0 -1
- data/lib/fog/profitbricks.rb +4 -23
- data/lib/fog/profitbricks/compute.rb +1082 -1
- data/lib/fog/profitbricks/helpers/compute/data_helper.rb +12 -0
- data/lib/fog/profitbricks/models/base.rb +37 -0
- data/lib/fog/profitbricks/models/compute/datacenter.rb +64 -0
- data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/datacenters.rb +9 -4
- data/lib/fog/profitbricks/models/compute/firewall_rule.rb +101 -0
- data/lib/fog/profitbricks/models/compute/firewall_rules.rb +40 -0
- data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/flavor.rb +0 -0
- data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/flavors.rb +0 -0
- data/lib/fog/profitbricks/models/compute/image.rb +72 -0
- data/lib/fog/profitbricks/models/compute/images.rb +28 -0
- data/lib/fog/profitbricks/models/compute/ip_block.rb +58 -0
- data/lib/fog/profitbricks/models/compute/ip_blocks.rb +30 -0
- data/lib/fog/profitbricks/models/compute/lan.rb +89 -0
- data/lib/fog/profitbricks/models/compute/lans.rb +36 -0
- data/lib/fog/profitbricks/models/compute/load_balancer.rb +126 -0
- data/lib/fog/profitbricks/models/compute/load_balancers.rb +34 -0
- data/lib/fog/profitbricks/models/compute/location.rb +18 -0
- data/lib/fog/profitbricks/models/compute/locations.rb +28 -0
- data/lib/fog/profitbricks/models/compute/nic.rb +111 -0
- data/lib/fog/profitbricks/models/compute/nics.rb +38 -0
- data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/region.rb +0 -0
- data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/regions.rb +0 -0
- data/lib/fog/profitbricks/models/compute/request.rb +24 -0
- data/lib/fog/profitbricks/models/compute/requests.rb +37 -0
- data/lib/fog/profitbricks/models/compute/server.rb +263 -0
- data/lib/fog/profitbricks/models/compute/servers.rb +32 -0
- data/lib/fog/profitbricks/models/compute/snapshot.rb +81 -0
- data/lib/fog/profitbricks/models/compute/snapshots.rb +28 -0
- data/lib/fog/profitbricks/models/compute/volume.rb +123 -0
- data/lib/fog/profitbricks/models/compute/volumes.rb +33 -0
- data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +104 -0
- data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +88 -0
- data/lib/fog/profitbricks/requests/compute/attach_volume.rb +89 -0
- data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +89 -0
- data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +103 -0
- data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/create_flavor.rb +0 -0
- data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +81 -0
- data/lib/fog/profitbricks/requests/compute/create_lan.rb +160 -0
- data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +87 -0
- data/lib/fog/profitbricks/requests/compute/create_nic.rb +124 -0
- data/lib/fog/profitbricks/requests/compute/create_server.rb +257 -0
- data/lib/fog/profitbricks/requests/compute/create_volume.rb +133 -0
- data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +113 -0
- data/lib/fog/profitbricks/requests/compute/delete_datacenter.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb +47 -0
- data/lib/fog/profitbricks/requests/compute/delete_image.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/delete_ip_block.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/delete_lan.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/delete_nic.rb +46 -0
- data/lib/fog/profitbricks/requests/compute/delete_server.rb +48 -0
- data/lib/fog/profitbricks/requests/compute/delete_snapshot.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/delete_volume.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +52 -0
- data/lib/fog/profitbricks/requests/compute/detach_volume.rb +53 -0
- data/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb +59 -0
- data/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb +76 -0
- data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/get_all_flavors.rb +0 -0
- data/lib/fog/profitbricks/requests/compute/get_all_images.rb +66 -0
- data/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb +56 -0
- data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +120 -0
- data/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb +100 -0
- data/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb +117 -0
- data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +102 -0
- data/lib/fog/profitbricks/requests/compute/get_all_requests.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +134 -0
- data/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb +66 -0
- data/lib/fog/profitbricks/requests/compute/get_all_volumes.rb +78 -0
- data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +78 -0
- data/lib/fog/profitbricks/requests/compute/get_attached_volume.rb +79 -0
- data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +65 -0
- data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +71 -0
- data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/get_flavor.rb +0 -0
- data/lib/fog/profitbricks/requests/compute/get_image.rb +71 -0
- data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +58 -0
- data/lib/fog/profitbricks/requests/compute/get_lan.rb +120 -0
- data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +99 -0
- data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +116 -0
- data/lib/fog/profitbricks/requests/compute/get_location.rb +49 -0
- data/lib/fog/profitbricks/requests/compute/get_nic.rb +98 -0
- data/lib/fog/profitbricks/requests/compute/get_request.rb +61 -0
- data/lib/fog/profitbricks/requests/compute/get_request_status.rb +50 -0
- data/lib/fog/profitbricks/requests/compute/get_server.rb +133 -0
- data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +70 -0
- data/lib/fog/profitbricks/requests/compute/get_volume.rb +73 -0
- data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +74 -0
- data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +75 -0
- data/lib/fog/profitbricks/requests/compute/reboot_server.rb +47 -0
- data/lib/fog/profitbricks/requests/compute/remove_nic_association.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb +61 -0
- data/lib/fog/profitbricks/requests/compute/start_server.rb +49 -0
- data/lib/fog/profitbricks/requests/compute/stop_server.rb +50 -0
- data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +73 -0
- data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +87 -0
- data/lib/fog/profitbricks/requests/compute/update_image.rb +90 -0
- data/lib/fog/profitbricks/requests/compute/update_lan.rb +126 -0
- data/lib/fog/profitbricks/requests/compute/update_load_balancer.rb +70 -0
- data/lib/fog/profitbricks/requests/compute/update_nic.rb +107 -0
- data/lib/fog/profitbricks/requests/compute/update_server.rb +147 -0
- data/lib/fog/profitbricks/requests/compute/update_snapshot.rb +90 -0
- data/lib/fog/profitbricks/requests/compute/update_volume.rb +82 -0
- data/lib/fog/profitbricks/version.rb +1 -1
- data/tests/profitbricks/requests/compute/composite_create_tests.rb +241 -0
- data/tests/profitbricks/requests/compute/location_tests.rb +24 -12
- data/tests/profitbricks/requests/compute/nic_tests.rb +290 -0
- data/tests/profitbricks/requests/compute/request_tests.rb +52 -0
- data/tests/profitbricks/requests/compute/server_tests.rb +398 -175
- metadata +140 -133
- data/lib/fog/compute/profit_bricks.rb +0 -217
- data/lib/fog/compute/profit_bricks/models/datacenter.rb +0 -60
- data/lib/fog/compute/profit_bricks/models/image.rb +0 -27
- data/lib/fog/compute/profit_bricks/models/images.rb +0 -22
- data/lib/fog/compute/profit_bricks/models/interface.rb +0 -61
- data/lib/fog/compute/profit_bricks/models/interfaces.rb +0 -23
- data/lib/fog/compute/profit_bricks/models/server.rb +0 -104
- data/lib/fog/compute/profit_bricks/models/servers.rb +0 -22
- data/lib/fog/compute/profit_bricks/models/volume.rb +0 -71
- data/lib/fog/compute/profit_bricks/models/volumes.rb +0 -23
- data/lib/fog/compute/profit_bricks/requests/clear_data_center.rb +0 -51
- data/lib/fog/compute/profit_bricks/requests/connect_storage_to_server.rb +0 -83
- data/lib/fog/compute/profit_bricks/requests/create_data_center.rb +0 -62
- data/lib/fog/compute/profit_bricks/requests/create_nic.rb +0 -79
- data/lib/fog/compute/profit_bricks/requests/create_server.rb +0 -105
- data/lib/fog/compute/profit_bricks/requests/create_storage.rb +0 -96
- data/lib/fog/compute/profit_bricks/requests/delete_data_center.rb +0 -60
- data/lib/fog/compute/profit_bricks/requests/delete_nic.rb +0 -64
- data/lib/fog/compute/profit_bricks/requests/delete_server.rb +0 -64
- data/lib/fog/compute/profit_bricks/requests/delete_storage.rb +0 -64
- data/lib/fog/compute/profit_bricks/requests/disconnect_storage_from_server.rb +0 -76
- data/lib/fog/compute/profit_bricks/requests/get_all_data_centers.rb +0 -31
- data/lib/fog/compute/profit_bricks/requests/get_all_images.rb +0 -65
- data/lib/fog/compute/profit_bricks/requests/get_all_locations.rb +0 -44
- data/lib/fog/compute/profit_bricks/requests/get_all_nic.rb +0 -53
- data/lib/fog/compute/profit_bricks/requests/get_all_servers.rb +0 -57
- data/lib/fog/compute/profit_bricks/requests/get_all_storages.rb +0 -56
- data/lib/fog/compute/profit_bricks/requests/get_data_center.rb +0 -38
- data/lib/fog/compute/profit_bricks/requests/get_data_center_state.rb +0 -42
- data/lib/fog/compute/profit_bricks/requests/get_image.rb +0 -69
- data/lib/fog/compute/profit_bricks/requests/get_location.rb +0 -48
- data/lib/fog/compute/profit_bricks/requests/get_nic.rb +0 -63
- data/lib/fog/compute/profit_bricks/requests/get_server.rb +0 -98
- data/lib/fog/compute/profit_bricks/requests/get_storage.rb +0 -63
- data/lib/fog/compute/profit_bricks/requests/reset_server.rb +0 -49
- data/lib/fog/compute/profit_bricks/requests/set_internet_access.rb +0 -59
- data/lib/fog/compute/profit_bricks/requests/start_server.rb +0 -58
- data/lib/fog/compute/profit_bricks/requests/stop_server.rb +0 -58
- data/lib/fog/compute/profit_bricks/requests/update_data_center.rb +0 -54
- data/lib/fog/compute/profit_bricks/requests/update_nic.rb +0 -74
- data/lib/fog/compute/profit_bricks/requests/update_server.rb +0 -79
- data/lib/fog/compute/profit_bricks/requests/update_storage.rb +0 -73
- data/lib/fog/models/profit_bricks/base.rb +0 -11
- data/lib/fog/parsers/compute.rb +0 -37
- data/lib/fog/parsers/compute/profit_bricks/base.rb +0 -51
- data/lib/fog/parsers/compute/profit_bricks/clear_data_center.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/connect_storage_to_server.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/create_data_center.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/create_nic.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/create_server.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/create_storage.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/delete_data_center.rb +0 -20
- data/lib/fog/parsers/compute/profit_bricks/delete_nic.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/delete_server.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/delete_storage.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/disconnect_storage_from_server.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/get_all_data_centers.rb +0 -26
- data/lib/fog/parsers/compute/profit_bricks/get_all_images.rb +0 -30
- data/lib/fog/parsers/compute/profit_bricks/get_all_nic.rb +0 -30
- data/lib/fog/parsers/compute/profit_bricks/get_all_servers.rb +0 -57
- data/lib/fog/parsers/compute/profit_bricks/get_all_storages.rb +0 -33
- data/lib/fog/parsers/compute/profit_bricks/get_data_center.rb +0 -23
- data/lib/fog/parsers/compute/profit_bricks/get_data_center_state.rb +0 -20
- data/lib/fog/parsers/compute/profit_bricks/get_image.rb +0 -26
- data/lib/fog/parsers/compute/profit_bricks/get_nic.rb +0 -27
- data/lib/fog/parsers/compute/profit_bricks/get_server.rb +0 -57
- data/lib/fog/parsers/compute/profit_bricks/get_storage.rb +0 -30
- data/lib/fog/parsers/compute/profit_bricks/reset_server.rb +0 -20
- data/lib/fog/parsers/compute/profit_bricks/set_internet_access.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/update_data_center.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/update_nic.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/update_server.rb +0 -22
- data/lib/fog/parsers/compute/profit_bricks/update_storage.rb +0 -22
- data/lib/fog/profitbricks/storage.rb +0 -1
- data/tests/profitbricks/requests/compute/image_tests.rb +0 -50
- data/tests/profitbricks/requests/compute/interface_tests.rb +0 -101
@@ -0,0 +1,241 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:profitbricks] | composite create server request', ['profitbricks', 'compute']) do
|
2
|
+
|
3
|
+
@resource_schema = {
|
4
|
+
'id' => String,
|
5
|
+
'type' => String,
|
6
|
+
'href' => String,
|
7
|
+
'metadata' => Hash,
|
8
|
+
'properties' => Hash
|
9
|
+
}
|
10
|
+
|
11
|
+
@minimal_schema_with_items = {
|
12
|
+
'id' => String,
|
13
|
+
'type' => String,
|
14
|
+
'href' => String,
|
15
|
+
'items' => Array
|
16
|
+
}
|
17
|
+
|
18
|
+
service = Fog::Compute[:profitbricks]
|
19
|
+
|
20
|
+
tests('success') do
|
21
|
+
|
22
|
+
Excon.defaults[:connection_timeout] = 500
|
23
|
+
|
24
|
+
tests('#create_datacenter').data_matches_schema(@resource_schema) do
|
25
|
+
options = {}
|
26
|
+
options[:name] = 'FogTestDataCenter2'
|
27
|
+
options[:location] = 'us/las'
|
28
|
+
options[:description] = 'Part of server tests suite'
|
29
|
+
|
30
|
+
createDatacenterResponse = service.create_datacenter(options)
|
31
|
+
@datacenter_id = createDatacenterResponse.body['id']
|
32
|
+
|
33
|
+
if ENV["FOG_MOCK"] != "true"
|
34
|
+
service.datacenters.get(@datacenter_id).wait_for { ready? }
|
35
|
+
end
|
36
|
+
|
37
|
+
createDatacenterResponse.body
|
38
|
+
end
|
39
|
+
|
40
|
+
tests('#get_datacenter').data_matches_schema(@resource_schema) do
|
41
|
+
getDatacenterResponse = service.get_datacenter(@datacenter_id)
|
42
|
+
getDatacenterResponse.body
|
43
|
+
end
|
44
|
+
|
45
|
+
tests('#get_all_datacenters').data_matches_schema(@minimal_schema_with_items) do
|
46
|
+
getAllDatacentersResponse = service.get_all_datacenters
|
47
|
+
getAllDatacentersResponse.body
|
48
|
+
end
|
49
|
+
|
50
|
+
tests('#update_datacenter').data_matches_schema(@resource_schema) do
|
51
|
+
options = {}
|
52
|
+
options[:name] = 'FogTestDataCenter2Rename'
|
53
|
+
options[:description] = 'FogDataCenterDescriptionUpdated'
|
54
|
+
|
55
|
+
updateDatacenterResponse = service.update_datacenter(
|
56
|
+
@datacenter_id, options
|
57
|
+
)
|
58
|
+
|
59
|
+
if ENV["FOG_MOCK"] != "true"
|
60
|
+
service.datacenters.get(@datacenter_id).wait_for { ready? }
|
61
|
+
end
|
62
|
+
|
63
|
+
updateDatacenterResponse.body
|
64
|
+
end
|
65
|
+
|
66
|
+
tests('#create_lan').data_matches_schema(@resource_schema) do
|
67
|
+
options = {}
|
68
|
+
options[:name] = 'FogTestLan_3'
|
69
|
+
options[:public] = 'true'
|
70
|
+
|
71
|
+
createLanResponse = service.create_lan(@datacenter_id, options)
|
72
|
+
@lan_id = createLanResponse.body['id']
|
73
|
+
|
74
|
+
if ENV["FOG_MOCK"] != "true"
|
75
|
+
loop do
|
76
|
+
sleep(180)
|
77
|
+
lan = service.lans.get(@datacenter_id, @lan_id)
|
78
|
+
break unless !lan.ready?
|
79
|
+
end
|
80
|
+
|
81
|
+
service.datacenters.get(@datacenter_id).wait_for { ready? }
|
82
|
+
end
|
83
|
+
|
84
|
+
createLanResponse.body
|
85
|
+
end
|
86
|
+
|
87
|
+
tests('#create_server').data_matches_schema(@resource_schema) do
|
88
|
+
nic = {}
|
89
|
+
nic[:name] = 'FogTestNic_2'
|
90
|
+
nic[:lan] = @lan_id
|
91
|
+
|
92
|
+
properties = {}
|
93
|
+
properties[:name] = 'FogTestServer_2'
|
94
|
+
properties[:cores] = 1
|
95
|
+
properties[:ram] = 1024
|
96
|
+
properties[:availabilityZone] = 'ZONE_1'
|
97
|
+
properties[:cpuFamily] = 'INTEL_XEON'
|
98
|
+
|
99
|
+
entities = {}
|
100
|
+
entities[:volumes] = {}
|
101
|
+
entities[:volumes]['items'] = [
|
102
|
+
{
|
103
|
+
:properties => {
|
104
|
+
:name => 'FogRestTestVolume',
|
105
|
+
:size => 5,
|
106
|
+
:licenceType => 'LINUX',
|
107
|
+
:type => 'HDD'
|
108
|
+
}
|
109
|
+
}
|
110
|
+
]
|
111
|
+
|
112
|
+
entities[:nics] = {}
|
113
|
+
entities[:nics]['items'] = [
|
114
|
+
{
|
115
|
+
:properties => {
|
116
|
+
:name => 'FogTestNic_2',
|
117
|
+
:lan => @lan_id
|
118
|
+
},
|
119
|
+
|
120
|
+
:entities => {
|
121
|
+
:firewallrules => {
|
122
|
+
:items => [
|
123
|
+
{
|
124
|
+
:properties => {
|
125
|
+
:name => 'Fog test Firewall Rule 3',
|
126
|
+
:protocol => 'TCP',
|
127
|
+
:portRangeStart => '80',
|
128
|
+
:portRangeEnd => '80'
|
129
|
+
}
|
130
|
+
}
|
131
|
+
]
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
]
|
136
|
+
|
137
|
+
createServerResponse = service.create_server(@datacenter_id, properties, entities)
|
138
|
+
@server_id = createServerResponse.body['id']
|
139
|
+
|
140
|
+
if ENV["FOG_MOCK"] != "true"
|
141
|
+
loop do
|
142
|
+
sleep(480)
|
143
|
+
server = service.servers.get(@datacenter_id, @server_id)
|
144
|
+
break unless !server.ready?
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Calling wait_for causes ArgumentError
|
149
|
+
# server.wait_for { ready? }
|
150
|
+
|
151
|
+
createServerResponse.body
|
152
|
+
end
|
153
|
+
|
154
|
+
tests('#get_server').data_matches_schema(@resource_schema) do
|
155
|
+
getServerResponse = service.get_server(@datacenter_id, @server_id)
|
156
|
+
getServerResponse.body
|
157
|
+
end
|
158
|
+
|
159
|
+
tests('#update_server').data_matches_schema(@resource_schema) do
|
160
|
+
updateServerResponse = service.update_server(@datacenter_id, @server_id, { 'name' => 'FogTestServer_2_Rename' })
|
161
|
+
|
162
|
+
if ENV["FOG_MOCK"] != "true"
|
163
|
+
loop do
|
164
|
+
server = service.servers.get(@datacenter_id, @server_id)
|
165
|
+
sleep(1)
|
166
|
+
break unless !server.ready?
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# Calling wait_for causes ArgumentError
|
171
|
+
# server.wait_for { ready? }
|
172
|
+
|
173
|
+
updateServerResponse.body
|
174
|
+
end
|
175
|
+
|
176
|
+
tests('#get_all_servers').data_matches_schema(@minimal_schema_with_items) do
|
177
|
+
getAllServersResponse = service.get_all_servers(@datacenter_id)
|
178
|
+
|
179
|
+
getAllServersResponse.body
|
180
|
+
end
|
181
|
+
|
182
|
+
tests('#stop_server').succeeds do
|
183
|
+
stopServerResponse = service.stop_server(@datacenter_id, @server_id)
|
184
|
+
|
185
|
+
if ENV["FOG_MOCK"] != "true"
|
186
|
+
loop do
|
187
|
+
server = service.servers.get(@datacenter_id, @server_id)
|
188
|
+
sleep(1)
|
189
|
+
break unless !server.shutoff?
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# Calling wait_for causes ArgumentError
|
194
|
+
# server.wait_for { shutoff? }
|
195
|
+
|
196
|
+
stopServerResponse.status == 202
|
197
|
+
end
|
198
|
+
|
199
|
+
tests('#start_server').succeeds do
|
200
|
+
startServerResponse = service.start_server(@datacenter_id, @server_id)
|
201
|
+
|
202
|
+
if ENV["FOG_MOCK"] != "true"
|
203
|
+
loop do
|
204
|
+
server = service.servers.get(@datacenter_id, @server_id)
|
205
|
+
sleep(1)
|
206
|
+
break unless !server.running?
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
# Calling wait_for causes ArgumentError
|
211
|
+
# server.wait_for { running? }
|
212
|
+
|
213
|
+
startServerResponse.status == 202
|
214
|
+
end
|
215
|
+
|
216
|
+
tests('#reboot_server').succeeds do
|
217
|
+
rebootServerResponse = service.reboot_server(@datacenter_id, @server_id)
|
218
|
+
|
219
|
+
if ENV["FOG_MOCK"] != "true"
|
220
|
+
loop do
|
221
|
+
server = service.servers.get(@datacenter_id, @server_id)
|
222
|
+
sleep(1)
|
223
|
+
break unless !server.running?
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
rebootServerResponse.status == 202
|
228
|
+
end
|
229
|
+
|
230
|
+
tests('#delete_server').succeeds do
|
231
|
+
deleteServerResponse = service.delete_server(@datacenter_id, @server_id)
|
232
|
+
deleteServerResponse.status == 202
|
233
|
+
end
|
234
|
+
|
235
|
+
tests('#delete_datacenter').succeeds do
|
236
|
+
deleteDatacenterResponse = service.delete_datacenter(@datacenter_id)
|
237
|
+
deleteDatacenterResponse.status == 202
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
@@ -1,32 +1,44 @@
|
|
1
1
|
Shindo.tests('Fog::Compute[:profitbricks] | location request', ['profitbricks', 'compute']) do
|
2
2
|
|
3
|
-
@
|
4
|
-
'
|
5
|
-
'
|
6
|
-
'
|
3
|
+
@locations_schema = {
|
4
|
+
'id' => String,
|
5
|
+
'type' => String,
|
6
|
+
'href' => String,
|
7
|
+
'items' => Array
|
8
|
+
}
|
9
|
+
|
10
|
+
@location_schema = {
|
11
|
+
'id' => String,
|
12
|
+
'type' => String,
|
13
|
+
'href' => String,
|
14
|
+
'properties' => {
|
15
|
+
'name' => String,
|
16
|
+
'features' => Array
|
17
|
+
}
|
7
18
|
}
|
8
19
|
|
9
20
|
service = Fog::Compute[:profitbricks]
|
10
21
|
|
11
22
|
tests('success') do
|
12
|
-
|
13
|
-
|
23
|
+
|
24
|
+
Excon.defaults[:connection_timeout] = 500
|
25
|
+
|
26
|
+
tests('#get_all_locations').data_matches_schema(@locations_schema) do
|
14
27
|
data = service.get_all_locations
|
15
|
-
@location_id = data.body['
|
16
|
-
|
28
|
+
@location_id = data.body['items'][0]['id']
|
29
|
+
|
30
|
+
data.body
|
17
31
|
end
|
18
32
|
|
19
|
-
tests('#get_location').
|
20
|
-
# puts '#get_location'
|
33
|
+
tests('#get_location').data_matches_schema(@location_schema) do
|
21
34
|
data = service.get_location(@location_id)
|
22
|
-
data.body
|
35
|
+
data.body
|
23
36
|
end
|
24
37
|
|
25
38
|
end
|
26
39
|
|
27
40
|
tests('failure') do
|
28
41
|
tests('#get_location').raises(Fog::Errors::NotFound) do
|
29
|
-
# puts '#get_location'
|
30
42
|
data = service.get_location('00000000-0000-0000-0000-000000000000')
|
31
43
|
end
|
32
44
|
end
|
@@ -0,0 +1,290 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:profitbricks] | nic request', ['profitbricks', 'compute']) do
|
2
|
+
|
3
|
+
@resource_schema = {
|
4
|
+
'id' => String,
|
5
|
+
'type' => String,
|
6
|
+
'href' => String,
|
7
|
+
'metadata' => Hash,
|
8
|
+
'properties' => Hash
|
9
|
+
}
|
10
|
+
|
11
|
+
@extended_resource_schema = {
|
12
|
+
'id' => String,
|
13
|
+
'type' => String,
|
14
|
+
'href' => String,
|
15
|
+
'metadata' => Hash,
|
16
|
+
'properties' => Hash,
|
17
|
+
'entities' => Hash,
|
18
|
+
}
|
19
|
+
|
20
|
+
@minimal_schema_with_items = {
|
21
|
+
'id' => String,
|
22
|
+
'type' => String,
|
23
|
+
'href' => String,
|
24
|
+
'items' => Array
|
25
|
+
}
|
26
|
+
|
27
|
+
service = Fog::Compute[:profitbricks]
|
28
|
+
|
29
|
+
tests('success') do
|
30
|
+
|
31
|
+
Excon.defaults[:connection_timeout] = 200
|
32
|
+
|
33
|
+
tests('#create_datacenter').data_matches_schema(@resource_schema) do
|
34
|
+
options = {}
|
35
|
+
options[:name] = 'FogTestDataCenter'
|
36
|
+
options[:location] = 'us/las'
|
37
|
+
options[:description] = 'Part of server tests suite'
|
38
|
+
|
39
|
+
createDatacenterResponse = service.create_datacenter(options)
|
40
|
+
@datacenter_id = createDatacenterResponse.body['id']
|
41
|
+
|
42
|
+
if ENV["FOG_MOCK"] != "true"
|
43
|
+
service.datacenters.get(@datacenter_id).wait_for { ready? }
|
44
|
+
end
|
45
|
+
|
46
|
+
createDatacenterResponse.body
|
47
|
+
end
|
48
|
+
|
49
|
+
tests('#get_all_images').data_matches_schema(@minimal_schema_with_items) do
|
50
|
+
getAllImagesResponse = service.get_all_images
|
51
|
+
data = service.get_all_images.body['items'].find { |image|
|
52
|
+
image['properties']['location'] == 'us/las' &&
|
53
|
+
image['properties']['imageType'] == 'CDROM' &&
|
54
|
+
image['properties']['licenceType'] == 'LINUX'
|
55
|
+
}
|
56
|
+
@image_id = data['id']
|
57
|
+
getAllImagesResponse.body
|
58
|
+
end
|
59
|
+
|
60
|
+
tests('#create_server').data_matches_schema(@resource_schema) do
|
61
|
+
properties = {}
|
62
|
+
properties[:name] = 'FogTestServer_3'
|
63
|
+
properties[:cores] = 1
|
64
|
+
properties[:ram] = 1024
|
65
|
+
|
66
|
+
entities = {}
|
67
|
+
entities[:volumes] = {}
|
68
|
+
entities[:volumes]['items'] = [
|
69
|
+
{
|
70
|
+
'properties' => {
|
71
|
+
'size' => 5,
|
72
|
+
'name' => 'FogTestVolume',
|
73
|
+
'licenceType' => 'LINUX',
|
74
|
+
'type' => 'HDD'
|
75
|
+
}
|
76
|
+
}
|
77
|
+
]
|
78
|
+
|
79
|
+
createServerResponse = service.create_server(@datacenter_id, properties, entities)
|
80
|
+
@server_id = createServerResponse.body['id']
|
81
|
+
|
82
|
+
if ENV["FOG_MOCK"] != "true"
|
83
|
+
loop do
|
84
|
+
sleep(120)
|
85
|
+
server = service.servers.get(@datacenter_id, @server_id)
|
86
|
+
break unless !server.ready?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Calling wait_for causes ArgumentError
|
91
|
+
# server.wait_for { ready? }
|
92
|
+
|
93
|
+
createServerResponse.body
|
94
|
+
end
|
95
|
+
|
96
|
+
tests('#get_all_lans').data_matches_schema(@minimal_schema_with_items) do
|
97
|
+
getAllLansResponse = service.get_all_lans(@datacenter_id)
|
98
|
+
getAllLansResponse.body
|
99
|
+
end
|
100
|
+
|
101
|
+
tests('#create_lan').data_matches_schema(@extended_resource_schema) do
|
102
|
+
options = {}
|
103
|
+
options[:name] = 'FogTestLan_2'
|
104
|
+
options[:public] = 'true'
|
105
|
+
|
106
|
+
createLanResponse = service.create_lan(@datacenter_id, options)
|
107
|
+
@lan_id = createLanResponse.body['id']
|
108
|
+
|
109
|
+
if ENV["FOG_MOCK"] != "true"
|
110
|
+
loop do
|
111
|
+
sleep(180)
|
112
|
+
lan = service.lans.get(@datacenter_id, @lan_id)
|
113
|
+
break unless !lan.ready?
|
114
|
+
end
|
115
|
+
|
116
|
+
service.datacenters.get(@datacenter_id).wait_for { ready? }
|
117
|
+
end
|
118
|
+
|
119
|
+
createLanResponse.body
|
120
|
+
end
|
121
|
+
|
122
|
+
tests('#update_lan').data_matches_schema(@extended_resource_schema) do
|
123
|
+
updateLanResponse = service.update_lan(@datacenter_id, @lan_id, { 'name' => 'FogLan_2_Rename' })
|
124
|
+
updateLanResponse.body
|
125
|
+
end
|
126
|
+
|
127
|
+
tests('#get_lan').data_matches_schema(@extended_resource_schema) do
|
128
|
+
service.get_lan(@datacenter_id, @lan_id).body
|
129
|
+
end
|
130
|
+
|
131
|
+
tests('#create_nic').data_matches_schema(@extended_resource_schema) do
|
132
|
+
options = {}
|
133
|
+
options[:name] = 'FogTestNic_2'
|
134
|
+
options[:lan] = @lan_id
|
135
|
+
|
136
|
+
createNicResponse = service.create_nic(@datacenter_id, @server_id, options, {})
|
137
|
+
@nic_id = createNicResponse.body['id']
|
138
|
+
|
139
|
+
createNicResponse.body
|
140
|
+
end
|
141
|
+
|
142
|
+
tests('#get_nic').data_matches_schema(@extended_resource_schema) do
|
143
|
+
if ENV["FOG_MOCK"] != "true"
|
144
|
+
sleep(180)
|
145
|
+
end
|
146
|
+
|
147
|
+
getNicResponse = service.get_nic(@datacenter_id, @server_id, @nic_id)
|
148
|
+
getNicResponse.body
|
149
|
+
end
|
150
|
+
|
151
|
+
tests('#update_nic').data_matches_schema(@extended_resource_schema) do
|
152
|
+
updateNicResponse = service.update_nic(@datacenter_id, @server_id, @nic_id, { 'name' => 'FogTestNic_2_Rename' })
|
153
|
+
updateNicResponse.body
|
154
|
+
end
|
155
|
+
|
156
|
+
tests('#get_all_nic').data_matches_schema(@minimal_schema_with_items) do
|
157
|
+
getAllNicResponse = service.get_all_nic(@datacenter_id, @server_id)
|
158
|
+
getAllNicResponse.body
|
159
|
+
end
|
160
|
+
|
161
|
+
tests('#create_ip_block').data_matches_schema(@resource_schema) do
|
162
|
+
options = {}
|
163
|
+
options[:location] = 'us/las'
|
164
|
+
options[:size] = 3
|
165
|
+
options[:name] = 'Fog test IP Block 1'
|
166
|
+
|
167
|
+
createIpBlockResponse = service.create_ip_block(options)
|
168
|
+
@ip_block_id = createIpBlockResponse.body['id']
|
169
|
+
createIpBlockResponse.body
|
170
|
+
end
|
171
|
+
|
172
|
+
tests('#get_ip_block').data_matches_schema(@resource_schema) do
|
173
|
+
service.get_ip_block(@ip_block_id).body
|
174
|
+
end
|
175
|
+
|
176
|
+
tests('#get_all_ip_blocks').data_matches_schema(@minimal_schema_with_items) do
|
177
|
+
getAllIpBlocksResponse = service.get_all_ip_blocks
|
178
|
+
getAllIpBlocksResponse.body
|
179
|
+
end
|
180
|
+
|
181
|
+
tests('#create_firewall_rule').data_matches_schema(@resource_schema) do
|
182
|
+
options = {}
|
183
|
+
options[:name] = 'Fog test Firewall Rule 3'
|
184
|
+
options[:protocol] = 'TCP'
|
185
|
+
options[:portRangeStart] = '80'
|
186
|
+
options[:portRangeEnd] = '80'
|
187
|
+
|
188
|
+
createFirewallRuleResponse = service.create_firewall_rule(@datacenter_id, @server_id, @nic_id, options)
|
189
|
+
@firewall_rule_id = createFirewallRuleResponse.body['id']
|
190
|
+
createFirewallRuleResponse.body
|
191
|
+
end
|
192
|
+
|
193
|
+
tests('#get_firewall_rule').data_matches_schema(@resource_schema) do
|
194
|
+
if ENV["FOG_MOCK"] != "true"
|
195
|
+
sleep(180)
|
196
|
+
end
|
197
|
+
service.get_firewall_rule(@datacenter_id, @server_id, @nic_id, @firewall_rule_id).body
|
198
|
+
end
|
199
|
+
|
200
|
+
tests('#update_firewall_rule').data_matches_schema(@resource_schema) do
|
201
|
+
updateFirewallRuleResponse = service.update_firewall_rule(@datacenter_id, @server_id, @nic_id, @firewall_rule_id, { 'name' => 'Fog test Firewall Rule 2 Rename' })
|
202
|
+
updateFirewallRuleResponse.body
|
203
|
+
end
|
204
|
+
|
205
|
+
tests('#get_all_firewall_rules').data_matches_schema(@minimal_schema_with_items) do
|
206
|
+
getAllFirewallRulesResponse = service.get_all_firewall_rules(@datacenter_id, @server_id, @nic_id)
|
207
|
+
getAllFirewallRulesResponse.body
|
208
|
+
end
|
209
|
+
|
210
|
+
tests('#create_load_balancer').data_matches_schema(@resource_schema) do
|
211
|
+
options = {}
|
212
|
+
options[:name] = 'FogTestLoadBalancer_2'
|
213
|
+
|
214
|
+
createLoadBalancerResponse = service.create_load_balancer(@datacenter_id, options, {})
|
215
|
+
@load_balancer_id = createLoadBalancerResponse.body['id']
|
216
|
+
createLoadBalancerResponse.body
|
217
|
+
end
|
218
|
+
|
219
|
+
tests('#get_load_balancer').data_matches_schema(@resource_schema) do
|
220
|
+
if ENV["FOG_MOCK"] != "true"
|
221
|
+
sleep(60)
|
222
|
+
end
|
223
|
+
|
224
|
+
service.get_load_balancer(@datacenter_id, @load_balancer_id).body
|
225
|
+
end
|
226
|
+
|
227
|
+
tests('#update_load_balancer').data_matches_schema(@resource_schema) do
|
228
|
+
updateLoadBalancerResponse = service.update_load_balancer(@datacenter_id, @load_balancer_id, { 'name' => 'FogTestLoadBalancer_2_Rename' })
|
229
|
+
updateLoadBalancerResponse.body
|
230
|
+
end
|
231
|
+
|
232
|
+
tests('#get_all_load_balancers').data_matches_schema(@minimal_schema_with_items) do
|
233
|
+
getAllLoadBalancersResponse = service.get_all_load_balancers(@datacenter_id)
|
234
|
+
getAllLoadBalancersResponse.body
|
235
|
+
end
|
236
|
+
|
237
|
+
tests('#associate_nic_to_load_balancer').succeeds do
|
238
|
+
associateNicToLoadBalancerResponse = service.associate_nic_to_load_balancer(@datacenter_id, @load_balancer_id, @nic_id)
|
239
|
+
associateNicToLoadBalancerResponse.status == 202
|
240
|
+
end
|
241
|
+
|
242
|
+
tests('#get_all_load_balancerd_nics').succeeds do
|
243
|
+
getAllLoadBalancedNicsResponse = service.get_all_load_balanced_nics(@datacenter_id, @load_balancer_id)
|
244
|
+
getAllLoadBalancedNicsResponse.status == 200
|
245
|
+
end
|
246
|
+
|
247
|
+
tests('#get_load_balanced_nic').succeeds do
|
248
|
+
if ENV["FOG_MOCK"] != "true"
|
249
|
+
sleep(60)
|
250
|
+
end
|
251
|
+
getAllLoadBalancedNicsResponse = service.get_load_balanced_nic(@datacenter_id, @load_balancer_id, @nic_id)
|
252
|
+
getAllLoadBalancedNicsResponse.status == 200
|
253
|
+
end
|
254
|
+
|
255
|
+
tests('#remove_nic_association').succeeds do
|
256
|
+
removeNicAssociationResponse = service.remove_nic_association(@datacenter_id, @load_balancer_id, @nic_id)
|
257
|
+
removeNicAssociationResponse.status == 202
|
258
|
+
end
|
259
|
+
|
260
|
+
tests('#delete_load_balancer').succeeds do
|
261
|
+
deleteLoadBalancerResponse = service.delete_load_balancer(@datacenter_id, @load_balancer_id)
|
262
|
+
deleteLoadBalancerResponse.status == 202
|
263
|
+
end
|
264
|
+
|
265
|
+
tests('#delete_firewall_rule').succeeds do
|
266
|
+
deleteFirewallRuleResponse = service.delete_firewall_rule(@datacenter_id, @server_id, @nic_id, @firewall_rule_id)
|
267
|
+
deleteFirewallRuleResponse.status == 202
|
268
|
+
end
|
269
|
+
|
270
|
+
tests('#delete_ip_block').succeeds do
|
271
|
+
deleteIpBlockResponse = service.delete_ip_block(@ip_block_id)
|
272
|
+
deleteIpBlockResponse.status == 202
|
273
|
+
end
|
274
|
+
|
275
|
+
tests('#delete_nic').succeeds do
|
276
|
+
deleteNicResponse = service.delete_nic(@datacenter_id, @server_id, @nic_id)
|
277
|
+
deleteNicResponse.status == 202
|
278
|
+
end
|
279
|
+
|
280
|
+
tests('#delete_server').succeeds do
|
281
|
+
deleteServerResponse = service.delete_server(@datacenter_id, @server_id)
|
282
|
+
deleteServerResponse.status == 202
|
283
|
+
end
|
284
|
+
|
285
|
+
tests('#delete_datacenter').succeeds do
|
286
|
+
deleteDatacenterResponse = service.delete_datacenter(@datacenter_id)
|
287
|
+
deleteDatacenterResponse.status == 202
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|