Provisioning & Lifecycle Management
Relevant source files
The following files were used as context for generating this wiki page:
Provisioning and Lifecycle Management in ManageIQ is a multi-layered system designed to automate the deployment, configuration, and retirement of virtual machines, cloud instances, and complex services. The system utilizes a request-task architecture where high-level requests are broken down into granular, executable tasks governed by a state machine and integrated with the Automate engine for dynamic policy enforcement and resource placement.
The lifecycle begins with a user interaction through a catalog item or a direct provisioning dialog, progresses through an approval phase, and culminates in the execution of one or more provisioning tasks. These tasks interact directly with specific provider managers (Infrastructure or Cloud) to perform cloning and post-installation configuration.
Core Architecture
The provisioning system is built upon a hierarchy of models that separate the user’s intent (the Request) from the technical execution (the Task).
Request and Task Relationship
The primary interaction involves an MiqRequest which acts as the container for the overall provisioning intent. For virtual machines, this is specifically an MiqProvisionRequest. Once approved, the request generates one or more MiqProvision tasks (aliased as miq_request_tasks) based on the requested count of resources.
Key Data Model Fields
| Model | Field | Type | Description |
|---|---|---|---|
MiqProvisionRequest | options | Hash | Contains user-selected configuration from the dialog. |
MiqProvisionRequest | request_state | String | Current state (pending, provisioned, finished). |
MiqProvision | state | String | Execution state (e.g., finished, provisioned). |
MiqProvision | options | Hash | Specific options for the individual task, including the target VM name. |
Sources: app/models/miq_provision_request.rb:14-22, app/models/miq_provision.rb:27-40
Provisioning Workflows & Dialogs
Workflows manage the logic of the user interface and data validation. The MiqProvisionWorkflow class and its provider-specific subclasses (like CloudManager::ProvisionWorkflow) determine which resources (flavors, networks, availability zones) are eligible for a given request.
Cloud Manager Workflow Logic
The CloudManager::ProvisionWorkflow provides methods to filter valid targets for cloud-specific environments, such as security groups, floating IPs, and availability zones.
- Allowed Resources: Methods like
allowed_availability_zonesandallowed_cloud_networksperform lookups based on the source template and provider management system. - Validation: Includes
DialogFieldValidationand support forCloudInitorSyspreptemplates for customization.
Sources: app/models/manageiq/providers/cloud_manager/provision_workflow.rb:1-50
Dialog Configuration
Provisioning dialogs are defined in YAML templates that specify the fields, data types, and default values presented to the user.
:requester:
:description: Request
:fields:
:owner_email:
:description: E-Mail
:required: true
:display: :edit
:data_type: :string
:environment:
:fields:
:placement_auto:
:description: Choose Automatically
:default: false
:data_type: :boolean
Sources: product/dialogs/miq_dialogs/miq_provision_google_dialogs_template.yaml:10-150
State Machine Execution
Execution is handled by the StateMachine module included in MiqProvision. This state machine orchestrates the transition from preparing the provision to starting the clone and performing post-installation actions.
Task Execution Flow
When a task is pulled from the queue, it follows a predefined sequence of signals:
- prepare_provision: Sets up the phase context and clone options (e.g., flavor refs, image refs).
- start_clone_task: Initiates the actual cloning process on the provider.
- post_create_destination: Updates the newly created resource with ownership, descriptions, and retirement dates.
- mark_as_completed: Transitions the task to a finished state.
Automate Integration
The MiqProvision::Automate module enables the provisioning system to call out to the ManageIQ Automate engine for dynamic decision-making.
Automated Decision Points
| Action | Automate Message | Description |
|---|---|---|
| Naming | get_vmname | Dynamically generates the target VM name based on patterns or logic. |
| Placement | get_placement | Determines the optimal Host, Storage, and Cluster for deployment. |
| Networking | get_networks | Retrieves VLAN and scope details for the specific environment. |
| Availability | get_availability_zone | Finds the most suitable zone for a cloud instance. |
Sources: app/models/miq_provision/automate.rb:1-50
Code Context: Placement Resolution
def get_placement_via_automate
attrs = automate_attributes('get_placement')
ws = MiqAeEngine.resolve_automation_object("REQUEST", get_user, attrs, :vmdb_object => self)
reload
{
:host => MiqAeMethodService::MiqAeServiceConverter.svc2obj(ws.root["host"]),
:storage => MiqAeMethodService::MiqAeServiceConverter.svc2obj(ws.root["storage"]),
:cluster => MiqAeMethodService::MiqAeServiceConverter.svc2obj(ws.root["cluster"]),
}
end
Sources: app/models/miq_provision/automate.rb:19-28
Service Catalog Integration
Complex deployments are managed through ServiceTemplate models, which can be "Atomic" (representing a single resource) or "Composite" (representing a bundle of resources).
- Atomic Templates: Usually contain one
MiqProvisionRequestTemplate. - Composite Templates: Contain multiple children
ServiceTemplateobjects, allowing for tiered application stacks. - Resource Actions: Define the entry points for Provision, Retirement, and Reconfigure operations within the Automate engine.
Sources: app/models/service_template.rb:15-50, app/models/service_template.rb:215-240
Lifecycle Sequence Diagram
The following diagram illustrates the interaction between a user ordering a service and the subsequent creation of provisioning tasks.
Summary
Provisioning & Lifecycle Management provides a standardized, provider-agnostic framework for resource deployment. By abstracting the complexities of different cloud and infrastructure platforms into requests and state-driven tasks, ManageIQ ensures consistent policy application through its Automate engine and provides a scalable way to manage resource lifecycles from initial creation to final retirement.