Skip to content

Commit

Permalink
Move ManagerRefresh to InventoryRefresh
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Sep 7, 2018
1 parent a82b18f commit 7b92a1f
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ def initialize(ems_event)

# Parses all targets that are present in the EmsEvent given in the initializer
#
# @return [Array] Array of ManagerRefresh::Target objects
# @return [Array] Array of InventoryRefresh::Target objects
def parse
parse_ems_event_targets(ems_event)
end

private

# Parses list of ManagerRefresh::Target out of the given EmsEvent
# Parses list of InventoryRefresh::Target out of the given EmsEvent
#
# @param event [EmsEvent] EmsEvent object
# @return [Array] Array of ManagerRefresh::Target objects
# @return [Array] Array of InventoryRefresh::Target objects
def parse_ems_event_targets(event)
target_collection = ManagerRefresh::TargetCollection.new(:manager => event.ext_management_system, :event => event)
target_collection = InventoryRefresh::TargetCollection.new(:manager => event.ext_management_system, :event => event)

parse_event_target(target_collection, event.full_data)

Expand Down
2 changes: 1 addition & 1 deletion app/models/manageiq/providers/azure/inventory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.default_manager_name

def self.parser_classes_for(ems, target)
case target
when ManagerRefresh::TargetCollection
when InventoryRefresh::TargetCollection
[ManageIQ::Providers::Azure::Inventory::Parser::CloudManager,
ManageIQ::Providers::Azure::Inventory::Parser::NetworkManager]
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def cloud_networks

manager.orchestration_stacks_resources.find_each do |resource|
persister.stack_resources_secondary_index[resource[:ems_ref].downcase] ||=
ManagerRefresh::ApplicationRecordReference.new(OrchestrationStack, resource.stack_id)
InventoryRefresh::ApplicationRecordReference.new(OrchestrationStack, resource.stack_id)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,88 +897,88 @@ def assert_stack_and_vm_targeted_refresh

def network_port_target
network_port_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test4/providers/Microsoft.Network/networkInterfaces/miqazure-linux-manag944"
ManagerRefresh::Target.new(:manager => @ems,
:association => :network_ports,
:manager_ref => {:ems_ref => network_port_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :network_ports,
:manager_ref => {:ems_ref => network_port_id})
end

def non_existent_network_port_target
network_port_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test4/providers/Microsoft.Network/networkInterfaces/non_existent"
ManagerRefresh::Target.new(:manager => @ems,
:association => :network_ports,
:manager_ref => {:ems_ref => network_port_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :network_ports,
:manager_ref => {:ems_ref => network_port_id})
end

def cloud_network_target
cloud_network_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test2/providers/Microsoft.Network/virtualNetworks/miq-azure-test2"
ManagerRefresh::Target.new(:manager => @ems,
:association => :cloud_networks,
:manager_ref => {:ems_ref => cloud_network_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :cloud_networks,
:manager_ref => {:ems_ref => cloud_network_id})
end

def non_existent_cloud_network_target
cloud_network_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test2/providers/Microsoft.Network/virtualNetworks/non_existent"
ManagerRefresh::Target.new(:manager => @ems,
:association => :cloud_networks,
:manager_ref => {:ems_ref => cloud_network_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :cloud_networks,
:manager_ref => {:ems_ref => cloud_network_id})
end

def security_group_target
security_group_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test4/providers/Microsoft.Network/networkSecurityGroups/miqazure-linux-managed-nsg"
ManagerRefresh::Target.new(:manager => @ems,
:association => :security_groups,
:manager_ref => {:ems_ref => security_group_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :security_groups,
:manager_ref => {:ems_ref => security_group_id})
end

def non_existent_security_group_target
security_group_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test4/providers/Microsoft.Network/networkSecurityGroups/non_existent"
ManagerRefresh::Target.new(:manager => @ems,
:association => :security_groups,
:manager_ref => {:ems_ref => security_group_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :security_groups,
:manager_ref => {:ems_ref => security_group_id})
end

def floating_ip_target
floating_ip_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test1/providers/Microsoft.Network/publicIPAddresses/spec0deply1ip"
ManagerRefresh::Target.new(:manager => @ems,
:association => :floating_ips,
:manager_ref => {:ems_ref => floating_ip_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :floating_ips,
:manager_ref => {:ems_ref => floating_ip_id})
end

def non_existent_floating_ip_target
floating_ip_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test1/providers/Microsoft.Network/publicIPAddresses/non_existent"
ManagerRefresh::Target.new(:manager => @ems,
:association => :floating_ips,
:manager_ref => {:ems_ref => floating_ip_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :floating_ips,
:manager_ref => {:ems_ref => floating_ip_id})
end

def resource_group_target
resource_group_id = "/subscriptions/#{@ems.subscription}/resourcegroups/miq-azure-test1"
ManagerRefresh::Target.new(:manager => @ems,
:association => :resource_groups,
:manager_ref => {:ems_ref => resource_group_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :resource_groups,
:manager_ref => {:ems_ref => resource_group_id})
end

def non_existent_resource_group_target
resource_group_id = "/subscriptions/#{@ems.subscription}/resourcegroups/miq-azure-test4"
ManagerRefresh::Target.new(:manager => @ems,
:association => :resource_groups,
:manager_ref => {:ems_ref => resource_group_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :resource_groups,
:manager_ref => {:ems_ref => resource_group_id})
end

def lb_non_stack_target
lb_resource_id = "/subscriptions/#{@ems.subscription}/"\
"resourceGroups/miq-azure-test1/providers/Microsoft.Network/loadBalancers/rspec-lb1"
ManagerRefresh::Target.new(:manager => @ems,
:association => :load_balancers,
:manager_ref => {:ems_ref => lb_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :load_balancers,
:manager_ref => {:ems_ref => lb_resource_id})
end

def lb_non_stack_target2
lb_resource_id2 = "/subscriptions/#{@ems.subscription}/"\
"resourceGroups/miq-azure-test1/providers/Microsoft.Network/loadBalancers/rspec-lb2"
ManagerRefresh::Target.new(:manager => @ems,
:association => :load_balancers,
:manager_ref => {:ems_ref => lb_resource_id2})
InventoryRefresh::Target.new(:manager => @ems,
:association => :load_balancers,
:manager_ref => {:ems_ref => lb_resource_id2})
end

def lbs_targets
Expand All @@ -987,124 +987,124 @@ def lbs_targets

def lbs_vms_targets
vm_resource_id1 = "#{@ems.subscription}/miq-azure-test1/microsoft.compute/virtualmachines/rspec-lb-a"
vm_target1 = ManagerRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id1})
vm_target1 = InventoryRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id1})

vm_resource_id2 = "#{@ems.subscription}/miq-azure-test1/microsoft.compute/virtualmachines/rspec-lb-b"
vm_target2 = ManagerRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id2})
vm_target2 = InventoryRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id2})
[vm_target1, vm_target2]
end

def vm_powered_on_target
vm_resource_id = "#{@ems.subscription}/#{@resource_group}/microsoft.compute/virtualmachines/#{@device_name}"

ManagerRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id})
end

def vm_powered_off_target
vm_resource_id = "#{@ems.subscription}/#{@resource_group}/microsoft.compute/virtualmachines/#{@vm_powered_off}"

ManagerRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id})
end

def vm_with_managed_disk_target
vm_resource_id = "#{@ems.subscription}/#{@resource_group_managed_vm}/microsoft.compute/virtualmachines/#{@managed_vm}"

ManagerRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id})
end

def non_existent_vm_target
vm_resource_id = "#{@ems.subscription}/#{@resource_group_managed_vm}/microsoft.compute/virtualmachines/non_existent_vm_that_does_not_exist"

ManagerRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id})
end

def parent_orchestration_stack_target
stack_resource_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test1/providers/Microsoft.Resources/deployments/spec-deployment-dont-delete"

ManagerRefresh::Target.new(:manager => @ems,
:association => :orchestration_stacks,
:manager_ref => {:ems_ref => stack_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :orchestration_stacks,
:manager_ref => {:ems_ref => stack_resource_id})
end

def non_existent_orchestration_stack_target
stack_resource_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test1/providers/Microsoft.Resources/deployments/non_existent"

ManagerRefresh::Target.new(:manager => @ems,
:association => :orchestration_stacks,
:manager_ref => {:ems_ref => stack_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :orchestration_stacks,
:manager_ref => {:ems_ref => stack_resource_id})
end

def child_orchestration_stack_vm_target
vm_resource_id = "#{@ems.subscription}/miq-azure-test1/microsoft.compute/virtualmachines/spec0deply1vm0"
ManagerRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id})
end

def child_orchestration_stack_vm_target2
vm_resource_id2 = "#{@ems.subscription}/miq-azure-test1/microsoft.compute/virtualmachines/spec0deply1vm1"
ManagerRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id2})
InventoryRefresh::Target.new(:manager => @ems,
:association => :vms,
:manager_ref => {:ems_ref => vm_resource_id2})
end

def lb_target
lb_resource_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test1/providers/Microsoft.Network/loadBalancers/spec0deply1lb"
ManagerRefresh::Target.new(:manager => @ems,
:association => :load_balancers,
:manager_ref => {:ems_ref => lb_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :load_balancers,
:manager_ref => {:ems_ref => lb_resource_id})
end

def non_existent_lb_target
lb_resource_id = "/subscriptions/#{@ems.subscription}/resourceGroups/miq-azure-test1/providers/Microsoft.Network/loadBalancers/non_existent_lb"
ManagerRefresh::Target.new(:manager => @ems,
:association => :load_balancers,
:manager_ref => {:ems_ref => lb_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :load_balancers,
:manager_ref => {:ems_ref => lb_resource_id})
end

def template_target
template_resource_id = "https://miqazuretest14047.blob.core.windows.net/system/"\
"Microsoft.Compute/Images/miq-test-container/"\
"test-win2k12-img-osDisk.e17a95b0-f4fb-4196-93c5-0c8be7d5c536.vhd"

ManagerRefresh::Target.new(:manager => @ems,
:association => :miq_templates,
:manager_ref => {:ems_ref => template_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :miq_templates,
:manager_ref => {:ems_ref => template_resource_id})
end

def non_existent_template_target
template_resource_id = "https://miqazuretest14047.blob.core.windows.net/system/"\
"Microsoft.Compute/Images/miq-test-container/"\
"non_existent_template.vhd"

ManagerRefresh::Target.new(:manager => @ems,
:association => :miq_templates,
:manager_ref => {:ems_ref => template_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :miq_templates,
:manager_ref => {:ems_ref => template_resource_id})
end

def flavor_target
flavor_resource_id = "basic_a0"
ManagerRefresh::Target.new(:manager => @ems,
:association => :flavors,
:manager_ref => {:ems_ref => flavor_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :flavors,
:manager_ref => {:ems_ref => flavor_resource_id})
end

def non_existent_flavor_target
flavor_resource_id = "non_existent"
ManagerRefresh::Target.new(:manager => @ems,
:association => :flavors,
:manager_ref => {:ems_ref => flavor_resource_id})
InventoryRefresh::Target.new(:manager => @ems,
:association => :flavors,
:manager_ref => {:ems_ref => flavor_resource_id})
end
end

0 comments on commit 7b92a1f

Please sign in to comment.