fog-profitbricks 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +11 -4
- data/README.md +8 -5
- data/Rakefile +1 -1
- data/examples/pb_demo.rb +49 -49
- data/fog-profitbricks.gemspec +4 -5
- data/gemfiles/Gemfile.1.9.2+ +1 -0
- data/lib/fog/bin/profitbricks.rb +5 -5
- data/lib/fog/profitbricks.rb +3 -3
- data/lib/fog/profitbricks/compute.rb +209 -204
- data/lib/fog/profitbricks/helpers/compute/data_helper.rb +1 -1
- data/lib/fog/profitbricks/models/compute/datacenter.rb +1 -1
- data/lib/fog/profitbricks/models/compute/datacenters.rb +6 -7
- data/lib/fog/profitbricks/models/compute/firewall_rule.rb +2 -2
- data/lib/fog/profitbricks/models/compute/firewall_rules.rb +5 -8
- data/lib/fog/profitbricks/models/compute/flavors.rb +1 -4
- data/lib/fog/profitbricks/models/compute/image.rb +4 -0
- data/lib/fog/profitbricks/models/compute/images.rb +2 -5
- data/lib/fog/profitbricks/models/compute/ip_block.rb +1 -1
- data/lib/fog/profitbricks/models/compute/ip_blocks.rb +3 -8
- data/lib/fog/profitbricks/models/compute/lan.rb +1 -1
- data/lib/fog/profitbricks/models/compute/lans.rb +4 -7
- data/lib/fog/profitbricks/models/compute/load_balancer.rb +6 -7
- data/lib/fog/profitbricks/models/compute/load_balancers.rb +5 -9
- data/lib/fog/profitbricks/models/compute/locations.rb +2 -5
- data/lib/fog/profitbricks/models/compute/nic.rb +6 -3
- data/lib/fog/profitbricks/models/compute/nics.rb +2 -5
- data/lib/fog/profitbricks/models/compute/regions.rb +1 -4
- data/lib/fog/profitbricks/models/compute/request.rb +0 -1
- data/lib/fog/profitbricks/models/compute/requests.rb +2 -4
- data/lib/fog/profitbricks/models/compute/server.rb +10 -13
- data/lib/fog/profitbricks/models/compute/servers.rb +3 -6
- data/lib/fog/profitbricks/models/compute/snapshot.rb +2 -2
- data/lib/fog/profitbricks/models/compute/snapshots.rb +3 -6
- data/lib/fog/profitbricks/models/compute/volume.rb +11 -9
- data/lib/fog/profitbricks/models/compute/volumes.rb +3 -6
- data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +26 -13
- data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +25 -16
- data/lib/fog/profitbricks/requests/compute/attach_volume.rb +25 -16
- data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +22 -23
- data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +24 -26
- data/lib/fog/profitbricks/requests/compute/create_flavor.rb +34 -34
- data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +18 -20
- data/lib/fog/profitbricks/requests/compute/create_lan.rb +151 -150
- data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +67 -26
- data/lib/fog/profitbricks/requests/compute/create_nic.rb +24 -26
- data/lib/fog/profitbricks/requests/compute/create_server.rb +70 -61
- data/lib/fog/profitbricks/requests/compute/create_volume.rb +122 -122
- data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +42 -45
- data/lib/fog/profitbricks/requests/compute/delete_datacenter.rb +34 -36
- data/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb +8 -11
- data/lib/fog/profitbricks/requests/compute/delete_image.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/delete_ip_block.rb +8 -10
- data/lib/fog/profitbricks/requests/compute/delete_lan.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb +8 -10
- data/lib/fog/profitbricks/requests/compute/delete_nic.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/delete_server.rb +6 -10
- data/lib/fog/profitbricks/requests/compute/delete_snapshot.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/delete_volume.rb +36 -38
- data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +11 -13
- data/lib/fog/profitbricks/requests/compute/detach_volume.rb +16 -13
- data/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb +6 -7
- data/lib/fog/profitbricks/requests/compute/get_all_flavors.rb +72 -72
- data/lib/fog/profitbricks/requests/compute/get_all_images.rb +62 -62
- data/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb +5 -5
- data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +113 -113
- data/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb +15 -9
- data/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb +9 -9
- data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +6 -6
- data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +94 -94
- data/lib/fog/profitbricks/requests/compute/get_all_requests.rb +38 -38
- data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +8 -9
- data/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb +4 -4
- data/lib/fog/profitbricks/requests/compute/get_all_volumes.rb +71 -71
- data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +11 -11
- data/lib/fog/profitbricks/requests/compute/get_attached_volume.rb +16 -11
- data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +4 -6
- data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +8 -11
- data/lib/fog/profitbricks/requests/compute/get_flavor.rb +9 -9
- data/lib/fog/profitbricks/requests/compute/get_image.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +8 -10
- data/lib/fog/profitbricks/requests/compute/get_lan.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +16 -12
- data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_location.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_nic.rb +8 -11
- data/lib/fog/profitbricks/requests/compute/get_request.rb +55 -57
- data/lib/fog/profitbricks/requests/compute/get_request_status.rb +44 -46
- data/lib/fog/profitbricks/requests/compute/get_server.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_volume.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +8 -8
- data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +18 -8
- data/lib/fog/profitbricks/requests/compute/reboot_server.rb +7 -11
- data/lib/fog/profitbricks/requests/compute/remove_nic_association.rb +9 -11
- data/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb +15 -17
- data/lib/fog/profitbricks/requests/compute/start_server.rb +7 -11
- data/lib/fog/profitbricks/requests/compute/stop_server.rb +7 -11
- data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +20 -15
- data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +9 -11
- data/lib/fog/profitbricks/requests/compute/update_image.rb +15 -15
- data/lib/fog/profitbricks/requests/compute/update_lan.rb +6 -8
- data/lib/fog/profitbricks/requests/compute/update_load_balancer.rb +10 -12
- data/lib/fog/profitbricks/requests/compute/update_nic.rb +10 -12
- data/lib/fog/profitbricks/requests/compute/update_server.rb +10 -13
- data/lib/fog/profitbricks/requests/compute/update_snapshot.rb +10 -13
- data/lib/fog/profitbricks/requests/compute/update_volume.rb +10 -13
- data/lib/fog/profitbricks/version.rb +1 -1
- data/spec/minitest_helper.rb +1 -3
- data/tests/helpers/formats_helper.rb +8 -8
- data/tests/profitbricks/models/compute/compute_tests.rb +529 -0
- data/tests/profitbricks/requests/compute/composite_create_tests.rb +16 -83
- data/tests/profitbricks/requests/compute/flavor_tests.rb +1 -4
- data/tests/profitbricks/requests/compute/location_tests.rb +14 -17
- data/tests/profitbricks/requests/compute/nic_tests.rb +60 -70
- data/tests/profitbricks/requests/compute/request_tests.rb +1 -3
- data/tests/profitbricks/requests/compute/server_tests.rb +163 -161
- metadata +5 -18
@@ -36,47 +36,88 @@ module Fog
|
|
36
36
|
# See the NIC section for attribute definitions
|
37
37
|
#
|
38
38
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-load-balancer]
|
39
|
-
def create_load_balancer(datacenter_id, properties={}, entities={})
|
39
|
+
def create_load_balancer(datacenter_id, properties = {}, entities = {})
|
40
40
|
load_balancer = {
|
41
|
-
|
42
|
-
|
41
|
+
:properties => properties,
|
42
|
+
:entities => entities
|
43
43
|
}
|
44
44
|
|
45
45
|
request(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
:expects => [202],
|
47
|
+
:method => 'POST',
|
48
|
+
:path => "/datacenters/#{datacenter_id}/loadbalancers",
|
49
|
+
:body => Fog::JSON.encode(load_balancer)
|
50
50
|
)
|
51
|
-
rescue => error
|
52
|
-
Fog::Errors::NotFound.new(error)
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
54
|
class Mock
|
57
|
-
def create_load_balancer(datacenter_id, properties={},
|
55
|
+
def create_load_balancer(datacenter_id, properties = {}, _entities = {})
|
58
56
|
response = Excon::Response.new
|
59
57
|
response.status = 202
|
60
58
|
|
61
|
-
load_balancer_id
|
59
|
+
load_balancer_id = Fog::UUID.uuid
|
60
|
+
nic_1_id = Fog::UUID.uuid
|
61
|
+
serv_1_id = Fog::UUID.uuid
|
62
|
+
|
62
63
|
load_balancer = {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
'
|
64
|
+
'id' => load_balancer_id,
|
65
|
+
'type' => 'nic',
|
66
|
+
'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}",
|
67
|
+
'metadata' => {
|
68
|
+
'createdDate' => '2015-03-18T19:00:51Z',
|
69
|
+
'createdBy' => 'test@stackpointcloud.com',
|
70
|
+
'etag' => 'faa67fbacb1c0e2e02cf9650657251f2',
|
71
|
+
'lastModifiedDate' => '2015-03-18T19:00:51Z',
|
72
|
+
'lastModifiedBy' => 'test@stackpointcloud.com',
|
73
|
+
'state' => 'AVAILABLE'
|
74
|
+
},
|
75
|
+
'properties' => properties,
|
76
|
+
'entities' => {
|
77
|
+
'balancednics' => {
|
78
|
+
'id' => "#{load_balancer_id}/balancednics",
|
79
|
+
'type' => 'collection',
|
80
|
+
'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics",
|
81
|
+
'items' =>
|
82
|
+
[
|
83
|
+
{
|
84
|
+
'id' => nic_1_id,
|
85
|
+
'type' => 'nic',
|
86
|
+
'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{serv_1_id}/nics/#{nic_1_id}",
|
87
|
+
'metadata' => {
|
88
|
+
'createdDate' => '2015-03-18T19:00:51Z',
|
89
|
+
'createdBy' => 'test@stackpointcloud.com',
|
90
|
+
'etag' => 'faa67fbacb1c0e2e02cf9650657251f1',
|
91
|
+
'lastModifiedDate' => '2015-03-18T19:00:51Z',
|
92
|
+
'lastModifiedBy' => 'test@stackpointcloud.com',
|
93
|
+
'state' => 'AVAILABLE'
|
94
|
+
},
|
95
|
+
'properties' => {
|
96
|
+
'name' => 'FogTestLoadBalancedNIC_1',
|
97
|
+
'mac' => '02:01:36:5f:09:da',
|
98
|
+
'ips' => ['10.9.194.12'],
|
99
|
+
'dhcp' => 'true',
|
100
|
+
'lan' => 2,
|
101
|
+
'firewallActive' => 'false'
|
102
|
+
},
|
103
|
+
'entities' => {
|
104
|
+
'firewallrules' => {
|
105
|
+
'id' => "#{nic_1_id}/firewallrules",
|
106
|
+
'type' => 'collection',
|
107
|
+
'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{serv_1_id}/nics/#{nic_1_id}/firewallrules",
|
108
|
+
'items' => []
|
109
|
+
}
|
110
|
+
},
|
111
|
+
'datacenter_id' => datacenter_id,
|
112
|
+
'load_balancer_id' => load_balancer_id
|
113
|
+
}
|
114
|
+
]
|
115
|
+
}
|
116
|
+
},
|
117
|
+
'datacenter_id' => datacenter_id
|
77
118
|
}
|
78
119
|
|
79
|
-
|
120
|
+
data[:load_balancers]['items'] << load_balancer
|
80
121
|
response.body = load_balancer
|
81
122
|
|
82
123
|
response
|
@@ -72,48 +72,46 @@ module Fog
|
|
72
72
|
# portRangeEnd value null to allow all ports
|
73
73
|
#
|
74
74
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-a-nic]
|
75
|
-
def create_nic(datacenter_id, server_id, options={}, entities={})
|
75
|
+
def create_nic(datacenter_id, server_id, options = {}, entities = {})
|
76
76
|
nic = {
|
77
|
-
|
78
|
-
|
77
|
+
:properties => options,
|
78
|
+
:entities => entities
|
79
79
|
}
|
80
80
|
|
81
81
|
request(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
:expects => [202],
|
83
|
+
:method => 'POST',
|
84
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics",
|
85
|
+
:body => Fog::JSON.encode(nic)
|
86
86
|
)
|
87
|
-
rescue => error
|
88
|
-
Fog::Errors::NotFound.new(error)
|
89
87
|
end
|
90
88
|
end
|
91
89
|
|
92
90
|
class Mock
|
93
|
-
def create_nic(datacenter_id, server_id, options={}, entities={})
|
91
|
+
def create_nic(datacenter_id, server_id, options = {}, entities = {})
|
94
92
|
response = Excon::Response.new
|
95
93
|
response.status = 202
|
96
94
|
|
97
95
|
nic_id = Fog::UUID.uuid
|
98
96
|
nic = {
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
97
|
+
'id' => nic_id,
|
98
|
+
'type' => 'nic',
|
99
|
+
'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}",
|
100
|
+
'metadata' => {
|
101
|
+
'createdDate' => '2015-03-18T19:00:51Z',
|
102
|
+
'createdBy' => 'test@stackpointcloud.com',
|
103
|
+
'etag' => 'faa67fbacb1c0e2e02cf9650657251f2',
|
104
|
+
'lastModifiedDate' => '2015-03-18T19:00:51Z',
|
105
|
+
'lastModifiedBy' => 'test@stackpointcloud.com',
|
106
|
+
'state' => 'AVAILABLE'
|
107
|
+
},
|
108
|
+
'properties' => options,
|
109
|
+
'entities' => entities,
|
110
|
+
'datacenter_id' => datacenter_id,
|
111
|
+
'server_id' => server_id
|
114
112
|
}
|
115
113
|
|
116
|
-
|
114
|
+
data[:nics]['items'] << nic
|
117
115
|
response.body = nic
|
118
116
|
|
119
117
|
response
|
@@ -116,33 +116,37 @@ module Fog
|
|
116
116
|
# * items<~Array> - An array of individual firewall rules associated to the NIC
|
117
117
|
#
|
118
118
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-a-server]
|
119
|
-
def create_server(datacenter_id, properties={}, entities={})
|
119
|
+
def create_server(datacenter_id, properties = {}, entities = {})
|
120
120
|
server = {
|
121
|
-
|
122
|
-
|
121
|
+
:properties => properties,
|
122
|
+
:entities => entities
|
123
123
|
}
|
124
124
|
|
125
125
|
request(
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
126
|
+
:expects => [202],
|
127
|
+
:method => 'POST',
|
128
|
+
:path => "/datacenters/#{datacenter_id}/servers",
|
129
|
+
:body => Fog::JSON.encode(server)
|
130
130
|
)
|
131
|
-
rescue => error
|
132
|
-
Fog::Errors::NotFound.new(error)
|
133
131
|
end
|
134
132
|
end
|
135
133
|
|
136
134
|
class Mock
|
137
|
-
def create_server(datacenter_id, properties={}, entities={})
|
135
|
+
def create_server(datacenter_id, properties = {}, entities = {})
|
138
136
|
server_id = Fog::UUID.uuid
|
139
|
-
|
140
|
-
|
137
|
+
|
138
|
+
volume_id = if entities[:volumes] && entities[:volumes]['items'] && entities[:volumes]['items'][0] && entities[:volumes]['items'][0]['id']
|
139
|
+
entities[:volumes]['items'][0]['id']
|
140
|
+
else
|
141
|
+
Fog::UUID.uuid
|
142
|
+
end
|
143
|
+
|
141
144
|
server = {
|
142
145
|
'id' => server_id,
|
143
146
|
'type' => 'server',
|
144
147
|
'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}",
|
145
|
-
'
|
148
|
+
'datacenter_id' => datacenter_id,
|
149
|
+
'metadata' => {
|
146
150
|
'createdDate' => '2014-10-20T21:20:46Z',
|
147
151
|
'createdBy' => 'test@stackpointcloud.com',
|
148
152
|
'etag' => '0018832d7a7ba455db74ac41ae9f11fe',
|
@@ -150,15 +154,18 @@ module Fog
|
|
150
154
|
'lastModifiedBy' => 'test@stackpointcloud.com',
|
151
155
|
'state' => 'AVAILABLE'
|
152
156
|
},
|
153
|
-
'properties'
|
157
|
+
'properties' => {
|
154
158
|
'name' => properties[:name],
|
155
159
|
'cores' => properties[:cores],
|
156
160
|
'ram' => properties[:ram],
|
157
161
|
'availabilityZone' => properties[:availabilityZone],
|
158
162
|
'vmState' => 'RUNNING',
|
159
163
|
'cpuFamily' => properties[:cpuFamily]
|
160
|
-
}
|
161
|
-
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
if entities[:volumes]
|
168
|
+
server['entities'] = {
|
162
169
|
'volumes' => {
|
163
170
|
'id' => "#{server_id}/volumes",
|
164
171
|
'type' => 'collection',
|
@@ -177,7 +184,7 @@ module Fog
|
|
177
184
|
'lastModifiedBy' => 'test@stackpointcloud.com',
|
178
185
|
'state' => 'AVAILABLE'
|
179
186
|
},
|
180
|
-
'properties'
|
187
|
+
'properties' => {
|
181
188
|
'name' => 'FogRestTestVolume',
|
182
189
|
'type' => 'HDD',
|
183
190
|
'size' => 5,
|
@@ -198,52 +205,54 @@ module Fog
|
|
198
205
|
}
|
199
206
|
}
|
200
207
|
]
|
201
|
-
},
|
202
|
-
'cdroms' => {
|
203
|
-
'id' => "#{server_id}/cdroms",
|
204
|
-
'type' => 'collection',
|
205
|
-
'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms",
|
206
|
-
'items' =>
|
207
|
-
[
|
208
|
-
{
|
209
|
-
'id' => 'dfcb40db-28b5-11e6-9336-52540005ab80',
|
210
|
-
'type' => 'image',
|
211
|
-
'href' => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80',
|
212
|
-
'metadata' => {
|
213
|
-
'createdDate' => '2016-06-02T11:33:49Z',
|
214
|
-
'createdBy' => 'System',
|
215
|
-
'etag' => '9909709d99655c6f31aca789998d7d89',
|
216
|
-
'lastModifiedDate' => '2016-06-02T11:33:49Z',
|
217
|
-
'lastModifiedBy' => 'System',
|
218
|
-
'state' => 'AVAILABLE'
|
219
|
-
},
|
220
|
-
'properties' => {
|
221
|
-
'name' => 'CentOS-6.8-x86_64-netinstall.iso',
|
222
|
-
'description' => '',
|
223
|
-
'location' => 'us/las',
|
224
|
-
'size' => 0.23,
|
225
|
-
'cpuHotPlug' => 'true',
|
226
|
-
'cpuHotUnplug' => 'false',
|
227
|
-
'ramHotPlug' => 'true',
|
228
|
-
'ramHotUnplug' => 'false',
|
229
|
-
'nicHotPlug' => 'true',
|
230
|
-
'nicHotUnplug' => 'true',
|
231
|
-
'discVirtioHotPlug' => 'true',
|
232
|
-
'discVirtioHotUnplug' => 'true',
|
233
|
-
'discScsiHotPlug' => 'false',
|
234
|
-
'discScsiHotUnplug' => 'false',
|
235
|
-
'licenceType' => 'LINUX',
|
236
|
-
'imageType' => 'CDROM',
|
237
|
-
'public' => 'true'
|
238
|
-
}
|
239
|
-
}
|
240
|
-
]
|
241
208
|
}
|
242
|
-
}
|
243
|
-
|
244
|
-
|
209
|
+
}
|
210
|
+
end
|
211
|
+
|
212
|
+
if entities[:cdroms]
|
213
|
+
server['entities']['cdroms'] = {
|
214
|
+
'id' => "#{server_id}/cdroms",
|
215
|
+
'type' => 'collection',
|
216
|
+
'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms",
|
217
|
+
'items' =>
|
218
|
+
[
|
219
|
+
{
|
220
|
+
'id' => 'dfcb40db-28b5-11e6-9336-52540005ab80',
|
221
|
+
'type' => 'image',
|
222
|
+
'href' => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80',
|
223
|
+
'metadata' => {
|
224
|
+
'createdDate' => '2016-06-02T11:33:49Z',
|
225
|
+
'createdBy' => 'System',
|
226
|
+
'etag' => '9909709d99655c6f31aca789998d7d89',
|
227
|
+
'lastModifiedDate' => '2016-06-02T11:33:49Z',
|
228
|
+
'lastModifiedBy' => 'System',
|
229
|
+
'state' => 'AVAILABLE'
|
230
|
+
},
|
231
|
+
'properties' => {
|
232
|
+
'name' => 'CentOS-6.8-x86_64-netinstall.iso',
|
233
|
+
'description' => '',
|
234
|
+
'location' => 'us/las',
|
235
|
+
'size' => 0.23,
|
236
|
+
'cpuHotPlug' => 'true',
|
237
|
+
'cpuHotUnplug' => 'false',
|
238
|
+
'ramHotPlug' => 'true',
|
239
|
+
'ramHotUnplug' => 'false',
|
240
|
+
'nicHotPlug' => 'true',
|
241
|
+
'nicHotUnplug' => 'true',
|
242
|
+
'discVirtioHotPlug' => 'true',
|
243
|
+
'discVirtioHotUnplug' => 'true',
|
244
|
+
'discScsiHotPlug' => 'false',
|
245
|
+
'discScsiHotUnplug' => 'false',
|
246
|
+
'licenceType' => 'LINUX',
|
247
|
+
'imageType' => 'CDROM',
|
248
|
+
'public' => 'true'
|
249
|
+
}
|
250
|
+
}
|
251
|
+
]
|
252
|
+
}
|
253
|
+
end
|
245
254
|
|
246
|
-
|
255
|
+
data[:servers]['items'] << server
|
247
256
|
|
248
257
|
response = Excon::Response.new
|
249
258
|
response.status = 202
|
@@ -1,133 +1,133 @@
|
|
1
1
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
# Creates a volume within the data center. This will NOT attach the volume to a server.
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * datacenter_id<~String> - Required, UUID of virtual data center
|
9
|
+
# * options<~Hash>:
|
10
|
+
# * name<~String> - The name of the volume
|
11
|
+
# * size<~Integer> - Required, the size of the volume in GB
|
12
|
+
# * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO.
|
13
|
+
# * image<~String> - Required**, the image or snapshot ID
|
14
|
+
# * type<~String> - The volume type, HDD or SSD
|
15
|
+
# * licenceType<~String> - Required**, the licence type of the volume. Options: LINUX, WINDOWS, UNKNOWN, OTHER
|
16
|
+
# * imagePassword<~String> - One-time password is set on the Image for the appropriate account.
|
17
|
+
# This field may only be set in creation requests. When reading, it always returns null.
|
18
|
+
# Password has to contain 8-50 characters.
|
19
|
+
# Only these characters are allowed: [abcdefghjkmnpqrstuvxABCDEFGHJKLMNPQRSTUVX23456789]
|
20
|
+
# * sshKeys<~String> - SSH keys to allow access to the volume via SSH
|
21
|
+
#
|
22
|
+
# ** Either the image or the licenceType parameters need to be provided.
|
23
|
+
# licenceType is required, but if image is supplied, it will already have a licenceType set.
|
24
|
+
#
|
25
|
+
# ==== Returns
|
26
|
+
# * response<~Excon::Response>:
|
27
|
+
# * body<~Hash>:
|
28
|
+
# * id<~String> - The resource's unique identifier
|
29
|
+
# * type<~String> - The type of the created resource
|
30
|
+
# * href<~String> - URL to the object's representation (absolute path)
|
31
|
+
# * metadata<~Hash> - Hash containing the volume metadata
|
32
|
+
# * createdDate<~String> - The date the resource was created
|
33
|
+
# * createdBy<~String> - The user who created the resource
|
34
|
+
# * etag<~String> - The etag for the resource
|
35
|
+
# * lastModifiedDate<~String> - The last time the resource has been modified
|
36
|
+
# * lastModifiedBy<~String> - The user who last modified the resource
|
37
|
+
# * state<~String> - Volume state
|
38
|
+
# * properties<~Hash> - Hash containing the volume properties
|
39
|
+
# * name<~String> - The name of the volume.
|
40
|
+
# * type<~String> - The volume type, HDD or SSD.
|
41
|
+
# * size<~Integer> - The size of the volume in GB.
|
42
|
+
# * image<~String> - The image or snapshot ID.
|
43
|
+
# * imagePassword<~String> - Indicates if a password is set on the image.
|
44
|
+
# * sshKeys<~String> - SSH keys
|
45
|
+
# * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO.
|
46
|
+
# * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN)
|
47
|
+
# * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required)
|
48
|
+
# * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required)
|
49
|
+
# * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required)
|
50
|
+
# * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required)
|
51
|
+
# * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required)
|
52
|
+
# * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required)
|
53
|
+
# * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required)
|
54
|
+
# * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required)
|
55
|
+
# * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required)
|
56
|
+
# * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required)
|
57
|
+
# * deviceNumber<~Integer> - The LUN ID of the volume volume
|
58
|
+
#
|
59
|
+
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-volume]
|
60
|
+
def create_volume(datacenter_id, options = {})
|
61
|
+
volume = {
|
62
|
+
:properties => options
|
63
|
+
}
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
65
|
+
request(
|
66
|
+
:expects => [202],
|
67
|
+
:method => 'POST',
|
68
|
+
:path => "/datacenters/#{datacenter_id}/volumes",
|
69
|
+
:body => Fog::JSON.encode(volume)
|
70
|
+
)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class Mock
|
75
|
+
def create_volume(datacenter_id, options = {})
|
76
|
+
response = Excon::Response.new
|
77
|
+
response.status = 202
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
response.status = 202
|
79
|
+
if datacenter = data[:datacenters]['items'].find do |attrib|
|
80
|
+
attrib['id'] == datacenter_id
|
81
|
+
end
|
80
82
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
else
|
86
|
-
raise Fog::Errors::NotFound.new('Data center resource could not be found')
|
87
|
-
end
|
83
|
+
datacenter['version'] += 1 if datacenter['version']
|
84
|
+
else
|
85
|
+
raise Fog::Errors::NotFound, 'Data center resource could not be found'
|
86
|
+
end
|
88
87
|
|
89
|
-
|
88
|
+
volume_id = Fog::UUID.uuid
|
90
89
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
90
|
+
volume = {
|
91
|
+
'id' => volume_id,
|
92
|
+
'type' => 'volume',
|
93
|
+
'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter['id']}/volumes/#{volume_id}",
|
94
|
+
'metadata' => {
|
95
|
+
'createdDate' => '2015-03-18T19=>00=>51Z',
|
96
|
+
'createdBy' => 'test@stackpointcloud.com',
|
97
|
+
'etag' => 'c4a2fde6ba91a038ff953b939cc21efe',
|
98
|
+
'lastModifiedDate' => '2015-03-18T19=>00=>51Z',
|
99
|
+
'lastModifiedBy' => 'test@stackpointcloud.com',
|
100
|
+
'state' => 'AVAILABLE'
|
101
|
+
},
|
102
|
+
'properties' => {
|
103
|
+
'name' => options[:name],
|
104
|
+
'type' => options[:type],
|
105
|
+
'size' => options[:size],
|
106
|
+
'image' => options[:image],
|
107
|
+
'availabilityZone' => options[:availabilityZone],
|
108
|
+
'bus' => 'VIRTIO',
|
109
|
+
'licenceType' => 'OTHER',
|
110
|
+
'cpuHotPlug' => 'true',
|
111
|
+
'cpuHotUnplug' => 'false',
|
112
|
+
'ramHotPlug' => 'false',
|
113
|
+
'ramHotUnplug' => 'false',
|
114
|
+
'nicHotPlug' => 'true',
|
115
|
+
'nicHotUnplug' => 'true',
|
116
|
+
'discVirtioHotPlug' => 'true',
|
117
|
+
'discVirtioHotUnplug' => 'true',
|
118
|
+
'discScsiHotPlug' => 'false',
|
119
|
+
'discScsiHotUnplug' => 'false',
|
120
|
+
'deviceNumber' => 1
|
121
|
+
},
|
122
|
+
'datacenter_id' => datacenter['id']
|
123
|
+
}
|
124
124
|
|
125
|
-
|
125
|
+
data[:volumes]['items'] << volume
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
end
|
130
|
-
end
|
127
|
+
response.body = volume
|
128
|
+
response
|
131
129
|
end
|
130
|
+
end
|
132
131
|
end
|
132
|
+
end
|
133
133
|
end
|