bosh_cpi 0.5.1 → 1.2640.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 +7 -0
- data/lib/bosh/cpi/cli.rb +113 -0
- data/lib/bosh/cpi/compatibility_helpers/delete_vm.rb +15 -0
- data/lib/bosh/cpi/compatibility_helpers.rb +5 -0
- data/lib/bosh/cpi/tasks/spec.rake +10 -0
- data/lib/bosh/cpi/tasks.rb +1 -0
- data/lib/bosh/cpi.rb +5 -0
- data/lib/cloud/config.rb +3 -1
- data/lib/cloud/errors.rb +1 -2
- data/lib/cloud/external_cpi.rb +152 -0
- data/lib/cloud/provider.rb +19 -2
- data/lib/cloud/version.rb +1 -1
- data/lib/cloud.rb +47 -17
- metadata +28 -37
- data/Rakefile +0 -50
- data/spec/lib/cloud/spec.rb +0 -9
- data/spec/spec_helper.rb +0 -30
- data/spec/unit/config_spec.rb +0 -19
- data/spec/unit/provider_spec.rb +0 -19
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: f6e0ba743536c85e046f03c6dac64272848e7e61
|
|
4
|
+
data.tar.gz: 2c1d2224807aba9c21d687f5fbe05cdb7d9a046c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ba3eea9560b217dce22a637109e9c7b3fd609484deb2bd409bb50d1f81f24bf152e33c5d2956932cf327343f0401c4cfb653c1d78cad6868ee58ca4bb2fafce2
|
|
7
|
+
data.tar.gz: 00205870912e42bed5dd9e3a73cad88a4d0739c1316aa6519205955ae46729a2fe575db82cb1b725e58b93ceee6ed8078563af65b699f0c5b010489a85ecab40
|
data/lib/bosh/cpi/cli.rb
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
class Bosh::Cpi::Cli
|
|
4
|
+
KNOWN_RPC_METHODS = %w(
|
|
5
|
+
current_vm_id
|
|
6
|
+
create_stemcell
|
|
7
|
+
delete_stemcell
|
|
8
|
+
create_vm
|
|
9
|
+
delete_vm
|
|
10
|
+
has_vm
|
|
11
|
+
reboot_vm
|
|
12
|
+
set_vm_metadata
|
|
13
|
+
configure_networks
|
|
14
|
+
create_disk
|
|
15
|
+
delete_disk
|
|
16
|
+
attach_disk
|
|
17
|
+
detach_disk
|
|
18
|
+
snapshot_disk
|
|
19
|
+
delete_snapshot
|
|
20
|
+
get_disks
|
|
21
|
+
ping
|
|
22
|
+
).freeze
|
|
23
|
+
|
|
24
|
+
RPC_METHOD_TO_RUBY_METHOD = {
|
|
25
|
+
'has_vm' => 'has_vm?',
|
|
26
|
+
}.freeze
|
|
27
|
+
|
|
28
|
+
INVALID_CALL_ERROR_TYPE = 'InvalidCall'.freeze
|
|
29
|
+
UNKNOWN_ERROR_TYPE = 'Unknown'.freeze
|
|
30
|
+
|
|
31
|
+
def initialize(cpi, logs_string_io, result_io)
|
|
32
|
+
@cpi = cpi
|
|
33
|
+
@logs_string_io = logs_string_io
|
|
34
|
+
@result_io = result_io
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def run(json)
|
|
38
|
+
begin
|
|
39
|
+
request = JSON.load(json)
|
|
40
|
+
rescue JSON::ParserError
|
|
41
|
+
return error_response(INVALID_CALL_ERROR_TYPE, 'Request cannot be deserialized', false)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
method = request['method']
|
|
45
|
+
unless method.is_a?(String)
|
|
46
|
+
return error_response(INVALID_CALL_ERROR_TYPE, 'Method must be a String', false)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
unless KNOWN_RPC_METHODS.include?(method)
|
|
50
|
+
return error_response(INVALID_CALL_ERROR_TYPE, 'Method is not known', false)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
arguments = request['arguments']
|
|
54
|
+
unless arguments.is_a?(Array)
|
|
55
|
+
return error_response(INVALID_CALL_ERROR_TYPE, 'Arguments must be an Array', false)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context = request['context']
|
|
59
|
+
unless context.is_a?(Hash) && context['director_uuid'].is_a?(String)
|
|
60
|
+
return error_response(INVALID_CALL_ERROR_TYPE, 'Request should include context with director uuid', false)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
configure_director(context['director_uuid'])
|
|
64
|
+
|
|
65
|
+
ruby_method = RPC_METHOD_TO_RUBY_METHOD[method] || method
|
|
66
|
+
|
|
67
|
+
begin
|
|
68
|
+
result = @cpi.public_send(ruby_method, *arguments)
|
|
69
|
+
rescue Bosh::Clouds::RetriableCloudError => e
|
|
70
|
+
return error_response(error_name(e), e.message, e.ok_to_retry)
|
|
71
|
+
rescue Bosh::Clouds::CloudError, Bosh::Clouds::CpiError => e
|
|
72
|
+
return error_response(error_name(e), e.message, false)
|
|
73
|
+
rescue ArgumentError
|
|
74
|
+
return error_response(INVALID_CALL_ERROR_TYPE, 'Arguments are not correct', false)
|
|
75
|
+
rescue Exception => e
|
|
76
|
+
return error_response(UNKNOWN_ERROR_TYPE, e.message, false)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
result_response(result)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
private
|
|
83
|
+
|
|
84
|
+
def configure_director(director_uuid)
|
|
85
|
+
Bosh::Clouds::Config.uuid = director_uuid
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def error_response(type, message, ok_to_retry)
|
|
89
|
+
hash = {
|
|
90
|
+
result: nil,
|
|
91
|
+
error: {
|
|
92
|
+
type: type,
|
|
93
|
+
message: message,
|
|
94
|
+
ok_to_retry: ok_to_retry,
|
|
95
|
+
},
|
|
96
|
+
log: @logs_string_io.string,
|
|
97
|
+
}
|
|
98
|
+
@result_io.print(JSON.dump(hash)); nil
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def result_response(result)
|
|
102
|
+
hash = {
|
|
103
|
+
result: result,
|
|
104
|
+
error: nil,
|
|
105
|
+
log: @logs_string_io.string,
|
|
106
|
+
}
|
|
107
|
+
@result_io.print(JSON.dump(hash)); nil
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def error_name(error)
|
|
111
|
+
error.class.name
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'bosh/cpi/compatibility_helpers'
|
|
2
|
+
|
|
3
|
+
module Bosh::Cpi::CompatibilityHelpers
|
|
4
|
+
def it_can_delete_non_existent_vm(vm_cid='vm-cid')
|
|
5
|
+
describe "delete_vm (deleting non existent vm)" do
|
|
6
|
+
context "when VM is not present" do
|
|
7
|
+
it "raises VMNotFound error" do
|
|
8
|
+
expect {
|
|
9
|
+
cpi.delete_vm(vm_cid)
|
|
10
|
+
}.to raise_error(Bosh::Clouds::VMNotFound, "VM `#{vm_cid}' not found")
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir.glob(File.expand_path('tasks/**/*.rake', File.dirname(__FILE__))).each { |r| import r }
|
data/lib/bosh/cpi.rb
ADDED
data/lib/cloud/config.rb
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
require 'forwardable'
|
|
2
|
+
|
|
1
3
|
module Bosh::Clouds
|
|
2
4
|
class Config
|
|
3
5
|
|
|
4
6
|
class << self
|
|
5
7
|
extend Forwardable
|
|
6
|
-
def_delegators :@delegate, :db, :logger, :uuid, :task_checkpoint
|
|
8
|
+
def_delegators :@delegate, :db, :logger, :uuid, :uuid=, :task_checkpoint, :cpi_task_log
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
# @param [Bosh::Director::Config] config director config file
|
data/lib/cloud/errors.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
module Bosh::Clouds
|
|
2
|
-
|
|
3
2
|
class CpiError < StandardError; end
|
|
4
3
|
class NotImplemented < CpiError; end
|
|
5
4
|
class NotSupported < CpiError; end
|
|
@@ -18,5 +17,5 @@ module Bosh::Clouds
|
|
|
18
17
|
class NoDiskSpace < RetriableCloudError; end
|
|
19
18
|
class DiskNotAttached < RetriableCloudError; end
|
|
20
19
|
class DiskNotFound < RetriableCloudError; end
|
|
21
|
-
|
|
20
|
+
class VMCreationFailed < RetriableCloudError; end
|
|
22
21
|
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
require 'membrane'
|
|
2
|
+
require 'open3'
|
|
3
|
+
|
|
4
|
+
module Bosh::Clouds
|
|
5
|
+
class ExternalCpi
|
|
6
|
+
# Raised when the external CPI executable returns an error unknown to director
|
|
7
|
+
class UnknownError < StandardError; end
|
|
8
|
+
|
|
9
|
+
# Raised when the external CPI executable returns nil or invalid JSON format to director
|
|
10
|
+
class InvalidResponse < StandardError; end
|
|
11
|
+
|
|
12
|
+
# Raised when the external CPI bin/cpi is not executable
|
|
13
|
+
class NonExecutable < StandardError; end
|
|
14
|
+
|
|
15
|
+
KNOWN_RPC_ERRORS = %w(
|
|
16
|
+
Bosh::Clouds::CpiError
|
|
17
|
+
Bosh::Clouds::NotSupported
|
|
18
|
+
Bosh::Clouds::NotImplemented
|
|
19
|
+
|
|
20
|
+
Bosh::Clouds::CloudError
|
|
21
|
+
Bosh::Clouds::VMNotFound
|
|
22
|
+
|
|
23
|
+
Bosh::Clouds::NoDiskSpace
|
|
24
|
+
Bosh::Clouds::DiskNotAttached
|
|
25
|
+
Bosh::Clouds::DiskNotFound
|
|
26
|
+
Bosh::Clouds::VMCreationFailed
|
|
27
|
+
).freeze
|
|
28
|
+
|
|
29
|
+
KNOWN_RPC_METHODS = %w(
|
|
30
|
+
current_vm_id
|
|
31
|
+
create_stemcell
|
|
32
|
+
delete_stemcell
|
|
33
|
+
create_vm
|
|
34
|
+
delete_vm
|
|
35
|
+
has_vm?
|
|
36
|
+
reboot_vm
|
|
37
|
+
set_vm_metadata
|
|
38
|
+
configure_networks
|
|
39
|
+
create_disk
|
|
40
|
+
delete_disk
|
|
41
|
+
attach_disk
|
|
42
|
+
detach_disk
|
|
43
|
+
snapshot_disk
|
|
44
|
+
delete_snapshot
|
|
45
|
+
get_disks
|
|
46
|
+
ping
|
|
47
|
+
).freeze
|
|
48
|
+
|
|
49
|
+
RESPONSE_SCHEMA = Membrane::SchemaParser.parse do
|
|
50
|
+
{
|
|
51
|
+
'result' => any,
|
|
52
|
+
'error' => enum(nil,
|
|
53
|
+
{ 'type' => String,
|
|
54
|
+
'message' => String,
|
|
55
|
+
'ok_to_retry' => bool
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
'log' => String
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def initialize(cpi_path, director_uuid)
|
|
63
|
+
@cpi_path = cpi_path
|
|
64
|
+
@director_uuid = director_uuid
|
|
65
|
+
@logger = Config.logger
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
KNOWN_RPC_METHODS.each do |method_name|
|
|
69
|
+
define_method method_name do |*arguments|
|
|
70
|
+
request = JSON.dump({
|
|
71
|
+
'method' => method_name.gsub(/\?$/,''),
|
|
72
|
+
'arguments' => arguments,
|
|
73
|
+
'context' => {
|
|
74
|
+
'director_uuid' => @director_uuid
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
env = {'PATH' => '/usr/sbin:/usr/bin:/sbin:/bin', 'TMPDIR' => ENV['TMPDIR']}
|
|
79
|
+
cpi_exec_path = checked_cpi_exec_path
|
|
80
|
+
|
|
81
|
+
@logger.debug("External CPI sending request: #{request} with command: #{cpi_exec_path}")
|
|
82
|
+
cpi_response, stderr, exit_status = Open3.capture3(env, cpi_exec_path, stdin_data: request)
|
|
83
|
+
@logger.debug("External CPI got response: #{cpi_response}, err: #{stderr}, exit_status: #{exit_status}")
|
|
84
|
+
|
|
85
|
+
parsed_response = parsed_response(cpi_response)
|
|
86
|
+
validate_response(parsed_response)
|
|
87
|
+
|
|
88
|
+
if parsed_response['error']
|
|
89
|
+
handle_error(parsed_response['error'])
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
save_cpi_log(parsed_response['log'])
|
|
93
|
+
|
|
94
|
+
parsed_response['result']
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
def checked_cpi_exec_path
|
|
101
|
+
unless File.executable?(@cpi_path)
|
|
102
|
+
raise NonExecutable, "Failed to run cpi: `#{@cpi_path}' is not executable"
|
|
103
|
+
end
|
|
104
|
+
@cpi_path
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def handle_error(error_response)
|
|
108
|
+
error_type = error_response['type']
|
|
109
|
+
error_message = error_response['message']
|
|
110
|
+
unless KNOWN_RPC_ERRORS.include?(error_type)
|
|
111
|
+
raise UnknownError, "Received unknown error from cpi: #{error_type} with message #{error_message}"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
error_class = constantize(error_type)
|
|
115
|
+
|
|
116
|
+
if error_class <= RetriableCloudError
|
|
117
|
+
error = error_class.new(error_response['ok_to_retry'])
|
|
118
|
+
else
|
|
119
|
+
error = error_class.new(error_message)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
raise error, error_message
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def save_cpi_log(output)
|
|
126
|
+
# cpi log path is set up at the beginning of every task in Config
|
|
127
|
+
# see JobRunner#setup_task_logging
|
|
128
|
+
File.open(Config.cpi_task_log, 'a') do |f|
|
|
129
|
+
f.write(output)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def parsed_response(input)
|
|
134
|
+
begin
|
|
135
|
+
JSON.load(input)
|
|
136
|
+
rescue JSON::ParserError => e
|
|
137
|
+
raise InvalidResponse, "Received invalid response from cpi with error #{e.message}"
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def validate_response(response)
|
|
142
|
+
RESPONSE_SCHEMA.validate(response)
|
|
143
|
+
rescue Membrane::SchemaValidationError => e
|
|
144
|
+
raise InvalidResponse, "Received invalid response from cpi with error #{e.message}"
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def constantize(camel_cased_word)
|
|
148
|
+
error_name = camel_cased_word.split('::').last
|
|
149
|
+
Bosh::Clouds.const_get(error_name)
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
data/lib/cloud/provider.rb
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
module Bosh::Clouds
|
|
2
2
|
class Provider
|
|
3
|
+
def self.create(cloud_config, director_uuid)
|
|
4
|
+
if cloud_config.fetch('external_cpi', {}).fetch('enabled', false)
|
|
5
|
+
ExternalCpiProvider.create(cloud_config['external_cpi'], director_uuid)
|
|
6
|
+
else
|
|
7
|
+
PluginCloudProvider.create(cloud_config['plugin'], cloud_config['properties'])
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
3
13
|
|
|
14
|
+
class PluginCloudProvider
|
|
4
15
|
def self.create(plugin, options)
|
|
5
16
|
begin
|
|
6
17
|
require "cloud/#{plugin}"
|
|
7
|
-
rescue LoadError
|
|
8
|
-
raise CloudError, "Could not
|
|
18
|
+
rescue LoadError => error
|
|
19
|
+
raise CloudError, "Could not load Cloud Provider Plugin: #{plugin}, with error #{error.inspect}"
|
|
9
20
|
end
|
|
21
|
+
|
|
10
22
|
Bosh::Clouds.const_get(plugin.capitalize).new(options)
|
|
11
23
|
end
|
|
24
|
+
end
|
|
12
25
|
|
|
26
|
+
class ExternalCpiProvider
|
|
27
|
+
def self.create(external_cpi_config, director_uuid)
|
|
28
|
+
ExternalCpi.new(external_cpi_config['cpi_path'], director_uuid)
|
|
29
|
+
end
|
|
13
30
|
end
|
|
14
31
|
end
|
data/lib/cloud/version.rb
CHANGED
data/lib/cloud.rb
CHANGED
|
@@ -7,6 +7,7 @@ require "forwardable"
|
|
|
7
7
|
require "cloud/config"
|
|
8
8
|
require "cloud/errors"
|
|
9
9
|
require "cloud/provider"
|
|
10
|
+
require "cloud/external_cpi"
|
|
10
11
|
|
|
11
12
|
module Bosh
|
|
12
13
|
|
|
@@ -27,6 +28,14 @@ module Bosh
|
|
|
27
28
|
def initialize(options)
|
|
28
29
|
end
|
|
29
30
|
|
|
31
|
+
##
|
|
32
|
+
# Get the vm_id of this host
|
|
33
|
+
#
|
|
34
|
+
# @return [String] opaque id later used by other methods of the CPI
|
|
35
|
+
def current_vm_id
|
|
36
|
+
not_implemented(:current_vm_id)
|
|
37
|
+
end
|
|
38
|
+
|
|
30
39
|
##
|
|
31
40
|
# Creates a stemcell
|
|
32
41
|
#
|
|
@@ -42,7 +51,7 @@ module Bosh
|
|
|
42
51
|
# Deletes a stemcell
|
|
43
52
|
#
|
|
44
53
|
# @param [String] stemcell stemcell id that was once returned by {#create_stemcell}
|
|
45
|
-
# @return
|
|
54
|
+
# @return [void]
|
|
46
55
|
def delete_stemcell(stemcell_id)
|
|
47
56
|
not_implemented(:delete_stemcell)
|
|
48
57
|
end
|
|
@@ -92,17 +101,26 @@ module Bosh
|
|
|
92
101
|
# Deletes a VM
|
|
93
102
|
#
|
|
94
103
|
# @param [String] vm vm id that was once returned by {#create_vm}
|
|
95
|
-
# @return
|
|
104
|
+
# @return [void]
|
|
96
105
|
def delete_vm(vm_id)
|
|
97
106
|
not_implemented(:delete_vm)
|
|
98
107
|
end
|
|
99
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
|
+
|
|
100
118
|
##
|
|
101
119
|
# Reboots a VM
|
|
102
120
|
#
|
|
103
121
|
# @param [String] vm vm id that was once returned by {#create_vm}
|
|
104
122
|
# @param [Optional, Hash] CPI specific options (e.g hard/soft reboot)
|
|
105
|
-
# @return
|
|
123
|
+
# @return [void]
|
|
106
124
|
def reboot_vm(vm_id)
|
|
107
125
|
not_implemented(:reboot_vm)
|
|
108
126
|
end
|
|
@@ -114,7 +132,7 @@ module Bosh
|
|
|
114
132
|
#
|
|
115
133
|
# @param [String] vm vm id that was once returned by {#create_vm}
|
|
116
134
|
# @param [Hash] metadata metadata key/value pairs
|
|
117
|
-
# @return
|
|
135
|
+
# @return [void]
|
|
118
136
|
def set_vm_metadata(vm, metadata)
|
|
119
137
|
not_implemented(:set_vm_metadata)
|
|
120
138
|
end
|
|
@@ -125,7 +143,7 @@ module Bosh
|
|
|
125
143
|
# @param [String] vm vm id that was once returned by {#create_vm}
|
|
126
144
|
# @param [Hash] networks list of networks and their settings needed for this VM,
|
|
127
145
|
# same as the networks argument in {#create_vm}
|
|
128
|
-
# @return
|
|
146
|
+
# @return [void]
|
|
129
147
|
def configure_networks(vm_id, networks)
|
|
130
148
|
not_implemented(:configure_networks)
|
|
131
149
|
end
|
|
@@ -148,36 +166,48 @@ module Bosh
|
|
|
148
166
|
# Will raise an exception if the disk is attached to a VM
|
|
149
167
|
#
|
|
150
168
|
# @param [String] disk disk id that was once returned by {#create_disk}
|
|
151
|
-
# @return
|
|
169
|
+
# @return [void]
|
|
152
170
|
def delete_disk(disk_id)
|
|
153
171
|
not_implemented(:delete_disk)
|
|
154
172
|
end
|
|
155
173
|
|
|
156
|
-
##
|
|
157
174
|
# Attaches a disk
|
|
158
|
-
#
|
|
159
175
|
# @param [String] vm vm id that was once returned by {#create_vm}
|
|
160
176
|
# @param [String] disk disk id that was once returned by {#create_disk}
|
|
161
|
-
# @return
|
|
177
|
+
# @return [void]
|
|
162
178
|
def attach_disk(vm_id, disk_id)
|
|
163
179
|
not_implemented(:attach_disk)
|
|
164
180
|
end
|
|
165
181
|
|
|
166
|
-
|
|
182
|
+
# Take snapshot of disk
|
|
183
|
+
# @param [String] disk_id disk id of the disk to take the snapshot of
|
|
184
|
+
# @param [Hash] metadata metadata key/value pairs
|
|
185
|
+
# @return [String] snapshot id
|
|
186
|
+
def snapshot_disk(disk_id, metadata={})
|
|
187
|
+
not_implemented(:snapshot_disk)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Delete a disk snapshot
|
|
191
|
+
# @param [String] snapshot_id snapshot id to delete
|
|
192
|
+
# @return [void]
|
|
193
|
+
def delete_snapshot(snapshot_id)
|
|
194
|
+
not_implemented(:delete_snapshot)
|
|
195
|
+
end
|
|
196
|
+
|
|
167
197
|
# Detaches a disk
|
|
168
|
-
#
|
|
169
198
|
# @param [String] vm vm id that was once returned by {#create_vm}
|
|
170
199
|
# @param [String] disk disk id that was once returned by {#create_disk}
|
|
171
|
-
# @return
|
|
200
|
+
# @return [void]
|
|
172
201
|
def detach_disk(vm_id, disk_id)
|
|
173
202
|
not_implemented(:detach_disk)
|
|
174
203
|
end
|
|
175
204
|
|
|
176
|
-
|
|
177
|
-
#
|
|
178
|
-
# @
|
|
179
|
-
|
|
180
|
-
|
|
205
|
+
# List the attached disks of the VM.
|
|
206
|
+
# @param [String] vm_id is the CPI-standard vm_id (eg, returned from current_vm_id)
|
|
207
|
+
# @return [array[String]] list of opaque disk_ids that can be used with the
|
|
208
|
+
# other disk-related methods on the CPI
|
|
209
|
+
def get_disks(vm_id)
|
|
210
|
+
not_implemented(:get_disks)
|
|
181
211
|
end
|
|
182
212
|
|
|
183
213
|
private
|
metadata
CHANGED
|
@@ -1,81 +1,72 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bosh_cpi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 1.2640.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- VMware
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: bosh_common
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
|
-
version:
|
|
19
|
+
version: 1.2640.0
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- - ~>
|
|
24
|
+
- - "~>"
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
30
|
-
description:
|
|
31
|
-
|
|
26
|
+
version: 1.2640.0
|
|
27
|
+
description: |-
|
|
28
|
+
BOSH CPI
|
|
29
|
+
986896
|
|
30
|
+
email: support@cloudfoundry.com
|
|
32
31
|
executables: []
|
|
33
32
|
extensions: []
|
|
34
33
|
extra_rdoc_files: []
|
|
35
34
|
files:
|
|
35
|
+
- README
|
|
36
|
+
- lib/bosh/cpi.rb
|
|
37
|
+
- lib/bosh/cpi/cli.rb
|
|
38
|
+
- lib/bosh/cpi/compatibility_helpers.rb
|
|
39
|
+
- lib/bosh/cpi/compatibility_helpers/delete_vm.rb
|
|
40
|
+
- lib/bosh/cpi/tasks.rb
|
|
41
|
+
- lib/bosh/cpi/tasks/spec.rake
|
|
36
42
|
- lib/cloud.rb
|
|
37
43
|
- lib/cloud/config.rb
|
|
38
44
|
- lib/cloud/errors.rb
|
|
45
|
+
- lib/cloud/external_cpi.rb
|
|
39
46
|
- lib/cloud/provider.rb
|
|
40
47
|
- lib/cloud/version.rb
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
- spec/unit/config_spec.rb
|
|
46
|
-
- spec/unit/provider_spec.rb
|
|
47
|
-
homepage: http://www.vmware.com
|
|
48
|
-
licenses: []
|
|
48
|
+
homepage: https://github.com/cloudfoundry/bosh
|
|
49
|
+
licenses:
|
|
50
|
+
- Apache 2.0
|
|
51
|
+
metadata: {}
|
|
49
52
|
post_install_message:
|
|
50
53
|
rdoc_options: []
|
|
51
54
|
require_paths:
|
|
52
55
|
- lib
|
|
53
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
|
-
none: false
|
|
55
57
|
requirements:
|
|
56
|
-
- -
|
|
58
|
+
- - ">="
|
|
57
59
|
- !ruby/object:Gem::Version
|
|
58
|
-
version:
|
|
59
|
-
segments:
|
|
60
|
-
- 0
|
|
61
|
-
hash: 899826630051890030
|
|
60
|
+
version: 1.9.3
|
|
62
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
|
-
none: false
|
|
64
62
|
requirements:
|
|
65
|
-
- -
|
|
63
|
+
- - ">="
|
|
66
64
|
- !ruby/object:Gem::Version
|
|
67
65
|
version: '0'
|
|
68
|
-
segments:
|
|
69
|
-
- 0
|
|
70
|
-
hash: 899826630051890030
|
|
71
66
|
requirements: []
|
|
72
67
|
rubyforge_project:
|
|
73
|
-
rubygems_version:
|
|
68
|
+
rubygems_version: 2.2.2
|
|
74
69
|
signing_key:
|
|
75
|
-
specification_version:
|
|
70
|
+
specification_version: 4
|
|
76
71
|
summary: BOSH CPI
|
|
77
|
-
test_files:
|
|
78
|
-
- spec/lib/cloud/spec.rb
|
|
79
|
-
- spec/spec_helper.rb
|
|
80
|
-
- spec/unit/config_spec.rb
|
|
81
|
-
- spec/unit/provider_spec.rb
|
|
72
|
+
test_files: []
|
data/Rakefile
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
|
2
|
-
|
|
3
|
-
$:.unshift(File.expand_path("../../rake", __FILE__))
|
|
4
|
-
|
|
5
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
|
|
6
|
-
|
|
7
|
-
require "rubygems"
|
|
8
|
-
require "bundler"
|
|
9
|
-
Bundler.setup(:default, :test)
|
|
10
|
-
|
|
11
|
-
require "rake"
|
|
12
|
-
begin
|
|
13
|
-
require "rspec/core/rake_task"
|
|
14
|
-
rescue LoadError
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
require "bundler_task"
|
|
18
|
-
require "ci_task"
|
|
19
|
-
|
|
20
|
-
gem_helper = Bundler::GemHelper.new(Dir.pwd)
|
|
21
|
-
|
|
22
|
-
desc "Build CPI gem into the pkg directory"
|
|
23
|
-
task "build" do
|
|
24
|
-
gem_helper.build_gem
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
desc "Build and install CPI into system gems"
|
|
28
|
-
task "install" do
|
|
29
|
-
Rake::Task["bundler:install"].invoke
|
|
30
|
-
gem_helper.install_gem
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
BundlerTask.new
|
|
34
|
-
|
|
35
|
-
if defined?(RSpec)
|
|
36
|
-
namespace :spec do
|
|
37
|
-
desc "Run Unit Tests"
|
|
38
|
-
rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
|
|
39
|
-
t.pattern = "spec/unit/**/*_spec.rb"
|
|
40
|
-
t.rspec_opts = %w(--format progress --colour)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
CiTask.new do |task|
|
|
44
|
-
task.rspec_task = rspec_task
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
desc "Run tests"
|
|
49
|
-
task :spec => %w(spec:unit)
|
|
50
|
-
end
|
data/spec/lib/cloud/spec.rb
DELETED
data/spec/spec_helper.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
|
2
|
-
|
|
3
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
|
|
4
|
-
|
|
5
|
-
require "rubygems"
|
|
6
|
-
require "bundler"
|
|
7
|
-
Bundler.setup(:default, :test)
|
|
8
|
-
|
|
9
|
-
require "rspec"
|
|
10
|
-
require "cloud"
|
|
11
|
-
require "logger"
|
|
12
|
-
|
|
13
|
-
class CloudSpecConfig
|
|
14
|
-
|
|
15
|
-
attr_accessor :db, :uuid
|
|
16
|
-
|
|
17
|
-
def logger
|
|
18
|
-
if @logger.nil?
|
|
19
|
-
@logger = Logger.new(STDOUT)
|
|
20
|
-
@logger.level = Logger::ERROR
|
|
21
|
-
end
|
|
22
|
-
@logger
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def uuid
|
|
26
|
-
@uuid ||= self.class.name
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
Bosh::Clouds::Config.configure(CloudSpecConfig.new)
|
data/spec/unit/config_spec.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require File.expand_path("../../spec_helper", __FILE__)
|
|
2
|
-
|
|
3
|
-
describe Bosh::Clouds::Config do
|
|
4
|
-
it "should configure a logger" do
|
|
5
|
-
Bosh::Clouds::Config.logger.should be_kind_of(Logger)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it "should configure a uuid" do
|
|
9
|
-
Bosh::Clouds::Config.uuid.should be_kind_of(String)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "should not have a db configured" do
|
|
13
|
-
Bosh::Clouds::Config.db.should be_nil
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should configure a task_checkpoint" do
|
|
17
|
-
Bosh::Clouds::Config.respond_to?(:task_checkpoint).should be_true
|
|
18
|
-
end
|
|
19
|
-
end
|
data/spec/unit/provider_spec.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require File.expand_path("../../spec_helper", __FILE__)
|
|
2
|
-
$:.unshift(File.expand_path("../../lib", __FILE__))
|
|
3
|
-
|
|
4
|
-
describe Bosh::Clouds::Provider do
|
|
5
|
-
it "should create a provider instance" do
|
|
6
|
-
|
|
7
|
-
provider = Bosh::Clouds::Provider.create("spec", {})
|
|
8
|
-
provider.should be_kind_of(Bosh::Clouds::Spec)
|
|
9
|
-
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "should fail to create an invalid provider" do
|
|
13
|
-
|
|
14
|
-
lambda {
|
|
15
|
-
Bosh::Clouds::Provider.create("enoent", {})
|
|
16
|
-
}.should raise_error(Bosh::Clouds::CloudError)
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
end
|