Skip to content

Commit

Permalink
Merge pull request ManageIQ#15561 from bdunne/un_seattle
Browse files Browse the repository at this point in the history
Un Seattle
  • Loading branch information
Fryguy authored Sep 6, 2017
2 parents 15556ad + 266cde6 commit 9291810
Show file tree
Hide file tree
Showing 214 changed files with 868 additions and 871 deletions.
2 changes: 1 addition & 1 deletion app/channels/notification_channel.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class NotificationChannel < ApplicationCable::Channel
def subscribed
stream_from "notifications_#{current_user.id}" if current_user
stream_from("notifications_#{current_user.id}") if current_user
end

def unsubscribed
Expand Down
16 changes: 8 additions & 8 deletions app/models/asset_tag_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def verify
objs = MiqBulkImport.find_entry_by_keys(@klass, keys)
if objs.empty?
bad += 1
_log.warn "#{@keys[0].titleize} #{line[@keys[0]]}: Unable to find a #{@klass.name}"
_log.warn("#{@keys[0].titleize} #{line[@keys[0]]}: Unable to find a #{@klass.name}")
err = "#{@klass.name.downcase}notfound".to_sym
@errors.add(err, "#{@keys[0].titleize}: #{line[@keys[0]]}: Unable to find a #{@klass.name}")
next
end
if objs.length > 1
bad += 1
err = "serveral#{@klass.name.downcase}sfound4keys".to_sym
_log.warn "#{@keys[0].titleize}: #{line[@keys[0]]}: Could not resolve a #{@klass.name}, an entry will be skipped"
_log.warn("#{@keys[0].titleize}: #{line[@keys[0]]}: Could not resolve a #{@klass.name}, an entry will be skipped")
@errors.add(err, "#{@keys[0].titleize}: #{line[@keys[0]]}: Could not resolve a #{@klass.name}, an entry will be skipped")
else
@verified_data[objs[0].id] ||= []
Expand All @@ -73,14 +73,14 @@ def verify
obj = @klass.find_by(:id => id)
while data.length > 1
data.shift
_log.warn "#{@klass.name} #{obj.name}, Multiple lines for the same object, the last line is applied"
_log.warn("#{@klass.name} #{obj.name}, Multiple lines for the same object, the last line is applied")
@errors.add(:singlevaluedassettag, "#{@klass.name}: #{obj.name}, Multiple lines for the same object, the last line is applied")
end
end
end

@stats = {:good => good, :bad => bad}
_log.info "Number of valid entries #{@stats[:good]}, number of invalid entries #{@stats[:bad]}"
_log.info("Number of valid entries #{@stats[:good]}, number of invalid entries #{@stats[:bad]}")
@stats
end

Expand All @@ -95,17 +95,17 @@ def apply
attr = attrs.detect { |ca| ca.name == key }
if attr.nil?
if value.blank?
_log.info "#{@klass.name}: #{obj.name}, Skipping tag <#{key}> due to blank value"
_log.info("#{@klass.name}: #{obj.name}, Skipping tag <#{key}> due to blank value")
else
_log.info "#{@klass.name}: #{obj.name}, Adding tag <#{key}>, value <#{value}>"
_log.info("#{@klass.name}: #{obj.name}, Adding tag <#{key}>, value <#{value}>")
new_attrs << {:name => key, :value => value, :source => 'EVM'}
end
else
if value.blank?
_log.info "#{@klass.name}: #{obj.name}, Deleting tag <#{key}> due to blank value"
_log.info("#{@klass.name}: #{obj.name}, Deleting tag <#{key}> due to blank value")
attr.delete
else
_log.info "#{@klass.name}: #{obj.name}, Updating tag <#{key}>, value <#{value}>"
_log.info("#{@klass.name}: #{obj.name}, Updating tag <#{key}>, value <#{value}>")
attr.update_attribute(:value, value)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/auth_token.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class AuthToken < Authentication
def auth_key=(val)
@auth_changed = true if val != auth_key
super val
super(val)
end
end
4 changes: 2 additions & 2 deletions app/models/auth_userid_password.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class AuthUseridPassword < Authentication
def password=(val)
@auth_changed = true if val != password
super val
super(val)
end

def userid=(val)
@auth_changed = true if val != userid
super val
super(val)
end
end
2 changes: 1 addition & 1 deletion app/models/authentication_ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ def assign_values(options)
options.each do |key, val|
hash["ldap_" + key.to_s] = val
end
super hash
super(hash)
end
end
2 changes: 1 addition & 1 deletion app/models/authenticator/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def authenticate(username, password, request = nil, options = {})
end

rescue MiqException::MiqEVMLoginError => err
_log.warn err.message
_log.warn(err.message)
raise
rescue Exception => err
_log.log_backtrace(err)
Expand Down
2 changes: 1 addition & 1 deletion app/models/authenticator/httpd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def user_attrs_from_external_directory(username)

sysbus = DBus.system_bus
ifp_service = sysbus["org.freedesktop.sssd.infopipe"]
ifp_object = ifp_service.object "/org/freedesktop/sssd/infopipe"
ifp_object = ifp_service.object("/org/freedesktop/sssd/infopipe")
ifp_object.introspect
ifp_interface = ifp_object["org.freedesktop.sssd.infopipe"]
begin
Expand Down
4 changes: 2 additions & 2 deletions app/models/automation_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AutomationRequest < MiqRequest
# parameters: var1=vvvvv|var2=wwww|var3=xxxxx
##############################################
def self.create_from_ws(version, user, uri_parts, parameters, requester)
_log.info "Starting with interface version=<#{version}> for user=<#{user.userid}> with uri_parts=<#{uri_parts.inspect}>, parameters=<#{parameters.inspect}> and requester=<#{requester.inspect}>"
_log.info("Starting with interface version=<#{version}> for user=<#{user.userid}> with uri_parts=<#{uri_parts.inspect}>, parameters=<#{parameters.inspect}> and requester=<#{requester.inspect}>")

options = {}
requester_options = MiqRequestWorkflow.parse_ws_string(requester)
Expand All @@ -22,7 +22,7 @@ def self.create_from_ws(version, user, uri_parts, parameters, requester)

uri_options = MiqRequestWorkflow.parse_ws_string(uri_parts)
[:namespace, :class, :instance, :message].each { |key| options[key] = uri_options.delete(key) if uri_options.key?(key) }
uri_options.keys.each { |key| _log.warn "invalid keyword <#{key}> specified in uri_parts" }
uri_options.keys.each { |key| _log.warn("invalid keyword <#{key}> specified in uri_parts") }
options[:namespace] = (options.delete(:namespace) || DEFAULT_NAMESPACE).strip.gsub(/(^\/|\/$)/, "") # Strip blanks and slashes from beginning and end of string
options[:class_name] = (options.delete(:class) || DEFAULT_CLASS).strip.gsub(/(^\/|\/$)/, "")
options[:instance_name] = (options.delete(:instance) || DEFAULT_INSTANCE).strip
Expand Down
2 changes: 1 addition & 1 deletion app/models/bottleneck_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def format(value, method, options = {})
end

def substitute(str)
eval "result = \"#{str}\""
eval("result = \"#{str}\"")
end

# Future event calculation methods
Expand Down
10 changes: 5 additions & 5 deletions app/models/classification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class Classification < ApplicationRecord
validates :syntax, :inclusion => {:in => %w( string integer boolean ),
:message => "should be one of 'string', 'integer' or 'boolean'"}

scope :visible, -> { where :show => true }
scope :read_only, -> { where :read_only => true }
scope :writeable, -> { where :read_only => false }
scope :visible, -> { where(:show => true) }
scope :read_only, -> { where(:read_only => true) }
scope :writeable, -> { where(:read_only => false) }

DEFAULT_NAMESPACE = "/managed"

Expand All @@ -56,7 +56,7 @@ def self.hash_all_by_type_and_name(conditions = {})
end

def self.parent_ids(parent_ids)
where :parent_id => parent_ids
where(:parent_id => parent_ids)
end

def self.tags_arel
Expand Down Expand Up @@ -376,7 +376,7 @@ def enforce_policy(obj, event)

def self.export_to_array
categories.inject([]) do |a, c|
a.concat c.export_to_array
a.concat(c.export_to_array)
end
end

Expand Down
14 changes: 7 additions & 7 deletions app/models/classification_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ def verify
vms = MiqBulkImport.find_entry_by_keys(VmOrTemplate, keys)
if vms.empty?
bad += 1
_log.warn "#{@keys[0].titleize}: #{line[@keys[0]]}: Unable to find VM"
_log.warn("#{@keys[0].titleize}: #{line[@keys[0]]}: Unable to find VM")
@errors.add(:vmnotfound, "#{@keys[0].titleize}: #{line[@keys[0]]}: Unable to find VM")
next
end
if vms.length > 1
bad += 1
_log.warn "#{@keys[0].titleize}: #{line[@keys[0]]}: Could not resolve a vm, an entry will be skipped"
_log.warn("#{@keys[0].titleize}: #{line[@keys[0]]}: Could not resolve a vm, an entry will be skipped")
@errors.add(:severalvmsfound4keys, "#{@keys[0].titleize}: #{line[@keys[0]]}: Could not resolve a vm, an entry will be skipped")
else
cat = Classification.find_by(:description => line["category"])
if cat.nil?
bad += 1
_log.warn "#{@keys[0].titleize}: #{line[@keys[0]]}: Unable to find category #{line["category"]}"
_log.warn("#{@keys[0].titleize}: #{line[@keys[0]]}: Unable to find category #{line["category"]}")
@errors.add(:categorynotfound, "#{@keys[0].titleize}: #{line[@keys[0]]}: Unable to find category #{line["category"]}")
next
end
Expand All @@ -62,7 +62,7 @@ def verify
end
if entry.nil?
bad += 1
_log.warn "#{@keys[0].titleize}: #{line[@keys[0]]}, category: #{line["category"]}: Unable to find entry #{line["entry"]})"
_log.warn("#{@keys[0].titleize}: #{line[@keys[0]]}, category: #{line["category"]}: Unable to find entry #{line["entry"]})")
@errors.add(:entrynotfound, "#{@keys[0].titleize}: #{line[@keys[0]]}, category: #{line["category"]}: Unable to find entry #{line["entry"]}")
next
end
Expand All @@ -77,14 +77,14 @@ def verify
vm = VmOrTemplate.find_by(:id => id)
while entries.length > 1
e = entries.shift
_log.warn "Vm: #{vm.name}, Location: #{vm.location}, Category: #{category}: Multiple values given for single-valued category, value #{e} will be ignored"
_log.warn("Vm: #{vm.name}, Location: #{vm.location}, Category: #{category}: Multiple values given for single-valued category, value #{e} will be ignored")
@errors.add(:singlevaluedcategory, "Vm #{vm.name}, Location: #{vm.location}, Category: #{category}: Multiple values given for single-valued category, value #{e} will be ignored")
end
end
end
end
@stats = {:good => good, :bad => bad}
_log.info "Number of valid entries: #{@stats[:good]}, number of invalid entries: #{@stats[:bad]}"
_log.info("Number of valid entries: #{@stats[:good]}, number of invalid entries: #{@stats[:bad]}")
@stats
end

Expand All @@ -98,7 +98,7 @@ def apply
entries.each do|ent|
cat.entries.each do|e|
if e.description == ent
_log.info "Vm: #{vm.name}, Location: #{vm.location}, Category: #{cat.description}: Applying entry #{ent}"
_log.info("Vm: #{vm.name}, Location: #{vm.location}, Category: #{cat.description}: Applying entry #{ent}")
e.assign_entry_to(vm)
break
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/cloud_subnet/operations.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module CloudSubnet::Operations
def self.included(base)
base.send :include, InstanceMethods
base.send(:include, InstanceMethods)
base.extend ClassMethods
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/cloud_volume/operations.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module CloudVolume::Operations
def self.included(base)
base.send :include, InstanceMethods
base.send(:include, InstanceMethods)
base.extend ClassMethods
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def perf_rollup_parents(_interval_name = nil)

def disconnect_inv
return if archived?
_log.info "Disconnecting Container [#{name}] id [#{id}] from EMS "
_log.info("Disconnecting Container [#{name}] id [#{id}] from EMS")
self.deleted_on = Time.now.utc
save
end
Expand Down
34 changes: 17 additions & 17 deletions app/models/container_deployment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def identity_provider_auth
end

def roles_addresses(role)
if role.include? "deployment_master"
extract_public_ip_or_hostname container_nodes_by_role(role).first
if role.include?("deployment_master")
extract_public_ip_or_hostname(container_nodes_by_role(role).first)
else
addresses_array(container_nodes_by_role(role))
end
Expand Down Expand Up @@ -118,17 +118,17 @@ def create_deployment(params, user)
self.method_type = params["method_type"]
create_needed_tags
if method_type.include?("existing_managed")
self.deployed_on_ems = ExtManagementSystem.find params["underline_provider_id"]
self.deployed_on_ems = ExtManagementSystem.find(params["underline_provider_id"])
elsif method_type.include?("provision")
self.deployed_on_ems = ExtManagementSystem.find params["underline_provider_id"]
self.deployed_on_ems = ExtManagementSystem.find(params["underline_provider_id"])
keys = generate_ssh_keys
public_key = keys[:public_key]
private_key = keys[:private_key]
params["ssh_authentication"]["auth_key"] = private_key.chomp
params["ssh_authentication"]["public_key"] = public_key
params["ssh_authentication"]["userid"] = "root"
end
add_deployment_master_role params["nodes"]
add_deployment_master_role(params["nodes"])
create_deployment_nodes(params["nodes"])
create_deployment_authentication(params["identity_authentication"])
create_deployment_authentication(params["ssh_authentication"].merge("type" => "AuthPrivateKey"))
Expand All @@ -141,7 +141,7 @@ def create_deployment(params, user)
def create_deployment_authentication(authentication)
auth = authentication["type"].safe_constantize.new
auth.authtype = AUTHENTICATIONS_NAMES[authentication["type"]]
auth.assign_values authentication
auth.assign_values(authentication)
authentications << auth
save!
end
Expand All @@ -154,15 +154,15 @@ def extract_public_ip_or_hostname(deployment_node)
end

def create_deployment_nodes(nodes)
work_by_vm_id = method_type.include? "existing_managed"
work_by_vm_id = method_type.include?("existing_managed")
nodes.each do |node|
container_deployment_node = ContainerDeploymentNode.new
container_deployment_node.address = node["name"] unless work_by_vm_id
container_deployment_node.vm = Vm.find(node["id"]) if work_by_vm_id
container_deployment_nodes << container_deployment_node
node["roles"].each do |key, value|
if value
container_deployment_node.tag_add key
container_deployment_node.tag_add(key)
end
end
container_deployment_node.save!
Expand Down Expand Up @@ -230,7 +230,7 @@ def identity_ansible_config_format
"requestHeaderEmailHeaders" => authentication.request_header_email_headers
}
end
{'name' => "example_name", 'login' => "true", 'challenge' => "true", 'kind' => authentication.authtype}.merge! options
{'name' => "example_name", 'login' => "true", 'challenge' => "true", 'kind' => authentication.authtype}.merge!(options)
end

private
Expand All @@ -250,15 +250,15 @@ def generate_roles
result = {}
roles = container_deployment_nodes.collect(&:roles).flatten.uniq
result["master"] = {"osm_use_cockpit" => "false",
"openshift_master_identity_providers" => [identity_ansible_config_format]} if roles.include? "master"
"openshift_master_identity_providers" => [identity_ansible_config_format]} if roles.include?("master")
unless identity_provider_auth.first.htpassd_users.empty?
result["master"]["openshift_master_htpasswd_users"] = htpasswd_hash
end
result["node"] = {} if roles.include? "node"
result["storage"] = {} if roles.include? "storage"
result["etcd"] = {} if roles.include? "etcd"
result["master_lb"] = {} if roles.include? "master_lb"
result["dns"] = {} if roles.include? "dns"
result["node"] = {} if roles.include?("node")
result["storage"] = {} if roles.include?("storage")
result["etcd"] = {} if roles.include?("etcd")
result["master_lb"] = {} if roles.include?("master_lb")
result["dns"] = {} if roles.include?("dns")
result
end

Expand All @@ -282,7 +282,7 @@ def generate_automation_params(params)
:containerized => containerized,
:rhsub_sku => rhsm_auth.rhsm_sku
}
if method_type.include? "provision"
if method_type.include?("provision")
node_template = VmOrTemplate.find(params["nodes_creation_template_id"])
master_template = VmOrTemplate.find(params["masters_creation_template_id"])
parameters_provision = {
Expand Down Expand Up @@ -336,7 +336,7 @@ def vm_fields(type, params)
options["vm_name"] = params["#{type.singularize}_base_name"]
options["vm_memory"] = params[type + "_vm_memory"] if params[type + "_vm_memory"]
options["cpu"] = params[type + "_cpu"] if params[type + "_cpu"]
if deployed_on_ems.kind_of? ManageIQ::Providers::Amazon::CloudManager
if deployed_on_ems.kind_of?(ManageIQ::Providers::Amazon::CloudManager)
options["instance_type"] = 1 || params[type + "_instance_type"]
options["placement_auto"] = true
end
Expand Down
3 changes: 1 addition & 2 deletions app/models/container_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def perf_rollup_parents(interval_name = nil)

def disconnect_inv
return if archived?
_log.info "Disconnecting Pod [#{name}] id [#{id}] from EMS [#{ext_management_system.name}]" \
"id [#{ext_management_system.id}] "
_log.info("Disconnecting Pod [#{name}] id [#{id}] from EMS [#{ext_management_system.name}] id [#{ext_management_system.id}]")
self.containers.each(&:disconnect_inv)
self.container_node_id = nil
self.container_services = []
Expand Down
2 changes: 1 addition & 1 deletion app/models/container_group_performance.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ContainerGroupPerformance < MetricRollup
default_scope { where "resource_type = 'ContainerGroup' and resource_id IS NOT NULL" }
default_scope { where("resource_type = 'ContainerGroup' and resource_id IS NOT NULL") }

belongs_to :container_group, :foreign_key => :resource_id, :class_name => ContainerGroup.name
end
3 changes: 1 addition & 2 deletions app/models/container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ def openscap_failed_rules_summary

def disconnect_inv
return if archived?
_log.info "Disconnecting Image [#{name}] id [#{id}] from EMS [#{ext_management_system.name}]" \
"id [#{ext_management_system.id}] "
_log.info("Disconnecting Image [#{name}] id [#{id}] from EMS [#{ext_management_system.name}] id [#{ext_management_system.id}]")
self.container_image_registry = nil
self.deleted_on = Time.now.utc
save
Expand Down
2 changes: 1 addition & 1 deletion app/models/container_label_tag_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def self.find_or_create_tag(tag_hash)
category = Tag.find(tag_hash[:category_tag_id]).classification
entry = category.find_entry_by_name(tag_hash[:entry_name])
unless entry
category.lock :exclusive do
category.lock(:exclusive) do
begin
entry = category.add_entry(:name => tag_hash[:entry_name],
:description => tag_hash[:entry_description])
Expand Down
Loading

0 comments on commit 9291810

Please sign in to comment.