bosh_cpi 2.4.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/bosh/cpi/cli.rb +8 -1
- data/lib/cloud.rb +3 -246
- data/lib/cloud/errors.rb +1 -0
- data/lib/cloud_v1.rb +270 -0
- data/lib/cloud_v2.rb +102 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4dac2f17efac6e742ca6ee8403f088184fc887166269adbad9e10212797cbcd7
|
4
|
+
data.tar.gz: 6f82d9a5aa37ee49140e0572729c23df6af684597b747b8d94556a346ae3fd50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dcb6fdf43d4ae9abd8e356400127b9956e4cce37ef4c75c615fda32c27cca330a68f56d2ab452e45da7ba70d56032cf2af56ad9262188ea3d9fd9f98c1c67d7
|
7
|
+
data.tar.gz: 7dd0378a47313cb03fc107fa3502abbe6ce610b6ab326d870e0a99251b31d3a5687a3e9f08a9ba4be81b1ba0b18e36ac106c1eaf85bfdf99d581abd23ce04c2d
|
data/lib/bosh/cpi/cli.rb
CHANGED
@@ -23,6 +23,8 @@ class Bosh::Cpi::Cli
|
|
23
23
|
resize_disk
|
24
24
|
ping
|
25
25
|
calculate_vm_cloud_properties
|
26
|
+
create_network
|
27
|
+
delete_network
|
26
28
|
).freeze
|
27
29
|
|
28
30
|
RPC_METHOD_TO_RUBY_METHOD = {
|
@@ -61,6 +63,11 @@ class Bosh::Cpi::Cli
|
|
61
63
|
return error_response(INVALID_CALL_ERROR_TYPE, "Arguments must be an Array", false)
|
62
64
|
end
|
63
65
|
|
66
|
+
cpi_api_version = request['api_version']
|
67
|
+
if request.has_key?('api_version') && !cpi_api_version.is_a?(Integer)
|
68
|
+
return error_response(INVALID_CALL_ERROR_TYPE, "CPI api_version requested must be an Integer", false)
|
69
|
+
end
|
70
|
+
|
64
71
|
context = request['context']
|
65
72
|
unless context.is_a?(Hash) && context['director_uuid'].is_a?(String)
|
66
73
|
return error_response(INVALID_CALL_ERROR_TYPE, "Request should include context with director uuid", false)
|
@@ -77,7 +84,7 @@ class Bosh::Cpi::Cli
|
|
77
84
|
start_time = Time.now.utc
|
78
85
|
@logger.info("Starting #{method}...")
|
79
86
|
|
80
|
-
cpi = @cpi.call(context)
|
87
|
+
cpi = @cpi.call(context, cpi_api_version)
|
81
88
|
|
82
89
|
result = cpi.public_send(ruby_method, *arguments)
|
83
90
|
rescue Bosh::Clouds::RetriableCloudError => e
|
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/errors.rb
CHANGED
data/lib/cloud_v1.rb
ADDED
@@ -0,0 +1,270 @@
|
|
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
|
+
# Specify VM's hardware resources
|
236
|
+
# @param [Hash] vm_properties (typically cpu, ram, ephemeral_disk_size)
|
237
|
+
# @return [Hash] opaque description of the VM's configuration that
|
238
|
+
# can be used with {#create_vm}
|
239
|
+
def calculate_vm_cloud_properties(vm_properties)
|
240
|
+
not_implemented(:calculate_vm_cloud_properties)
|
241
|
+
end
|
242
|
+
|
243
|
+
##
|
244
|
+
# Creates a network that will be used to place VMs on.
|
245
|
+
#
|
246
|
+
# @param [Hash] network_definition properties required for creating network.
|
247
|
+
# may contain range and gateway keys. Has to have cloud_properties - properties required for creating
|
248
|
+
# this network specific to a CPI
|
249
|
+
# @return [Hash] network_cid key has unique id of network, cloud_properties are properties required for placing VMs
|
250
|
+
def create_network(network_definition)
|
251
|
+
not_implemented(:create_network)
|
252
|
+
end
|
253
|
+
|
254
|
+
##
|
255
|
+
# Deletes network by given network_id
|
256
|
+
# @param [String] network_id of network to delete
|
257
|
+
# @return [void]
|
258
|
+
def delete_network(network_id)
|
259
|
+
not_implemented(:delete_network)
|
260
|
+
end
|
261
|
+
|
262
|
+
private
|
263
|
+
|
264
|
+
def not_implemented(method)
|
265
|
+
raise Bosh::Clouds::NotImplemented,
|
266
|
+
"'#{method}' is not implemented by #{self.class}"
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
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.5.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: 2018-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: membrane
|
@@ -57,6 +57,8 @@ files:
|
|
57
57
|
- lib/cloud/config.rb
|
58
58
|
- lib/cloud/errors.rb
|
59
59
|
- lib/cloud/version.rb
|
60
|
+
- lib/cloud_v1.rb
|
61
|
+
- lib/cloud_v2.rb
|
60
62
|
homepage: https://github.com/cloudfoundry/bosh
|
61
63
|
licenses:
|
62
64
|
- Apache 2.0
|
@@ -77,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
79
|
version: '0'
|
78
80
|
requirements: []
|
79
81
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.7.7
|
81
83
|
signing_key:
|
82
84
|
specification_version: 4
|
83
85
|
summary: BOSH CPI
|