chapter21/scripts/AutomationRequest_Pending.rb
def emailapprover(miq_request, appliance, msg)
  $evm.log('info', "Approver email logic starting")

  # Get requester object
  requester = miq_request.requester

  # Get requester email else set to nil
  requester_email = requester.email || nil

  # Get Owner Email else set to nil
  owner_email = miq_request.options[:owner_email] || nil
  $evm.log('info', "Requester email:<#{requester_email}> Owner Email:<#{owner_email}>")

  # Override to email address below or get to_email_address from from model
  to = nil
  to  ||= $evm.object['to_email_address']

  # Override from_email_address below or get from_email_address from model
  from = nil
  from ||= $evm.object['from_email_address']

  # Get signature from model unless specified below
  signature = nil
  signature ||= $evm.object['signature']

  # Set email subject
  subject = "Request ID #{miq_request.id} - Automation request was not approved"


  # Build email body
  body = "Approver, "
  body += "<br>An automation request received from #{requester_email} is pending."
  body += "<br><br>#{msg}."
  body += "<br><br>For more information you can go to: <a href='https://#{appliance}/miq_request/show/#{miq_request.id}'>https://#{appliance}/miq_request/show/#{miq_request.id}</a>"
  body += "<br><br> Thank you,"
  body += "<br> #{signature}"

  # Send email to approver
  $evm.log('info', "Sending email to <#{to}> from <#{from}> subject: <#{subject}>")
  $evm.execute(:send_email, to, from, subject, body)
end
###################################
#
# Method: emailapprover
#
# Build email to approver with reason
#
###################################
emailapprover
Build email to approver with reason
emailapprover Build email to approver with reason
def emailapprover(miq_request, appliance, msg)
  $evm.log('info', "Approver email logic starting")
  requester = miq_request.requester
  requester_email = requester.email || nil
  owner_email = miq_request.options[:owner_email] || nil
  $evm.log('info', "Requester email:<#{requester_email}> Owner Email:<#{owner_email}>")
  to = nil
  to  ||= $evm.object['to_email_address']
  from = nil
  from ||= $evm.object['from_email_address']
  signature = nil
  signature ||= $evm.object['signature']
  subject = "Request ID #{miq_request.id} - Automation request was not approved"
  body = "Approver, "
  body += "<br>An automation request received from #{requester_email} is pending."
  body += "<br><br>#{msg}."
  body += "<br><br>For more information you can go to: <a href='https://#{appliance}/miq_request/show/#{miq_request.id}'>https://#{appliance}/miq_request/show/#{miq_request.id}</a>"
  body += "<br><br> Thank you,"
  body += "<br> #{signature}"
  $evm.log('info', "Sending email to <#{to}> from <#{from}> subject: <#{subject}>")
  $evm.execute(:send_email, to, from, subject, body)
end
def emailapprover ( miq_request , appliance , msg ) $evm . log ( 'info' , "Approver email logic starting" ) requester = miq_request . requester requester_email = requester . email || nil owner_email = miq_request . options [ :owner_email ] || nil $evm . log ( 'info' , "Requester email:<#{requester_email}> Owner Email:<#{owner_email}>" ) to = nil to ||= $evm . object [ 'to_email_address' ] from = nil from ||= $evm . object [ 'from_email_address' ] signature = nil signature ||= $evm . object [ 'signature' ] subject = "Request ID #{miq_request.id} - Automation request was not approved" body = "Approver, " body += "<br>An automation request received from #{requester_email} is pending." body += "<br><br>#{msg}." body += "<br><br>For more information you can go to: <a href='https://#{appliance}/miq_request/show/#{miq_request.id}'>https://#{appliance}/miq_request/show/#{miq_request.id}</a>" body += "<br><br> Thank you," body += "<br> #{signature}" $evm . log ( 'info' , "Sending email to <#{to}> from <#{from}> subject: <#{subject}>" ) $evm . execute ( :send_email , to , from , subject , body ) end
Method: emailapprover
Build email to approver with reason
Method : emailapprover Build email to approver with reason
# Get requester object # Get requester email else set to nil # Get Owner Email else set to nil # Override to email address below or get to_email_address from from model # Override from_email_address below or get from_email_address from model # Get signature from model unless specified below # Set email subject # Build email body # Send email to approver
miq_request
appliance
msg