-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathcontainer_manager_mixin.rb
65 lines (53 loc) · 1.98 KB
/
container_manager_mixin.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
module ManageIQ::Providers::Openshift::ContainerManagerMixin
extend ActiveSupport::Concern
include ManageIQ::Providers::Kubernetes::ContainerManagerMixin
DEFAULT_PORT = 8443
DEFAULT_EXTERNAL_LOGGING_ROUTE_NAME = "logging-kibana-ops".freeze
included do
has_many :container_routes, :foreign_key => :ems_id, :dependent => :destroy
end
# This is the API version that we use and support throughout the entire code
# (parsers, events, etc.). It should be explicitly selected here and not
# decided by the user nor out of control in the defaults of openshift gem
# because it's not guaranteed that the next default version will work with
# our specific code in ManageIQ.
delegate :api_version, :to => :class
def api_version=(_value)
raise 'OpenShift api_version cannot be modified'
end
class_methods do
def api_version
'v1'
end
def raw_connect(hostname, port, options)
options[:service] ||= "openshift"
send("#{options[:service]}_connect", hostname, port, options)
end
def openshift_connect(hostname, port, options)
options = {:path => '/oapi', :version => api_version}.merge(options)
kubernetes_connect(hostname, port, options)
end
end
def connect_client(api_version, method_name)
@clients ||= {}
api, version = api_version.split('/', 2)
if version
@clients[api_version] ||= connect(:service => 'kubernetes', :version => version, :path => '/apis/' + api)
else
openshift = 'oapi' + api_version
kubernetes = 'api' + api_version
@clients[openshift] ||= connect(:version => api_version)
@clients[kubernetes] ||= connect(:service => 'kubernetes', :version => api_version)
@clients[openshift].respond_to?(method_name) ? @clients[openshift] : @clients[kubernetes]
end
end
def external_logging_route_name
DEFAULT_EXTERNAL_LOGGING_ROUTE_NAME
end
def external_logging_query
nil # should be empty to return all
end
def external_logging_path
'/'
end
end