nifty 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/nifty.yml +3 -0
- data/lib/nifty/backends/opennebula.rb +1 -1
- data/lib/nifty/command_executioner.rb +11 -3
- data/lib/nifty/errors/transfer_methods/no_remote_host_error.rb +1 -0
- data/lib/nifty/errors/transfer_methods/scp_command_execution_error.rb +1 -0
- data/lib/nifty/transfer_method.rb +3 -2
- data/lib/nifty/transfer_methods/opennebula/cp.rb +1 -1
- data/lib/nifty/transfer_methods/opennebula/scp.rb +61 -0
- data/lib/nifty/version.rb +1 -1
- data/nifty.gemspec +1 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bb90e66cb5a6b7793a52fd759d51383d80351f3
|
4
|
+
data.tar.gz: 7b415c03cf167b1484b264b543d99d1838c6d73c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b23e146c4e2390dbc4d7052180dedd77b5e3d08fcdf4b679faff9b87b7567705d36a79401c632329a7346af2a79e5bd959e00b19eb2bee968a7356b25715d103
|
7
|
+
data.tar.gz: 8b00582017c6899d7cf96497e0d7785683431b0347224d1a370511c70d06537b24ca4d0a41def9f54f4b00b5ce6a691280a453ba3669b2f80552ed0bf5a5854b
|
data/config/nifty.yml
CHANGED
@@ -3,6 +3,9 @@ production:
|
|
3
3
|
transfer:
|
4
4
|
method: noop # Transfer method for image upload. Available methods can be listed in help.
|
5
5
|
destination: # Image upload destination. Format depends on transfer method.
|
6
|
+
# SCP method specific:
|
7
|
+
# remote-host: # Address of the remote host to copy images to
|
8
|
+
# remote-user: # Name of the remote user used to access the remote host
|
6
9
|
opennebula:
|
7
10
|
secret: oneadmin:opennebula # If not specified, looking for secret in environment variable ONE_AUTH and file ~/.one/one_auth
|
8
11
|
endpoint: http://localhost:2633/RPC2 # If not specified, looking for endpoint in environment variable ONE_XMLRPC and file ~/.one/one_endpoint
|
@@ -169,7 +169,7 @@ class Nifty::Backends::Opennebula < Nifty::Backend
|
|
169
169
|
# @option parameters [String] secret OpenNebula's secret
|
170
170
|
# @option parameters [String] endpoint OpenNebula's endpoint
|
171
171
|
def expiration_check(parameters)
|
172
|
-
interval = ChronicDuration.parse(parameters[:'expiration-interval'])
|
172
|
+
interval = ChronicDuration.parse(parameters[:'expiration-interval'].to_s)
|
173
173
|
return unless interval
|
174
174
|
|
175
175
|
client = Nifty::Backends::Utils::Opennebula::Helper.client(parameters[:secret], parameters[:endpoint])
|
@@ -63,6 +63,14 @@ class Nifty::CommandExecutioner < Thor
|
|
63
63
|
:type => :string,
|
64
64
|
:aliases => '-t',
|
65
65
|
:desc => 'Image upload destination'
|
66
|
+
class_option :"remote-host",
|
67
|
+
:default => Nifty::Settings['transfer']['remote-host'],
|
68
|
+
:type => :string,
|
69
|
+
:desc => 'Name of the remote host'
|
70
|
+
class_option :"remote-user",
|
71
|
+
:default => Nifty::Settings['transfer']['remote-user'],
|
72
|
+
:type => :string,
|
73
|
+
:desc => 'Name of the remote user'
|
66
74
|
class_option :"logging-level",
|
67
75
|
:required => true,
|
68
76
|
:default => Nifty::Settings['logging']['level'],
|
@@ -95,7 +103,7 @@ class Nifty::CommandExecutioner < Thor
|
|
95
103
|
backend_clazz = Nifty::Backends.const_get(backend.camelize)
|
96
104
|
options = backend_clazz.options
|
97
105
|
options.each do |name, parameters|
|
98
|
-
parameters[:default] = Nifty::Settings[backend][name.to_s]
|
106
|
+
parameters[:default] = Nifty::Settings[backend][name.to_s] || parameters[:default]
|
99
107
|
method_option name, parameters
|
100
108
|
end
|
101
109
|
|
@@ -118,7 +126,7 @@ end
|
|
118
126
|
if backend_clazz.respond_to? 'migrate'
|
119
127
|
options = backend_clazz.migrate_options
|
120
128
|
options.each do |name, parameters|
|
121
|
-
parameters[:default] = Nifty::Settings[backend][name.to_s]
|
129
|
+
parameters[:default] = Nifty::Settings[backend][name.to_s] || parameters[:default]
|
122
130
|
method_option name, parameters
|
123
131
|
end
|
124
132
|
|
@@ -219,7 +227,7 @@ end
|
|
219
227
|
def construct_transfer_method(backend, parameters)
|
220
228
|
transfer_method_const = transfer_method_constant(backend, parameters[:"transfer-method"])
|
221
229
|
|
222
|
-
transfer_method_const.new(parameters[:"transfer-destination"])
|
230
|
+
transfer_method_const.new(parameters[:"transfer-destination"], parameters)
|
223
231
|
rescue Nifty::Errors::TransferMethodError => ex
|
224
232
|
$stdout.puts ex.message
|
225
233
|
exit Nifty::ExitCodes::TRANSFER_METHOD_ERROR_EXIT_CODE
|
@@ -0,0 +1 @@
|
|
1
|
+
class Nifty::Errors::TransferMethods::NoRemoteHostError < Nifty::Errors::TransferMethodError; end
|
@@ -0,0 +1 @@
|
|
1
|
+
class Nifty::Errors::TransferMethods::ScpCommandExecutionError < Nifty::Errors::TransferMethodError; end
|
@@ -6,7 +6,7 @@ require 'fileutils'
|
|
6
6
|
# @abstract
|
7
7
|
# @attr_reader [String] destination path to destination directory for the transfer method
|
8
8
|
class Nifty::TransferMethod
|
9
|
-
attr_reader :destination
|
9
|
+
attr_reader :destination, :options
|
10
10
|
|
11
11
|
class << self
|
12
12
|
# Helper method to recognize NIFTY transfer method
|
@@ -37,8 +37,9 @@ class Nifty::TransferMethod
|
|
37
37
|
# Constructor
|
38
38
|
#
|
39
39
|
# @param [String] destination for the transfer method
|
40
|
-
def initialize(destination)
|
40
|
+
def initialize(destination, options={})
|
41
41
|
@destination = destination
|
42
|
+
@options = options
|
42
43
|
end
|
43
44
|
|
44
45
|
# Transfers file to the destination
|
@@ -19,7 +19,7 @@ class Nifty::TransferMethods::Opennebula::Cp < Nifty::TransferMethod
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# @see Nifty::TransferMethod#initialize
|
22
|
-
def initialize(destination)
|
22
|
+
def initialize(destination, options={})
|
23
23
|
fail Nifty::Errors::TransferMethods::DestinationNotDirectoryError, "Destination #{destination.inspect} is not a directory" unless (destination && File.directory?(destination))
|
24
24
|
fail Nifty::Errors::TransferMethods::DestinationNotWritableError, "Destination directory #{destination.inspect} is not writable" unless File.writable?(destination)
|
25
25
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'etc'
|
2
|
+
require 'mixlib/shellout'
|
3
|
+
|
4
|
+
# SCP transfer method
|
5
|
+
# Copies file from remote server to the destination and clens it after the event is processed
|
6
|
+
class Nifty::TransferMethods::Opennebula::Scp < Nifty::TransferMethod
|
7
|
+
attr_reader :user, :host
|
8
|
+
class << self
|
9
|
+
# @see Nifty::TransferMethod#description
|
10
|
+
def description
|
11
|
+
'SCP transfer method - copies images from remote host'
|
12
|
+
end
|
13
|
+
|
14
|
+
# @see Nifty::TransferMethod#backend
|
15
|
+
def backend
|
16
|
+
Nifty::Backends::Opennebula
|
17
|
+
end
|
18
|
+
|
19
|
+
# @see Nifty::TransferMethod#transfer_method?
|
20
|
+
def transfer_method?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @see Nifty::TransferMethod#initialize
|
26
|
+
def initialize(destination, options={})
|
27
|
+
fail Nifty::Errors::TransferMethods::NoRemoteHostError, 'Missing remote host option for SCP transfer method' unless options[:'remote-host']
|
28
|
+
|
29
|
+
@host = options[:'remote-host']
|
30
|
+
@user = options[:'remote-user'] || Etc.getlogin
|
31
|
+
|
32
|
+
super(destination, options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# @see Nifty::TransferMethod#transfer
|
36
|
+
def transfer(file)
|
37
|
+
destination_line = "#{user}@#{host}:#{destination}"
|
38
|
+
logger.debug("Copying file #{file.inspect} to destination #{destination_line.inspect}")
|
39
|
+
scp_command = Mixlib::ShellOut.new('scp', file, destination_line)
|
40
|
+
scp_command.run_command
|
41
|
+
|
42
|
+
if scp_command.error?
|
43
|
+
raise Nifty::Errors::TransferMethods::ScpCommandExecutionError, "Command #{scp_command.command.inspect} terminated with an " \
|
44
|
+
"error: #{scp_command.stderr}"
|
45
|
+
end
|
46
|
+
|
47
|
+
destination_file file
|
48
|
+
end
|
49
|
+
|
50
|
+
# @see Nifty::TransferMethod#clean_copy
|
51
|
+
def clean_copy(file)
|
52
|
+
# no remote cleaning
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
#TODO duplicit method (cp transfer method) -> move to helper class
|
58
|
+
def destination_file(file)
|
59
|
+
File.join(destination, File.basename(file))
|
60
|
+
end
|
61
|
+
end
|
data/lib/nifty/version.rb
CHANGED
data/nifty.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_runtime_dependency 'json-schema', '~> 2.5'
|
37
37
|
spec.add_runtime_dependency 'tilt', '~> 2.0'
|
38
38
|
spec.add_runtime_dependency 'chronic_duration', '~> 0.10'
|
39
|
+
spec.add_runtime_dependency 'mixlib-shellout', '~> 2.2'
|
39
40
|
|
40
41
|
spec.required_ruby_version = '>= 1.9.3'
|
41
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nifty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Kimle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -254,6 +254,20 @@ dependencies:
|
|
254
254
|
- - "~>"
|
255
255
|
- !ruby/object:Gem::Version
|
256
256
|
version: '0.10'
|
257
|
+
- !ruby/object:Gem::Dependency
|
258
|
+
name: mixlib-shellout
|
259
|
+
requirement: !ruby/object:Gem::Requirement
|
260
|
+
requirements:
|
261
|
+
- - "~>"
|
262
|
+
- !ruby/object:Gem::Version
|
263
|
+
version: '2.2'
|
264
|
+
type: :runtime
|
265
|
+
prerelease: false
|
266
|
+
version_requirements: !ruby/object:Gem::Requirement
|
267
|
+
requirements:
|
268
|
+
- - "~>"
|
269
|
+
- !ruby/object:Gem::Version
|
270
|
+
version: '2.2'
|
257
271
|
description: A tool for uploading and registering cloud appliances in OpenNebula.
|
258
272
|
email:
|
259
273
|
- kimle.michal@gmail.com
|
@@ -314,6 +328,8 @@ files:
|
|
314
328
|
- lib/nifty/errors/transfer_methods/destination_not_directory_error.rb
|
315
329
|
- lib/nifty/errors/transfer_methods/destination_not_writable_error.rb
|
316
330
|
- lib/nifty/errors/transfer_methods/image_file_not_readable_error.rb
|
331
|
+
- lib/nifty/errors/transfer_methods/no_remote_host_error.rb
|
332
|
+
- lib/nifty/errors/transfer_methods/scp_command_execution_error.rb
|
317
333
|
- lib/nifty/event.rb
|
318
334
|
- lib/nifty/event/converter.rb
|
319
335
|
- lib/nifty/event/loader.rb
|
@@ -334,6 +350,7 @@ files:
|
|
334
350
|
- lib/nifty/transfer_methods/opennebula.rb
|
335
351
|
- lib/nifty/transfer_methods/opennebula/cp.rb
|
336
352
|
- lib/nifty/transfer_methods/opennebula/noop.rb
|
353
|
+
- lib/nifty/transfer_methods/opennebula/scp.rb
|
337
354
|
- lib/nifty/version.rb
|
338
355
|
- nifty.gemspec
|
339
356
|
- schema/appliance.json
|
@@ -359,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
359
376
|
version: '0'
|
360
377
|
requirements: []
|
361
378
|
rubyforge_project:
|
362
|
-
rubygems_version: 2.
|
379
|
+
rubygems_version: 2.5.1
|
363
380
|
signing_key:
|
364
381
|
specification_version: 4
|
365
382
|
summary: A tool for uploading and registering cloud appliances in OpenNebula.
|