fog-openstack 0.1.18 → 0.1.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ad255185b61e76ee76ad8d89711b167918a27f7
4
- data.tar.gz: b02a996a6244f9d382d619086358f15209d5ce27
3
+ metadata.gz: dc6df6714fdc0919e30d872748400f21dd6a1b76
4
+ data.tar.gz: 3d057c3aad27a48d1ee8901f71b4b85fe7e03de2
5
5
  SHA512:
6
- metadata.gz: 0a4dace55598a9e1da519522da4d133d53b617e64f7b4f9492fdb0e559074b21abc0f00d64163a40544b0c75160ea231af452664ecda648cc104c612f727d92c
7
- data.tar.gz: 1bed7b31da6d4529b432d4e55254dc56259e7810a60e9731895cb2d839b34380379c4c5aa86d3bec8cd5cda77f813e72073e5071ffba81201735169439987fc8
6
+ metadata.gz: 36bfe27a022057590ce817e20089d3bfe7ff00e42be16173d9077cb3b1dd314047486d359ad5f65dd0d3d489804315506031d014ba8b2cfe02f88f195d10ead1
7
+ data.tar.gz: bc82e6dee769885e863f2f0e9dd822d4210e1fb2628fa8daec888c08f29dca37c6c1be55e7b626b601a0f8e7e24df6b0ef6c9a4f897668d84f1158afdd18379d
@@ -15,6 +15,7 @@ module Fog
15
15
  attribute :minDisk
16
16
  attribute :minRam
17
17
  attribute :server, :aliases => 'server'
18
+ attribute :size, :aliases => 'OS-EXT-IMG-SIZE:size'
18
19
  attribute :metadata
19
20
  attribute :links
20
21
 
@@ -3,7 +3,6 @@ module Fog
3
3
  class OpenStack
4
4
  class Real
5
5
  def update_quota(tenant_id, options = {})
6
- options['tenant_id'] = tenant_id
7
6
  request(
8
7
  :body => Fog::JSON.encode('quota_set' => options),
9
8
  :expects => 200,
@@ -23,7 +23,12 @@ module Fog
23
23
  end
24
24
 
25
25
  def find_by_id(id)
26
- all.find { |image| image.id == id }
26
+ marker = 'X-Image-Meta-'
27
+ params = service.get_image_by_id(id).headers.select{|h,_| h.include?(marker) }
28
+ params = params.map{|k,v| [k.gsub(marker,'').downcase, convert_to_type(v)]}
29
+ new(Hash[params])
30
+ rescue Fog::Image::OpenStack::NotFound
31
+ nil
27
32
  end
28
33
  alias get find_by_id
29
34
 
@@ -62,6 +67,23 @@ module Fog
62
67
  attribute = attribute.to_s.gsub("find_by_", "")
63
68
  load(service.list_public_images_detailed(attribute, value).body['images'])
64
69
  end
70
+
71
+ private
72
+
73
+ def convert_to_type(v)
74
+ case v
75
+ when /^\d+$/
76
+ v.to_i
77
+ when 'True'
78
+ true
79
+ when 'False'
80
+ false
81
+ when /^\d\d\d\d\-\d\d\-\d\dT/
82
+ ::Time.parse(v)
83
+ else
84
+ v
85
+ end
86
+ end
65
87
  end
66
88
  end
67
89
  end
@@ -5,27 +5,35 @@ module Fog
5
5
  class Real
6
6
  def get_image_by_id(image_id)
7
7
  request(
8
- :expects => [200, 204],
9
- :method => 'GET',
8
+ :expects => [200],
9
+ :method => 'HEAD',
10
10
  :path => "images/#{image_id}"
11
11
  )
12
12
  end
13
13
  end # class Real
14
14
 
15
15
  class Mock
16
- def get_image_by_id(_image_id)
16
+ def get_image_by_id(image_id)
17
17
  response = Excon::Response.new
18
18
  response.status = [200, 204][rand(2)]
19
- response.body = {
20
- "images" => [{
21
- "name" => "mock-image-name",
22
- "size" => 25165824,
23
- "disk_format" => "ami",
24
- "container_format" => "ami",
25
- "id" => "0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
26
- "checksum" => "2f81976cae15c16ef0010c51e3a6c163"
27
- }]
19
+ response.headers = {
20
+ 'X-Image-Meta-Checksum' => '8a40c862b5735975d82605c1dd395796',
21
+ 'X-Image-Meta-Container_format' => 'aki',
22
+ 'X-Image-Meta-Created_at' => '2016-01-06T03:22:20.000000',
23
+ 'X-Image-Meta-Deleted' => 'False',
24
+ 'X-Image-Meta-Disk_format' => 'aki',
25
+ 'X-Image-Meta-Id' => image_id,
26
+ 'X-Image-Meta-Is_public' => 'True',
27
+ 'X-Image-Meta-Min_disk' => 0,
28
+ 'X-Image-Meta-Min_ram' => 0,
29
+ 'X-Image-Meta-Name' => 'cirros-0.3.4-x86_64-uec-kernel',
30
+ 'X-Image-Meta-Owner' => '13cc6052265b41529e2fd0fc461fa8ef',
31
+ 'X-Image-Meta-Protected' => 'False',
32
+ 'X-Image-Meta-Size' => 4979632,
33
+ 'X-Image-Meta-Status' => 'deactivated',
34
+ 'X-Image-Meta-Updated_at' => '2016-02-25T03:02:05.000000'
28
35
  }
36
+ response.body = {}
29
37
  response
30
38
  end # def list_tenants
31
39
  end # class Mock
@@ -18,6 +18,8 @@ module Fog
18
18
 
19
19
  def find_by_id(id)
20
20
  new(service.get_image_by_id(id).body)
21
+ rescue Fog::Image::OpenStack::NotFound
22
+ nil
21
23
  end
22
24
 
23
25
  alias get find_by_id
@@ -9,7 +9,7 @@ module Fog
9
9
  }
10
10
  }
11
11
 
12
- vanilla_options = [:port_id, :tenant_id, :fixed_ip_address, :floating_ip_address]
12
+ vanilla_options = [:port_id, :tenant_id, :fixed_ip_address, :floating_ip_address, :subnet_id]
13
13
  vanilla_options.reject { |o| options[o].nil? }.each do |key|
14
14
  data['floatingip'][key] = options[key]
15
15
  end
@@ -1,6 +1,6 @@
1
1
  module Fog
2
2
  module Openstack
3
- VERSION = "0.1.18"
3
+ VERSION = "0.1.19"
4
4
 
5
5
  def self.included(base)
6
6
  if RUBY_VERSION < "2"
@@ -3,7 +3,6 @@ module Fog
3
3
  class OpenStack
4
4
  module Real
5
5
  def update_quota(tenant_id, options = {})
6
- options['tenant_id'] = tenant_id
7
6
  request(
8
7
  :body => Fog::JSON.encode('quota_set' => options),
9
8
  :expects => 200,
@@ -12,6 +12,7 @@ module Fog
12
12
  attribute :display_description
13
13
  attribute :metadata
14
14
  attribute :force
15
+ attribute :size
15
16
 
16
17
  def save
17
18
  requires :display_name
@@ -12,6 +12,7 @@ module Fog
12
12
  attribute :description
13
13
  attribute :metadata
14
14
  attribute :force
15
+ attribute :size
15
16
 
16
17
  def save
17
18
  requires :name
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-openstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Darby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-25 00:00:00.000000000 Z
11
+ date: 2017-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core