forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change Contains: provider, parser, refresher, refresh worker, persistence of container_project and container_route and autofill of default port values for both containers providers in the UI
- Loading branch information
Showing
19 changed files
with
283 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ContainerProject < ActiveRecord::Base | ||
include CustomAttributeMixin | ||
include ReportableMixin | ||
belongs_to :ext_management_system, :foreign_key => "ems_id" | ||
|
||
has_many :labels, :class_name => CustomAttribute, :as => :resource, :conditions => {:section => "labels"} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ContainerRoute < ActiveRecord::Base | ||
include CustomAttributeMixin | ||
include ReportableMixin | ||
|
||
belongs_to :ext_management_system, :foreign_key => "ems_id" | ||
has_many :labels, :class_name => CustomAttribute, :as => :resource, :conditions => {:section => "labels"} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class EmsOpenshift < EmsContainer | ||
include ContainerProviderMixin | ||
|
||
has_many :container_routes, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :container_projects, :foreign_key => :ems_id, :dependent => :destroy | ||
|
||
default_value_for :port, 8443 | ||
|
||
def self.ems_type | ||
@ems_type ||= "openshift".freeze | ||
end | ||
|
||
def self.description | ||
@description ||= "OpenShift".freeze | ||
end | ||
|
||
def self.raw_connect(hostname, port, service = nil) | ||
service ||= "openshift" | ||
send("#{service}_connect", hostname, port) | ||
end | ||
|
||
def self.openshift_connect(hostname, port) | ||
require 'openshift_client' | ||
api_endpoint = raw_api_endpoint(hostname, port) | ||
osclient = OpenshiftClient::Client.new(api_endpoint) | ||
# TODO: support real authentication using certificates | ||
osclient.ssl_options(:verify_ssl => OpenSSL::SSL::VERIFY_NONE) | ||
osclient | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module EmsRefresh | ||
module Parsers | ||
class Openshift < Kubernetes | ||
def ems_inv_to_hashes(inventory) | ||
super(inventory) | ||
get_projects(inventory) | ||
get_routes(inventory) | ||
EmsRefresh.log_inv_debug_trace(@data, "data:") | ||
@data | ||
end | ||
|
||
def get_routes(inventory) | ||
process_collection(inventory["route"], :container_routes) { |n| parse_route(n) } | ||
end | ||
|
||
def get_projects(inventory) | ||
process_collection(inventory["project"], :container_projects) { |n| parse_project(n) } | ||
end | ||
|
||
def parse_project(project) | ||
new_result = parse_base_item(project) | ||
new_result.except!(:namespace) | ||
new_result.merge!( | ||
:labels => parse_labels(project), | ||
:display_name => project.displayName | ||
) | ||
new_result | ||
end | ||
|
||
def parse_route(route) | ||
new_result = parse_base_item(route) | ||
new_result.merge!( | ||
# TODO: persist tls | ||
:host_name => route.host, | ||
:labels => parse_labels(route), | ||
# TODO: this part needs to be modified to service_id instead | ||
:service_name => route.serviceName, | ||
:path => route.path | ||
) | ||
new_result | ||
end | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
vmdb/app/models/ems_refresh/refreshers/openshift_refresher.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module EmsRefresh | ||
module Refreshers | ||
class OpenshiftRefresher < BaseRefresher | ||
include EmsRefresherMixin | ||
|
||
def parse_inventory(ems, _targets = nil) | ||
all_entities = ems.with_provider_connection(&:all_entities) | ||
all_entities.merge!(ems.with_provider_connection(:service => EmsKubernetes.ems_type, &:all_entities)) | ||
EmsRefresh.log_inv_debug_trace(all_entities, "inv_hash:") | ||
EmsRefresh::Parsers::Openshift.ems_inv_to_hashes(all_entities) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class MiqEmsRefreshWorkerOpenshift < MiqEmsRefreshWorker | ||
def self.ems_class | ||
EmsOpenshift | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
module ContainerProviderMixin | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
has_many :container_nodes, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :container_groups, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :container_services, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :container_replication_controllers, :foreign_key => :ems_id, :dependent => :destroy | ||
end | ||
|
||
module ClassMethods | ||
def raw_api_endpoint(hostname, port) | ||
URI::HTTPS.build(:host => hostname, :port => port.to_i) | ||
end | ||
|
||
def kubernetes_connect(hostname, port) | ||
require 'kubeclient' | ||
api_endpoint = raw_api_endpoint(hostname, port) | ||
kubeclient = Kubeclient::Client.new(api_endpoint) | ||
# TODO: support real authentication using certificates | ||
kubeclient.ssl_options(:verify_ssl => OpenSSL::SSL::VERIFY_NONE) | ||
kubeclient | ||
end | ||
end | ||
|
||
# UI methods for determining availability of fields | ||
def supports_port? | ||
true | ||
end | ||
|
||
def api_endpoint | ||
self.class.raw_api_endpoint(hostname, port) | ||
end | ||
|
||
def connect(options = {}) | ||
self.class.raw_connect(hostname, port, options[:service]) | ||
end | ||
|
||
def authentication_check | ||
# TODO: support real authentication using certificates | ||
[true, ""] | ||
end | ||
|
||
def verify_credentials(_auth_type = nil, _options = {}) | ||
# TODO: support real authentication using certificates | ||
true | ||
end | ||
|
||
def authentication_status_ok?(_type = nil) | ||
# TODO: support real authentication using certificates | ||
true | ||
end | ||
|
||
# required by aggregate_hardware | ||
def all_computer_system_ids | ||
MiqPreloader.preload(container_nodes, :computer_system) | ||
container_nodes.collect { |n| n.computer_system.id } | ||
end | ||
|
||
def aggregate_logical_cpus(targets = nil) | ||
aggregate_hardware(:computer_systems, :logical_cpus, targets) | ||
end | ||
|
||
def aggregate_memory(targets = nil) | ||
aggregate_hardware(:computer_systems, :memory_cpu, targets) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.