Decrypting text box in CustomizeRequest method


#1

Greetings,

I’ve tried this code, but unfortunately it is not working. My goal is to get password from the encrypted text box and add it to the customization specification before VM deployment starts. The following code resides in vmware_CustomizeRequest method.

Renaming encrypted text box to root_password is not helping (customization not working)

$evm.log(:info, "BEGIN CUSTOM")
  
  require 'miq-password'
  
  prov.set_network_adapter("0", {:network => "#{prov.miq_provision_request.options[:dialog]['dialog_vm_vlan']}", :devicetype => "VirtualVmxnet3", :is_dvs => true }) 
  
  prov.set_option(:vm_target_name, prov.miq_provision_request.options[:dialog]['dialog_vm_vmname'])
  prov.set_option(:vm_target_hostname, prov.miq_provision_request.options[:dialog]['dialog_vm_hostname'])
  prov.set_option(:vm_name, prov.miq_provision_request.options[:dialog]['dialog_vm_vmname'])
  prov.set_option(:linux_host_name, prov.miq_provision_request.options[:dialog]['dialog_vm_hostname'])
  prov.set_option(:host_name, prov.miq_provision_request.options[:dialog]['dialog_vm_hostname'])
  prov.set_option(:name, prov.miq_provision_request.options[:dialog]['dialog_vm_vmname'])
  prov.set_option(:hostname, prov.miq_provision_request.options[:dialog]['dialog_vm_hostname'])
  prov.set_option(:sysprep_computer_name, prov.miq_provision_request.options[:dialog]['dialog_vm_hostname'])
  
  $evm.log(:info, "PASSWORD [#{prov.miq_provision_request.options[:dialog][:"password::dialog_vm_password"]}]")
  $evm.log(:info, "PASSWORD [#{prov.miq_provision_request.options[:dialog]['dialog_vm_password']}]")
  $evm.log(:info, "PASSWORD [#{MiqPassword.decrypt( prov.miq_provision_request.options[:dialog][:"password::dialog_vm_password"] )}]")
  $evm.log(:info, "PASSWORD [#{MiqPassword.decrypt( prov.miq_provision_request.options[:dialog]['dialog_vm_password'] )}]")
  
  prov.set_option( :root_password, MiqPassword.decrypt( prov.miq_provision_request.options[:dialog]['dialog_vm_password'] ) )
  
  Investigative_Debugging::Discovery::ObjectWalker.walk_objects
  
  process_vmware(mapping, prov, template, product, provider)
  
  $evm.log(:info, "END CUSTOM")

Result is as following

[----] I, [2019-03-07T11:51:39.139166 #24877:3edfd98]  INFO -- : Q-task_id([r1000000000084_miq_provision_1000000000206]) <AEMethod vmware_customizerequest> PASSWORD []

[----] I, [2019-03-07T11:57:26.129960 #24877:3f7cbfc]  INFO -- : Q-task_id([r1000000000086_miq_provision_1000000000212]) <AEMethod vmware_customizerequest> PASSWORD []

[----] I, [2019-03-07T11:57:26.131889 #24877:3f7cbfc]  INFO -- : Q-task_id([r1000000000086_miq_provision_1000000000212]) <AEMethod vmware_customizerequest> PASSWORD []

[----] I, [2019-03-07T11:57:26.133885 #24877:3f7cbfc]  INFO -- : Q-task_id([r1000000000086_miq_provision_1000000000212]) <AEMethod vmware_customizerequest> PASSWORD []

[----] I, [2019-03-07T11:57:26.135803 #24877:3f7cbfc]  INFO -- : Q-task_id([r1000000000086_miq_provision_1000000000212]) <AEMethod vmware_customizerequest> PASSWORD []

  
[root@cfme3esxi1 log]# /root/object_walker_reader.rb 2019-03-07T11:41:59.247838 | grep dialog
     |    |    $evm.root['miq_provision'].options[:available_dialogs] = {1000000000001=>"Transform VM", 1000000000002=>"VM", 1000000000003=>"Tag Portgroup", 1000000000004=>"HDD-dialogue"}   (type: Hash)
     |    |    $evm.root['miq_provision'].options[:dialog_id] = 1000000000002   (type: Integer)
     |    |    $evm.root['miq_provision'].options[:dialog_number_of_sockets] = 1   (type: Integer)
     |    |    $evm.root['miq_provision'].options[:dialog_vm_hostname] = w   (type: String)
     |    |    $evm.root['miq_provision'].options[:dialog_vm_memory] = 2048   (type: Integer)
     |    |    $evm.root['miq_provision'].options[:dialog_vm_usage_type] = prod   (type: String)
     |    |    $evm.root['miq_provision'].options[:dialog_vm_vlan] = DP_132VLAN_backup_DELL   (type: String)
     |    |    $evm.root['miq_provision'].options[:dialog_vm_vmname] = q   (type: String)
     |    |    $evm.root['miq_provision'].options[:miq_request_dialog_name] = miq_provision_vmware_dialogs_template   (type: String)
     |    |    $evm.root['miq_provision'].options[:password::dialog_vm_password] = ********   (type: String)
     |    |    |    miq_provision_request.options[:dialog] = {"dialog_vm_vmname"=>"q", "dialog_vm_hostname"=>"w", "dialog_number_of_sockets"=>1, "dialog_vm_memory"=>2048, "dialog_vm_usage_type"=>"prod", "dialog_vm_vlan"=>"DP_132VLAN_backup_DELL", "password::dialog_vm_password"=>"********"}   (type: Hash)
     |    |    |    miq_provision_request.options[:workflow_settings] = {:resource_action_id=>1000000000085, :dialog_id=>1000000000002}   (type: Hash)
     |    |    |    |    miq_request_task.options[:dialog] = {"dialog_vm_vmname"=>"q", "dialog_vm_hostname"=>"w", "dialog_number_of_sockets"=>1, "dialog_vm_memory"=>2048, "dialog_vm_usage_type"=>"prod", "dialog_vm_vlan"=>"DP_132VLAN_backup_DELL", "password::dialog_vm_password"=>"********", "request"=>"clone_to_service", :service_action=>"Provision", "Service::Service"=>1000000000064}   (type: Hash)
     |    |    |    |    miq_request_task.options[:parsed_dialog_options] = ---
     |    |    |    |      :dialog_vm_vmname: q
     |    |    |    |      :dialog_vm_hostname: w
     |    |    |    |      :dialog_number_of_sockets: 1
     |    |    |    |      :dialog_vm_memory: 2048
     |    |    |    |      :dialog_vm_usage_type: prod
     |    |    |    |      :dialog_vm_vlan: DP_132VLAN_backup_DELL
     |    |    |    |      :password::dialog_vm_password: ********
     |    |    |    |    miq_request_task.options[:parsed_dialog_tags] = --- {}
     |    |    |    |    miq_request_task.options[:workflow_settings] = {:resource_action_id=>1000000000085, :dialog_id=>1000000000002}   (type: Hash)
     |    |    |    |    |    destination.options[:dialog] = {"dialog_vm_vmname"=>"q", "dialog_vm_hostname"=>"w", "dialog_number_of_sockets"=>1, "dialog_vm_memory"=>2048, "dialog_vm_usage_type"=>"prod", "dialog_vm_vlan"=>"DP_132VLAN_backup_DELL", "password::dialog_vm_password"=>"********", "password::vm_password"=>"********"}   (type: Hash)
     |    |    |    |    |    destination.dialog_options
     |    |    |    |    |    destination.get_dialog_option
     |    |    |    |    |    destination.set_dialog_option
     |    |    |    |    |    miq_request_task.options[:dialog] = {"request"=>"clone_to_service", "Service::Service"=>1000000000064}   (type: Hash)
     |    |    |    |    |    miq_request_task.options[:workflow_settings] = {:resource_action_id=>1000000000085, :dialog_id=>1000000000002}   (type: Hash)
     |    |    |    |    |    |    |    resource.options[:available_dialogs] = {1000000000001=>"Transform VM", 1000000000002=>"VM", 1000000000003=>"Tag Portgroup", 1000000000004=>"HDD-dialogue"}   (type: Hash)
     |    |    |    |    |    |    |    resource.options[:dialog_id] = 1000000000002   (type: Integer)
     |    |    |    |    |    |    |    resource.options[:miq_request_dialog_name] = miq_provision_vmware_dialogs_template   (type: String)
     |    |    |    |    |    miq_request_task.dialog_options
     |    |    |    |    |    miq_request_task.get_dialog_option
     |    |    |    |    |    miq_request_task.set_dialog_option
     |    |    |    |    miq_request_task.dialog_options
     |    |    |    |    miq_request_task.get_dialog_option
     |    |    |    |    miq_request_task.set_dialog_option

I suppose I’m not decrypting in a proper way. May I ask for your help?


#2

MiqPassword.decrypt( prov.miq_provision_request.options[:dialog][“password::dialog_vm_password”] is the correct way