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

Convert Automate Methods to new style using classes #8

Open
mkanoor opened this Issue Dec 19, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@mkanoor
Contributor

mkanoor commented Dec 19, 2016

Convert the Automate methods to new style using classes to facilitate testing outside the Automate Engine.

Notes:

  1. Each method needs to be a class under a well defined namespace
  2. Each method needs to have a corresponding spec using the same path as the method file.
  3. Most of the methods can be tested outside of the Automate Engine using
    • Mock Service
    • Mock Objects
  4. The methods should not have an exit call since that exits RSpec.
  5. As each method is converted we should check the box next to the item
  6. Look for methods which might be the same in Cloud and Infrastructure namespaces.
  7. @billfitzgerald0120 is working on consolidating the email methods so we should check with him before converting email methods.
  8. When calling the VMDB objects please ensure that they are service model objects and not the actual vmdb objects.
  9. Why is this necessary
if __FILE__ == $PROGRAM_NAME
  MyMethodClass.new.main
end

This idea is borrowed from Python, which allows us to source in the file without executing any code. The if block gets executed only when we directly pass in the file to the ruby interpreter. When we test the method script we source in the file in the spec and then instantiate it for testing, it allows us to pass in a mock service for testing.

Good sample of a method
https://github.com/ManageIQ/manageiq-content/blob/master/content/automate/ManageIQ/Cloud/Orchestration/Operations/Methods.class/__methods__/available_availability_zones.rb

Good sample of a spec
https://github.com/ManageIQ/manageiq-content/blob/master/spec/content/automate/ManageIQ/Cloud/Orchestration/Operations/Methods.class/__methods__/available_availability_zones_spec.rb

In the spec the line
require_domain_file
loads the method file from the correct directory
The methods have been categorized based on different lifecycle's

  1. Provisioning
  2. Retirement
  3. Reconfigure/Reconfiguration
  4. Operations
  5. Migrate

ManageIQ/Cloud/Orchestration/Operations

ManageIQ/Cloud/Orchestration/Provisioning

ManageIQ/Cloud/Orchestration/Reconfiguration

  • /Email.class/methods/servicereconfigure_complete.rb
  • /Email.class/methods/servicereconfigurerequest_approved.rb
  • /StateMachines/Methods.class/methods/check_reconfigured.rb
  • /StateMachines/Methods.class/methods/postreconfigure.rb
  • /StateMachines/Methods.class/methods/prereconfigure.rb
  • /StateMachines/Methods.class/methods/reconfigure.rb
  • /StateMachines/Reconfigure.class/methods/update_servicereconfigure_status.rb

ManageIQ/Cloud/Orchestration/Retirement

  • /Email.class/methods/stack_retirement_emails.rb
  • /StateMachines/Methods.class/methods/check_removed_from_provider.rb
  • /StateMachines/Methods.class/methods/delete_from_vmdb.rb
  • /StateMachines/Methods.class/methods/finish_retirement.rb
  • /StateMachines/Methods.class/methods/remove_from_provider.rb
  • /StateMachines/Methods.class/methods/start_retirement.rb
  • /StateMachines/StackRetirement.class/methods/update_retirement_status.rb

ManageIQ/Cloud/VM/Provisioning

  • /Email.class/methods/miqprovision_complete.rb
  • /Email.class/methods/miqprovisionrequest_approved.rb
  • /Email.class/methods/miqprovisionrequest_denied.rb
  • /Email.class/methods/miqprovisionrequest_pending.rb
  • /Naming.class/methods/vmname.rb
  • /Placement.class/methods/best_fit_amazon.rb
  • /Placement.class/methods/best_fit_azure.rb
  • /Placement.class/methods/best_fit_google.rb
  • /Placement.class/methods/best_fit_openstack.rb
  • /Profile.class/methods/get_deploy_dialog.rb
  • /Profile.class/methods/vm_dialog_name_prefix.rb
  • /StateMachines/Methods.class/methods/amazon_customizerequest.rb
  • /StateMachines/Methods.class/methods/amazon_postprovision.rb
  • /StateMachines/Methods.class/methods/amazon_preprovision.rb
  • /StateMachines/Methods.class/methods/amazon_preprovision_clone_to_vm.rb
  • /StateMachines/Methods.class/methods/check_provisioned.rb
  • /StateMachines/Methods.class/methods/openstack_customizerequest.rb
  • /StateMachines/Methods.class/methods/openstack_postprovision.rb
  • /StateMachines/Methods.class/methods/openstack_preprovision.rb
  • /StateMachines/Methods.class/methods/openstack_preprovision_clone_to_vm.rb
  • /StateMachines/Methods.class/methods/postprovision.rb
  • /StateMachines/Methods.class/methods/preprovision.rb
  • /StateMachines/Methods.class/methods/provision.rb
  • /StateMachines/Methods.class/methods/scan.rb
  • /StateMachines/ProvisionRequestApproval.class/methods/approve_request.rb
  • /StateMachines/ProvisionRequestApproval.class/methods/pending_request.rb
  • /StateMachines/ProvisionRequestApproval.class/methods/validate_request.rb
  • /StateMachines/ProvisionRequestQuotaVerification.class/methods/rejected.rb
  • /StateMachines/ProvisionRequestQuotaVerification.class/methods/validate_quotas.rb
  • /StateMachines/VMProvision_VM.class/methods/update_provision_status.rb

ManageIQ/Cloud/VM/Retirement

  • /Email.class/methods/vm_retire_extend.rb
  • /Email.class/methods/vm_retirement_emails.rb
  • /StateMachines/Methods.class/methods/amazon_check_pre_retirement.rb
  • /StateMachines/Methods.class/methods/amazon_pre_retirement.rb
  • /StateMachines/Methods.class/methods/check_deleted_from_provider.rb
  • /StateMachines/Methods.class/methods/check_powered_off.rb
  • /StateMachines/Methods.class/methods/check_pre_retirement.rb
  • /StateMachines/Methods.class/methods/check_removed_from_provider.rb
  • /StateMachines/Methods.class/methods/delete_from_vmdb.rb
  • /StateMachines/Methods.class/methods/finish_retirement.rb
  • /StateMachines/Methods.class/methods/openstack_pre_retirement.rb
  • /StateMachines/Methods.class/methods/pre_retirement.rb
  • /StateMachines/Methods.class/methods/remove_from_provider.rb
  • /StateMachines/Methods.class/methods/start_retirement.rb
  • /StateMachines/VMRetirement.class/methods/update_retirement_status.rb

ManageIQ/ConfigurationManagement/AnsibleTower/Operations

ManageIQ/ConfigurationManagement/AnsibleTower/Service/Provisioning

  • /Email.class/methods/serviceprovision_complete.rb
  • /Email.class/methods/servicetemplateprovisionrequest_approved.rb
  • /StateMachines/Provision.class/methods/check_provisioned.rb
  • /StateMachines/Provision.class/methods/post_provision.rb
  • /StateMachines/Provision.class/methods/preprovision.rb
  • /StateMachines/Provision.class/methods/provision.rb
  • /StateMachines/Provision.class/methods/update_serviceprovision_status.rb

ManageIQ/Control/

  • /Email.class/methods/ems_cluster_alert.rb
  • /Email.class/methods/ext_management_system_alert.rb
  • /Email.class/methods/host_alert.rb
  • /Email.class/methods/miq_server_alert.rb
  • /Email.class/methods/parse_alerts.rb
  • /Email.class/methods/storage_alert.rb
  • /Email.class/methods/vm_alert.rb

ManageIQ/Deployment/ContainerProvider/System/

  • /StateMachine/Deployment.class/methods/add_provider.rb
  • /StateMachine/Deployment.class/methods/analyze_deployment.rb
  • StateMachine/Deployment.class/methods/check_ssh.rb
  • /StateMachine/Deployment.class/methods/cleanup.rb
  • /StateMachine/Deployment.class/methods/deployment.rb
  • /StateMachine/Deployment.class/methods/post_provision.rb
  • /StateMachine/Deployment.class/methods/pre_deployment.rb
  • /StateMachine/Deployment.class/methods/pre_validate.rb
  • /StateMachine/Deployment.class/methods/provision.rb

ManageIQ/Infrastructure/Cluster/Operations

  • /Methods.class/methods/cluster_workload_management.rb

ManageIQ/Infrastructure/Configured_System/Provisioning

  • /Email.class/methods/provision_complete.rb
  • /Email.class/methods/request_approved.rb
  • /StateMachines/Methods.class/methods/check_provisioned.rb
  • /StateMachines/Methods.class/methods/preprovision.rb
  • /StateMachines/Methods.class/methods/provision.rb
  • /StateMachines/Provision.class/methods/update_provision_status.rb
  • /StateMachines/ProvisionRequestApproval.class/methods/approve_request.rb
  • /StateMachines/ProvisionRequestApproval.class/methods/pending_request.rb
  • /StateMachines/ProvisionRequestApproval.class/methods/validate_request.rb
  • /StateMachines/ProvisionRequestQuotaVerification.class/methods/rejected.rb
  • /StateMachines/ProvisionRequestQuotaVerification.class/methods/validate_quotas.rb

ManageIQ/Infrastructure/Host/Operations

  • /Methods.class/methods/host_evacuation.rb

ManageIQ/Infrastructure/Host/Provisioning

  • /Email.class/methods/miqhostprovision_complete.rb
  • /Email.class/methods/miqhostprovisionrequest_approved.rb
  • /Profile.class/methods/get_deploy_dialog.rb
  • /StateMachines/HostProvision.class/methods/update_provision_status.rb
  • /StateMachines/Methods.class/methods/check_provisioned.rb
  • /StateMachines/Methods.class/methods/customizerequest.rb
  • /StateMachines/Methods.class/methods/postprovision_host.rb
  • /StateMachines/Methods.class/methods/preprovision_host.rb
  • /StateMachines/Methods.class/methods/provision.rb

ManageIQ/Infrastructure/VM/Migrate

  • /Email.class/methods/vmmigraterequest_approved.rb
  • /Email.class/methods/vmmigratetask_complete.rb
  • /Profile.class/methods/get_deploy_dialog.rb
  • /StateMachines/Methods.class/methods/besthost.rb
  • /StateMachines/Methods.class/methods/beststorage.rb
  • /StateMachines/Methods.class/methods/checkmigration.rb
  • /StateMachines/Methods.class/methods/migrate.rb
  • /StateMachines/Methods.class/methods/postmigration.rb
  • /StateMachines/Methods.class/methods/premigration.rb
  • /StateMachines/VMMigrate.class/methods/update_migration_status.rb

ManageIQ/Infrastructure/VM/Operations

  • /Methods.class/methods/vm_placement_optimization.rb

ManageIQ/Infrastructure/VM/Provisioning

  • /Email.class/methods/miqprovision_complete.rb
  • /Email.class/methods/miqprovisionrequest_approved.rb
  • /Email.class/methods/miqprovisionrequest_denied.rb
  • /Email.class/methods/miqprovisionrequest_pending.rb
  • /Naming.class/methods/vmname.rb
  • /Placement.class/methods/microsoft_best_fit_least_utilized.rb
  • /Placement.class/methods/redhat_best_fit_cluster.rb
  • /Placement.class/methods/vmware_best_fit_least_utilized.rb
  • /Profile.class/methods/get_deploy_dialog.rb
  • /Profile.class/methods/vm_dialog_name_prefix.rb
  • /StateMachines/Methods.class/methods/check_provisioned.rb
  • /StateMachines/Methods.class/methods/provision.rb
  • /StateMachines/Methods.class/methods/redhat_customizerequest.rb
  • /StateMachines/Methods.class/methods/redhat_postprovision.rb
  • /StateMachines/Methods.class/methods/redhat_preprovision.rb
  • /StateMachines/Methods.class/methods/redhat_preprovision_clone_to_template.rb
  • /StateMachines/Methods.class/methods/redhat_preprovision_clone_to_vm.rb
  • /StateMachines/Methods.class/methods/scan.rb
  • /StateMachines/Methods.class/methods/vmware_customizerequest.rb
  • /StateMachines/Methods.class/methods/vmware_postprovision.rb
  • /StateMachines/Methods.class/methods/vmware_preprovision.rb
  • /StateMachines/Methods.class/methods/vmware_preprovision_clone_to_template.rb
  • /StateMachines/Methods.class/methods/vmware_preprovision_clone_to_vm.rb
  • /StateMachines/ProvisionRequestApproval.class/methods/approve_request.rb
  • /StateMachines/ProvisionRequestApproval.class/methods/pending_request.rb
  • /StateMachines/ProvisionRequestApproval.class/methods/validate_request.rb
  • /StateMachines/ProvisionRequestQuotaVerification.class/methods/rejected.rb
  • /StateMachines/ProvisionRequestQuotaVerification.class/methods/validate_quotas.rb
  • /StateMachines/VMProvision_Template.class/methods/update_provision_status.rb
  • /StateMachines/VMProvision_VM.class/methods/update_provision_status.rb

ManageIQ/Infrastructure/VM/Reconfigure

  • /Email.class/methods/vmreconfigure_request_approved.rb
  • /Email.class/methods/vmreconfigure_task_complete.rb

ManageIQ/Infrastructure/VM/Retirement

  • /Email.class/methods/vm_retire_extend.rb
  • /Email.class/methods/vm_retirement_emails.rb
  • /StateMachines/Methods.class/methods/check_powered_off.rb
  • /StateMachines/Methods.class/methods/check_pre_retirement.rb
  • /StateMachines/Methods.class/methods/check_removed_from_provider.rb
  • /StateMachines/Methods.class/methods/delete_from_vmdb.rb
  • /StateMachines/Methods.class/methods/finish_retirement.rb
  • /StateMachines/Methods.class/methods/power_off.rb
  • /StateMachines/Methods.class/methods/pre_retirement.rb
  • /StateMachines/Methods.class/methods/remove_from_provider.rb
  • /StateMachines/Methods.class/methods/start_retirement.rb
  • /StateMachines/VMRetirement.class/methods/update_retirement_status.rb

ManageIQ/Service/Provisioning/

  • /Email.class/methods/serviceprovision_complete.rb
  • /Email.class/methods/servicetemplateprovisionrequest_approved.rb
  • /Email.class/methods/servicetemplateprovisionrequest_denied.rb
  • /Email.class/methods/servicetemplateprovisionrequest_pending.rb
  • /Email.class/methods/servicetemplateprovisionrequest_warning.rb
  • /ServiceFilter.class/methods/filterbydialogparameters.rb
  • /StateMachines/Methods.class/methods/catalogbundleinitialization.rb
  • /StateMachines/Methods.class/methods/catalogiteminitialization.rb
  • /StateMachines/Methods.class/methods/check_provisioned.rb
  • /StateMachines/Methods.class/methods/dialog_parser.rb
  • /StateMachines/Methods.class/methods/groupsequencecheck.rb
  • /StateMachines/Methods.class/methods/provision.rb
  • /StateMachines/Methods.class/methods/statemachine_finished.rb
  • /StateMachines/ServiceProvisionRequestApproval.class/methods/approve_request.rb
  • /StateMachines/ServiceProvisionRequestApproval.class/methods/pending_request.rb
  • /StateMachines/ServiceProvisionRequestApproval.class/methods/validate_request.rb
  • /StateMachines/ServiceProvision_Template.class/methods/update_serviceprovision_status.rb

ManageIQ/Service/Retirement

  • /StateMachines/Methods.class/methods/check_service_retired.rb
  • /StateMachines/Methods.class/methods/delete_service_from_vmdb.rb
  • /StateMachines/Methods.class/methods/finish_retirement.rb
  • /StateMachines/Methods.class/methods/get_retirement_entrypoint.rb
  • /StateMachines/Methods.class/methods/mark_service_as_retired.rb
  • /StateMachines/Methods.class/methods/retire_service.rb
  • /StateMachines/Methods.class/methods/start_retirement.rb
  • /StateMachines/ServiceRetirement.class/methods/update_service_retirement_status.rb

ManageIQ/System

  • /CommonMethods/QuotaMethods.class/methods/limits.rb
  • /CommonMethods/QuotaMethods.class/methods/quota_source.rb
  • /CommonMethods/QuotaMethods.class/methods/requested.rb
  • /CommonMethods/QuotaMethods.class/methods/used.rb
  • /CommonMethods/QuotaMethods.class/methods/validate_quota.rb
  • /CommonMethods/QuotaStateMachine.class/methods/rejected.rb
  • /CommonMethods/StateMachineMethods.class/methods/task_finished.rb
  • /Policy.class/methods/get_request_type.rb
  • /Policy.class/methods/miqhostprovision_auto_approve.rb
  • /Policy.class/methods/vmmigraterequest_auto_approve.rb
  • /Policy.class/methods/vmreconfigure_request_auto_approve.rb
  • /Request.class/methods/inspectme.rb
@miq-bot

This comment has been minimized.

Show comment
Hide comment
@miq-bot

miq-bot Dec 11, 2017

Member

This issue has been automatically marked as stale because it has not been updated for at least 6 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions!

Member

miq-bot commented Dec 11, 2017

This issue has been automatically marked as stale because it has not been updated for at least 6 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment