forked from ManageIQ/manageiq-providers-openstack
-
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.
Merge pull request ManageIQ#74 from mansam/targeted-refresh
Targeted Refresh for Cloud VMs
- Loading branch information
Showing
42 changed files
with
29,572 additions
and
25,595 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
class ManageIQ::Providers::Openstack::Builder | ||
class << self | ||
def build_inventory(ems, target) | ||
case target | ||
when ManageIQ::Providers::Openstack::CloudManager | ||
cloud_manager_inventory(ems, target) | ||
when ManageIQ::Providers::Openstack::NetworkManager | ||
inventory( | ||
ems, | ||
target, | ||
ManageIQ::Providers::Openstack::Inventory::Collector::NetworkManager, | ||
ManageIQ::Providers::Openstack::Inventory::Persister::NetworkManager, | ||
[ManageIQ::Providers::Openstack::Inventory::Parser::NetworkManager] | ||
) | ||
when ManagerRefresh::TargetCollection | ||
inventory( | ||
ems, | ||
target, | ||
ManageIQ::Providers::Openstack::Inventory::Collector::TargetCollection, | ||
ManageIQ::Providers::Openstack::Inventory::Persister::TargetCollection, | ||
[ManageIQ::Providers::Openstack::Inventory::Parser::CloudManager, | ||
ManageIQ::Providers::Openstack::Inventory::Parser::NetworkManager] | ||
) | ||
else | ||
# Fallback to ems refresh | ||
cloud_manager_inventory(ems, target) | ||
end | ||
end | ||
|
||
private | ||
|
||
def cloud_manager_inventory(ems, target) | ||
inventory( | ||
ems, | ||
target, | ||
ManageIQ::Providers::Openstack::Inventory::Collector::CloudManager, | ||
ManageIQ::Providers::Openstack::Inventory::Persister::CloudManager, | ||
[ManageIQ::Providers::Openstack::Inventory::Parser::CloudManager] | ||
) | ||
end | ||
|
||
def inventory(manager, raw_target, collector_class, persister_class, parsers_classes) | ||
collector = collector_class.new(manager, raw_target) | ||
# TODO(lsmola) figure out a way to pass collector info, probably via target | ||
persister = persister_class.new(manager, raw_target, collector) | ||
|
||
::ManageIQ::Providers::Openstack::Inventory.new( | ||
persister, | ||
collector, | ||
parsers_classes.map(&:new) | ||
) | ||
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 ManageIQ::Providers::Openstack::Inventory < ManagerRefresh::Inventory | ||
require_nested :Collector | ||
require_nested :Parser | ||
require_nested :Persister | ||
end |
87 changes: 87 additions & 0 deletions
87
app/models/manageiq/providers/openstack/inventory/collector.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,87 @@ | ||
class ManageIQ::Providers::Openstack::Inventory::Collector < ManagerRefresh::Inventory::Collector | ||
include ManageIQ::Providers::Openstack::RefreshParserCommon::HelperMethods | ||
include Vmdb::Logging | ||
|
||
require_nested :CloudManager | ||
require_nested :NetworkManager | ||
require_nested :TargetCollection | ||
|
||
attr_reader :availability_zones | ||
attr_reader :cloud_services | ||
attr_reader :tenants | ||
attr_accessor :flavors | ||
attr_reader :host_aggregates | ||
attr_reader :key_pairs | ||
attr_reader :miq_templates | ||
attr_reader :orchestration_stacks | ||
attr_reader :quotas | ||
attr_reader :vms | ||
attr_reader :vnfs | ||
attr_reader :vnfds | ||
attr_reader :cloud_networks | ||
attr_reader :floating_ips | ||
attr_reader :network_ports | ||
attr_reader :network_routers | ||
attr_reader :security_groups | ||
|
||
def initialize(_manager, _target) | ||
super | ||
|
||
initialize_inventory_sources | ||
end | ||
|
||
def initialize_inventory_sources | ||
# cloud | ||
@availability_zones = [] | ||
@cloud_services = [] | ||
@tenants = [] | ||
@flavors = [] | ||
@host_aggregates = [] | ||
@key_pairs = [] | ||
@images = [] | ||
@orchestration_stacks = [] | ||
@quotas = [] | ||
@vms = [] | ||
@vnfs = [] | ||
@vnfds = [] | ||
# network | ||
@cloud_networks = [] | ||
@floating_ips = [] | ||
@network_ports = [] | ||
@network_routers = [] | ||
@security_groups = [] | ||
end | ||
|
||
def connection | ||
@os_handle ||= manager.openstack_handle | ||
@connection ||= manager.connect | ||
end | ||
|
||
def compute_service | ||
connection | ||
end | ||
|
||
def identity_service | ||
@identity_service ||= manager.openstack_handle.identity_service | ||
end | ||
|
||
def image_service | ||
@image_service ||= manager.openstack_handle.detect_image_service | ||
end | ||
|
||
def network_service | ||
@network_service ||= manager.openstack_handle.detect_network_service | ||
end | ||
|
||
def nfv_service | ||
@nfv_service ||= manager.openstack_handle.detect_nfv_service | ||
end | ||
|
||
def volume_service | ||
@volume_service ||= manager.openstack_handle.detect_volume_service | ||
end | ||
|
||
def orchestration_service | ||
@orchestration_service ||= manager.openstack_handle.detect_orchestration_service | ||
end | ||
end |
Oops, something went wrong.