chapter21/scripts/AutomationRequest_Pending.rb
###################################
#
# Method: emailrequester
#
# Build email to requester with reason
#
###################################
emailrequester
Build email to requester with reason
emailrequester Build email to requester with reason
def emailrequester(miq_request, appliance, msg)
  $evm.log('info', "Requester 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 ||= requester_email 
  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} - Your Automation Request was not Auto-Approved"
  body = "Hello, "
  body += "<br>#{msg}."
  body += "<br><br>Please review your Request and update or wait for approval from an Administrator."
  body += "<br><br>To view this Request go to: "
  body += "<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 emailrequester ( miq_request , appliance , msg ) $evm . log ( 'info' , "Requester 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 ||= requester_email 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} - Your Automation Request was not Auto-Approved" body = "Hello, " body += "<br>#{msg}." body += "<br><br>Please review your Request and update or wait for approval from an Administrator." body += "<br><br>To view this Request go to: " body += "<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: emailrequester
Build email to requester with reason
Method : emailrequester Build email to requester with reason
# Get requester object # Get requester email else set to nil # Get Owner Email else set to nil # if to is nil then use requester_email or owner_email # || owner_email # If to is still nil use to_email_address from model # Get from_email_address from model unless specified below # Get signature from model unless specified below # Set email subject # Build email body # Send email to requester
miq_request
<not_specific>
appliance
<not_specific>
msg
<not_specific>