openstack-router 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: 6e4ca3bc4dc4784bbde2456f6c8f345066529d4c9451885f07c1b20e2094cb41
4
- data.tar.gz: 781556f8136ece2e07fdce30788aa9af2be3fb14a005228a3ed0adac96d7dfe1
3
+ metadata.gz: c0f75a1372ca48807478db771b5cef9e87dcf6692b1d996b83b79a46e1e5e094
4
+ data.tar.gz: 45c8b6994b400d5f00e812faa71100680dbabb0810284492f84fc77ea0a2d1cf
5
5
  SHA512:
6
- metadata.gz: b095cdc56abd579f074f5e2a1566b833b242328715bd2f24c8a4268ae19edf90f44ec607291a1942e52d42a34d28797b9d67195e892e93ceec507b278df4eecc
7
- data.tar.gz: 3dcfb962b7edd53cd5ee6f22e39029ec42fd2a92d30ff8cf01f4e2da93d5466c56f492e96c2ab0610e332591917cd2377efef04ebb84918b634128061970da72
6
+ metadata.gz: 8bf430ddb4daced99473fea95d448f9da4877810e3ac26d53a88bd6a30d873d1c8aee9220032831c3a1f1a02203b653973a150bb6e1d9a079a703830691901f9
7
+ data.tar.gz: a9e6948efba2df9bc0106c16cb50d1d2d3f7a4d56d2acb85fd1960fefbb27bb87e76fb6023cb04b6f19c4042e4770bbae6483b0ffc0f67c7b93801fafeedbacd
@@ -21,18 +21,21 @@ module OpenStackRouter
21
21
  attr_reader :username
22
22
  attr_reader :api_key
23
23
  attr_reader :tenant
24
- attr_reader :project_id
24
+ attr_reader :tenant_id
25
25
  attr_reader :region
26
26
 
27
27
  # The mandatory options needed to be pass in argument at initialization of that class.
28
- MANDATORY_OPTIONS = %i[auth_url username api_key tenant project_id].freeze
28
+ MANDATORY_OPTIONS = %i[auth_url username api_key].freeze
29
+ # Paired mandatory options (means that one of one pair must me present, not the other).
30
+ PAIRED_MANDATORY_OPTIONS = [%i[tenant tenant_id]].freeze
29
31
  # The options that are not mandatory for this object.
30
32
  OTHER_OPTIONS = %i[region].freeze
31
33
  # Constant containing all the available options.
32
- ALL_OPTIONS = (MANDATORY_OPTIONS + OTHER_OPTIONS).freeze
34
+ ALL_OPTIONS = (MANDATORY_OPTIONS + PAIRED_MANDATORY_OPTIONS.flatten + OTHER_OPTIONS).freeze
33
35
 
34
36
  def initialize(options)
35
37
  mandatory_options(options)
38
+ paired_mandatory_options(options)
36
39
  other_options(options)
37
40
  end
38
41
 
@@ -68,7 +71,7 @@ module OpenStackRouter
68
71
  attr_writer :username
69
72
  attr_writer :api_key
70
73
  attr_writer :tenant
71
- attr_writer :project_id
74
+ attr_writer :tenant_id
72
75
  attr_writer :region
73
76
 
74
77
  def mandatory_options(cfg)
@@ -83,6 +86,20 @@ module OpenStackRouter
83
86
  raise ArgumentError, "Missing keys: #{missing_keys}" unless missing_keys.empty?
84
87
  end
85
88
 
89
+ def paired_mandatory_options(cfg)
90
+ missing_keys = []
91
+ PAIRED_MANDATORY_OPTIONS.each do |key1, key2|
92
+ if cfg.key? key1
93
+ send("#{key1}=".to_sym, cfg[key1])
94
+ elsif cfg.key? key2
95
+ send("#{key2}=".to_sym, cfg[key2])
96
+ else
97
+ missing_keys.append([key1, key2])
98
+ end
99
+ end
100
+ raise ArgumentError, "Missing paired keys: #{missing_keys}" unless missing_keys.empty?
101
+ end
102
+
86
103
  def other_options(cfg)
87
104
  cfg.each do |key, value|
88
105
  send("#{key}=".to_sym, value) if OTHER_OPTIONS.include?(key)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module OpenStackRouter
4
4
  # The version number of this library
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstack-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roland Laurès
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-10 00:00:00.000000000 Z
11
+ date: 2019-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-openstack