From 03628cfb07a72ff3bbefe3cae2ce5f460d04d2e8 Mon Sep 17 00:00:00 2001 From: William Fitzgerald Date: Mon, 24 Feb 2020 12:35:24 -0500 Subject: [PATCH] Removed all deprecated email components from Infrastructure namespace. Removed class and all instances and methods from 4 classes: Infrastructure/VM/Provisioning/Email Infrastructure/VM/Migrate/Email Infrastructure/VM/Reconfigure/Email Infrastructure/VM/Retirement/Email Email is now in System/Notification/Email class. @miq-bot add_label hammer/no, ivanchuk/no, changelog/yes, technical debt Removing vm_retire_extend_spec --- .../VM/Migrate/Email.class/__class__.yaml | 113 ------------- .../__methods__/vmmigraterequest_approved.rb | 50 ------ .../vmmigraterequest_approved.yaml | 12 -- .../__methods__/vmmigratetask_complete.rb | 53 ------ .../__methods__/vmmigratetask_complete.yaml | 12 -- .../vmmigraterequest_approved.yaml | 12 -- .../Email.class/vmmigratetask_complete.yaml | 12 -- .../Provisioning/Email.class/__class__.yaml | 113 ------------- .../__methods__/miqprovision_complete.rb | 85 ---------- .../__methods__/miqprovision_complete.yaml | 12 -- .../miqprovisionrequest_approved.rb | 105 ------------ .../miqprovisionrequest_approved.yaml | 12 -- .../__methods__/miqprovisionrequest_denied.rb | 130 -------------- .../miqprovisionrequest_denied.yaml | 12 -- .../miqprovisionrequest_pending.rb | 129 -------------- .../miqprovisionrequest_pending.yaml | 12 -- .../Email.class/miqprovision_complete.yaml | 12 -- .../miqprovisionrequest_approved.yaml | 12 -- .../miqprovisionrequest_denied.yaml | 12 -- .../miqprovisionrequest_pending.yaml | 12 -- .../VM/Reconfigure/Email.class/__class__.yaml | 93 ---------- .../vmreconfigure_request_approved.rb | 46 ----- .../vmreconfigure_request_approved.yaml | 12 -- .../vmreconfigure_task_complete.rb | 48 ------ .../vmreconfigure_task_complete.yaml | 12 -- .../vmreconfigurerequestapproved.yaml | 12 -- .../vmreconfiguretaskcomplete.yaml | 12 -- .../VM/Retirement/Email.class/__class__.yaml | 113 ------------- .../__methods__/vm_retire_extend.rb | 87 ---------- .../__methods__/vm_retire_extend.yaml | 12 -- .../__methods__/vm_retirement_emails.rb | 160 ------------------ .../__methods__/vm_retirement_emails.yaml | 12 -- .../Email.class/vm_retire_extend.yaml | 14 -- .../Email.class/vm_retirement_emails.yaml | 12 -- .../__methods__/vm_retire_extend_spec.rb | 89 ---------- 35 files changed, 1656 deletions(-) delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__class__.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigraterequest_approved.rb delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigraterequest_approved.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigratetask_complete.rb delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigratetask_complete.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/vmmigraterequest_approved.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/vmmigratetask_complete.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__class__.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovision_complete.rb delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovision_complete.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_approved.rb delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_approved.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_denied.rb delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_denied.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_pending.rb delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_pending.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovision_complete.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_approved.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_denied.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_pending.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__class__.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_request_approved.rb delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_request_approved.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_task_complete.rb delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_task_complete.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/vmreconfigurerequestapproved.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/vmreconfiguretaskcomplete.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__class__.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend.rb delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retirement_emails.rb delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retirement_emails.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/vm_retire_extend.yaml delete mode 100644 content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/vm_retirement_emails.yaml delete mode 100644 spec/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend_spec.rb diff --git a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__class__.yaml b/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__class__.yaml deleted file mode 100644 index 53bac39be..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__class__.yaml +++ /dev/null @@ -1,113 +0,0 @@ ---- -object_type: class -version: 1.0 -object: - attributes: - description: Deprecated please use System/Notification/Email - display_name: Email (Deprecated) - name: Email - type: - inherits: - visibility: - owner: - schema: - - field: - aetype: attribute - name: to_email_address - display_name: - datatype: string - priority: 1 - owner: - default_value: evmadmin@example.com - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: from_email_address - display_name: - datatype: string - priority: 2 - owner: - default_value: evmadmin@example.com - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: signature - display_name: - datatype: string - priority: 3 - owner: - default_value: Virtualization Infrastructure Team - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: vm_retire_extend_days - display_name: - datatype: string - priority: 4 - owner: - default_value: - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: method - name: method1 - display_name: - datatype: string - priority: 5 - owner: - default_value: - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: diff --git a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigraterequest_approved.rb b/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigraterequest_approved.rb deleted file mode 100644 index ea44bf073..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigraterequest_approved.rb +++ /dev/null @@ -1,50 +0,0 @@ -# -# Description: This method is used to email the provision requester that -# VM provisioning request has been approved -# -# Events: request_approved -# Model Notes: -# 1. to_email_address - used to specify an email address in the case where the -# requester does not have a valid email address. To specify more than one email -# address separate email address with commas. (I.e. admin@example.com,user@example.com) -# 2. from_email_address - used to specify an email address in the event the -# requester replies to the email -# 3. signature - used to stamp the email with a custom signature -# - -$evm.log("warn", "[DEPRECATION] This method will be deprecated. Please use similarly named method from System/Notification/Email class.") -# Get miq_request object -miq_request = $evm.root["miq_request"] - -# Override the default appliance IP Address below -appliance ||= $evm.root['miq_server'].ipaddress - -# Build email to requester with reason -$evm.log('info', "Requester email logic starting") - -# Get requester email -requester = $evm.root['miq_request'].requester - -# Get to_email_address from requester.email then from model if nil -to = requester.email || $evm.object['to_email_address'] - -# Get from_email_address from model unless specified below -from = nil -from ||= $evm.object['from_email_address'] - -# Get signature from model unless specified below -signature = nil -signature ||= $evm.object['signature'] - -# Build subject -subject = "Request ID #{miq_request.id} - Your request to migrate Virtual Machine was Approved" - -# Build email body -body = "Hello, " -body += "
Your Virtual Machine migration request was approved. You will be notified via email when the VM(s) have been migrated." -body += "

To view this Request go to: https://#{appliance}/miq_request/show/#{miq_request.id}" -body += "

Thank you," -body += "
#{signature}" - -$evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") -$evm.execute(:send_email, to, from, subject, body) diff --git a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigraterequest_approved.yaml b/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigraterequest_approved.yaml deleted file mode 100644 index fe0749597..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigraterequest_approved.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: method -version: 1.0 -object: - attributes: - name: VmMigrateRequest_Approved - display_name: - description: - scope: instance - language: ruby - location: inline - inputs: [] diff --git a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigratetask_complete.rb b/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigratetask_complete.rb deleted file mode 100644 index afca8a117..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigratetask_complete.rb +++ /dev/null @@ -1,53 +0,0 @@ -# -# Description: This method sends an e-mail when the following event is raised: -# -# Events: VmMigrateTask_Complete -# Model Notes: -# 1. to_email_address - used to specify an email address in the case where the -# vm's owner does not have an email address. To specify more than one email -# address separate email address with commas. (I.e. admin@example.com,user@example.com) -# 2. from_email_address - used to specify an email address in the event the -# requester replies to the email -# 3. signature - used to stamp the email with a custom signature -# - -$evm.log("warn", "[DEPRECATION] This method will be deprecated. Please use similarly named method from System/Notification/Email class.") -# Look in the Root Object for the request -miq_task = $evm.root['vm_migrate_task'] -miq_server = $evm.root['miq_server'] - -$evm.log("info", "Inspecting miq_task: #{miq_task.inspect}") - -vm = miq_task.source -raise "VM not found" if vm.nil? - -# Get VM Owner Name and Email -evm_owner_id = vm.attributes['evm_owner_id'] -owner = nil -owner = $evm.vmdb('user', evm_owner_id) unless evm_owner_id.nil? -$evm.log("info", "VM Owner: #{owner.inspect}") - -requester = miq_task.miq_request.requester - -to = owner.try(:email) || requester.email || $evm.object['to_email_address'] - -# Get from_email_address from model unless specified below -from = nil -from ||= $evm.object['from_email_address'] - -# Get signature from model unless specified below -signature = nil -signature ||= $evm.object['signature'] - -subject = "Your virtual machine request has Completed - VM: #{vm['name']}" - -body = "Hello, " - -# VM Migration Email Body -body += "

Your request to migrate virtual machine #{vm.name} was approved and completed on #{Time.zone.now.strftime('%A, %B %d, %Y at %I:%M%p')}. " -body += "

If you are not already logged in, you can access and manage your virtual machine here https://#{miq_server.ipaddress}/vm/show/#{vm['id']}" -body += "

Thank you," -body += "
#{signature}" - -$evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") -$evm.execute('send_email', to, from, subject, body) diff --git a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigratetask_complete.yaml b/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigratetask_complete.yaml deleted file mode 100644 index bc5214202..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/__methods__/vmmigratetask_complete.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: method -version: 1.0 -object: - attributes: - name: VmMigrateTask_Complete - display_name: - description: - scope: instance - language: ruby - location: inline - inputs: [] diff --git a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/vmmigraterequest_approved.yaml b/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/vmmigraterequest_approved.yaml deleted file mode 100644 index 3773401ec..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/vmmigraterequest_approved.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: instance -version: 1.0 -object: - attributes: - display_name: - name: VmMigrateRequest_Approved - inherits: - description: - fields: - - method1: - value: VmMigrateRequest_Approved diff --git a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/vmmigratetask_complete.yaml b/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/vmmigratetask_complete.yaml deleted file mode 100644 index 54f086874..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Migrate/Email.class/vmmigratetask_complete.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: instance -version: 1.0 -object: - attributes: - display_name: - name: VmMigrateTask_Complete - inherits: - description: - fields: - - method1: - value: VmMigrateTask_Complete diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__class__.yaml b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__class__.yaml deleted file mode 100644 index 53bac39be..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__class__.yaml +++ /dev/null @@ -1,113 +0,0 @@ ---- -object_type: class -version: 1.0 -object: - attributes: - description: Deprecated please use System/Notification/Email - display_name: Email (Deprecated) - name: Email - type: - inherits: - visibility: - owner: - schema: - - field: - aetype: attribute - name: to_email_address - display_name: - datatype: string - priority: 1 - owner: - default_value: evmadmin@example.com - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: from_email_address - display_name: - datatype: string - priority: 2 - owner: - default_value: evmadmin@example.com - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: signature - display_name: - datatype: string - priority: 3 - owner: - default_value: Virtualization Infrastructure Team - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: vm_retire_extend_days - display_name: - datatype: string - priority: 4 - owner: - default_value: - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: method - name: method1 - display_name: - datatype: string - priority: 5 - owner: - default_value: - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovision_complete.rb b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovision_complete.rb deleted file mode 100644 index b16841fd7..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovision_complete.rb +++ /dev/null @@ -1,85 +0,0 @@ -# -# Description: This method sends an e-mail when the following event is raised: -# Events: vm_provisioned -# -# Model Notes: -# 1. to_email_address - used to specify an email address in the case where the -# vm's owner does not have an email address. To specify more than one email -# address separate email address with commas. (I.e. admin@example.com,user@example.com) -# 2. from_email_address - used to specify an email address in the event the -# requester replies to the email -# 3. signature - used to stamp the email with a custom signature -# - -$evm.log("warn", "[DEPRECATION] This method will be deprecated. Please use similarly named method from System/Notification/Email class.") -# Get vm from miq_provision object -prov = $evm.root['miq_provision'] -vm = prov.vm -raise "VM not found" if vm.nil? - -# Override the default appliance IP Address below -appliance ||= $evm.root['miq_server'].ipaddress - -# Get VM Owner Name and Email -evm_owner_id = vm.attributes['evm_owner_id'] -owner = nil -owner = $evm.vmdb('user', evm_owner_id) unless evm_owner_id.nil? -$evm.log("info", "VM Owner: #{owner.inspect}") - -to = nil -to = owner.email unless owner.nil? -to ||= $evm.object['to_email_address'] -if to.nil? - $evm.log("info", "Email not sent because no recipient specified.") - exit MIQ_OK -end - -# Assign original to_email_Address to orig_to for later use -orig_to = to - -# Get from_email_address from model unless specified below -from = nil -from ||= $evm.object['from_email_address'] - -# Get signature from model unless specified below -signature = nil -signature ||= $evm.object['signature'] - -subject = "Your virtual machine request has Completed - VM: #{vm['name']}" - -body = "Hello, " - -# Override email to VM owner and send email to a different email address -# if the template provisioned contains 'xx' -if prov.vm_template.name.downcase.include?('_xx_') - $evm.log("info", "Setup of special email for DBMS VM") - - # Specify special email address below - to = 'evmadmin@example.com' - - body += "This email was sent by EVM to inform you of the provisioning of a new DBMS VM.
" - body += "This new VM requires changes to DNS and DHCP to function correctly.
" - body += "Please set the IP Address to static.
" - body += "Once that has been completed, use this message to inform the " - body += "requester that their new VM is ready.

" - body += "--------------------------------
" - body += "Forward the message below to
" - body += "#{orig_to}
" - body += "--------------------------------

" - body += "
" -end - -# VM Provisioned Email Body -body += "

Your request to provision a virtual machine was approved and completed on #{Time.now.strftime('%A, %B %d, %Y at %I:%M%p')}. " -body += "

Virtual machine #{vm['name']} will be available in approximately 15 minutes. " -body += "

For Windows VM access is available via RDP and for Linux VM access is available via putty/ssh, etc. Or you can use the Console Access feature found in the detail view of your VM. " -body += "

This VM will automatically be retired on #{vm['retires_on'].strftime('%A, %B %d, %Y')}, unless you request an extension. " if vm['retires_on'].respond_to?('strftime') -body += " You will receive a warning #{vm['reserved'][:retirement][:warn]} days before #{vm['name']} set retirement date." if vm['reserved'] && vm['reserved'][:retirement] && vm['reserved'][:retirement][:warn] -body += " As the designated owner you will receive expiration warnings at this email address: #{orig_to}" -body += "

If you are not already logged in, you can access and manage your virtual machine here https://#{appliance}/vm_or_template/show/#{vm['id']}'" -body += "

If you have any issues with your new virtual machine please contact Support." -body += "

Thank you," -body += "
#{signature}" - -$evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") -$evm.execute('send_email', to, from, subject, body) diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovision_complete.yaml b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovision_complete.yaml deleted file mode 100644 index 6f371f2c1..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovision_complete.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: method -version: 1.0 -object: - attributes: - name: MiqProvision_Complete - display_name: - description: - scope: instance - language: ruby - location: inline - inputs: [] diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_approved.rb b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_approved.rb deleted file mode 100644 index 5f6106176..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_approved.rb +++ /dev/null @@ -1,105 +0,0 @@ -# -# Description: This method is used to email the provision requester that -# VM provisioning request has been approved -# Events: request_approved -# Model Notes: -# 1. to_email_address - used to specify an email address in the case where the -# requester does not have a valid email address. To specify more than one email -# address separate email address with commas. (I.e. admin@example.com,user@example.com) -# 2. from_email_address - used to specify an email address in the event the -# requester replies to the email -# 3. signature - used to stamp the email with a custom signature -# - -# Send email to requester -def emailrequester(miq_request, appliance) - $evm.log('info', "Requester 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}>") - - # if to is nil then use requester_email - to = nil - to ||= requester_email - - # If to is still nil use to_email_address from model - to ||= $evm.object['to_email_address'] - - # Get from_email_address from model unless specified below - from = nil - from ||= $evm.object['from_email_address'] - - # Get signature from model unless specified below - signature = nil - signature ||= $evm.object['signature'] - - # Build subject - subject = "Request ID #{miq_request.id} - Your Virtual Machine configuration was Approved, pending Quota Validation" - - # Build email body - body = "Hello, " - body += "
Your Virtual Machine Request was approved. If Quota validation is successful you will be notified via email when the VM is available." - body += "

Approvers notes: #{miq_request.reason}" - body += "

To view this Request go to: https://#{appliance}/miq_request/show/#{miq_request.id}" - body += "

Thank you," - body += "
#{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) - $evm.log('info', "Requester email logic starting") - - # Get requester object - requester = miq_request.requester - - # Get requester email else set to nil - requester_email = requester.email || nil - - # If to is still nil use to_email_address from model - to = nil - to ||= $evm.object['to_email_address'] - - # Get from_email_address from model unless specified below - from = nil - from ||= $evm.object['from_email_address'] - - # Get signature from model unless specified below - signature = nil - signature ||= $evm.object['signature'] - - # Build subject - subject = "Request ID #{miq_request.id} - Your Virtual Machine configuration was Approved, pending Quota Validation" - - # Build email body - body = "Approver, " - body += "
Virtual Machine request received from #{requester_email} was approved." - body += "

Approvers reason: #{miq_request.reason}" - body += "

To view this Request go to: https://#{appliance}/miq_request/show/#{miq_request.id}" - body += "

Thank you," - body += "
#{signature}" - - $evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") - $evm.execute(:send_email, to, from, subject, body) -end - -$evm.log("warn", "[DEPRECATION] This method will be deprecated. Please use similarly named method from System/Notification/Email class.") -# Get miq_request from root -miq_request = $evm.root['miq_request'] -raise "miq_request missing" if miq_request.nil? -$evm.log("info", "Detected Request:<#{miq_request.id}> with Approval State:<#{miq_request.approval_state}>") - -# Override the default appliance IP Address below -appliance = nil -appliance ||= $evm.root['miq_server'].ipaddress - -# Email Requester -emailrequester(miq_request, appliance) diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_approved.yaml b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_approved.yaml deleted file mode 100644 index 1d450ae1b..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_approved.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: method -version: 1.0 -object: - attributes: - name: MiqProvisionRequest_Approved - display_name: - description: - scope: instance - language: ruby - location: inline - inputs: [] diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_denied.rb b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_denied.rb deleted file mode 100644 index 439fe1fdb..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_denied.rb +++ /dev/null @@ -1,130 +0,0 @@ -# -# Description: This method is used to email the provision requester and approver that -# the VM provision request has been denied -# Events: request_denied -# Model Notes: -# 1. to_email_address - used to specify an email address in the case where the -# requester does not have a valid email address.To specify more than one email -# address separate email address with commas. (I.e. admin@example.com,user@example.com) -# 2. from_email_address - used to specify an email address in the event the -# requester replies to the email -# 3. signature - used to stamp the email with a custom signature -# - -# Build email to requester with reason -def emailrequester(miq_request, appliance, msg, provisionRequestApproval) - $evm.log("info", "Requester 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}>") - - # if to is nil then use requester_email or owner_email - to = nil - to ||= requester_email || owner_email - - # If to is still nil use to_email_address from model - to ||= $evm.object['to_email_address'] - - # Get from_email_address from model unless specified below - from = nil - from ||= $evm.object['from_email_address'] - - # Get signature from model unless specified below - signature = nil - signature ||= $evm.object['signature'] - - # Set email subject - if provisionRequestApproval - subject = "Request ID #{miq_request.id} - Your virtual machine request was not approved" - else - subject = "Request ID #{miq_request.id} - Virtual Machine request was denied due to quota limitations" - end - - # Build email body - body = "Hello, " - body += "
#{msg}." - body += "

Approvers notes: #{miq_request.reason}" if provisionRequestApproval - body += "

For more information you can go to: https://#{appliance}/miq_request/show/#{miq_request.id}" - body += "

Thank you," - body += "
#{signature}" - - $evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") - $evm.execute(:send_email, to, from, subject, body) -end - -# Build email to approver with reason -def emailapprover(miq_request, appliance, msg, provisionRequestApproval) - $evm.log("info", "Approver email logic starting") - - # Override to requesters to_email_address below or get value from requester.email then from model - requester_email = miq_request.requester.email - if requester_email.to_s.empty? - requester_email ||= miq_request.requester.email - else - requester_email ||= $evm.object['to_email_address'] - end - - # 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 - if provisionRequestApproval - subject = "Request ID #{miq_request.id} - Virtual machine request was not approved" - else - subject = "Request ID #{miq_request.id} - Virtual Machine request was denied due to quota limitations" - end - - # Build email body - body = "Approver, " - body += "
A request received from #{requester_email} was denied." - body += "

#{msg}." - body += "

Approvers notes: #{miq_request.reason}" if provisionRequestApproval - body += "

For more information you can go to: https://#{appliance}/miq_request/show/#{miq_request.id}" - body += "

Thank you," - body += "
#{signature}" - - $evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") - $evm.execute(:send_email, to, from, subject, body) -end - -$evm.log("warn", "[DEPRECATION] This method will be deprecated. Please use similarly named method from System/Notification/Email class.") -# Get miq_request from root -miq_request = $evm.root['miq_request'] -raise "miq_request missing" if miq_request.nil? -$evm.log("info", "Detected Request:<#{miq_request.id}> with Approval State:<#{miq_request.approval_state}>") - -# Override the default appliance IP Address below -appliance = nil -appliance ||= $evm.root['miq_server'].ipaddress - -# Get incoming message or set it to default if nil -msg = miq_request.resource.message || "Request denied" - -# Check to see which state machine called this method -if msg.downcase.include?('quota') - provisionRequestApproval = false -else - provisionRequestApproval = true -end - -# Email Requester -emailrequester(miq_request, appliance, msg, provisionRequestApproval) - -# Email Approver -emailapprover(miq_request, appliance, msg, provisionRequestApproval) diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_denied.yaml b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_denied.yaml deleted file mode 100644 index e38c77f05..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_denied.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: method -version: 1.0 -object: - attributes: - name: MiqProvisionRequest_Denied - display_name: - description: - scope: instance - language: ruby - location: inline - inputs: [] diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_pending.rb b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_pending.rb deleted file mode 100644 index 77082c619..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_pending.rb +++ /dev/null @@ -1,129 +0,0 @@ -# -# Description: This method is launched from the not_approved method which raises the requst_pending event -# when the provisioning request is NOT auto-approved -# Events: request_pending -# Model Notes: -# 1. to_email_address - used to specify an email address in the case where the -# requester does not have a valid email address.To specify more than one email -# address separate email address with commas. (I.e. admin@example.com,user@example.com) -# 2. from_email_address - used to specify an email address in the event the -# requester replies to the email -# 3. signature - used to stamp the email with a custom signature -# - -# Build email to requester with reason -def emailrequester(miq_request, appliance, msg) - $evm.log("info", "Requester 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}>") - - # if to is nil then use requester_email or owner_email - to = nil - to ||= requester_email # || owner_email - - # If to is still nil use to_email_address from model - to ||= $evm.object['to_email_address'] - - # Get from_email_address from model unless specified below - 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} - Your Request for a new VM(s) was not Auto-Approved" - - # Build email body - body = "Hello, " - body += "
#{msg}." - body += "

Please review your Request and update or wait for approval from an Administrator." - body += "

To view this Request go to: " - body += "https://#{appliance}/miq_request/show/#{miq_request.id}" - body += "

Thank you," - body += "
#{signature}" - - $evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") - $evm.execute(:send_email, to, from, subject, body) -end - -# Build email to approver with reason -def emailapprover(miq_request, appliance, msg, provisionRequestApproval) - $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 - if provisionRequestApproval - subject = "Request ID #{miq_request.id} - Virtual machine request was not approved" - else - subject = "Request ID #{miq_request.id} - Virtual Machine request was denied due to quota limitations" - end - - # Build email body - body = "Approver, " - body += "
A request received from #{requester_email} is pending." - body += "

#{msg}." - body += "

Approvers notes: #{miq_request.reason}" if provisionRequestApproval - body += "

For more information you can go to: https://#{appliance}/miq_request/show/#{miq_request.id}" - body += "

Thank you," - body += "
#{signature}" - - $evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") - $evm.execute(:send_email, to, from, subject, body) -end - -$evm.log("warn", "[DEPRECATION] This method will be deprecated. Please use similarly named method from System/Notification/Email class.") -# Get miq_request from root -miq_request = $evm.root['miq_request'] -raise "miq_request missing" if miq_request.nil? -$evm.log("info", "Detected Request:<#{miq_request.id}> with Approval State:<#{miq_request.approval_state}>") - -# Override the default appliance IP Address below -appliance = nil -appliance ||= $evm.root['miq_server'].ipaddress - -# Get incoming message or set it to default if nil -msg = miq_request.resource.message || "Request pending" - -# Check to see which state machine called this method -if msg.downcase.include?('quota') - provisionRequestApproval = false -else - provisionRequestApproval = true -end - -# Email Requester -emailrequester(miq_request, appliance, msg) - -# Email Approver -emailapprover(miq_request, appliance, msg, provisionRequestApproval) diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_pending.yaml b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_pending.yaml deleted file mode 100644 index a357bbe91..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/__methods__/miqprovisionrequest_pending.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: method -version: 1.0 -object: - attributes: - name: MiqProvisionRequest_Pending - display_name: - description: - scope: instance - language: ruby - location: inline - inputs: [] diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovision_complete.yaml b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovision_complete.yaml deleted file mode 100644 index 782bb1fd4..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovision_complete.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: instance -version: 1.0 -object: - attributes: - display_name: - name: MiqProvision_Complete - inherits: - description: - fields: - - method1: - value: MiqProvision_Complete diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_approved.yaml b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_approved.yaml deleted file mode 100644 index 2252bf5cd..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_approved.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: instance -version: 1.0 -object: - attributes: - display_name: - name: MiqProvisionRequest_Approved - inherits: - description: - fields: - - method1: - value: MiqProvisionRequest_Approved diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_denied.yaml b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_denied.yaml deleted file mode 100644 index 3985bbd96..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_denied.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: instance -version: 1.0 -object: - attributes: - display_name: - name: MiqProvisionRequest_Denied - inherits: - description: - fields: - - method1: - value: MiqProvisionRequest_Denied diff --git a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_pending.yaml b/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_pending.yaml deleted file mode 100644 index f0626cc3c..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Provisioning/Email.class/miqprovisionrequest_pending.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: instance -version: 1.0 -object: - attributes: - display_name: - name: MiqProvisionRequest_Pending - inherits: - description: - fields: - - method1: - value: MiqProvisionRequest_Pending diff --git a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__class__.yaml b/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__class__.yaml deleted file mode 100644 index 2e5e5386d..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__class__.yaml +++ /dev/null @@ -1,93 +0,0 @@ ---- -object_type: class -version: 1.0 -object: - attributes: - description: Deprecated please use System/Notification/Email - display_name: Email (Deprecated) - name: Email - type: - inherits: - visibility: - owner: - schema: - - field: - aetype: attribute - name: to_email_address - display_name: - datatype: string - priority: 1 - owner: - default_value: evmadmin@example.com - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: from_email_address - display_name: - datatype: string - priority: 2 - owner: - default_value: evmadmin@example.com - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: signature - display_name: - datatype: string - priority: 3 - owner: - default_value: Virtualization Infrastructure Team - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: method - name: method1 - display_name: - datatype: string - priority: 4 - owner: - default_value: - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: diff --git a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_request_approved.rb b/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_request_approved.rb deleted file mode 100644 index de8705f93..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_request_approved.rb +++ /dev/null @@ -1,46 +0,0 @@ -# -# Description: This method is used to email the requester that -# VM Reconfiguration request has been approved -# -# Events: vmreconfigure_request_approved -# Model Notes: -# 1. to_email_address - used to specify an email address in the case where the -# requester does not have a valid email address. To specify more than one email -# address separate email address with commas. (I.e. admin@example.com,user@example.com) -# 2. from_email_address - used to specify an email address in the event the -# requester replies to the email -# 3. signature - used to stamp the email with a custom signature -# - -$evm.log("warn", "[DEPRECATION] This method will be deprecated. Please use similarly named method from System/Notification/Email class.") -# Get miq_request object -miq_request = $evm.root["miq_request"] - -raise "miq_request missing" if miq_request.nil? - -# Build email to requester with reason -$evm.log('info', "Requester email logic starting") - -# Get requester email -requester = $evm.root['miq_request'].requester - -# Get to_email_address from requester.email then from model if nil -to = requester.email || $evm.object['to_email_address'] - -# Get from_email_address from model unless specified below -from = $evm.object['from_email_address'] - -# Get signature from model unless specified below -signature = $evm.object['signature'] - -# Build subject -subject = "Request ID #{miq_request.id} - Your request to Reconfigure the Virtual Machine was Approved" - -# Build email body -body = "Hello, " -body += "
Your Virtual Machine VM Reconfiguration request was approved. " -body += "

Thank you," -body += "
#{signature}" - -$evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") -$evm.execute(:send_email, to, from, subject, body) diff --git a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_request_approved.yaml b/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_request_approved.yaml deleted file mode 100644 index 799e34d00..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_request_approved.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: method -version: 1.0 -object: - attributes: - name: vmreconfigure_request_approved - display_name: - description: - scope: instance - language: ruby - location: inline - inputs: [] diff --git a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_task_complete.rb b/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_task_complete.rb deleted file mode 100644 index 099432d3b..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_task_complete.rb +++ /dev/null @@ -1,48 +0,0 @@ -# -# Description: This method sends an e-mail when the following event is raised: -# -# Events: VmReconfigure_Task_Complete -# Model Notes: -# 1. to_email_address - used to specify an email address in the case where the -# vm's owner does not have an email address. To specify more than one email -# address separate email address with commas. (I.e. admin@example.com,user@example.com) -# 2. from_email_address - used to specify an email address in the event the -# requester replies to the email -# 3. signature - used to stamp the email with a custom signature -# - -$evm.log("warn", "[DEPRECATION] This method will be deprecated. Please use similarly named method from System/Notification/Email class.") -vm = $evm.root['vm'] - -raise "VM object not specified" if vm.nil? - -$evm.log("info", "Reconfiguration of VM Completed - VM: #{vm['name']}") - -evm_owner_id = vm['evm_owner_id'] -owner = $evm.vmdb('user', evm_owner_id) unless evm_owner_id.nil? - -# to_email_address from owner.email then from model if nil -to = owner.email unless owner.nil? -to ||= $evm.object['to_email_address'] -if to.nil? - $evm.log("info", "Reconfiguration email not sent because no recipient specified.") - exit MIQ_OK -end - -# Get from_email_address from model unless specified below -from = $evm.object['from_email_address'] - -# Get signature from model unless specified below -signature = $evm.object['signature'] - -subject = "Your virtual machine request has Completed - VM: #{vm['name']}" - -body = "Hello, " - -# VM Migration Email Body -body += "

Your request to Reconfigure virtual machine #{vm.name} was approved and completed. " -body += "

Thank you," -body += "
#{signature}" - -$evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") -$evm.execute('send_email', to, from, subject, body) diff --git a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_task_complete.yaml b/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_task_complete.yaml deleted file mode 100644 index edb20816d..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/__methods__/vmreconfigure_task_complete.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: method -version: 1.0 -object: - attributes: - name: vmreconfigure_task_complete - display_name: - description: - scope: instance - language: ruby - location: inline - inputs: [] diff --git a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/vmreconfigurerequestapproved.yaml b/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/vmreconfigurerequestapproved.yaml deleted file mode 100644 index 1079483c4..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/vmreconfigurerequestapproved.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: instance -version: 1.0 -object: - attributes: - display_name: - name: VmReconfigureRequestApproved - inherits: - description: - fields: - - method1: - value: vmreconfigure_request_approved diff --git a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/vmreconfiguretaskcomplete.yaml b/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/vmreconfiguretaskcomplete.yaml deleted file mode 100644 index 0602e53f1..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Reconfigure/Email.class/vmreconfiguretaskcomplete.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: instance -version: 1.0 -object: - attributes: - display_name: - name: VmReconfigureTaskComplete - inherits: - description: - fields: - - method1: - value: vmreconfigure_task_complete diff --git a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__class__.yaml b/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__class__.yaml deleted file mode 100644 index 53bac39be..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__class__.yaml +++ /dev/null @@ -1,113 +0,0 @@ ---- -object_type: class -version: 1.0 -object: - attributes: - description: Deprecated please use System/Notification/Email - display_name: Email (Deprecated) - name: Email - type: - inherits: - visibility: - owner: - schema: - - field: - aetype: attribute - name: to_email_address - display_name: - datatype: string - priority: 1 - owner: - default_value: evmadmin@example.com - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: from_email_address - display_name: - datatype: string - priority: 2 - owner: - default_value: evmadmin@example.com - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: signature - display_name: - datatype: string - priority: 3 - owner: - default_value: Virtualization Infrastructure Team - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: attribute - name: vm_retire_extend_days - display_name: - datatype: string - priority: 4 - owner: - default_value: - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: - - field: - aetype: method - name: method1 - display_name: - datatype: string - priority: 5 - owner: - default_value: - substitute: true - message: create - visibility: - collect: - scope: - description: - condition: - on_entry: - on_exit: - on_error: - max_retries: - max_time: diff --git a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend.rb b/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend.rb deleted file mode 100644 index c2f82f2bd..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend.rb +++ /dev/null @@ -1,87 +0,0 @@ -# -# Description: This method is used to add 14 days to retirement date when target -# VM has a retires_on value and is not already retired -# - -module ManageIQ - module Automate - module Infrastructure - module VM - module Retirement - module Email - class VmRetireExtend - def initialize(handle = $evm) - @handle = handle - end - - def main - @handle.log("warn", "[DEPRECATION] This method will be deprecated. Please use similarly named method from System/Notification/Email class.") - @handle.log("info", "Starting vm_retire_extend") - check_retire_extend(vm) - @handle.log("info", "Ending vm_retire_extend") - end - - private - - def vm - raise "ERROR - vm object not passed in" unless @handle.root['vm'] - @handle.root['vm'] - end - - def check_retire_extend(vm) - vm_retire_extend_days = @handle.object['vm_retire_extend_days'] - raise "ERROR - vm_retire_extend_days not found!" if vm_retire_extend_days.nil? - - @handle.log("info", "Number of days to extend: <#{vm_retire_extend_days}>") - - vm_name = vm.name - - if vm.retires_on.blank? - @handle.log("info", "VM '#{vm_name}' has no retirement date - extension bypassed") - return - end - - if vm.retired - @handle.log("info", "VM '#{vm_name}' is already retired. retires_on date: #{vm.retires_on}. No Action taken") - return - end - - @handle.log("info", "VM: <#{vm_name}> current retirement date is #{vm.retires_on}") - @handle.log("info", "Extending retirement <#{vm_retire_extend_days}> days for VM: <#{vm_name}>") - - vm.extend_retires_on(vm_retire_extend_days, vm.retires_on) - - @handle.log("info", "VM: <#{vm_name}> new retirement date is #{vm.retires_on}") - @handle.log("info", "Inspecting retirement vm: <#{vm.retirement_state}>") - - evm_owner_id = vm.attributes['evm_owner_id'] - owner = @handle.vmdb('user', evm_owner_id) if evm_owner_id - @handle.log("info", "Inspecting VM Owner: #{owner.inspect}") - - to = if owner - owner.email - else - @handle.object['to_email_address'] - end - - from = @handle.object['from_email_address'] - signature = @handle.object['signature'] - subject = "VM Retirement Extended for #{vm_name}" - - body = "Hello, " - body += "

The retirement date for your virtual machine: [#{vm_name}] has been extended to: [#{vm.retires_on}]." - body += "

Thank you," - body += "
#{signature}" - - @handle.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") - @handle.execute('send_email', to, from, subject, body) - end - end - end - end - end - end - end -end - -ManageIQ::Automate::Infrastructure::VM::Retirement::Email::VmRetireExtend.new.main diff --git a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend.yaml b/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend.yaml deleted file mode 100644 index d04ba8c0d..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: method -version: 1.0 -object: - attributes: - name: vm_retire_extend - display_name: - description: - scope: instance - language: ruby - location: inline - inputs: [] diff --git a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retirement_emails.rb b/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retirement_emails.rb deleted file mode 100644 index 2aa20109b..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retirement_emails.rb +++ /dev/null @@ -1,160 +0,0 @@ -# -# Description: This method sends out retirement emails when the following events are raised: -# Events: vm_retire_warn, vm_retired, vm_entered_retirement -# Model Notes: -# 1. to_email_address - used to specify an email address in the case where the -# vm's owner does not have an email address. To specify more than one email -# address separate email address with commas. (I.e. admin@example.com,user@example.com) -# 2. from_email_address - used to specify an email address in the event the -# requester replies to the email -# 3. signature - used to stamp the email with a custom signature -# - -$evm.log("warn", "[DEPRECATION] This method will be deprecated. Please use similarly named method from System/Notification/Email class.") -# Look in the current object for a VM -vm = $evm.object['vm'] -if vm.nil? - vm_id = $evm.object['vm_id'].to_i - vm = $evm.vmdb('vm', vm_id) unless vm_id == 0 -end - -# Look in the Root Object for a VM -if vm.nil? - vm = $evm.root['vm'] - if vm.nil? - vm_id = $evm.root['vm_id'].to_i - vm = $evm.vmdb('vm', vm_id) unless vm_id == 0 - end -end - -# Look in the Root Object for a Provision/Request -prov = $evm.root['miq_provision_request'] || $evm.root['miq_provision'] -vm = prov.vm if prov && vm.nil? - -raise "User not specified" if vm.nil? - -# Get VM Name -vm_name = vm['name'] - -# Look at the Event Type in the Current Object or in the Root Object -event_type = $evm.object['event'] || $evm.root['event_type'] - -# Get VM Owner Name and Email -evm_owner_id = vm.attributes['evm_owner_id'] -owner = nil -owner = $evm.vmdb('user', evm_owner_id) unless evm_owner_id.nil? - -# to_email_address from owner.email then from model if nil -if owner - to = owner.email -else - to = $evm.object['to_email_address'] -end - -###################################### -# -# VM Retirement Warning Email -# -###################################### -if event_type == "vm_retire_warn" - - # Get from_email_address from model unless specified below - from = nil - from ||= $evm.object['from_email_address'] - - # Get signature from model unless specified below - signature = nil - signature ||= $evm.object['signature'] - - # email subject - subject = "VM Retirement Warning for #{vm_name}" - - # Build email body - body = "Hello, " - body += "

Your virtual machine: [#{vm_name}] will be retired on [#{vm['retires_on']}]." - body += "

If you need to use this virtual machine past this date please request" - body += "

an extension by contacting Support." - body += "

Thank you," - body += "
#{signature}" -end - -###################################### -# -# VM Retirement Exended Email -# -###################################### -if event_type == "vm_retire_extend" - - # Get from_email_address from model unless specified below - from = nil - from ||= $evm.object['from_email_address'] - - # Get signature from model unless specified below - signature = nil - signature ||= $evm.object['signature'] - - # email subject - subject = "VM Retirement Extended for #{vm_name}" - - # Build email body - body = "Hello, " - body += "

Your virtual machine: [#{vm_name}] will now be retired on [#{vm['retires_on']}]." - body += "

If you need to use this virtual machine past this date please request" - body += "

an extension by contacting Support." - body += "

Thank you," - body += "
#{signature}" -end - -###################################### -# -# VM has entered Retirement Email -# -###################################### -if event_type == "vm_entered_retirement" - - # Get from_email_address from model unless specified below - from = nil - from ||= $evm.object['from_email_address'] - - # Get signature from model unless specified below - signature = nil - signature ||= $evm.object['signature'] - - # email subject - subject = "VM #{vm_name} has entered retirement" - - # Build email body - body = "Hello, " - body += "

Your virtual machine named [#{vm_name}] has been retired." - body += "

You will have up to 3 days to un-retire this VM. Afterwhich time the VM will be deleted." - body += "

Thank you," - body += "
#{signature}" -end - -###################################### -# -# VM Retirement Email -# -###################################### -if event_type == "vm_retired" - - # Get from_email_address from model unless specified below - from = nil - from ||= $evm.object['from_email_address'] - - # Get signature from model unless specified below - signature = nil - signature ||= $evm.object['signature'] - - # email subject - subject = "VM Retirement Alert for #{vm_name}" - - # Build email body - body = "Hello, " - body += "

Your virtual machine named [#{vm_name}] has been retired." - body += "

Thank you," - body += "
#{signature}" -end - -$evm.log("info", "Sending email to <#{to}> from <#{from}> subject: <#{subject}>") -$evm.execute('send_email', to, from, subject, body) diff --git a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retirement_emails.yaml b/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retirement_emails.yaml deleted file mode 100644 index f91f9aa34..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retirement_emails.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: method -version: 1.0 -object: - attributes: - name: vm_retirement_emails - display_name: - description: - scope: instance - language: ruby - location: inline - inputs: [] diff --git a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/vm_retire_extend.yaml b/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/vm_retire_extend.yaml deleted file mode 100644 index 0c76be684..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/vm_retire_extend.yaml +++ /dev/null @@ -1,14 +0,0 @@ ---- -object_type: instance -version: 1.0 -object: - attributes: - display_name: - name: vm_retire_extend - inherits: - description: - fields: - - vm_retire_extend_days: - value: '14' - - method1: - value: vm_retire_extend diff --git a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/vm_retirement_emails.yaml b/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/vm_retirement_emails.yaml deleted file mode 100644 index c3f7f20e0..000000000 --- a/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/vm_retirement_emails.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -object_type: instance -version: 1.0 -object: - attributes: - display_name: - name: vm_retirement_emails - inherits: - description: - fields: - - method1: - value: vm_retirement_emails diff --git a/spec/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend_spec.rb b/spec/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend_spec.rb deleted file mode 100644 index f439895ee..000000000 --- a/spec/content/automate/ManageIQ/Infrastructure/VM/Retirement/Email.class/__methods__/vm_retire_extend_spec.rb +++ /dev/null @@ -1,89 +0,0 @@ -require_domain_file - -describe ManageIQ::Automate::Infrastructure::VM::Retirement::Email::VmRetireExtend do - let(:user) { FactoryBot.create(:user_with_email_and_group) } - let(:zone) { FactoryBot.create(:zone) } - let(:ems) { FactoryBot.create(:ems_microsoft, :zone => zone, :tenant => Tenant.root_tenant) } - let(:miq_server) { EvmSpecHelper.local_miq_server } - let(:vm) do - FactoryBot.create(:vm_microsoft, - :raw_power_state => "PowerOff", - :retires_on => Time.zone.now, - :evm_owner => user, - :ems_id => ems.id) - end - - let(:root_hash) do - { 'vm' => vm } - end - - let(:root_object) do - Spec::Support::MiqAeMockObject.new(root_hash) - end - - let(:ae_service) do - Spec::Support::MiqAeMockService.new(root_object).tap do |service| - current_object = Spec::Support::MiqAeMockObject.new - current_object.parent = root_object - service.object = current_object - end - end - - before do - allow(ae_service).to receive(:execute) - end - - context "when vm_retire_extend_days is 7" do - it "Calls execute to send_email" do - ae_service.object[:vm_retire_extend_days] = 7 - ae_service.object[:from_email_address] = "evmadmin@example.com" - expect(ae_service).to receive(:execute).once - described_class.new(ae_service).main - end - - it "returns a new retirement date " do - ae_service.object[:vm_retire_extend_days] = 7 - future_retires_on = Time.zone.now + 7.days - described_class.new(ae_service).main - expect(vm.retires_on.day).to eq(future_retires_on.day) - end - end - - context "when vm_retire_extend_days is nil" do - it "raises error message" do - ae_service.object[:vm_retire_extend_days] = nil - errormsg = 'ERROR - vm_retire_extend_days not found!' - expect { described_class.new(ae_service).main }.to raise_error(errormsg) - end - end - - context "when vm retires_on is nil" do - it "does not update retires_on date" do - ae_service.object[:vm_retire_extend_days] = 7 - vm.update(:retires_on => nil) - expect(ae_service).not_to receive(:execute) - described_class.new(ae_service).main - expect(ae_service.root['ae_result']).to be_nil - end - end - - context "when vm retired is true " do - it "does not update retires_on date" do - ae_service.object[:vm_retire_extend_days] = 7 - vm.update(:retired => true) - expect(ae_service).not_to receive(:execute) - described_class.new(ae_service).main - expect(ae_service.root['ae_result']).to be_nil - end - end - - context "when there is no vm" do - let(:root_hash) { {} } - let(:svc_model_service) { nil } - let(:vm) { nil } - it "raises error message" do - errormsg = 'ERROR - vm object not passed in' - expect { described_class.new(ae_service).main }.to raise_error(errormsg) - end - end -end