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.
Add parsing events with OvirtSDK, this respects the setting use_ovirt_engine_sdk and will use only Ovirt gem if it is set to false.
- Loading branch information
Boris Odnopozov
committed
Apr 2, 2017
1 parent
053c16e
commit c589205
Showing
8 changed files
with
215 additions
and
38 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
3 changes: 3 additions & 0 deletions
3
app/models/manageiq/providers/redhat/infra_manager/ovirt_services.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,3 @@ | ||
module ManageIQ::Providers::Redhat::InfraManager::OvirtServices | ||
require_nested :Builder | ||
end |
15 changes: 15 additions & 0 deletions
15
app/models/manageiq/providers/redhat/infra_manager/ovirt_services/builder.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,15 @@ | ||
module ManageIQ::Providers::Redhat::InfraManager::OvirtServices | ||
class Builder | ||
attr_reader :ext_management_system | ||
|
||
def initialize(ems) | ||
@ext_management_system = ems | ||
end | ||
|
||
def build | ||
strategy_model = ManageIQ::Providers::Redhat::InfraManager::OvirtServices::Strategies | ||
api_version = ext_management_system.highest_allowed_api_version | ||
"#{strategy_model}::V#{api_version}".constantize | ||
end | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
app/models/manageiq/providers/redhat/infra_manager/ovirt_services/strategies/v3.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,21 @@ | ||
module ManageIQ::Providers::Redhat::InfraManager::OvirtServices::Strategies | ||
class V3 | ||
attr_reader :ext_management_system | ||
|
||
def initialize(args) | ||
@ext_management_system = args[:ems] | ||
end | ||
|
||
def username_by_href(href) | ||
ext_management_system.with_provider_connection do |rhevm| | ||
Ovirt::User.find_by_href(rhevm, href).try(:[], :user_name) | ||
end | ||
end | ||
|
||
def cluster_name_href(href) | ||
ext_management_system.with_provider_connection do |rhevm| | ||
Ovirt::Cluster.find_by_href(rhevm, href).try(:[], :name) | ||
end | ||
end | ||
end | ||
end |
32 changes: 32 additions & 0 deletions
32
app/models/manageiq/providers/redhat/infra_manager/ovirt_services/strategies/v4.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,32 @@ | ||
module ManageIQ::Providers::Redhat::InfraManager::OvirtServices::Strategies | ||
class V4 | ||
attr_reader :ext_management_system | ||
|
||
def initialize(args) | ||
@ext_management_system = args[:ems] | ||
end | ||
|
||
def username_by_href(href) | ||
ext_management_system.with_provider_connection(:version => 4) do |connection| | ||
user = connection.system_service.users_service.user_service(get_uuid_from_href(href)).get | ||
"#{user.name}@#{user.domain.name}" | ||
end | ||
end | ||
|
||
def cluster_name_href(href) | ||
ext_management_system.with_provider_connection(:version => 4) do |connection| | ||
cluster_proxy_from_href(href, connection).name | ||
end | ||
end | ||
|
||
private | ||
|
||
def cluster_proxy_from_href(href, con) | ||
con.system_service.clusters_service.cluster_service(get_uuid_from_href(href)).get | ||
end | ||
|
||
def get_uuid_from_href(ems_ref) | ||
URI(ems_ref).path.split('/').last | ||
end | ||
end | ||
end |
41 changes: 41 additions & 0 deletions
41
spec/models/manageiq/providers/redhat/infra_manager/event_parser/response_yamls/user.yml
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,41 @@ | ||
--- !ruby/object:OvirtSDK4::User | ||
href: "/ovirt-engine/api/users/58ad9d2d-013a-00aa-018f-00000000022e" | ||
comment: | ||
description: | ||
id: 58ad9d2d-013a-00aa-018f-00000000022e | ||
name: admin | ||
department: | ||
domain: !ruby/object:OvirtSDK4::Domain | ||
href: "/ovirt-engine/api/domains/696E7465726E616C2D617574687A" | ||
comment: | ||
description: | ||
id: 696E7465726E616C2D617574687A | ||
name: internal-authz | ||
groups: | ||
user: | ||
users: | ||
domain_entry_id: 30663066383031392D353864322D343937302D626464302D666561323334613732663263 | ||
email: | ||
groups: | ||
last_name: | ||
logged_in: | ||
namespace: "*" | ||
password: | ||
permissions: !ruby/array:OvirtSDK4::List | ||
internal: [] | ||
ivars: | ||
:@href: "/ovirt-engine/api/users/58ad9d2d-013a-00aa-018f-00000000022e/permissions" | ||
principal: admin | ||
roles: !ruby/array:OvirtSDK4::List | ||
internal: [] | ||
ivars: | ||
:@href: "/ovirt-engine/api/users/58ad9d2d-013a-00aa-018f-00000000022e/roles" | ||
ssh_public_keys: !ruby/array:OvirtSDK4::List | ||
internal: [] | ||
ivars: | ||
:@href: "/ovirt-engine/api/users/58ad9d2d-013a-00aa-018f-00000000022e/sshpublickeys" | ||
tags: !ruby/array:OvirtSDK4::List | ||
internal: [] | ||
ivars: | ||
:@href: "/ovirt-engine/api/users/58ad9d2d-013a-00aa-018f-00000000022e/tags" | ||
user_name: admin@internal-authz |
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