bosh_cpi 2.4.1 → 2.6.0
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.
- checksums.yaml +5 -5
- data/lib/bosh/cpi/cli.rb +9 -1
- data/lib/cloud/errors.rb +1 -0
- data/lib/cloud.rb +3 -246
- data/lib/cloud_v1.rb +281 -0
- data/lib/cloud_v2.rb +102 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5b7ea28ce41080258160b7d802c4eb5c7b8e5caea0176bd4fe06c83ef0904692
|
4
|
+
data.tar.gz: 6fee64af30ecf8933d43cfe09743adff2b4b78e3b6c65080429f73151b112f9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0894fb8a53ee2f27205ce72e1d1c44ddb6e5244854bc13200644d63bd32fe27b983b4de80ff692925a6d6a7c91ac13a11290d5a828bdbc99661bb3020b79422
|
7
|
+
data.tar.gz: 2433575b3eaafcc8fea333245cd93e778121026662241d2fd6e8b8525fe7b90b81bea588e0afb62792866ea97605cac6170da5a754c833e77a748311fd29a10f
|
data/lib/bosh/cpi/cli.rb
CHANGED
@@ -13,6 +13,7 @@ class Bosh::Cpi::Cli
|
|
13
13
|
set_vm_metadata
|
14
14
|
set_disk_metadata
|
15
15
|
create_disk
|
16
|
+
update_disk
|
16
17
|
has_disk
|
17
18
|
delete_disk
|
18
19
|
attach_disk
|
@@ -23,6 +24,8 @@ class Bosh::Cpi::Cli
|
|
23
24
|
resize_disk
|
24
25
|
ping
|
25
26
|
calculate_vm_cloud_properties
|
27
|
+
create_network
|
28
|
+
delete_network
|
26
29
|
).freeze
|
27
30
|
|
28
31
|
RPC_METHOD_TO_RUBY_METHOD = {
|
@@ -61,6 +64,11 @@ class Bosh::Cpi::Cli
|
|
61
64
|
return error_response(INVALID_CALL_ERROR_TYPE, "Arguments must be an Array", false)
|
62
65
|
end
|
63
66
|
|
67
|
+
cpi_api_version = request['api_version']
|
68
|
+
if request.has_key?('api_version') && !cpi_api_version.is_a?(Integer)
|
69
|
+
return error_response(INVALID_CALL_ERROR_TYPE, "CPI api_version requested must be an Integer", false)
|
70
|
+
end
|
71
|
+
|
64
72
|
context = request['context']
|
65
73
|
unless context.is_a?(Hash) && context['director_uuid'].is_a?(String)
|
66
74
|
return error_response(INVALID_CALL_ERROR_TYPE, "Request should include context with director uuid", false)
|
@@ -77,7 +85,7 @@ class Bosh::Cpi::Cli
|
|
77
85
|
start_time = Time.now.utc
|
78
86
|
@logger.info("Starting #{method}...")
|
79
87
|
|
80
|
-
cpi = @cpi.call(context)
|
88
|
+
cpi = @cpi.call(context, cpi_api_version)
|
81
89
|
|
82
90
|
result = cpi.public_send(ruby_method, *arguments)
|
83
91
|
rescue Bosh::Clouds::RetriableCloudError => e
|
data/lib/cloud/errors.rb
CHANGED
data/lib/cloud.rb
CHANGED
@@ -6,254 +6,11 @@ require "forwardable"
|
|
6
6
|
|
7
7
|
require "cloud/config"
|
8
8
|
require "cloud/errors"
|
9
|
+
require "cloud_v1"
|
9
10
|
|
10
11
|
module Bosh
|
11
|
-
|
12
|
-
##
|
13
|
-
# CPI - Cloud Provider Interface, used for interfacing with various IaaS APIs.
|
14
|
-
#
|
15
|
-
# Key terms:
|
16
|
-
# Stemcell: template used for creating VMs (shouldn't be powered on)
|
17
|
-
# VM: VM created from a stemcell with custom settings (networking and resources)
|
18
|
-
# Disk: volume that can be attached and detached from the VMs,
|
19
|
-
# never attached to more than a single VM at one time
|
12
|
+
# Base class definition for backwards compatibility
|
20
13
|
class Cloud
|
21
|
-
|
22
|
-
##
|
23
|
-
# Cloud initialization
|
24
|
-
#
|
25
|
-
# @param [Hash] options cloud options
|
26
|
-
def initialize(options)
|
27
|
-
end
|
28
|
-
|
29
|
-
## Information about cpi
|
30
|
-
#
|
31
|
-
# Sample info response:
|
32
|
-
# {"stemcell_formats" =>
|
33
|
-
# ["aws-raw", "aws-light"]
|
34
|
-
# }
|
35
|
-
# @return [Hash] information about cpi, currently stemcell formats, which are supported
|
36
|
-
def info
|
37
|
-
not_implemented(:info)
|
38
|
-
end
|
39
|
-
|
40
|
-
##
|
41
|
-
# Get the vm_id of this host
|
42
|
-
#
|
43
|
-
# @return [String] opaque id later used by other methods of the CPI
|
44
|
-
def current_vm_id
|
45
|
-
not_implemented(:current_vm_id)
|
46
|
-
end
|
47
|
-
|
48
|
-
##
|
49
|
-
# Creates a stemcell
|
50
|
-
#
|
51
|
-
# @param [String] image_path path to an opaque blob containing the stemcell image
|
52
|
-
# @param [Hash] cloud_properties properties required for creating this template
|
53
|
-
# specific to a CPI
|
54
|
-
# @return [String] opaque id later used by {#create_vm} and {#delete_stemcell}
|
55
|
-
def create_stemcell(image_path, cloud_properties)
|
56
|
-
not_implemented(:create_stemcell)
|
57
|
-
end
|
58
|
-
|
59
|
-
##
|
60
|
-
# Deletes a stemcell
|
61
|
-
#
|
62
|
-
# @param [String] stemcell stemcell id that was once returned by {#create_stemcell}
|
63
|
-
# @return [void]
|
64
|
-
def delete_stemcell(stemcell_id)
|
65
|
-
not_implemented(:delete_stemcell)
|
66
|
-
end
|
67
|
-
|
68
|
-
##
|
69
|
-
# Creates a VM - creates (and powers on) a VM from a stemcell with the proper resources
|
70
|
-
# and on the specified network. When disk locality is present the VM will be placed near
|
71
|
-
# the provided disk so it won't have to move when the disk is attached later.
|
72
|
-
#
|
73
|
-
# Sample networking config:
|
74
|
-
# {"network_a" =>
|
75
|
-
# {
|
76
|
-
# "netmask" => "255.255.248.0",
|
77
|
-
# "ip" => "172.30.41.40",
|
78
|
-
# "gateway" => "172.30.40.1",
|
79
|
-
# "dns" => ["172.30.22.153", "172.30.22.154"],
|
80
|
-
# "cloud_properties" => {"name" => "VLAN444"}
|
81
|
-
# }
|
82
|
-
# }
|
83
|
-
#
|
84
|
-
# Sample resource pool config (CPI specific):
|
85
|
-
# {
|
86
|
-
# "ram" => 512,
|
87
|
-
# "disk" => 512,
|
88
|
-
# "cpu" => 1
|
89
|
-
# }
|
90
|
-
# or similar for EC2:
|
91
|
-
# {"name" => "m1.small"}
|
92
|
-
#
|
93
|
-
# @param [String] agent_id UUID for the agent that will be used later on by the director
|
94
|
-
# to locate and talk to the agent
|
95
|
-
# @param [String] stemcell stemcell id that was once returned by {#create_stemcell}
|
96
|
-
# @param [Hash] resource_pool cloud specific properties describing the resources needed
|
97
|
-
# for this VM
|
98
|
-
# @param [Hash] networks list of networks and their settings needed for this VM
|
99
|
-
# @param [String, Array] disk_locality disk id(s) if known of the disk(s) that will be
|
100
|
-
# attached to this vm
|
101
|
-
# @param [Hash] env environment that will be passed to this vm
|
102
|
-
# @return [String] opaque id later used by {#attach_disk}, {#detach_disk} and {#delete_vm}
|
103
|
-
def create_vm(agent_id, stemcell_id, resource_pool,
|
104
|
-
networks, disk_locality, env)
|
105
|
-
not_implemented(:create_vm)
|
106
|
-
end
|
107
|
-
|
108
|
-
##
|
109
|
-
# Deletes a VM. If the VM has already been deleted, this call returns normally and has no effect.
|
110
|
-
#
|
111
|
-
# @param [String] vm vm id that was once returned by {#create_vm}
|
112
|
-
# @return [void]
|
113
|
-
def delete_vm(vm_id)
|
114
|
-
not_implemented(:delete_vm)
|
115
|
-
end
|
116
|
-
|
117
|
-
##
|
118
|
-
# Checks if a VM exists
|
119
|
-
#
|
120
|
-
# @param [String] vm vm id that was once returned by {#create_vm}
|
121
|
-
# @return [Boolean] True if the vm exists
|
122
|
-
def has_vm?(vm_id)
|
123
|
-
not_implemented(:has_vm?)
|
124
|
-
end
|
125
|
-
|
126
|
-
##
|
127
|
-
# Checks if a disk exists
|
128
|
-
#
|
129
|
-
# @param [String] disk disk_id that was once returned by {#create_disk}
|
130
|
-
# @return [Boolean] True if the disk exists
|
131
|
-
def has_disk?(disk_id)
|
132
|
-
not_implemented(:has_disk?)
|
133
|
-
end
|
134
|
-
|
135
|
-
##
|
136
|
-
# Reboots a VM
|
137
|
-
#
|
138
|
-
# @param [String] vm vm id that was once returned by {#create_vm}
|
139
|
-
# @param [Optional, Hash] CPI specific options (e.g hard/soft reboot)
|
140
|
-
# @return [void]
|
141
|
-
def reboot_vm(vm_id)
|
142
|
-
not_implemented(:reboot_vm)
|
143
|
-
end
|
144
|
-
|
145
|
-
##
|
146
|
-
# Set metadata for a VM
|
147
|
-
#
|
148
|
-
# Optional. Implement to provide more information for the IaaS.
|
149
|
-
#
|
150
|
-
# @param [String] vm vm id that was once returned by {#create_vm}
|
151
|
-
# @param [Hash] metadata metadata key/value pairs
|
152
|
-
# @return [void]
|
153
|
-
def set_vm_metadata(vm, metadata)
|
154
|
-
not_implemented(:set_vm_metadata)
|
155
|
-
end
|
156
|
-
|
157
|
-
##
|
158
|
-
# Set metadata for a disk
|
159
|
-
#
|
160
|
-
# Optional. Implement to provide more information for the IaaS.
|
161
|
-
#
|
162
|
-
# @param [String] disk_id disk id that was once returned by {#create_disk}
|
163
|
-
# @param [Hash] metadata metadata key/value pairs
|
164
|
-
# @return [void]
|
165
|
-
def set_disk_metadata(disk_id, metadata)
|
166
|
-
not_implemented(:set_disk_metadata)
|
167
|
-
end
|
168
|
-
|
169
|
-
##
|
170
|
-
# Creates a disk (possibly lazily) that will be attached later to a VM. When
|
171
|
-
# VM locality is specified the disk will be placed near the VM so it won't have to move
|
172
|
-
# when it's attached later.
|
173
|
-
#
|
174
|
-
# @param [Integer] size disk size in MB
|
175
|
-
# @param [Hash] cloud_properties properties required for creating this disk
|
176
|
-
# specific to a CPI
|
177
|
-
# @param [String] vm_locality vm id if known of the VM that this disk will
|
178
|
-
# be attached to
|
179
|
-
# @return [String] opaque id later used by {#attach_disk}, {#detach_disk}, and {#delete_disk}
|
180
|
-
def create_disk(size, cloud_properties, vm_locality)
|
181
|
-
not_implemented(:create_disk)
|
182
|
-
end
|
183
|
-
|
184
|
-
##
|
185
|
-
# Deletes a disk
|
186
|
-
# Will raise an exception if the disk is attached to a VM
|
187
|
-
#
|
188
|
-
# @param [String] disk disk id that was once returned by {#create_disk}
|
189
|
-
# @return [void]
|
190
|
-
def delete_disk(disk_id)
|
191
|
-
not_implemented(:delete_disk)
|
192
|
-
end
|
193
|
-
|
194
|
-
# Attaches a disk
|
195
|
-
# @param [String] vm vm id that was once returned by {#create_vm}
|
196
|
-
# @param [String] disk disk id that was once returned by {#create_disk}
|
197
|
-
# @return [void]
|
198
|
-
def attach_disk(vm_id, disk_id)
|
199
|
-
not_implemented(:attach_disk)
|
200
|
-
end
|
201
|
-
|
202
|
-
# Take snapshot of disk
|
203
|
-
# @param [String] disk_id disk id of the disk to take the snapshot of
|
204
|
-
# @param [Hash] metadata metadata key/value pairs
|
205
|
-
# @return [String] snapshot id
|
206
|
-
def snapshot_disk(disk_id, metadata)
|
207
|
-
not_implemented(:snapshot_disk)
|
208
|
-
end
|
209
|
-
|
210
|
-
# Delete a disk snapshot
|
211
|
-
# @param [String] snapshot_id snapshot id to delete
|
212
|
-
# @return [void]
|
213
|
-
def delete_snapshot(snapshot_id)
|
214
|
-
not_implemented(:delete_snapshot)
|
215
|
-
end
|
216
|
-
|
217
|
-
# Detaches a disk
|
218
|
-
# @param [String] vm vm id that was once returned by {#create_vm}
|
219
|
-
# @param [String] disk disk id that was once returned by {#create_disk}
|
220
|
-
# @return [void]
|
221
|
-
def detach_disk(vm_id, disk_id)
|
222
|
-
not_implemented(:detach_disk)
|
223
|
-
end
|
224
|
-
|
225
|
-
# List the attached disks of the VM.
|
226
|
-
# @param [String] vm_id is the CPI-standard vm_id (eg, returned from current_vm_id)
|
227
|
-
# @return [array[String]] list of opaque disk_ids that can be used with the
|
228
|
-
# other disk-related methods on the CPI
|
229
|
-
def get_disks(vm_id)
|
230
|
-
not_implemented(:get_disks)
|
231
|
-
end
|
232
|
-
|
233
|
-
##
|
234
|
-
# Resizes an existing disk
|
235
|
-
#
|
236
|
-
# @param [String] disk_id disk id
|
237
|
-
# @param [Integer] new_size disk size in MiB
|
238
|
-
# @return [void]
|
239
|
-
def resize_disk(disk_id, new_size)
|
240
|
-
not_implemented(:resize_disk)
|
241
|
-
end
|
242
|
-
|
243
|
-
# Specify VM's hardware resources
|
244
|
-
# @param [Hash] vm_properties (typically cpu, ram, ephemeral_disk_size)
|
245
|
-
# @return [Hash] opaque description of the VM's configuration that
|
246
|
-
# can be used with {#create_vm}
|
247
|
-
def calculate_vm_cloud_properties(vm_properties)
|
248
|
-
not_implemented(:calculate_vm_cloud_properties)
|
249
|
-
end
|
250
|
-
|
251
|
-
private
|
252
|
-
|
253
|
-
def not_implemented(method)
|
254
|
-
raise Bosh::Clouds::NotImplemented,
|
255
|
-
"'#{method}' is not implemented by #{self.class}"
|
256
|
-
end
|
257
|
-
|
14
|
+
include Bosh::CloudV1
|
258
15
|
end
|
259
16
|
end
|
data/lib/cloud_v1.rb
ADDED
@@ -0,0 +1,281 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh; module Clouds; end; end
|
4
|
+
|
5
|
+
require "forwardable"
|
6
|
+
|
7
|
+
require "cloud/config"
|
8
|
+
require "cloud/errors"
|
9
|
+
|
10
|
+
module Bosh
|
11
|
+
|
12
|
+
##
|
13
|
+
# CPI - Cloud Provider Interface, used for interfacing with various IaaS APIs.
|
14
|
+
#
|
15
|
+
# Key terms:
|
16
|
+
# Stemcell: template used for creating VMs (shouldn't be powered on)
|
17
|
+
# VM: VM created from a stemcell with custom settings (networking and resources)
|
18
|
+
# Disk: volume that can be attached and detached from the VMs,
|
19
|
+
# never attached to more than a single VM at one time
|
20
|
+
module CloudV1
|
21
|
+
## Information about cpi
|
22
|
+
#
|
23
|
+
# Sample info response:
|
24
|
+
# {
|
25
|
+
# "stemcell_formats" => ["aws-raw", "aws-light"],
|
26
|
+
# "api_version" => <highest supported version>,
|
27
|
+
# }
|
28
|
+
# @return [Hash] information about cpi, currently supported stemcell formats; CPI api_version this cpi supports
|
29
|
+
def info
|
30
|
+
not_implemented(:info)
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Get the vm_id of this host
|
35
|
+
#
|
36
|
+
# @return [String] opaque id later used by other methods of the CPI
|
37
|
+
def current_vm_id
|
38
|
+
not_implemented(:current_vm_id)
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Creates a stemcell
|
43
|
+
#
|
44
|
+
# @param [String] image_path path to an opaque blob containing the stemcell image
|
45
|
+
# @param [Hash] cloud_properties properties required for creating this template
|
46
|
+
# specific to a CPI
|
47
|
+
# @return [String] opaque id later used by {#create_vm} and {#delete_stemcell}
|
48
|
+
def create_stemcell(image_path, cloud_properties)
|
49
|
+
not_implemented(:create_stemcell)
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Deletes a stemcell
|
54
|
+
#
|
55
|
+
# @param [String] stemcell stemcell id that was once returned by {#create_stemcell}
|
56
|
+
# @return [void]
|
57
|
+
def delete_stemcell(stemcell_id)
|
58
|
+
not_implemented(:delete_stemcell)
|
59
|
+
end
|
60
|
+
|
61
|
+
##
|
62
|
+
# Creates a VM - creates (and powers on) a VM from a stemcell with the proper resources
|
63
|
+
# and on the specified network. When disk locality is present the VM will be placed near
|
64
|
+
# the provided disk so it won't have to move when the disk is attached later.
|
65
|
+
#
|
66
|
+
# Sample networking config:
|
67
|
+
# {"network_a" =>
|
68
|
+
# {
|
69
|
+
# "netmask" => "255.255.248.0",
|
70
|
+
# "ip" => "172.30.41.40",
|
71
|
+
# "gateway" => "172.30.40.1",
|
72
|
+
# "dns" => ["172.30.22.153", "172.30.22.154"],
|
73
|
+
# "cloud_properties" => {"name" => "VLAN444"}
|
74
|
+
# }
|
75
|
+
# }
|
76
|
+
#
|
77
|
+
# Sample resource pool config (CPI specific):
|
78
|
+
# {
|
79
|
+
# "ram" => 512,
|
80
|
+
# "disk" => 512,
|
81
|
+
# "cpu" => 1
|
82
|
+
# }
|
83
|
+
# or similar for EC2:
|
84
|
+
# {"name" => "m1.small"}
|
85
|
+
#
|
86
|
+
# @param [String] agent_id UUID for the agent that will be used later on by the director
|
87
|
+
# to locate and talk to the agent
|
88
|
+
# @param [String] stemcell_id stemcell id that was once returned by {#create_stemcell}
|
89
|
+
# @param [Hash] resource_pool cloud specific properties describing the resources needed
|
90
|
+
# for this VM
|
91
|
+
# @param [Hash] networks list of networks and their settings needed for this VM
|
92
|
+
# @param [String, Array] disk_locality disk id(s) if known of the disk(s) that will be
|
93
|
+
# attached to this vm
|
94
|
+
# @param [Hash] env environment that will be passed to this vm
|
95
|
+
# @return [String] opaque id later used by {#attach_disk}, {#detach_disk} and {#delete_vm}
|
96
|
+
def create_vm(agent_id, stemcell_id, resource_pool, networks, disk_locality, env)
|
97
|
+
not_implemented(:create_vm)
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Deletes a VM. If the VM has already been deleted, this call returns normally and has no effect.
|
102
|
+
#
|
103
|
+
# @param [String] vm vm id that was once returned by {#create_vm}
|
104
|
+
# @return [void]
|
105
|
+
def delete_vm(vm_id)
|
106
|
+
not_implemented(:delete_vm)
|
107
|
+
end
|
108
|
+
|
109
|
+
##
|
110
|
+
# Checks if a VM exists
|
111
|
+
#
|
112
|
+
# @param [String] vm vm id that was once returned by {#create_vm}
|
113
|
+
# @return [Boolean] True if the vm exists
|
114
|
+
def has_vm?(vm_id)
|
115
|
+
not_implemented(:has_vm?)
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Checks if a disk exists
|
120
|
+
#
|
121
|
+
# @param [String] disk disk_id that was once returned by {#create_disk}
|
122
|
+
# @return [Boolean] True if the disk exists
|
123
|
+
def has_disk?(disk_id)
|
124
|
+
not_implemented(:has_disk?)
|
125
|
+
end
|
126
|
+
|
127
|
+
##
|
128
|
+
# Reboots a VM
|
129
|
+
#
|
130
|
+
# @param [String] vm vm id that was once returned by {#create_vm}
|
131
|
+
# @param [Optional, Hash] CPI specific options (e.g hard/soft reboot)
|
132
|
+
# @return [void]
|
133
|
+
def reboot_vm(vm_id)
|
134
|
+
not_implemented(:reboot_vm)
|
135
|
+
end
|
136
|
+
|
137
|
+
##
|
138
|
+
# Set metadata for a VM
|
139
|
+
#
|
140
|
+
# Optional. Implement to provide more information for the IaaS.
|
141
|
+
#
|
142
|
+
# @param [String] vm vm id that was once returned by {#create_vm}
|
143
|
+
# @param [Hash] metadata metadata key/value pairs
|
144
|
+
# @return [void]
|
145
|
+
def set_vm_metadata(vm, metadata)
|
146
|
+
not_implemented(:set_vm_metadata)
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# Set metadata for a disk
|
151
|
+
#
|
152
|
+
# Optional. Implement to provide more information for the IaaS.
|
153
|
+
#
|
154
|
+
# @param [String] disk_id disk id that was once returned by {#create_disk}
|
155
|
+
# @param [Hash] metadata metadata key/value pairs
|
156
|
+
# @return [void]
|
157
|
+
def set_disk_metadata(disk_id, metadata)
|
158
|
+
not_implemented(:set_disk_metadata)
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Creates a disk (possibly lazily) that will be attached later to a VM. When
|
163
|
+
# VM locality is specified the disk will be placed near the VM so it won't have to move
|
164
|
+
# when it's attached later.
|
165
|
+
#
|
166
|
+
# @param [Integer] size disk size in MB
|
167
|
+
# @param [Hash] cloud_properties properties required for creating this disk
|
168
|
+
# specific to a CPI
|
169
|
+
# @param [String] vm_locality vm id if known of the VM that this disk will
|
170
|
+
# be attached to
|
171
|
+
# @return [String] opaque id later used by {#attach_disk}, {#detach_disk}, and {#delete_disk}
|
172
|
+
def create_disk(size, cloud_properties, vm_locality)
|
173
|
+
not_implemented(:create_disk)
|
174
|
+
end
|
175
|
+
|
176
|
+
##
|
177
|
+
# Deletes a disk
|
178
|
+
# Will raise an exception if the disk is attached to a VM
|
179
|
+
#
|
180
|
+
# @param [String] disk disk id that was once returned by {#create_disk}
|
181
|
+
# @return [void]
|
182
|
+
def delete_disk(disk_id)
|
183
|
+
not_implemented(:delete_disk)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Attaches a disk
|
187
|
+
# @param [String] vm vm id that was once returned by {#create_vm}
|
188
|
+
# @param [String] disk disk id that was once returned by {#create_disk}
|
189
|
+
# @return [void]
|
190
|
+
def attach_disk(vm_id, disk_id)
|
191
|
+
not_implemented(:attach_disk)
|
192
|
+
end
|
193
|
+
|
194
|
+
# Take snapshot of disk
|
195
|
+
# @param [String] disk_id disk id of the disk to take the snapshot of
|
196
|
+
# @param [Hash] metadata metadata key/value pairs
|
197
|
+
# @return [String] snapshot id
|
198
|
+
def snapshot_disk(disk_id, metadata)
|
199
|
+
not_implemented(:snapshot_disk)
|
200
|
+
end
|
201
|
+
|
202
|
+
# Delete a disk snapshot
|
203
|
+
# @param [String] snapshot_id snapshot id to delete
|
204
|
+
# @return [void]
|
205
|
+
def delete_snapshot(snapshot_id)
|
206
|
+
not_implemented(:delete_snapshot)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Detaches a disk
|
210
|
+
# @param [String] vm vm id that was once returned by {#create_vm}
|
211
|
+
# @param [String] disk disk id that was once returned by {#create_disk}
|
212
|
+
# @return [void]
|
213
|
+
def detach_disk(vm_id, disk_id)
|
214
|
+
not_implemented(:detach_disk)
|
215
|
+
end
|
216
|
+
|
217
|
+
# List the attached disks of the VM.
|
218
|
+
# @param [String] vm_id is the CPI-standard vm_id (eg, returned from current_vm_id)
|
219
|
+
# @return [array[String]] list of opaque disk_ids that can be used with the
|
220
|
+
# other disk-related methods on the CPI
|
221
|
+
def get_disks(vm_id)
|
222
|
+
not_implemented(:get_disks)
|
223
|
+
end
|
224
|
+
|
225
|
+
##
|
226
|
+
# Resizes an existing disk
|
227
|
+
#
|
228
|
+
# @param [String] disk_id disk id
|
229
|
+
# @param [Integer] new_size disk size in MiB
|
230
|
+
# @return [void]
|
231
|
+
def resize_disk(disk_id, new_size)
|
232
|
+
not_implemented(:resize_disk)
|
233
|
+
end
|
234
|
+
|
235
|
+
##
|
236
|
+
# Updates an existing disk via the IaaS API
|
237
|
+
#
|
238
|
+
# @param [String] disk_id disk id
|
239
|
+
# @param [Integer] new_size disk size in MiB
|
240
|
+
# @param [Hash] cloud_properties properties required for updating this disk
|
241
|
+
# specific to a CPI
|
242
|
+
# @return [void]
|
243
|
+
def update_disk(disk_id, new_size, cloud_properties)
|
244
|
+
not_implemented(:update_disk)
|
245
|
+
end
|
246
|
+
|
247
|
+
# Specify VM's hardware resources
|
248
|
+
# @param [Hash] vm_properties (typically cpu, ram, ephemeral_disk_size)
|
249
|
+
# @return [Hash] opaque description of the VM's configuration that
|
250
|
+
# can be used with {#create_vm}
|
251
|
+
def calculate_vm_cloud_properties(vm_properties)
|
252
|
+
not_implemented(:calculate_vm_cloud_properties)
|
253
|
+
end
|
254
|
+
|
255
|
+
##
|
256
|
+
# Creates a network that will be used to place VMs on.
|
257
|
+
#
|
258
|
+
# @param [Hash] network_definition properties required for creating network.
|
259
|
+
# may contain range and gateway keys. Has to have cloud_properties - properties required for creating
|
260
|
+
# this network specific to a CPI
|
261
|
+
# @return [Hash] network_cid key has unique id of network, cloud_properties are properties required for placing VMs
|
262
|
+
def create_network(network_definition)
|
263
|
+
not_implemented(:create_network)
|
264
|
+
end
|
265
|
+
|
266
|
+
##
|
267
|
+
# Deletes network by given network_id
|
268
|
+
# @param [String] network_id of network to delete
|
269
|
+
# @return [void]
|
270
|
+
def delete_network(network_id)
|
271
|
+
not_implemented(:delete_network)
|
272
|
+
end
|
273
|
+
|
274
|
+
private
|
275
|
+
|
276
|
+
def not_implemented(method)
|
277
|
+
raise Bosh::Clouds::NotImplemented,
|
278
|
+
"'#{method}' is not implemented by #{self.class}"
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
data/lib/cloud_v2.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# Copyright (c) 2009-2018 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh; module Clouds; end; end
|
4
|
+
|
5
|
+
require "forwardable"
|
6
|
+
|
7
|
+
require "cloud/config"
|
8
|
+
require "cloud/errors"
|
9
|
+
require "cloud_v1"
|
10
|
+
|
11
|
+
module Bosh
|
12
|
+
|
13
|
+
##
|
14
|
+
# CPI - Cloud Provider Interface, used for interfacing with various IaaS APIs.
|
15
|
+
#
|
16
|
+
# Key terms:
|
17
|
+
# Stemcell: template used for creating VMs (shouldn't be powered on)
|
18
|
+
# VM: VM created from a stemcell with custom settings (networking and resources)
|
19
|
+
# Disk: volume that can be attached and detached from the VMs,
|
20
|
+
# never attached to more than a single VM at one time
|
21
|
+
module CloudV2
|
22
|
+
include Bosh::CloudV1
|
23
|
+
##
|
24
|
+
# Creates a VM - creates (and powers on) a VM from a stemcell with the proper resources
|
25
|
+
# and on the specified network. When disk locality is present the VM will be placed near
|
26
|
+
# the provided disk so it won't have to move when the disk is attached later.
|
27
|
+
#
|
28
|
+
# Sample networking config:
|
29
|
+
# {"network_a" =>
|
30
|
+
# {
|
31
|
+
# "netmask" => "255.255.248.0",
|
32
|
+
# "ip" => "172.30.41.40",
|
33
|
+
# "gateway" => "172.30.40.1",
|
34
|
+
# "dns" => ["172.30.22.153", "172.30.22.154"],
|
35
|
+
# "cloud_properties" => {"name" => "VLAN444"}
|
36
|
+
# }
|
37
|
+
# }
|
38
|
+
#
|
39
|
+
# Sample resource pool config (CPI specific):
|
40
|
+
# {
|
41
|
+
# "ram" => 512,
|
42
|
+
# "disk" => 512,
|
43
|
+
# "cpu" => 1
|
44
|
+
# }
|
45
|
+
# or similar for EC2:
|
46
|
+
# {"name" => "m1.small"}
|
47
|
+
#
|
48
|
+
# Sample return value:
|
49
|
+
# [
|
50
|
+
# "vm-cid-123",
|
51
|
+
# { # ... networks ...
|
52
|
+
# "private": {
|
53
|
+
# "type": "manual",
|
54
|
+
# "netmask": "255.255.255.0",
|
55
|
+
# "gateway": "10.230.13.1",
|
56
|
+
# "ip": "10.230.13.6",
|
57
|
+
# "default": [ "dns", "gateway" ],
|
58
|
+
# "cloud_properties": {
|
59
|
+
# "net_id": "d29fdb0d-44d8-4e04-818d-5b03888f8eaa"
|
60
|
+
# }
|
61
|
+
# },
|
62
|
+
# "public": {
|
63
|
+
# "type": "vip",
|
64
|
+
# "ip": "173.101.112.104",
|
65
|
+
# "cloud_properties": {}
|
66
|
+
# }
|
67
|
+
# }
|
68
|
+
# ]
|
69
|
+
#
|
70
|
+
# @param [String] agent_id UUID for the agent that will be used later on by the director
|
71
|
+
# to locate and talk to the agent
|
72
|
+
# @param [String] stemcell_id stemcell id that was once returned by {#create_stemcell}
|
73
|
+
# @param [Hash] resource_pool cloud specific properties describing the resources needed
|
74
|
+
# for this VM
|
75
|
+
# @param [Hash] networks list of networks and their settings needed for this VM
|
76
|
+
# @param [String, Array] disk_locality disk id(s) if known of the disk(s) that will be
|
77
|
+
# attached to this vm
|
78
|
+
# @param [Hash] env environment that will be passed to this vm
|
79
|
+
# @return [Array] [VM_ID, {...networks...}]
|
80
|
+
def create_vm(agent_id, stemcell_id, resource_pool, networks, disk_locality, env)
|
81
|
+
not_implemented(:create_vm)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Attaches a disk
|
85
|
+
# @param [String] vm vm id that was once returned by {#create_vm}
|
86
|
+
# @param [String] disk disk id that was once returned by {#create_disk}
|
87
|
+
# @return [Object] hint for location of attached disk - varies by IaaS
|
88
|
+
#
|
89
|
+
# Sample return value for attach_disk
|
90
|
+
# "/dev/sdd"
|
91
|
+
#
|
92
|
+
def attach_disk(vm_id, disk_id)
|
93
|
+
not_implemented(:attach_disk)
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def not_implemented(method)
|
99
|
+
raise Bosh::Clouds::NotImplemented, "'#{method}' is not implemented by #{self.class}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_cpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VMware
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: membrane
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.8.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: BOSH CPI
|
42
56
|
email: support@cloudfoundry.com
|
43
57
|
executables: []
|
@@ -57,6 +71,8 @@ files:
|
|
57
71
|
- lib/cloud/config.rb
|
58
72
|
- lib/cloud/errors.rb
|
59
73
|
- lib/cloud/version.rb
|
74
|
+
- lib/cloud_v1.rb
|
75
|
+
- lib/cloud_v2.rb
|
60
76
|
homepage: https://github.com/cloudfoundry/bosh
|
61
77
|
licenses:
|
62
78
|
- Apache 2.0
|
@@ -76,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
92
|
- !ruby/object:Gem::Version
|
77
93
|
version: '0'
|
78
94
|
requirements: []
|
79
|
-
|
80
|
-
rubygems_version: 2.6.12
|
95
|
+
rubygems_version: 3.5.18
|
81
96
|
signing_key:
|
82
97
|
specification_version: 4
|
83
98
|
summary: BOSH CPI
|