From c5efc2aa1b25e1310d676ddd01a49a328ba5b15a Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Tue, 3 Jan 2017 17:46:15 +0100 Subject: [PATCH] Rename dto to inventory Rename dto to inventory --- ....rb => refresh_parser_inventory_object.rb} | 108 +++++++++--------- .../amazon/cloud_manager/refresher.rb | 4 +- ....rb => refresh_parser_inventory_object.rb} | 82 ++++++------- .../amazon/network_manager/refresher.rb | 4 +- ....rb => refresher_inventory_object_spec.rb} | 26 ++--- .../cloud_manager/stubbed_refresher_spec.rb | 34 +++--- .../network_manager/stubbed_refresher_spec.rb | 6 +- .../aws_refresh_performance_cloud_manager.rb | 84 +++++++------- ...aws_refresh_performance_network_manager.rb | 44 +++---- ...dto.yml => refresher_inventory_object.yml} | 0 10 files changed, 196 insertions(+), 196 deletions(-) rename app/models/manageiq/providers/amazon/cloud_manager/{refresh_parser_dto.rb => refresh_parser_inventory_object.rb} (77%) rename app/models/manageiq/providers/amazon/network_manager/{refresh_parser_dto.rb => refresh_parser_inventory_object.rb} (83%) rename spec/models/manageiq/providers/amazon/cloud_manager/{refresher_dto_spec.rb => refresher_inventory_object_spec.rb} (58%) rename spec/vcr_cassettes/manageiq/providers/amazon/cloud_manager/{refresher_dto.yml => refresher_inventory_object.yml} (100%) diff --git a/app/models/manageiq/providers/amazon/cloud_manager/refresh_parser_dto.rb b/app/models/manageiq/providers/amazon/cloud_manager/refresh_parser_inventory_object.rb similarity index 77% rename from app/models/manageiq/providers/amazon/cloud_manager/refresh_parser_dto.rb rename to app/models/manageiq/providers/amazon/cloud_manager/refresh_parser_inventory_object.rb index 76602ac2e..cf059100a 100644 --- a/app/models/manageiq/providers/amazon/cloud_manager/refresh_parser_dto.rb +++ b/app/models/manageiq/providers/amazon/cloud_manager/refresh_parser_inventory_object.rb @@ -1,6 +1,6 @@ # TODO: Separate collection from parsing (perhaps collecting in parallel a la RHEVM) -class ManageIQ::Providers::Amazon::CloudManager::RefreshParserDto < ManageIQ::Providers::CloudManager::RefreshParserDto +class ManageIQ::Providers::Amazon::CloudManager::RefreshParserInventoryObject < ManageIQ::Providers::CloudManager::RefreshParserInventoryObject include ManageIQ::Providers::Amazon::RefreshHelperMethods def initialize(ems, options = Config::Options.new) @@ -10,50 +10,50 @@ def initialize(ems, options = Config::Options.new) @aws_cloud_formation = ems.connect(:service => :CloudFormation) @known_flavors = Set.new - initialize_dto_collections - end - - def initialize_dto_collections - add_dto_collection(ManageIQ::Providers::Amazon::CloudManager::Vm, - :vms) - add_dto_collection(ManageIQ::Providers::Amazon::CloudManager::Template, - :miq_templates) - add_dto_collection(Hardware, - :hardwares, - [:vm_or_template]) - add_dto_collection(Network, - :networks, - [:hardware, :description]) - add_dto_collection(Disk, - :disks, - [:hardware, :device_name]) - add_dto_collection(ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack, - :orchestration_stacks) - add_dto_collection(ManageIQ::Providers::Amazon::CloudManager::AvailabilityZone, - :availability_zones) - add_dto_collection(ManageIQ::Providers::Amazon::CloudManager::Flavor, - :flavors) - add_dto_collection(ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack, - :orchestration_stacks) - add_dto_collection(OrchestrationStackOutput, - :orchestration_stacks_outputs) - add_dto_collection(OrchestrationStackParameter, - :orchestration_stacks_parameters) - add_dto_collection(OrchestrationStackResource, - :orchestration_stacks_resources) - add_dto_collection(ManageIQ::Providers::Amazon::CloudManager::AuthKeyPair, - :key_pairs, - [:name]) + initialize_inventory_collections + end + + def initialize_inventory_collections + add_inventory_collection(ManageIQ::Providers::Amazon::CloudManager::Vm, + :vms) + add_inventory_collection(ManageIQ::Providers::Amazon::CloudManager::Template, + :miq_templates) + add_inventory_collection(Hardware, + :hardwares, + [:vm_or_template]) + add_inventory_collection(Network, + :networks, + [:hardware, :description]) + add_inventory_collection(Disk, + :disks, + [:hardware, :device_name]) + add_inventory_collection(ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack, + :orchestration_stacks) + add_inventory_collection(ManageIQ::Providers::Amazon::CloudManager::AvailabilityZone, + :availability_zones) + add_inventory_collection(ManageIQ::Providers::Amazon::CloudManager::Flavor, + :flavors) + add_inventory_collection(ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack, + :orchestration_stacks) + add_inventory_collection(OrchestrationStackOutput, + :orchestration_stacks_outputs) + add_inventory_collection(OrchestrationStackParameter, + :orchestration_stacks_parameters) + add_inventory_collection(OrchestrationStackResource, + :orchestration_stacks_resources) + add_inventory_collection(ManageIQ::Providers::Amazon::CloudManager::AuthKeyPair, + :key_pairs, + [:name]) # TODO(lsmola) do refactoring, we shouldn't need this custom saving block - orchestration_template_save_block = lambda do |_ems, dto_collection| - hashes = dto_collection.data.map(&:attributes) + orchestration_template_save_block = lambda do |_ems, inventory_collection| + hashes = inventory_collection.data.map(&:attributes) templates = OrchestrationTemplate.find_or_create_by_contents(hashes) - dto_collection.data.zip(templates).each { |dto, template| dto.object = template } + inventory_collection.data.zip(templates).each { |inventory_object, template| inventory_object.object = template } end - @data[:orchestration_templates] = ::ManagerRefresh::DtoCollection.new( + @data[:orchestration_templates] = ::ManagerRefresh::InventoryCollection.new( OrchestrationTemplateCfn, :parent => @ems, :association => :orchestration_templates, @@ -81,17 +81,17 @@ def ems_inv_to_hashes private def get_flavors - process_dto_collection(ManageIQ::Providers::Amazon::InstanceTypes.all, :flavors) { |flavor| parse_flavor(flavor) } + process_inventory_collection(ManageIQ::Providers::Amazon::InstanceTypes.all, :flavors) { |flavor| parse_flavor(flavor) } end def get_availability_zones azs = @aws_ec2.client.describe_availability_zones[:availability_zones] - process_dto_collection(azs, :availability_zones) { |az| parse_availability_zone(az) } + process_inventory_collection(azs, :availability_zones) { |az| parse_availability_zone(az) } end def get_key_pairs kps = @aws_ec2.client.describe_key_pairs[:key_pairs] - process_dto_collection(kps, :key_pairs) { |kp| parse_key_pair(kp) } + process_inventory_collection(kps, :key_pairs) { |kp| parse_key_pair(kp) } end def get_private_images @@ -116,7 +116,7 @@ def get_public_images end def get_images(images, is_public = false) - process_dto_collection(images, :miq_templates) do |image| + process_inventory_collection(images, :miq_templates) do |image| get_image_hardware(image) parse_image(image, is_public) @@ -124,12 +124,12 @@ def get_images(images, is_public = false) end def get_image_hardware(image) - process_dto_collection([image], :hardwares) { |img| parse_image_hardware(img) } + process_inventory_collection([image], :hardwares) { |img| parse_image_hardware(img) } end def get_stacks stacks = @aws_cloud_formation.stacks - process_dto_collection(stacks, :orchestration_stacks) do |stack| + process_inventory_collection(stacks, :orchestration_stacks) do |stack| get_stack_resources(stack) get_stack_outputs(stack) get_stack_parameters(stack) @@ -142,7 +142,7 @@ def get_stacks def get_stack_parameters(stack) parameters = stack.parameters - process_dto_collection(parameters, :orchestration_stacks_parameters) do |parameter| + process_inventory_collection(parameters, :orchestration_stacks_parameters) do |parameter| parse_stack_parameter(parameter, stack) end end @@ -150,7 +150,7 @@ def get_stack_parameters(stack) def get_stack_outputs(stack) outputs = stack.outputs - process_dto_collection(outputs, :orchestration_stacks_outputs) do |output| + process_inventory_collection(outputs, :orchestration_stacks_outputs) do |output| parse_stack_output(output, stack) end end @@ -161,18 +161,18 @@ def get_stack_resources(stack) # physical_resource_id can be empty if the resource was not successfully created; ignore such resources.reject! { |r| r.physical_resource_id.nil? } - process_dto_collection(resources, :orchestration_stacks_resources) do |resource| + process_inventory_collection(resources, :orchestration_stacks_resources) do |resource| parse_stack_resource(resource, stack) end end def get_stack_template(stack) - process_dto_collection([stack], :orchestration_templates) { |the_stack| parse_stack_template(the_stack) } + process_inventory_collection([stack], :orchestration_templates) { |the_stack| parse_stack_template(the_stack) } end def get_instances instances = @aws_ec2.instances - process_dto_collection(instances, :vms) do |instance| + process_inventory_collection(instances, :vms) do |instance| # TODO(lsmola) we have a non lazy dependency, can we remove that? flavor = @data[:flavors].find(instance.instance_type) || @data[:flavors].find("unknown") @@ -183,7 +183,7 @@ def get_instances end def get_instance_hardware(instance, flavor) - process_dto_collection([instance], :hardwares) do |i| + process_inventory_collection([instance], :hardwares) do |i| get_hardware_networks(i) get_hardware_disks(i, flavor) @@ -192,8 +192,8 @@ def get_instance_hardware(instance, flavor) end def get_hardware_networks(instance) - process_dto_collection([instance], :networks) { |i| parse_hardware_private_network(i) } - process_dto_collection([instance], :networks) { |i| parse_hardware_public_network(i) } + process_inventory_collection([instance], :networks) { |i| parse_hardware_private_network(i) } + process_inventory_collection([instance], :networks) { |i| parse_hardware_public_network(i) } end def get_hardware_disks(instance, flavor) @@ -210,7 +210,7 @@ def get_hardware_disks(instance, flavor) d[:hardware] = @data[:hardwares].lazy_find(instance.id) end - process_dto_collection(disks, :disks) { |x| x } + process_inventory_collection(disks, :disks) { |x| x } end def parse_flavor(flavor) diff --git a/app/models/manageiq/providers/amazon/cloud_manager/refresher.rb b/app/models/manageiq/providers/amazon/cloud_manager/refresher.rb index 8219991bf..d5403685d 100644 --- a/app/models/manageiq/providers/amazon/cloud_manager/refresher.rb +++ b/app/models/manageiq/providers/amazon/cloud_manager/refresher.rb @@ -2,8 +2,8 @@ class ManageIQ::Providers::Amazon::CloudManager::Refresher < ManageIQ::Providers include ::EmsRefresh::Refreshers::EmsRefresherMixin def parse_legacy_inventory(ems) - if refresher_options.try(:[], :dto_refresh) - ManageIQ::Providers::Amazon::CloudManager::RefreshParserDto.ems_inv_to_hashes(ems, refresher_options) + if refresher_options.try(:[], :inventory_object_refresh) + ManageIQ::Providers::Amazon::CloudManager::RefreshParserInventoryObject.ems_inv_to_hashes(ems, refresher_options) else ManageIQ::Providers::Amazon::CloudManager::RefreshParser.ems_inv_to_hashes(ems, refresher_options) end diff --git a/app/models/manageiq/providers/amazon/network_manager/refresh_parser_dto.rb b/app/models/manageiq/providers/amazon/network_manager/refresh_parser_inventory_object.rb similarity index 83% rename from app/models/manageiq/providers/amazon/network_manager/refresh_parser_dto.rb rename to app/models/manageiq/providers/amazon/network_manager/refresh_parser_inventory_object.rb index 357d0e02d..333b69f13 100644 --- a/app/models/manageiq/providers/amazon/network_manager/refresh_parser_dto.rb +++ b/app/models/manageiq/providers/amazon/network_manager/refresh_parser_inventory_object.rb @@ -1,4 +1,4 @@ -class ManageIQ::Providers::Amazon::NetworkManager::RefreshParserDto < ::ManagerRefresh::RefreshParserDto +class ManageIQ::Providers::Amazon::NetworkManager::RefreshParserInventoryObject < ::ManagerRefresh::RefreshParserInventoryObject include ManageIQ::Providers::Amazon::RefreshHelperMethods def initialize(ems, options = nil) @@ -7,50 +7,50 @@ def initialize(ems, options = nil) @aws_ec2 = ems.connect @aws_elb = ems.connect(:service => :ElasticLoadBalancing) - initialize_dto_collections + initialize_inventory_collections end - def initialize_dto_collections - add_cloud_manager_db_cached_dto(ManageIQ::Providers::Amazon::CloudManager::Vm, + def initialize_inventory_collections + add_cloud_manager_db_cached_inventory_object(ManageIQ::Providers::Amazon::CloudManager::Vm, :vms) - add_cloud_manager_db_cached_dto(ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack, + add_cloud_manager_db_cached_inventory_object(ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack, :orchestration_stacks) - add_cloud_manager_db_cached_dto(ManageIQ::Providers::Amazon::CloudManager::AvailabilityZone, + add_cloud_manager_db_cached_inventory_object(ManageIQ::Providers::Amazon::CloudManager::AvailabilityZone, :availability_zones) - add_dto_collection(CloudSubnetNetworkPort, + add_inventory_collection(CloudSubnetNetworkPort, :cloud_subnet_network_ports, [:address, :cloud_subnet, :network_port]) - add_dto_collection(self.class.network_port_type, + add_inventory_collection(self.class.network_port_type, :network_ports) - add_dto_collection(self.class.floating_ip_type, + add_inventory_collection(self.class.floating_ip_type, :floating_ips) - add_dto_collection(self.class.cloud_subnet_type, + add_inventory_collection(self.class.cloud_subnet_type, :cloud_subnets) - add_dto_collection(self.class.cloud_network_type, + add_inventory_collection(self.class.cloud_network_type, :cloud_networks) - add_dto_collection(self.class.security_group_type, + add_inventory_collection(self.class.security_group_type, :security_groups) - add_dto_collection(FirewallRule, + add_inventory_collection(FirewallRule, :firewall_rules, [:resource, :source_security_group, :direction, :host_protocol, :port, :end_port, :source_ip_range]) - add_dto_collection(self.class.load_balancer_type, + add_inventory_collection(self.class.load_balancer_type, :load_balancers) - add_dto_collection(self.class.load_balancer_pool_type, + add_inventory_collection(self.class.load_balancer_pool_type, :load_balancer_pools) - add_dto_collection(self.class.load_balancer_pool_member_type, + add_inventory_collection(self.class.load_balancer_pool_member_type, :load_balancer_pool_members) - add_dto_collection(LoadBalancerPoolMemberPool, + add_inventory_collection(LoadBalancerPoolMemberPool, :load_balancer_pool_member_pools, [:load_balancer_pool, :load_balancer_pool_member]) - add_dto_collection(self.class.load_balancer_listener_type, + add_inventory_collection(self.class.load_balancer_listener_type, :load_balancer_listeners) - add_dto_collection(LoadBalancerListenerPool, + add_inventory_collection(LoadBalancerListenerPool, :load_balancer_listener_pools, [:load_balancer_listener, :load_balancer_pool]) - add_dto_collection(self.class.load_balancer_health_check_type, + add_inventory_collection(self.class.load_balancer_health_check_type, :load_balancer_health_checks) - add_dto_collection(LoadBalancerHealthCheckMember, + add_inventory_collection(LoadBalancerHealthCheckMember, :load_balancer_health_check_members, [:load_balancer_health_check, :load_balancer_pool_member]) end @@ -84,16 +84,16 @@ def network_ports def get_cloud_networks vpcs = @aws_ec2.client.describe_vpcs[:vpcs] - process_dto_collection(vpcs, :cloud_networks) { |vpc| parse_cloud_network(vpc) } + process_inventory_collection(vpcs, :cloud_networks) { |vpc| parse_cloud_network(vpc) } end def get_cloud_subnets cloud_subnets = @aws_ec2.client.describe_subnets[:subnets] - process_dto_collection(cloud_subnets, :cloud_subnets) { |s| parse_cloud_subnet(s) } + process_inventory_collection(cloud_subnets, :cloud_subnets) { |s| parse_cloud_subnet(s) } end def get_security_groups - process_dto_collection(security_groups, :security_groups) do |sg| + process_inventory_collection(security_groups, :security_groups) do |sg| get_outbound_firewall_rules(sg) get_inbound_firewall_rules(sg) @@ -103,18 +103,18 @@ def get_security_groups def get_inbound_firewall_rules(sg) parsed_rules = sg.ip_permissions.collect { |perm| parse_firewall_rule(perm, "inbound", sg) }.flatten - process_dto_collection(parsed_rules, :firewall_rules) { |firewall_rule| firewall_rule } + process_inventory_collection(parsed_rules, :firewall_rules) { |firewall_rule| firewall_rule } end def get_outbound_firewall_rules(sg) parsed_rules = sg.ip_permissions_egress.collect { |perm| parse_firewall_rule(perm, "outbound", sg) }.flatten - process_dto_collection(parsed_rules, :firewall_rules) { |firewall_rule| firewall_rule } + process_inventory_collection(parsed_rules, :firewall_rules) { |firewall_rule| firewall_rule } end def get_load_balancers load_balancers = @aws_elb.client.describe_load_balancers.load_balancer_descriptions - process_dto_collection(load_balancers, :load_balancers) do |lb| + process_inventory_collection(load_balancers, :load_balancers) do |lb| get_load_balancer_pools(lb) get_load_balancer_pool_members(lb) get_load_balancer_listeners(lb) @@ -125,11 +125,11 @@ def get_load_balancers end def get_load_balancer_pools(load_balancer) - process_dto_collection([load_balancer], :load_balancer_pools) { |lb| parse_load_balancer_pool(lb) } + process_inventory_collection([load_balancer], :load_balancer_pools) { |lb| parse_load_balancer_pool(lb) } end def get_load_balancer_pool_members(lb) - process_dto_collection(lb.instances, :load_balancer_pool_members) do |member| + process_inventory_collection(lb.instances, :load_balancer_pool_members) do |member| get_load_balancer_balancer_pool_member_pools(lb, member) parse_load_balancer_pool_member(member) @@ -137,7 +137,7 @@ def get_load_balancer_pool_members(lb) end def get_load_balancer_balancer_pool_member_pools(lb, member) - process_dto_collection([member], :load_balancer_pool_member_pools) do |m| + process_inventory_collection([member], :load_balancer_pool_member_pools) do |m| parse_load_balancer_pool_member_pools(lb, m) end end @@ -148,7 +148,7 @@ def listener_uid(lb, listener) end def get_load_balancer_listeners(lb) - process_dto_collection(lb.listener_descriptions, :load_balancer_listeners) do |listener| + process_inventory_collection(lb.listener_descriptions, :load_balancer_listeners) do |listener| listener = listener.listener get_load_balancer_listener_pool(listener, lb) @@ -158,13 +158,13 @@ def get_load_balancer_listeners(lb) end def get_load_balancer_listener_pool(listener, lb) - process_dto_collection([listener], :load_balancer_listener_pools) do |l| + process_inventory_collection([listener], :load_balancer_listener_pools) do |l| parse_load_balancer_listener_pool(l, lb) end end def get_load_balancer_health_checks(load_balancer) - process_dto_collection([load_balancer], :load_balancer_health_checks) do |lb| + process_inventory_collection([load_balancer], :load_balancer_health_checks) do |lb| get_load_balancer_health_check_members(lb) parse_load_balancer_health_check(lb) @@ -173,14 +173,14 @@ def get_load_balancer_health_checks(load_balancer) def get_load_balancer_health_check_members(lb) health_check_members = @aws_elb.client.describe_instance_health(:load_balancer_name => lb.load_balancer_name) - process_dto_collection(health_check_members.instance_states, :load_balancer_health_check_members) do |m| + process_inventory_collection(health_check_members.instance_states, :load_balancer_health_check_members) do |m| parse_load_balancer_health_check_member(lb, m) end end def get_floating_ips ips = @aws_ec2.client.describe_addresses.addresses - process_dto_collection(ips, :floating_ips) { |ip| parse_floating_ip(ip) } + process_inventory_collection(ips, :floating_ips) { |ip| parse_floating_ip(ip) } end def get_public_ips @@ -198,11 +198,11 @@ def get_public_ips end end end - process_dto_collection(public_ips, :floating_ips) { |public_ip| parse_public_ip(public_ip) } + process_inventory_collection(public_ips, :floating_ips) { |public_ip| parse_public_ip(public_ip) } end def get_network_ports - process_dto_collection(network_ports, :network_ports) do |n| + process_inventory_collection(network_ports, :network_ports) do |n| get_cloud_subnet_network_ports(n) parse_network_port(n) @@ -210,24 +210,24 @@ def get_network_ports end def get_cloud_subnet_network_ports(network_port) - process_dto_collection(network_port.private_ip_addresses, :cloud_subnet_network_ports) do |address| + process_inventory_collection(network_port.private_ip_addresses, :cloud_subnet_network_ports) do |address| parse_cloud_subnet_network_port(network_port, address) end end def get_ec2_floating_ips_and_ports instances = @aws_ec2.instances.select { |instance| instance.network_interfaces.blank? } - process_dto_collection(instances, :network_ports) do |instance| + process_inventory_collection(instances, :network_ports) do |instance| get_ec2_cloud_subnet_network_port(instance) parse_network_port_inferred_from_instance(instance) end - process_dto_collection(instances, :floating_ips) { |instance| parse_floating_ip_inferred_from_instance(instance) } + process_inventory_collection(instances, :floating_ips) { |instance| parse_floating_ip_inferred_from_instance(instance) } end def get_ec2_cloud_subnet_network_port(instance) # Create network_port placeholder for old EC2 instances, those do not have interface nor subnet nor VPC - process_dto_collection([instance], :cloud_subnet_network_ports) { |i| parse_ec2_cloud_subnet_network_port(i) } + process_inventory_collection([instance], :cloud_subnet_network_ports) { |i| parse_ec2_cloud_subnet_network_port(i) } end def parse_cloud_network(vpc) diff --git a/app/models/manageiq/providers/amazon/network_manager/refresher.rb b/app/models/manageiq/providers/amazon/network_manager/refresher.rb index 886cf2a4c..0af8795c4 100644 --- a/app/models/manageiq/providers/amazon/network_manager/refresher.rb +++ b/app/models/manageiq/providers/amazon/network_manager/refresher.rb @@ -3,8 +3,8 @@ class Amazon::NetworkManager::Refresher < ManageIQ::Providers::BaseManager::Refr include ::EmsRefresh::Refreshers::EmsRefresherMixin def parse_legacy_inventory(ems) - if refresher_options.try(:[], :dto_refresh) - ManageIQ::Providers::Amazon::NetworkManager::RefreshParserDto.ems_inv_to_hashes(ems, refresher_options) + if refresher_options.try(:[], :inventory_object_refresh) + ManageIQ::Providers::Amazon::NetworkManager::RefreshParserInventoryObject.ems_inv_to_hashes(ems, refresher_options) else ManageIQ::Providers::Amazon::NetworkManager::RefreshParser.ems_inv_to_hashes(ems, refresher_options) end diff --git a/spec/models/manageiq/providers/amazon/cloud_manager/refresher_dto_spec.rb b/spec/models/manageiq/providers/amazon/cloud_manager/refresher_inventory_object_spec.rb similarity index 58% rename from spec/models/manageiq/providers/amazon/cloud_manager/refresher_dto_spec.rb rename to spec/models/manageiq/providers/amazon/cloud_manager/refresher_inventory_object_spec.rb index c71ffd70d..065422965 100644 --- a/spec/models/manageiq/providers/amazon/cloud_manager/refresher_dto_spec.rb +++ b/spec/models/manageiq/providers/amazon/cloud_manager/refresher_inventory_object_spec.rb @@ -5,7 +5,7 @@ before(:each) do _guid, _server, zone = EvmSpecHelper.create_guid_miq_server_zone - @ems = FactoryGirl.create(:ems_amazon, :zone => zone) + @ems = FactoryGirl.create(:ems_amazon, :zone => zone) @ems.update_authentication(:default => {:userid => "0123456789ABCDEFGHIJ", :password => "ABCDEFGHIJKLMNO1234567890abcdefghijklmno"}) end @@ -14,26 +14,26 @@ end # Test all kinds of DTO refreshes, DTO refresh, DTO with recursive saving strategy - [{:dto_refresh => true}, - {:dto_saving_strategy => :recursive, :dto_refresh => true}, - ].each do |dto_settings| - context "with settings #{dto_settings}" do + [{:inventory_object_refresh => true}, + {:inventory_object_saving_strategy => :recursive, :inventory_object_refresh => true}, + ].each do |inventory_object_settings| + context "with settings #{inventory_object_settings}" do before(:each) do - settings = OpenStruct.new - settings.dto_batch_saving = dto_settings[:dto_batch_saving] - settings.dto_refresh = dto_settings[:dto_refresh] - settings.get_private_images = true - settings.get_shared_images = true - settings.get_public_images = false + settings = OpenStruct.new + settings.inventory_object_saving_strategy = inventory_object_settings[:inventory_object_saving_strategy] + settings.inventory_object_refresh = inventory_object_settings[:inventory_object_refresh] + settings.get_private_images = true + settings.get_shared_images = true + settings.get_public_images = false allow(Settings.ems_refresh).to receive(:ec2).and_return(settings) - allow(Settings.ems_refresh).to receive(:ec2_network).and_return(dto_settings) + allow(Settings.ems_refresh).to receive(:ec2_network).and_return(inventory_object_settings) end it "will perform a full refresh" do 2.times do # Run twice to verify that a second run with existing data does not change anything @ems.reload - VCR.use_cassette(described_class.name.underscore + '_dto') do + VCR.use_cassette(described_class.name.underscore + '_inventory_object') do EmsRefresh.refresh(@ems) EmsRefresh.refresh(@ems.network_manager) end diff --git a/spec/models/manageiq/providers/amazon/cloud_manager/stubbed_refresher_spec.rb b/spec/models/manageiq/providers/amazon/cloud_manager/stubbed_refresher_spec.rb index 6cbdd63a7..e49153392 100644 --- a/spec/models/manageiq/providers/amazon/cloud_manager/stubbed_refresher_spec.rb +++ b/spec/models/manageiq/providers/amazon/cloud_manager/stubbed_refresher_spec.rb @@ -13,28 +13,28 @@ end # Test all kinds of refreshes, DTO refresh, DTO with batch saving and the original refresh - [{:dto_refresh => true}, - {:dto_saving_strategy => :recursive, :dto_refresh => true}, - {:dto_refresh => false} - ].each do |dto_settings| - context "with settings #{dto_settings}" do + [{:inventory_object_refresh => true}, + {:inventory_object_saving_strategy => :recursive, :inventory_object_refresh => true}, + {:inventory_object_refresh => false} + ].each do |inventory_object_settings| + context "with settings #{inventory_object_settings}" do before :each do - settings = OpenStruct.new - settings.dto_refresh = dto_settings[:dto_refresh] - settings.dto_saving_strategy = dto_settings[:dto_saving_strategy] - settings.get_private_images = true - settings.get_shared_images = false - settings.get_public_images = false + settings = OpenStruct.new + settings.inventory_object_refresh = inventory_object_settings[:inventory_object_refresh] + settings.inventory_object_saving_strategy = inventory_object_settings[:inventory_object_saving_strategy] + settings.get_private_images = true + settings.get_shared_images = false + settings.get_public_images = false allow(Settings.ems_refresh).to receive(:ec2).and_return(settings) - @dto_settings = dto_settings + @inventory_object_settings = inventory_object_settings end it "2 refreshes, first creates all entities, second updates all entitites" do 2.times do # Make sure we don't do any delete&create instead of update - # TODO(lsmola) :dto_refresh => false is doing some non allowed deletes, investigate - assert_do_not_delete if @dto_settings[:dto_refresh] + # TODO(lsmola) :inventory_object_refresh => false is doing some non allowed deletes, investigate + assert_do_not_delete if @inventory_object_settings[:inventory_object_refresh] refresh_spec end @@ -54,8 +54,8 @@ @data_scaling = 1 2.times do # Make sure we don't do any delete&create instead of update - # TODO(lsmola) :dto_refresh => false is doing some non allowed deletes, investigate - assert_do_not_delete if @dto_settings[:dto_refresh] + # TODO(lsmola) :inventory_object_refresh => false is doing some non allowed deletes, investigate + assert_do_not_delete if @inventory_object_settings[:inventory_object_refresh] refresh_spec @data_scaling += 1 @@ -134,7 +134,7 @@ def expected_table_counts(disconnect = nil) :auth_private_key => test_counts[:key_pair_count], :ext_management_system => 2, # TODO(lsmola) collect all flavors for original refresh - :flavor => @dto_settings[:dto_refresh] ? 57 : 56, + :flavor => @inventory_object_settings[:inventory_object_refresh] ? 57 : 56, :availability_zone => 5, :vm_or_template => vm_count_plus_disconnect_inv + image_count_plus_disconnect_inv, :vm => vm_count_plus_disconnect_inv, diff --git a/spec/models/manageiq/providers/amazon/network_manager/stubbed_refresher_spec.rb b/spec/models/manageiq/providers/amazon/network_manager/stubbed_refresher_spec.rb index 14a97ad8d..3ee74f7e0 100644 --- a/spec/models/manageiq/providers/amazon/network_manager/stubbed_refresher_spec.rb +++ b/spec/models/manageiq/providers/amazon/network_manager/stubbed_refresher_spec.rb @@ -13,9 +13,9 @@ end # Test all kinds of refreshes, DTO refresh, DTO with batch saving and the original refresh - [{:dto_refresh => true}, - {:dto_saving_strategy => :recursive, :dto_refresh => true}, - {:dto_refresh => false} + [{:inventory_object_refresh => true}, + {:inventory_object_saving_strategy => :recursive, :inventory_object_refresh => true}, + {:inventory_object_refresh => false} ].each do |settings| context "with settings #{settings}" do before :each do diff --git a/spec/tools/refresh_performance/aws_refresh_performance_cloud_manager.rb b/spec/tools/refresh_performance/aws_refresh_performance_cloud_manager.rb index 883f125ed..71341fd4b 100644 --- a/spec/tools/refresh_performance/aws_refresh_performance_cloud_manager.rb +++ b/spec/tools/refresh_performance/aws_refresh_performance_cloud_manager.rb @@ -7,7 +7,7 @@ describe "refresh" do before(:each) do _guid, _server, zone = EvmSpecHelper.create_guid_miq_server_zone - @ems = FactoryGirl.create(:ems_amazon, :zone => zone, :name => ems_name) + @ems = FactoryGirl.create(:ems_amazon, :zone => zone, :name => ems_name) @ems.update_authentication(:default => {:userid => "0123456789", :password => "ABCDEFGHIJKL345678efghijklmno"}) end @@ -33,16 +33,16 @@ context "with data scaled for #{data_scaling}" do let(:data_scaling) { data_scaling } - context "with dto" do - let(:ems_name) { "dto_ems_scaled_#{data_scaling}x" } + context "with inventory_object" do + let(:ems_name) { "inventory_object_ems_scaled_#{data_scaling}x" } it "will perform a full refresh" do - @dto_settings = {:dto_saving_strategy => nil, :dto_refresh => true} - settings = OpenStruct.new - settings.dto_refresh = @dto_settings[:dto_refresh] - settings.dto_saving_strategy = @dto_settings[:dto_saving_strategy] - settings.get_private_images = true - settings.get_shared_images = false - settings.get_public_images = false + @inventory_object_settings = {:inventory_object_saving_strategy => nil, :inventory_object_refresh => true} + settings = OpenStruct.new + settings.inventory_object_refresh = @inventory_object_settings[:inventory_object_refresh] + settings.inventory_object_saving_strategy = @inventory_object_settings[:inventory_object_saving_strategy] + settings.get_private_images = true + settings.get_shared_images = false + settings.get_public_images = false allow(Settings.ems_refresh).to receive(:ec2).and_return(settings) @@ -50,17 +50,17 @@ end end - context "with recursive saving dto" do - let(:ems_name) { "non_bached_dto_ems_scaled_#{data_scaling}x" } + context "with recursive saving inventory_object" do + let(:ems_name) { "non_bached_inventory_object_ems_scaled_#{data_scaling}x" } it "will perform a full refresh" do - @dto_settings = {:dto_saving_strategy => :recursive, :dto_refresh => true} - settings = OpenStruct.new - settings.dto_refresh = @dto_settings[:dto_refresh] - settings.dto_saving_strategy = @dto_settings[:dto_saving_strategy] - settings.get_private_images = true - settings.get_shared_images = false - settings.get_public_images = false + @inventory_object_settings = {:inventory_object_saving_strategy => :recursive, :inventory_object_refresh => true} + settings = OpenStruct.new + settings.inventory_object_refresh = @inventory_object_settings[:inventory_object_refresh] + settings.inventory_object_saving_strategy = @inventory_object_settings[:inventory_object_saving_strategy] + settings.get_private_images = true + settings.get_shared_images = false + settings.get_public_images = false allow(Settings.ems_refresh).to receive(:ec2).and_return(settings) @@ -68,17 +68,17 @@ end end - context "with non dto" do - let(:ems_name) { "non_dto_ems_scaled_#{data_scaling}x" } + context "with non inventory_object" do + let(:ems_name) { "non_inventory_object_ems_scaled_#{data_scaling}x" } it "will perform a full refresh" do - @dto_settings = {:dto_refresh => false} - settings = OpenStruct.new - settings.dto_refresh = @dto_settings[:dto_refresh] - settings.dto_saving_strategy = @dto_settings[:dto_saving_strategy] - settings.get_private_images = true - settings.get_shared_images = false - settings.get_public_images = false + @inventory_object_settings = {:inventory_object_refresh => false} + settings = OpenStruct.new + settings.inventory_object_refresh = @inventory_object_settings[:inventory_object_refresh] + settings.inventory_object_saving_strategy = @inventory_object_settings[:inventory_object_saving_strategy] + settings.get_private_images = true + settings.get_shared_images = false + settings.get_public_images = false allow(Settings.ems_refresh).to receive(:ec2).and_return(settings) @@ -93,15 +93,15 @@ def test_counts(scaling = nil) scaling ||= scaling_factor super.merge({ - :instance_vpc_count => scaling * 8000, - :instance_ec2_count => scaling * 2000, - :image_count => scaling * 30000, - :key_pair_count => scaling * 200, - :stack_count => scaling * 800, - :stack_resource_count => scaling * 40, - :stack_parameter_count => scaling * 20, - :stack_output_count => scaling * 20, - }) + :instance_vpc_count => scaling * 8000, + :instance_ec2_count => scaling * 2000, + :image_count => scaling * 30000, + :key_pair_count => scaling * 200, + :stack_count => scaling * 800, + :stack_resource_count => scaling * 40, + :stack_parameter_count => scaling * 20, + :stack_output_count => scaling * 20, + }) end def refresh @@ -154,7 +154,7 @@ def write_benchmark_results(scaling, subname) :parse_targeted_inventory=>([\d\.e-]+).*? :save_inventory=>([\d\.e-]+).*? :ems_refresh=>([\d\.e-]+).*?/x) - output = [] + output = [] output << "#{ems_name} - #{subname}" output << expected_table_counts.values.sum output << scaling @@ -195,7 +195,7 @@ def expected_table_counts(disconnect = nil) :auth_private_key => test_counts[:key_pair_count], :ext_management_system => 2, # TODO(lsmola) collect all flavors for original refresh - :flavor => @dto_settings[:dto_refresh] ? 57 : 56, + :flavor => @inventory_object_settings[:inventory_object_refresh] ? 57 : 56, :availability_zone => 5, :vm_or_template => vm_count_plus_disconnect_inv + image_count_plus_disconnect_inv, :vm => vm_count_plus_disconnect_inv, @@ -281,9 +281,9 @@ def assert_ems ems = @ems expect(ems).to have_attributes( - :api_version => nil, # TODO: Should be 3.0 - :uid_ems => nil - ) + :api_version => nil, # TODO: Should be 3.0 + :uid_ems => nil + ) expect(ems.flavors.size).to eql(expected_table_counts[:flavor]) expect(ems.availability_zones.size).to eql(expected_table_counts[:availability_zone]) diff --git a/spec/tools/refresh_performance/aws_refresh_performance_network_manager.rb b/spec/tools/refresh_performance/aws_refresh_performance_network_manager.rb index 192051f18..8d4fe01d8 100644 --- a/spec/tools/refresh_performance/aws_refresh_performance_network_manager.rb +++ b/spec/tools/refresh_performance/aws_refresh_performance_network_manager.rb @@ -7,7 +7,7 @@ describe "refresh" do before(:each) do _guid, _server, zone = EvmSpecHelper.create_guid_miq_server_zone - @ems = FactoryGirl.create(:ems_amazon, :zone => zone, :name => ems_name) + @ems = FactoryGirl.create(:ems_amazon, :zone => zone, :name => ems_name) @ems.update_authentication(:default => {:userid => "0123456789", :password => "ABCDEFGHIJKL345678efghijklmno"}) end @@ -33,30 +33,30 @@ context "with data scaled for #{data_scaling}" do let(:data_scaling) { data_scaling } - context "with dto" do - let(:ems_name) { "dto_ems_scaled_#{data_scaling}x" } + context "with inventory_object" do + let(:ems_name) { "inventory_object_ems_scaled_#{data_scaling}x" } it "will perform a full refresh" do - allow(Settings.ems_refresh).to receive(:ec2_network).and_return({:dto_saving_strategy => nil, - :dto_refresh => true}) + allow(Settings.ems_refresh).to receive(:ec2_network).and_return({:inventory_object_saving_strategy => nil, + :inventory_object_refresh => true}) refresh end end - context "with non batched dto" do - let(:ems_name) { "non_bached_dto_ems_scaled_#{data_scaling}x" } + context "with non batched inventory_object" do + let(:ems_name) { "non_bached_inventory_object_ems_scaled_#{data_scaling}x" } it "will perform a full refresh" do - allow(Settings.ems_refresh).to receive(:ec2_network).and_return({:dto_saving_strategy => :recursive, - :dto_refresh => true}) + allow(Settings.ems_refresh).to receive(:ec2_network).and_return({:inventory_object_saving_strategy => :recursive, + :inventory_object_refresh => true}) refresh end end - context "with non dto" do - let(:ems_name) { "non_dto_ems_scaled_#{data_scaling}x" } + context "with non inventory_object" do + let(:ems_name) { "non_inventory_object_ems_scaled_#{data_scaling}x" } it "will perform a full refresh" do - allow(Settings.ems_refresh).to receive(:ec2_network).and_return({:dto_refresh => false}) + allow(Settings.ems_refresh).to receive(:ec2_network).and_return({:inventory_object_refresh => false}) refresh end end @@ -68,12 +68,12 @@ def test_counts(scaling = nil) scaling ||= scaling_factor super.merge({ - :instance_vpc_count => scaling * 2000, - :instance_ec2_count => scaling * 2000, - :load_balancer_instances_count => scaling * 2000, - :network_port_count => scaling * 3000, - :floating_ip_count => scaling * 2000, - }) + :instance_vpc_count => scaling * 2000, + :instance_ec2_count => scaling * 2000, + :load_balancer_instances_count => scaling * 2000, + :network_port_count => scaling * 3000, + :floating_ip_count => scaling * 2000, + }) end def refresh @@ -125,7 +125,7 @@ def write_benchmark_results(scaling, subname) :parse_targeted_inventory=>([\d\.e-]+).*? :save_inventory=>([\d\.e-]+).*? :ems_refresh=>([\d\.e-]+).*?/x) - output = [] + output = [] output << "#{ems_name} - #{subname}" output << expected_table_counts.values.sum output << scaling @@ -259,9 +259,9 @@ def assert_ems ems = @ems.network_manager expect(ems).to have_attributes( - :api_version => nil, # TODO: Should be 3.0 - :uid_ems => nil - ) + :api_version => nil, # TODO: Should be 3.0 + :uid_ems => nil + ) expect(ems.flavors.size).to eql(expected_table_counts[:flavor]) expect(ems.availability_zones.size).to eql(expected_table_counts[:availability_zone]) diff --git a/spec/vcr_cassettes/manageiq/providers/amazon/cloud_manager/refresher_dto.yml b/spec/vcr_cassettes/manageiq/providers/amazon/cloud_manager/refresher_inventory_object.yml similarity index 100% rename from spec/vcr_cassettes/manageiq/providers/amazon/cloud_manager/refresher_dto.yml rename to spec/vcr_cassettes/manageiq/providers/amazon/cloud_manager/refresher_inventory_object.yml