Skip to content

Commit

Permalink
Merge branch 'master' into issue_16739
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u authored Jan 10, 2018
2 parents 7ca8d0c + a20c47e commit 648bd83
Show file tree
Hide file tree
Showing 53 changed files with 287 additions and 312 deletions.
37 changes: 9 additions & 28 deletions .rubocop_local.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,33 @@
AllCops:
Exclude:
- lib/generators/provider/templates/**/*
- db/schema.rb
GlobalVars:
AllowedVariables:
# Loggers
- $audit_log
- $api_log
- $audit_log
- $aws_log
- $azure_log
- $cn_monitoring_log
- $container_log
- $datawarehouse_log
- $fog_log
- $kube_log
- $lenovo_log
- $log
- $miq_ae_logger
- $mw_log
- $policy_log
- $rails_log
- $rhevm_log
- $kube_log
- $mw_log
- $cn_monitoring_log
- $scvmm_log
- $vcloud_log
- $vim_log
- $websocket_log
- $vcloud_log
# In Automate methods
- $evm
#
# Special Exclusions
#
AllCops:
TargetRubyVersion: 2.2
Exclude:
- lib/generators/provider/templates/**/*
- db/schema.rb
- vendor/**/*
ClassAndModuleCamelCase:
Exclude:
- lib/miq_automation_engine/service_models/*.rb
FileName:
Exclude:
- lib/miq_automation_engine/service_models/*.rb
Metrics/LineLength:
Exclude:
- Gemfile
Rails/Exit:
Exclude:
- lib/workers/bin/*
Rails/Output:
Exclude:
- lib/workers/bin/*
Style/ExtraSpacing:
Exclude:
- Gemfile
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ unless ENV["APPLIANCE"]
group :development do
gem "foreman"
gem "haml_lint", "~>0.20.0", :require => false
gem "rubocop", "~>0.49.0", :require => false
gem "rubocop", "~>0.52.1", :require => false
# ruby_parser is required for i18n string extraction
gem "ruby_parser", :require => false
gem "scss_lint", "~>0.48.0", :require => false
Expand Down
4 changes: 2 additions & 2 deletions app/models/dialog_field_sorted_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ def determine_selected_default_value

def raw_values
@raw_values ||= dynamic ? values_from_automate : static_raw_values
reject_extranneous_nil_values unless dynamic?
reject_extraneous_nil_values unless dynamic?
@raw_values = sort_data(@raw_values)
add_nil_option unless dynamic?
determine_selected_default_value
@raw_values
end

def reject_extranneous_nil_values
def reject_extraneous_nil_values
@raw_values = @raw_values.reject { |value| value[0].nil? }
end

Expand Down
28 changes: 20 additions & 8 deletions app/models/manageiq/providers/cloud_manager/provision_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ def allowed_availability_zones(_options = {})
targets.each_with_object({}) { |az, h| h[az.id] = az.name }
end

def allowed_cloud_networks(_options = {})
return {} unless (src_obj = provider_or_tenant_object)

src_obj.all_cloud_networks.each_with_object({}) do |cn, hash|
hash[cn.id] = cn.cidr.blank? ? cn.name : "#{cn.name} (#{cn.cidr})"
end
end

def allowed_cloud_subnets(_options = {})
src = resources_for_ui
return {} if src[:cloud_network_id].nil?
Expand All @@ -33,6 +25,12 @@ def allowed_cloud_subnets(_options = {})
end
end

def allowed_cloud_networks(_options = {})
source = load_ar_obj(get_source_vm)
targets = get_targets_for_source(source, :cloud_filter, CloudNetwork, 'cloud_network_id')
allowed_ci(:cloud_network, [:availability_zone], targets.map(&:id))
end

def allowed_guest_access_key_pairs(_options = {})
source = load_ar_obj(get_source_vm)
targets = get_targets_for_ems(source, :cloud_filter, ManageIQ::Providers, 'key_pairs')
Expand Down Expand Up @@ -90,6 +88,20 @@ def allowed_ci(ci, relats, filtered_ids = nil)
super(ci, relats, sources, filtered_ids)
end

def availability_zone_to_cloud_network(src)
if src[:availability_zone]
load_ar_obj(src[:availability_zone]).cloud_subnets.each_with_object({}) do |cs, hash|
cn = cs.cloud_network
hash[cn.id] = cn.name
end
else
return {} unless load_ar_obj(src[:ems]).cloud_subnets
load_ar_obj(src[:ems]).cloud_subnets.collect(&:cloud_network).each_with_object({}) do |cn, hash|
hash[cn.id] = cn.name
end
end
end

def get_source_and_targets(refresh = false)
return @target_resource if @target_resource && refresh == false
result = super
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,45 +281,64 @@ def hosts(extra_attributes = {})
:builder_params => {
:ems_id => ->(persister) { persister.manager.id },
},
:custom_reconnect_block => reconnect_block
:custom_reconnect_block => lambda do |inventory_collection, inventory_objects_index, attributes_index|
relation = inventory_collection.model_class.where(:ems_id => nil)

return if relation.count <= 0

inventory_objects_index.each_slice(100) do |batch|
relation.where(inventory_collection.manager_ref.first => batch.map(&:first)).each do |record|
index = inventory_collection.object_index_with_keys(inventory_collection.manager_ref_to_cols, record)

# We need to delete the record from the inventory_objects_index and attributes_index, otherwise it
# would be sent for create.
inventory_object = inventory_objects_index.delete(index)
hash = attributes_index.delete(index)

record.assign_attributes(hash.except(:id, :type))
if !inventory_collection.check_changed? || record.changed?
record.save!
inventory_collection.store_updated_records(record)
end

inventory_object.id = record.id
end
end
end
}

attributes.merge!(extra_attributes)
end

def vms(extra_attributes = {})
attributes = {
:custom_reconnect_block => reconnect_block
}
:custom_reconnect_block => lambda do |inventory_collection, inventory_objects_index, attributes_index|
relation = inventory_collection.model_class.where(:ems_id => nil)

super(attributes.merge!(extra_attributes))
end
return if relation.count <= 0

def reconnect_block
lambda do |inventory_collection, inventory_objects_index, attributes_index|
relation = inventory_collection.model_class.where(:ems_id => nil)
inventory_objects_index.each_slice(100) do |batch|
relation.where(inventory_collection.manager_ref.first => batch.map(&:first)).each do |record|
index = inventory_collection.object_index_with_keys(inventory_collection.manager_ref_to_cols, record)

return if relation.count <= 0
# We need to delete the record from the inventory_objects_index and attributes_index, otherwise it
# would be sent for create.
inventory_object = inventory_objects_index.delete(index)
hash = attributes_index.delete(index)

inventory_objects_index.each_slice(100) do |batch|
relation.where(inventory_collection.manager_ref.first => batch.map(&:first)).each do |record|
index = inventory_collection.object_index_with_keys(inventory_collection.manager_ref_to_cols, record)
record.assign_attributes(hash.except(:id, :type))
if !inventory_collection.check_changed? || record.changed?
record.save!
inventory_collection.store_updated_records(record)
end

# We need to delete the record from the inventory_objects_index and attributes_index, otherwise it
# would be sent for create.
inventory_object = inventory_objects_index.delete(index)
hash = attributes_index.delete(index)

record.assign_attributes(hash.except(:id, :type))
if !inventory_collection.check_changed? || record.changed?
record.save!
inventory_collection.store_updated_records(record)
inventory_object.id = record.id
end

inventory_object.id = record.id
end
end
end
}

super(attributes.merge!(extra_attributes))
end

def host_storages(extra_attributes = {})
Expand Down
28 changes: 14 additions & 14 deletions app/models/miq_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ class MiqAction < ApplicationRecord

silence_warnings do
const_set("TYPES",
"create_snapshot" => "Create a Snapshot",
"email" => "Send an E-mail",
"snmp_trap" => "Send an SNMP Trap",
"tag" => "Tag",
"reconfigure_memory" => "Reconfigure Memory",
"reconfigure_cpus" => "Reconfigure CPUs",
"custom_automation" => "Invoke a Custom Automation",
"evaluate_alerts" => "Evaluate Alerts",
"assign_scan_profile" => "Assign Profile to Analysis Task",
"set_custom_attribute" => "Set a Custom Attribute in vCenter",
"inherit_parent_tags" => "Inherit Parent Tags",
"remove_tags" => "Remove Tags",
"delete_snapshots_by_age" => "Delete Snapshots by Age",
"run_ansible_playbook" => "Run Ansible Playbook"
"create_snapshot" => N_("Create a Snapshot"),
"email" => N_("Send an E-mail"),
"snmp_trap" => N_("Send an SNMP Trap"),
"tag" => N_("Tag"),
"reconfigure_memory" => N_("Reconfigure Memory"),
"reconfigure_cpus" => N_("Reconfigure CPUs"),
"custom_automation" => N_("Invoke a Custom Automation"),
"evaluate_alerts" => N_("Evaluate Alerts"),
"assign_scan_profile" => N_("Assign Profile to Analysis Task"),
"set_custom_attribute" => N_("Set a Custom Attribute in vCenter"),
"inherit_parent_tags" => N_("Inherit Parent Tags"),
"remove_tags" => N_("Remove Tags"),
"delete_snapshots_by_age" => N_("Delete Snapshots by Age"),
"run_ansible_playbook" => N_("Run Ansible Playbook")
)
end

Expand Down
1 change: 1 addition & 0 deletions app/models/miq_provision_virt_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def set_on_vm_id_changed
f[:notes] = vm_description
when :vlan
get_field(:vlan)
vlan ||= @values[fn].first
set_value_from_list(fn, f, vlan, allowed_vlans)
end
end
Expand Down
1 change: 1 addition & 0 deletions app/models/mixins/miq_provision_quota_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def vm_quota_values(pr, result)
end

def service_quota_values(request, result)
return unless request.service_template
request.service_template.service_resources.each do |sr|
if request.service_template.service_type == 'composite'
bundle_quota_values(sr, result)
Expand Down
1 change: 1 addition & 0 deletions app/models/mixins/supports_feature_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module SupportsFeatureMixin
:reboot_guest => 'Reboot Guest Operation',
:reconfigure => 'Reconfiguration',
:reconfigure_disks => 'Reconfigure Virtual Machines Disks',
:reconfigure_disksize => 'Reconfigure Virtual Machines Disk Size',
:refresh_network_interfaces => 'Refresh Network Interfaces for a Host',
:refresh_new_target => 'Refresh non-existing record',
:regions => 'Regions of a Provider',
Expand Down
1 change: 1 addition & 0 deletions app/models/vm_reconfigure_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def self.get_description(req_obj)
new_settings << "Total Processors: #{req_obj.options[:number_of_cpus].to_i}" unless req_obj.options[:number_of_cpus].blank?
new_settings << "Add Disks: #{req_obj.options[:disk_add].length}" unless req_obj.options[:disk_add].blank?
new_settings << "Remove Disks: #{req_obj.options[:disk_remove].length}" unless req_obj.options[:disk_remove].blank?
new_settings << "Resize Disks: #{req_obj.options[:disk_resize].length}" unless req_obj.options[:disk_resize].blank?
"#{request_class::TASK_DESCRIPTION} for: #{name} - #{new_settings.join(", ")}"
end

Expand Down
26 changes: 26 additions & 0 deletions config/locale_task_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
yaml_strings_to_extract:
db/fixtures/miq_product_features.*:
- name
- description
db/fixtures/miq_report_formats.*:
- description
db/fixtures/notification_types.*:
- message
product/charts/layouts/*.yaml:
- title
product/charts/layouts/*/*.yaml:
- title
product/compare/*.yaml:
- headers
- group
- menu_name
- title
product/reports/*/*.*:
- headers
- menu_name
- title
product/timelines/miq_reports/*.*:
- title
- name
- headers
Loading

0 comments on commit 648bd83

Please sign in to comment.