yao 0.13.1 → 0.14.0
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 +4 -4
- data/.github/workflows/rubocop.yml +19 -0
- data/.github/workflows/ubuntu-rvm.yml +1 -1
- data/.github/workflows/ubuntu.yml +1 -1
- data/.rubocop.yml +3 -6
- data/README.md +2 -1
- data/lib/yao/auth.rb +19 -1
- data/lib/yao/client.rb +12 -8
- data/lib/yao/config.rb +19 -0
- data/lib/yao/faraday_middlewares.rb +50 -3
- data/lib/yao/mode.rb +4 -0
- data/lib/yao/plugins/default_client_generator.rb +1 -1
- data/lib/yao/plugins/registry.rb +2 -1
- data/lib/yao/resources/action.rb +7 -0
- data/lib/yao/resources/aggregates.rb +1 -0
- data/lib/yao/resources/base.rb +27 -2
- data/lib/yao/resources/compute_services.rb +8 -1
- data/lib/yao/resources/flavor.rb +2 -0
- data/lib/yao/resources/floating_ip.rb +2 -0
- data/lib/yao/resources/hypervisor.rb +1 -1
- data/lib/yao/resources/image.rb +2 -0
- data/lib/yao/resources/loadbalancer.rb +4 -0
- data/lib/yao/resources/loadbalancer_healthmonitor.rb +3 -0
- data/lib/yao/resources/loadbalancer_listener.rb +2 -0
- data/lib/yao/resources/loadbalancer_pool.rb +6 -0
- data/lib/yao/resources/loadbalancer_pool_member.rb +21 -0
- data/lib/yao/resources/metadata_available.rb +21 -0
- data/lib/yao/resources/meter.rb +8 -1
- data/lib/yao/resources/network.rb +1 -0
- data/lib/yao/resources/network_associationable.rb +1 -0
- data/lib/yao/resources/old_sample.rb +4 -0
- data/lib/yao/resources/port.rb +2 -0
- data/lib/yao/resources/port_associationable.rb +1 -0
- data/lib/yao/resources/project.rb +6 -0
- data/lib/yao/resources/resource.rb +8 -2
- data/lib/yao/resources/restfully_accessible.rb +35 -5
- data/lib/yao/resources/role.rb +6 -4
- data/lib/yao/resources/role_assignment.rb +1 -0
- data/lib/yao/resources/router.rb +9 -0
- data/lib/yao/resources/sample.rb +4 -0
- data/lib/yao/resources/security_group.rb +1 -0
- data/lib/yao/resources/security_group_rule.rb +10 -0
- data/lib/yao/resources/server.rb +20 -0
- data/lib/yao/resources/server_group.rb +1 -1
- data/lib/yao/resources/server_usage_associationable.rb +12 -0
- data/lib/yao/resources/subnet.rb +1 -0
- data/lib/yao/resources/tenant.rb +6 -0
- data/lib/yao/resources/tenant_associationable.rb +1 -0
- data/lib/yao/resources/user.rb +2 -0
- data/lib/yao/resources.rb +3 -0
- data/lib/yao/token.rb +1 -0
- data/lib/yao/version.rb +1 -1
- data/test/support/restfully_accesible_stub.rb +1 -1
- data/test/yao/resources/test_base.rb +11 -0
- data/test/yao/resources/test_hypervisor.rb +3 -3
- data/test/yao/resources/test_image.rb +95 -4
- data/test/yao/resources/test_project.rb +20 -1
- data/test/yao/resources/test_server.rb +40 -0
- data/test/yao/resources/test_server_group.rb +1 -1
- data/test/yao/test_client.rb +5 -1
- data/yao.gemspec +2 -1
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55df2a0420c42a9448a180f6b0378d82bd8c6fb2d9efac004c152675d357ee3a
|
4
|
+
data.tar.gz: ff5477041bca286e2283ef8130c3659cd4762a8b415dbc374df73ff077dae51a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75274af855b318f6be285de56b21260f350e5dd892a291b4ef128db9683b9559e06a6284024f555e4123c879530a2b903b3abea29cc08be0c76fe54417638d38
|
7
|
+
data.tar.gz: 66ee630a29f13cd94eb4639fcabc711da46d71f1ff8ff779777b7833a052cf6899b5076f9bac7c25669449fb28a87d4c1d6a63857e5bbeae22bd27280834d84f
|
@@ -0,0 +1,19 @@
|
|
1
|
+
name: rubocop
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@master
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: actions/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.0
|
14
|
+
- name: Install dependencies
|
15
|
+
run: |
|
16
|
+
gem install bundler --no-document
|
17
|
+
bundle install
|
18
|
+
- name: Run rubocop
|
19
|
+
run: bundle exec rubocop
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
2
|
+
SuggestExtensions: false
|
3
|
+
TargetRubyVersion: 3.0
|
3
4
|
DisplayCopNames: true
|
4
5
|
DisabledByDefault: true
|
5
6
|
Exclude:
|
@@ -11,7 +12,7 @@ Style/HashSyntax:
|
|
11
12
|
Layout/EmptyLines:
|
12
13
|
Enabled: true
|
13
14
|
|
14
|
-
Layout/
|
15
|
+
Layout/TrailingEmptyLines:
|
15
16
|
Enabled: true
|
16
17
|
|
17
18
|
Layout/TrailingWhitespace:
|
@@ -52,7 +53,3 @@ Style/NumericLiteralPrefix:
|
|
52
53
|
Style/StabbyLambdaParentheses:
|
53
54
|
EnforcedStyle: require_parentheses
|
54
55
|
Enabled: true
|
55
|
-
|
56
|
-
Rails/ActionFilter:
|
57
|
-
EnforcedStyle: action
|
58
|
-
Enabled: true
|
data/README.md
CHANGED
data/lib/yao/auth.rb
CHANGED
@@ -5,19 +5,29 @@ require 'yao/token'
|
|
5
5
|
require 'yao/tokenv3'
|
6
6
|
|
7
7
|
module Yao
|
8
|
-
%i(tenant_name username password timeout client_cert client_key region_name
|
8
|
+
%i(tenant_name username password timeout ca_cert client_cert client_key region_name
|
9
9
|
identity_api_version user_domain_id user_domain_name project_domain_id project_domain_name).each do |name|
|
10
10
|
Yao.config.param name, nil
|
11
11
|
end
|
12
12
|
|
13
13
|
module Auth
|
14
14
|
class << self
|
15
|
+
# @return [Yao::Auth]
|
15
16
|
def try_new
|
16
17
|
if Yao.config.tenant_name && Yao.config.username && Yao.config.password && Yao.default_client
|
17
18
|
Yao::Auth.new
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
22
|
+
# @param tenant_name [String]
|
23
|
+
# @param username [String]
|
24
|
+
# @param password [String]
|
25
|
+
# @param default_domain [String]
|
26
|
+
# @param user_domain_id [String]
|
27
|
+
# @param user_domain_name [String]
|
28
|
+
# @param project_domain_id [String]
|
29
|
+
# @param project_domain_name [String]
|
30
|
+
# @return [Hash]
|
21
31
|
def build_authv3_info(tenant_name, username, password,
|
22
32
|
default_domain,
|
23
33
|
user_domain_id, user_domain_name,
|
@@ -55,6 +65,10 @@ module Yao
|
|
55
65
|
}
|
56
66
|
end
|
57
67
|
|
68
|
+
# @param tenant_name [String]
|
69
|
+
# @param username [String]
|
70
|
+
# @param password [String]
|
71
|
+
# @return [Hash]
|
58
72
|
def build_auth_info(tenant_name, username, password)
|
59
73
|
auth_info = {
|
60
74
|
auth: {
|
@@ -68,6 +82,10 @@ module Yao
|
|
68
82
|
auth_info
|
69
83
|
end
|
70
84
|
|
85
|
+
# if identity_api_version == "3"
|
86
|
+
# @return [TokenV3]
|
87
|
+
# else
|
88
|
+
# @return [Token]
|
71
89
|
def new(
|
72
90
|
tenant_name: Yao.config.tenant_name,
|
73
91
|
username: Yao.config.username,
|
data/lib/yao/client.rb
CHANGED
@@ -104,7 +104,7 @@ module Yao
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
# @param [String]
|
107
|
+
# @param new_endpoint [String]
|
108
108
|
def reset_client(new_endpoint=nil)
|
109
109
|
set = ClientSet.new
|
110
110
|
endpoint = {
|
@@ -124,13 +124,17 @@ module Yao
|
|
124
124
|
end
|
125
125
|
|
126
126
|
# Client Certificate Authentication
|
127
|
-
if Yao.config.client_cert && Yao.config.client_key
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
127
|
+
if (Yao.config.client_cert && Yao.config.client_key) || Yao.config.ca_cert
|
128
|
+
h = {}
|
129
|
+
if Yao.config.client_cert && Yao.config.client_key
|
130
|
+
cert = OpenSSL::X509::Certificate.new(File.read(Yao.config.client_cert))
|
131
|
+
key = OpenSSL::PKey.read(File.read(Yao.config.client_key))
|
132
|
+
h[:client_cert] = cert
|
133
|
+
h[:client_key] = key
|
134
|
+
end
|
135
|
+
|
136
|
+
h[:ca_file] = Yao.config.ca_cert if Yao.config.ca_cert
|
137
|
+
opt.merge!(ssl: h)
|
134
138
|
end
|
135
139
|
opt
|
136
140
|
end
|
data/lib/yao/config.rb
CHANGED
@@ -1,22 +1,30 @@
|
|
1
1
|
module Yao
|
2
2
|
class Config
|
3
|
+
|
4
|
+
# @return [Hash]
|
3
5
|
def _configuration_defaults
|
4
6
|
@_configuration_defaults ||= {}
|
5
7
|
end
|
6
8
|
|
9
|
+
# @return [Hash]
|
7
10
|
def _configuration_hooks
|
8
11
|
@_configuration_hooks ||= {}
|
9
12
|
end
|
10
13
|
|
14
|
+
# @return [Array]
|
11
15
|
def _configuration_hooks_queue
|
12
16
|
@_configuration_hooks_queue ||= []
|
13
17
|
end
|
14
18
|
|
19
|
+
# @return [Hash]
|
15
20
|
def configuration
|
16
21
|
@configuration ||= {}
|
17
22
|
end
|
18
23
|
|
19
24
|
HOOK_RENEW_CLIENT_KEYS = %i(tenant_name username password auth_url debug debug_record_response)
|
25
|
+
|
26
|
+
# @param v [Boolean]
|
27
|
+
# @return [Array]
|
20
28
|
def delay_hook=(v)
|
21
29
|
@delay_hook = v
|
22
30
|
if !v and !_configuration_hooks_queue.empty?
|
@@ -33,10 +41,14 @@ module Yao
|
|
33
41
|
end
|
34
42
|
end
|
35
43
|
|
44
|
+
# @return [Boolean]
|
36
45
|
def delay_hook?
|
37
46
|
@delay_hook
|
38
47
|
end
|
39
48
|
|
49
|
+
# @param name [String]
|
50
|
+
# @param default [String]
|
51
|
+
# @param hook [Proc]
|
40
52
|
def param(name, default, &hook)
|
41
53
|
raise("Duplicate definition of #{name}") if self.respond_to?(name)
|
42
54
|
|
@@ -55,6 +67,9 @@ module Yao
|
|
55
67
|
end
|
56
68
|
end
|
57
69
|
|
70
|
+
# @param name [String]
|
71
|
+
# @param value [String]
|
72
|
+
# @return [String]
|
58
73
|
def set(name, value)
|
59
74
|
raise("Undefined config key #{name}") unless self.respond_to?(name)
|
60
75
|
configuration[name.to_sym] = value
|
@@ -67,6 +82,8 @@ module Yao
|
|
67
82
|
end
|
68
83
|
end
|
69
84
|
|
85
|
+
# @param blk [Proc]
|
86
|
+
# @return [Yao::Config]
|
70
87
|
def self.config(&blk)
|
71
88
|
@__config ||= Config.new
|
72
89
|
if blk
|
@@ -77,6 +94,8 @@ module Yao
|
|
77
94
|
@__config
|
78
95
|
end
|
79
96
|
|
97
|
+
# @param blk [Proc]
|
98
|
+
# @return [Yao::Config]
|
80
99
|
def self.configure(&blk)
|
81
100
|
config(&blk)
|
82
101
|
end
|
@@ -64,21 +64,38 @@ class Faraday::Request::ReadOnly
|
|
64
64
|
end
|
65
65
|
Faraday::Request.register_middleware read_only: -> { Faraday::Request::ReadOnly }
|
66
66
|
|
67
|
+
class Faraday::Request::UserAgent
|
68
|
+
def initialize(app, user_agent=nil)
|
69
|
+
@app = app
|
70
|
+
@user_agent = user_agent || "Yao/#{Yao::VERSION} Faraday/#{Faraday::VERSION}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def call(env)
|
74
|
+
env[:request_headers]['User-Agent'] = @user_agent
|
75
|
+
@app.call(env)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
Faraday::Request.register_middleware user_agent: -> { Faraday::Request::UserAgent }
|
79
|
+
|
67
80
|
class Faraday::Response::OSDumper < Faraday::Response::Middleware
|
68
81
|
def on_complete(env)
|
69
82
|
require 'pp'
|
70
83
|
|
71
|
-
body = if env.response_headers["content-type"]
|
84
|
+
body = if env.response_headers["content-type"].start_with?("application/json")
|
72
85
|
JSON.parse(env.body)
|
73
86
|
else
|
74
87
|
env.body
|
75
88
|
end
|
89
|
+
body = conseal_token_in_body(body)
|
90
|
+
|
91
|
+
request_headers = conseal_token_in_request_headers(env.request_headers.dup)
|
92
|
+
response_headers= conseal_token_in_response_headers(env.response_headers.dup)
|
76
93
|
|
77
94
|
params = [
|
78
95
|
env.url.to_s,
|
79
96
|
body,
|
80
|
-
|
81
|
-
|
97
|
+
request_headers,
|
98
|
+
response_headers,
|
82
99
|
env.method,
|
83
100
|
env.status
|
84
101
|
].map(&:pretty_inspect)
|
@@ -101,6 +118,36 @@ Status Code: %s
|
|
101
118
|
|
102
119
|
FMT
|
103
120
|
end
|
121
|
+
|
122
|
+
private
|
123
|
+
def conseal_token_in_body(body)
|
124
|
+
# for keystone v2.0
|
125
|
+
if body.is_a?(Hash) && token = body.dig("access", "token", "id")
|
126
|
+
body["access"]["token"]["id"] = hashed_token(token)
|
127
|
+
end
|
128
|
+
body
|
129
|
+
end
|
130
|
+
|
131
|
+
def conseal_token_in_request_headers(headers)
|
132
|
+
if token = headers["X-Auth-Token"]
|
133
|
+
headers["X-Auth-Token"] = hashed_token(token)
|
134
|
+
end
|
135
|
+
headers
|
136
|
+
end
|
137
|
+
|
138
|
+
def conseal_token_in_response_headers(headers)
|
139
|
+
if token = headers["x-subject-token"]
|
140
|
+
headers["x-subject-token"] = hashed_token(token)
|
141
|
+
end
|
142
|
+
headers
|
143
|
+
end
|
144
|
+
|
145
|
+
def hashed_token(token)
|
146
|
+
require 'openssl'
|
147
|
+
|
148
|
+
# This format was based on openstack client.
|
149
|
+
"{SHA256}" + OpenSSL::Digest::SHA256.hexdigest(token)
|
150
|
+
end
|
104
151
|
end
|
105
152
|
Faraday::Response.register_middleware os_dumper: -> { Faraday::Response::OSDumper }
|
106
153
|
|
data/lib/yao/mode.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Yao
|
2
2
|
module Mode
|
3
|
+
# @param blk [Proc]
|
4
|
+
# @return [String]
|
3
5
|
def read_only!(&blk)
|
4
6
|
raise unless block_given?
|
5
7
|
|
@@ -16,6 +18,8 @@ module Yao
|
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
21
|
+
# @param blk [Proc]
|
22
|
+
# @return [String]
|
19
23
|
def read_only(&blk)
|
20
24
|
raise unless block_given?
|
21
25
|
|
@@ -8,6 +8,7 @@ module Yao::Plugins
|
|
8
8
|
def call(f, token)
|
9
9
|
f.request :accept, 'application/json'
|
10
10
|
f.request :url_encoded
|
11
|
+
f.request :user_agent
|
11
12
|
|
12
13
|
if token
|
13
14
|
f.request :os_token, token
|
@@ -19,7 +20,6 @@ module Yao::Plugins
|
|
19
20
|
f.response :json, content_type: /\bjson$/
|
20
21
|
|
21
22
|
if Yao.config.debug
|
22
|
-
f.response :logger
|
23
23
|
f.response :os_dumper
|
24
24
|
end
|
25
25
|
|
data/lib/yao/plugins/registry.rb
CHANGED
data/lib/yao/resources/action.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module Yao::Resources
|
2
2
|
module Action
|
3
|
+
|
4
|
+
# @param id [String]
|
5
|
+
# @param query [Hash]
|
6
|
+
# @return [Hash]
|
3
7
|
def action(id, query)
|
4
8
|
res = POST(action_path(id)) do |req|
|
5
9
|
req.body = query.to_json
|
@@ -9,6 +13,9 @@ module Yao::Resources
|
|
9
13
|
end
|
10
14
|
|
11
15
|
private
|
16
|
+
|
17
|
+
# @param id [String]
|
18
|
+
# @return [String]
|
12
19
|
def action_path(id)
|
13
20
|
[resources_name, id, "action"].join("/")
|
14
21
|
end
|
data/lib/yao/resources/base.rb
CHANGED
@@ -3,17 +3,21 @@ require 'time'
|
|
3
3
|
|
4
4
|
module Yao::Resources
|
5
5
|
class Base
|
6
|
+
|
7
|
+
# @param name [Array]
|
6
8
|
def self.friendly_attributes(*names)
|
7
9
|
names.map(&:to_s).each do |name|
|
8
10
|
define_method(name) do
|
9
11
|
if !@data.key?(name) && id
|
10
|
-
@data = self.class.get(id)
|
12
|
+
@data = self.class.get(id).to_hash
|
11
13
|
end
|
12
14
|
self[name]
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
19
|
+
# @param k_and_v [Hash]
|
20
|
+
# @return [Symbol]
|
17
21
|
def self.map_attribute_to_attribute(k_and_v)
|
18
22
|
as_json, as_method = *k_and_v.to_a.first.map(&:to_s)
|
19
23
|
define_method(as_method) do
|
@@ -21,14 +25,20 @@ module Yao::Resources
|
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
28
|
+
# @param k_and_v [Hash]
|
29
|
+
# @return [Symbol]
|
24
30
|
def self.map_attribute_to_resource(k_and_v)
|
25
31
|
_name, klass = *k_and_v.to_a.first
|
26
32
|
name = _name.to_s
|
27
33
|
define_method(name) do
|
28
|
-
self[
|
34
|
+
unless self[name].empty?
|
35
|
+
self[[name, klass].join("__")] ||= klass.new(self[name])
|
36
|
+
end
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
40
|
+
# @param k_and_v [Hash]
|
41
|
+
# @return [Symbol]
|
32
42
|
def self.map_attribute_to_resources(k_and_v)
|
33
43
|
_name, klass = *k_and_v.to_a.first
|
34
44
|
name = _name.to_s
|
@@ -39,28 +49,43 @@ module Yao::Resources
|
|
39
49
|
end
|
40
50
|
end
|
41
51
|
|
52
|
+
# @param data_via_json [Hash]
|
53
|
+
# @return [Hash]
|
42
54
|
def initialize(data_via_json)
|
43
55
|
@data = data_via_json
|
44
56
|
end
|
45
57
|
|
58
|
+
# @param name [String]
|
59
|
+
# @return [String]
|
46
60
|
def [](name)
|
47
61
|
@data[name]
|
48
62
|
end
|
49
63
|
|
64
|
+
# @param name [String]
|
65
|
+
# @param value [String]
|
66
|
+
# @return [String]
|
50
67
|
def []=(name, value)
|
51
68
|
@data[name] = value
|
52
69
|
end
|
53
70
|
|
71
|
+
# @return [Hash]
|
72
|
+
def to_hash
|
73
|
+
@data
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [String]
|
54
77
|
def id
|
55
78
|
self["id"]
|
56
79
|
end
|
57
80
|
|
81
|
+
# @return [Date]
|
58
82
|
def created
|
59
83
|
if date = self["created"] || self["created_at"]
|
60
84
|
Time.parse(date)
|
61
85
|
end
|
62
86
|
end
|
63
87
|
|
88
|
+
# @return [Date]
|
64
89
|
def updated
|
65
90
|
if date = self["updated"] || self["updated_at"]
|
66
91
|
Time.parse(date)
|
@@ -19,6 +19,9 @@ module Yao::Resources
|
|
19
19
|
end
|
20
20
|
|
21
21
|
class << self
|
22
|
+
# @param host [String]
|
23
|
+
# @param binary [String]
|
24
|
+
# @return [Yao::Resources::ComputeServices]
|
22
25
|
def enable(host, binary)
|
23
26
|
params = {
|
24
27
|
"host" => host,
|
@@ -27,6 +30,10 @@ module Yao::Resources
|
|
27
30
|
put("enable", params)
|
28
31
|
end
|
29
32
|
|
33
|
+
# @param host [String]
|
34
|
+
# @param binary [String]
|
35
|
+
# @param resason [String]
|
36
|
+
# @return [Yao::Resources::ComputeServices]
|
30
37
|
def disable(host, binary, reason = nil)
|
31
38
|
params = {
|
32
39
|
"host" => host,
|
@@ -55,4 +62,4 @@ module Yao::Resources
|
|
55
62
|
end
|
56
63
|
|
57
64
|
end
|
58
|
-
end
|
65
|
+
end
|
data/lib/yao/resources/flavor.rb
CHANGED
@@ -14,10 +14,12 @@ module Yao::Resources
|
|
14
14
|
self.resource_name = "floatingip"
|
15
15
|
self.resources_name = "floatingips"
|
16
16
|
|
17
|
+
# @return [Yao::Resources::Router]
|
17
18
|
def router
|
18
19
|
@router ||= Yao::Router.get(router_id)
|
19
20
|
end
|
20
21
|
|
22
|
+
# @return [Yao::Resources::Tenant]
|
21
23
|
def project
|
22
24
|
@project ||= Yao::Tenant.get(project_id)
|
23
25
|
end
|
data/lib/yao/resources/image.rb
CHANGED
@@ -6,6 +6,7 @@ module Yao::Resources
|
|
6
6
|
map_attribute_to_resources listeners: LoadBalancerListener
|
7
7
|
map_attribute_to_resources pools: LoadBalancerPool
|
8
8
|
|
9
|
+
# @return [Yao::Resources::Tenant]
|
9
10
|
def project
|
10
11
|
if project_id = self["project_id"]
|
11
12
|
Yao::Tenant.find project_id
|
@@ -13,18 +14,21 @@ module Yao::Resources
|
|
13
14
|
end
|
14
15
|
alias :tenant :project
|
15
16
|
|
17
|
+
# @return [Yao::Resources::Network]
|
16
18
|
def vip_network
|
17
19
|
if vip_network_id = self["vip_network_id"]
|
18
20
|
Yao::Network.find vip_network_id
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
24
|
+
# @return [Yao::Resources::Port]
|
22
25
|
def vip_port
|
23
26
|
if vip_port_id = self["vip_port_id"]
|
24
27
|
Yao::Port.find vip_port_id
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
31
|
+
# @return [Yao::Resources::Subnet]
|
28
32
|
def vip_subnet
|
29
33
|
if vip_subnet_id = self["vip_subnet_id"]
|
30
34
|
Yao::Subnet.find vip_subnet_id
|
@@ -7,14 +7,17 @@ module Yao::Resources
|
|
7
7
|
|
8
8
|
map_attribute_to_resources pools: LoadBalancerListener
|
9
9
|
|
10
|
+
# @return [Date]
|
10
11
|
def created_at
|
11
12
|
Date.parse(self["created_at"])
|
12
13
|
end
|
13
14
|
|
15
|
+
# @return [Date]
|
14
16
|
def updated_at
|
15
17
|
Date.parse(self["updated_at"])
|
16
18
|
end
|
17
19
|
|
20
|
+
# @return [Date]
|
18
21
|
def project
|
19
22
|
if project_id = self["project_id"]
|
20
23
|
Yao::Tenant.find project_id
|
@@ -8,6 +8,7 @@ module Yao::Resources
|
|
8
8
|
|
9
9
|
map_attribute_to_resources loadbalancers: LoadBalancer
|
10
10
|
|
11
|
+
# @return [Yao::Resources::Tenant]
|
11
12
|
def project
|
12
13
|
if project_id = self["project_id"]
|
13
14
|
Yao::Tenant.find project_id
|
@@ -15,6 +16,7 @@ module Yao::Resources
|
|
15
16
|
end
|
16
17
|
alias :tenant :project
|
17
18
|
|
19
|
+
# @return [Yao::Resources::LoadBalancerPool]
|
18
20
|
def default_pool
|
19
21
|
if default_pool_id = self["default_pool_id"]
|
20
22
|
Yao::LoadBalancerPool.find default_pool_id
|
@@ -7,20 +7,24 @@ module Yao::Resources
|
|
7
7
|
map_attribute_to_resources loadbalancers: LoadBalancer
|
8
8
|
map_attribute_to_resources listeners: LoadBalancerListener
|
9
9
|
|
10
|
+
# @return [Date]
|
10
11
|
def created_at
|
11
12
|
Date.parse(self["created_at"])
|
12
13
|
end
|
13
14
|
|
15
|
+
# @return [Date]
|
14
16
|
def updated_at
|
15
17
|
Date.parse(self["updated_at"])
|
16
18
|
end
|
17
19
|
|
20
|
+
# @return [Yao::Resources::LoadBalancerListener]
|
18
21
|
def listeners
|
19
22
|
self["listeners"].map do |listener|
|
20
23
|
Yao::LoadBalancerListener.find listener["id"]
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
27
|
+
# @return [Yao::Resources::Tenant]
|
24
28
|
def project
|
25
29
|
if project_id = self["project_id"]
|
26
30
|
Yao::Tenant.find project_id
|
@@ -28,12 +32,14 @@ module Yao::Resources
|
|
28
32
|
end
|
29
33
|
alias :tenant :project
|
30
34
|
|
35
|
+
# @return [Yao::Resources::LoadBalancerListener]
|
31
36
|
def members
|
32
37
|
self["members"].map do |member|
|
33
38
|
Yao::LoadBalancerPoolMember.find(self,member["id"])
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
42
|
+
# @return [Yao::Resources::LoadBalancerHealthMonitor]
|
37
43
|
def healthmonitor
|
38
44
|
if healthmonitor_id = self["healthmonitor_id"]
|
39
45
|
Yao::LoadBalancerHealthMonitor.find healthmonitor_id
|