cloudkeeper-one 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c702f53ba2245d3a4a786a1a73c052d919dd2a3b
4
- data.tar.gz: c93ebf8eab54d5e01fc116e7794fcaa32cc28674
3
+ metadata.gz: 2addc69f939c5497397accddbf6900526a21e402
4
+ data.tar.gz: 7f1d72b372c871774198b73320914b76f3b37008
5
5
  SHA512:
6
- metadata.gz: 80594791bd9a2e17b3ef1b4680388a82511fcb0ff0bc84609044e3128764797441ea9c8780da1f31f2b8d1d9e145abc5de8c74247dae82d977b753d68b70cd5e
7
- data.tar.gz: 3720bb3625430abba2a5403d0ecb1f6c61f33ed4a22f65e615d77e282b5ff5fd56d03ef2c5259470902f2702ca0f227a91f43d59acb71876edc5f81ffeb823dd
6
+ metadata.gz: 4e49c53da9aed9a46713c1cc89195a16c7005424a1cfc4816d12285aca4f59e1290ba8477e01a30a4c50a138315f8de21f5200087b966127d170f6c1e904e19e
7
+ data.tar.gz: e92811e8d5d75f193b7d896c9ea7f4f04d2f40216b93f7c190d30e3e724da03ad13747f0532702334c0e92572208b2cf12963fbc1ce5a674e681aad2731d5d11
@@ -17,6 +17,7 @@ cloudkeeper-one:
17
17
  - default
18
18
  users: # Handle only images/templates of specified users
19
19
  api-call-timeout: 3h # How long will cloudkeeper-one wait for image/template operations to finish in OpenNebula
20
+ allow-remote-source: true # Allows OpenNebula to directly download remote image
20
21
  logging:
21
22
  level: ERROR # Logging level
22
23
  file: /var/log/cloudkeeper/cloudkeeper-one.log # File to write log to. To turn off file logging leave this field empty.
@@ -6,11 +6,11 @@ module Cloudkeeper
6
6
  module Utils
7
7
  module ImageDownload
8
8
  def download_image(uri, username, password)
9
- logger.debug "Downloading image from #{uri.inspect} (username: #{username}, password: #{password})"
9
+ return generate_url uri, username, password if Cloudkeeper::One::Settings[:'opennebula-allow-remote-source']
10
+
10
11
  filename = generate_filename
11
12
  retrieve_image URI.parse(uri), username, password, filename
12
13
 
13
- logger.debug "Image stored into #{filename}"
14
14
  filename
15
15
  rescue URI::InvalidURIError => ex
16
16
  raise Cloudkeeper::One::Errors::NetworkConnectionError, ex
@@ -19,7 +19,9 @@ module Cloudkeeper
19
19
  private
20
20
 
21
21
  def retrieve_image(uri, username, password, filename)
22
- Net::HTTP.start(uri.host, uri.port) do |http|
22
+ logger.debug "Downloading image from #{uri.inspect} (username: #{username}, password: #{password})"
23
+ use_ssl = uri.scheme == 'https'
24
+ Net::HTTP.start(uri.host, uri.port, use_ssl: use_ssl) do |http|
23
25
  request = Net::HTTP::Get.new(uri)
24
26
  request.basic_auth username, password
25
27
 
@@ -28,14 +30,24 @@ module Cloudkeeper
28
30
  open(filename, 'w') { |file| response.read_body { |chunk| file.write(chunk) } }
29
31
  end
30
32
  end
33
+ logger.debug "Image stored into #{filename}"
31
34
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, Net::HTTPBadResponse,
32
- Net::HTTPHeaderSyntaxError, EOFError, Net::HTTPServerException => ex
35
+ Net::HTTPHeaderSyntaxError, EOFError, Net::HTTPServerException, Net::HTTPRetriableError => ex
33
36
  raise Cloudkeeper::One::Errors::NetworkConnectionError, ex
34
37
  end
35
38
 
36
39
  def generate_filename
37
40
  File.join(Cloudkeeper::One::Settings[:'appliances-tmp-dir'], SecureRandom.uuid)
38
41
  end
42
+
43
+ def generate_url(uri, username, password)
44
+ url = URI.parse(uri)
45
+ url.user = username
46
+ url.password = password
47
+
48
+ logger.debug "Generating remote source URL: #{url.to_s.inspect}"
49
+ url.to_s
50
+ end
39
51
  end
40
52
  end
41
53
  end
@@ -92,6 +92,10 @@ module Cloudkeeper
92
92
  default: Cloudkeeper::One::Settings['opennebula']['api-call-timeout'],
93
93
  type: :string,
94
94
  desc: 'How long will cloudkeeper-one wait for image/template operations to finish in OpenNebula'
95
+ method_option :'opennebula-allow-remote-source',
96
+ default: Cloudkeeper::One::Settings['opennebula']['allow-remote-source'],
97
+ type: :boolean,
98
+ desc: 'Allows OpenNebula to directly download remote image'
95
99
 
96
100
  desc 'sync', 'Runs synchronization process'
97
101
  def sync
@@ -125,7 +129,7 @@ module Cloudkeeper
125
129
 
126
130
  def validate_configuration!
127
131
  validate_configuration_group! :authentication,
128
- %i(certificate key core-certificate),
132
+ %i[certificate key core-certificate],
129
133
  'Authentication configuration missing'
130
134
  end
131
135
 
@@ -1,5 +1,5 @@
1
1
  module Cloudkeeper
2
2
  module One
3
- VERSION = '1.1.2'.freeze
3
+ VERSION = '1.2.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudkeeper-one
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Kimle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-31 00:00:00.000000000 Z
11
+ date: 2017-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler