Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up the password field and value in automate and evm.log #228

Merged
merged 2 commits into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/miq_automation_engine/engine/miq_ae_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ module MiqAeEngine
DEFAULT_ATTRIBUTES = %w( User::user MiqServer::miq_server object_name )

def self.instantiate(uri, user)
$miq_ae_logger.info("MiqAeEngine: Instantiating Workspace for URI=#{uri}")
$miq_ae_logger.info("MiqAeEngine: Instantiating Workspace for URI=#{MiqPassword.sanitize_string(uri)}")
workspace, t = Benchmark.realtime_block(:total_time) { MiqAeWorkspaceRuntime.instantiate(uri, user) }
$miq_ae_logger.info("MiqAeEngine: Instantiating Workspace for URI=#{uri}...Complete - Counts: #{format_benchmark_counts(t)}, Timings: #{format_benchmark_times(t)}")
$miq_ae_logger.info("MiqAeEngine: Instantiating Workspace for URI=#{MiqPassword.sanitize_string(uri)}...Complete - Counts: #{format_benchmark_counts(t)}, Timings: #{format_benchmark_times(t)}")
workspace
end

Expand Down Expand Up @@ -78,7 +78,7 @@ def self.deliver(*args)
begin
miq_task&.state_active
object_name = "#{options[:object_type]}.#{options[:object_id]}"
_log.info("Delivering #{options[:attrs].inspect} for object [#{object_name}] with state [#{state}] to Automate")
_log.info("Delivering #{MiqPassword.sanitize_string(options[:attrs].inspect)} for object [#{object_name}] with state [#{state}] to Automate")
automate_attrs = automate_attrs_from_options(options)

if options[:object_type]
Expand All @@ -92,7 +92,7 @@ def self.deliver(*args)
ws = resolve_automation_object(uri, user_obj)

if ws.nil? || ws.root.nil?
message = "Error delivering #{options[:attrs].inspect} for object [#{object_name}] with state [#{state}] to Automate: Empty Workspace"
message = "Error delivering #{MiqPassword.sanitize_string(options[:attrs].inspect)} for object [#{object_name}] with state [#{state}] to Automate: Empty Workspace"
_log.error(message)
return nil
end
Expand All @@ -105,7 +105,7 @@ def self.deliver(*args)
deliver_on = Time.now.utc + ae_retry_interval
change_options_by_ws(options, ws)

message = "Requeuing #{options.inspect} for object [#{object_name}] with state [#{options[:state]}] to Automate for delivery in [#{ae_retry_interval}] seconds"
message = "Requeuing #{MiqPassword.sanitize_string(options.inspect)} for object [#{object_name}] with state [#{options[:state]}] to Automate for delivery in [#{ae_retry_interval}] seconds"
_log.info(message)
queue_options = {:deliver_on => deliver_on}
queue_options[:server_guid] = MiqServer.my_guid if ws.root['ae_retry_server_affinity']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def find_first_fq_domain(uri, ns, klass, instance, method)
if matching_domain
parts[0] = matching_domain
updated_ns = parts.join('/')
$miq_ae_logger.info("Updated namespace [#{uri} #{updated_ns}]")
$miq_ae_logger.info("Updated namespace [#{MiqPassword.sanitize_string(uri)} #{updated_ns}]")
end
updated_ns
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def process_args_attribute(args, args_key)
if args_key.include?(CLASS_SEPARATOR)
key, klass = get_key_name_and_klass_from_key(args_key)
value = args.delete(args_key)
args["#{key}_id"] = value unless @attributes.key?(key)
args["#{key}_id"] = value if attribute_for_vmdb_object?(klass, value) && !@attributes.key?(key)
args[key] = MiqAeObject.convert_value_based_on_datatype(value, klass)
else
args[args_key.downcase] = args.delete(args_key) if args_key != args_key.downcase
Expand Down Expand Up @@ -854,5 +854,9 @@ def classify_value(value)
return self[value]
end
end

def attribute_for_vmdb_object?(klass, value)
klass.safe_constantize && value.to_i.nonzero?
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def varset(uri, value)
end

def instantiate(uri, user, root = nil)
$miq_ae_logger.info("Instantiating [#{uri}]") if root.nil?
$miq_ae_logger.info("Instantiating [#{MiqPassword.sanitize_string(uri)}]") if root.nil?
@ae_user = user
@dom_search.ae_user = user
scheme, userinfo, host, port, registry, path, opaque, query, fragment = MiqAeUri.split(uri, "miqaedb")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def disconnect_sql

def log(level, msg)
Thread.current["tracking_label"] = @tracking_label
$miq_ae_logger.send(level, "<AEMethod #{current_method}> #{msg}")
$miq_ae_logger.send(level, "<AEMethod #{current_method}> #{MiqPassword.sanitize_string(msg)}")
end

def set_state_var(name, value)
Expand Down