openstack-router 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: d97cd543afb99758645ca750a7224e38a108f1751709717c04e6fb25bbaafe58
4
- data.tar.gz: 7661baffd04619174102a8c6935e89887abdbfe826c72de4e6862cefe8a39c81
3
+ metadata.gz: 6e4ca3bc4dc4784bbde2456f6c8f345066529d4c9451885f07c1b20e2094cb41
4
+ data.tar.gz: 781556f8136ece2e07fdce30788aa9af2be3fb14a005228a3ed0adac96d7dfe1
5
5
  SHA512:
6
- metadata.gz: d076d94aad49faf567486a5289abe99af4b71da86e22b0d33fd55a891c473a50f6597c39b0e8c2132ee6c5ad57be003310e040241f1698f66faae1bd653221b1
7
- data.tar.gz: a1bc2b9b4ef9634d5d811fabd11e04eaf0a01a5a1e9f6680b477f5d3a4ad69cbe0d68721d843221b4df192288547930707de1c2e0faa84dba9fd7711382fe396
6
+ metadata.gz: b095cdc56abd579f074f5e2a1566b833b242328715bd2f24c8a4268ae19edf90f44ec607291a1942e52d42a34d28797b9d67195e892e93ceec507b278df4eecc
7
+ data.tar.gz: 3dcfb962b7edd53cd5ee6f22e39029ec42fd2a92d30ff8cf01f4e2da93d5466c56f492e96c2ab0610e332591917cd2377efef04ebb84918b634128061970da72
@@ -38,15 +38,29 @@ module OpenStackRouter
38
38
  # at each request. :compute will be converted to 'Compute'.
39
39
  # @param [Symbol] request This is the request you want to launch on the regions' service.
40
40
  # This is a method call, and then must be a Symbol.
41
+ # @param [...] request_args The remaining arguments are destinated to the request call and will be passed
42
+ # as is.
41
43
  # @see https://github.com/fog/fog-openstack For more information on available services and requests name
42
44
  #
43
- # @return [Hash] The result of each region, the key being the region_name and the value the
45
+ # @return [Hash] The result of each region, the key being the region_name and the value of the
44
46
  # result of Region#request with the given argument.
45
- # @see Region#request to understand how the block is managed.
46
- def request_each(service, request, *request_args, &block)
47
+ #
48
+ # @yield [region_name, answer] Block called for each region that answers
49
+ # @yieldparam [String] region_name The name of the region for that answer
50
+ # @yieldparam [Excon::Response] answer The answer to the request.
51
+ # @yieldreturn ['a] the return of the block is stored in the hash as a value
52
+ # to the key that will be the region_name.
53
+ def request_each(service, request, *request_args)
47
54
  # TODO: make the requests to be parallele to no do them sequentialy...
48
55
  Hash[@regions.map do |region|
49
- [region.name, region.request(service, request, *request_args, &block)]
56
+ [
57
+ region.name,
58
+ region.request(service, request, *request_args) do |answer|
59
+ next answer unless block_given?
60
+
61
+ yield(region.name, answer)
62
+ end
63
+ ]
50
64
  end]
51
65
  end
52
66
 
@@ -69,11 +83,33 @@ module OpenStackRouter
69
83
  @rr_circuits[rr_uuid]
70
84
  end
71
85
 
72
- def rr_request(rr_uuid, service, request, *request_args, &block)
86
+ # Run in the given circuit [rr_uuid] the request.
87
+ # @param [String] rr_uuid The uuid of the usd circuit. It must have been generated with {rr_create}
88
+ # @param [String | Symbol] service The service you want to interogate
89
+ # Service name should be capitalized, but by precaution, it is converted to string and capitalized
90
+ # at each request. :compute will be converted to 'Compute'.
91
+ # @param [Symbol] request This is the request you want to launch on the regions' service.
92
+ # This is a method call, and then must be a Symbol.
93
+ # @param [...] request_args The remaining arguments are destinated to the request call and will be passed
94
+ # as is.
95
+ # @see https://github.com/fog/fog-openstack For more information on available services and requests name
96
+ #
97
+ # @return ['a] The result of the selected region, the value of the
98
+ # result of Region#request with the given argument.
99
+ #
100
+ # @yield [region_name, answer] Block called over the result of the request.
101
+ # @yieldparam [String] region_name The name of the region that has been elected to run the request
102
+ # @yieldparam [Excon::Response] answer The answer to the request.
103
+ # @yieldreturn ['a] the result value of the block is returned by the method itself.
104
+ def rr_request(rr_uuid, service, request, *request_args)
73
105
  raise ArgumentError, 'Invalid UUID given' unless @rr_circuits.key?(rr_uuid)
74
106
 
75
107
  region = rr_next_region(rr_uuid)
76
- region.request(service, request, *region.my_args(request_args, region_names), &block)
108
+ region.request(service, request, *region.my_args(request_args, region_names)) do |answer|
109
+ next answer unless block_given?
110
+
111
+ yield(region.name, answer)
112
+ end
77
113
  end
78
114
 
79
115
  private
@@ -2,5 +2,5 @@
2
2
 
3
3
  module OpenStackRouter
4
4
  # The version number of this library
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
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.1
4
+ version: 0.1.2
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-08 00:00:00.000000000 Z
11
+ date: 2019-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-openstack