ManageIQ / manageiq-content

Default ManageIQ content
Apache License 2.0
13 stars 120 forks source link

Convert Automate Methods to new style using classes #8

Open mkanoor opened 7 years ago

mkanoor commented 7 years ago

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

ManageIQ/Cloud/Orchestration/Retirement

ManageIQ/Cloud/VM/Provisioning

ManageIQ/Cloud/VM/Retirement

ManageIQ/ConfigurationManagement/AnsibleTower/Operations

ManageIQ/ConfigurationManagement/AnsibleTower/Service/Provisioning

ManageIQ/Control/

ManageIQ/Deployment/ContainerProvider/System/

ManageIQ/Infrastructure/Cluster/Operations

ManageIQ/Infrastructure/Configured_System/Provisioning

ManageIQ/Infrastructure/Host/Operations

ManageIQ/Infrastructure/Host/Provisioning

ManageIQ/Infrastructure/VM/Migrate

ManageIQ/Infrastructure/VM/Operations

ManageIQ/Infrastructure/VM/Provisioning

ManageIQ/Infrastructure/VM/Reconfigure

ManageIQ/Infrastructure/VM/Retirement

ManageIQ/Service/Provisioning/

ManageIQ/Service/Retirement

ManageIQ/System

ManageIQ/Transformation

miq-bot commented 6 years ago

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!