Skip to content

Commit

Permalink
Merge pull request ManageIQ#244 from bzwei/v2v_init
Browse files Browse the repository at this point in the history
Automation for transformation plan
  • Loading branch information
gmcculloug authored Feb 8, 2018
2 parents ea73576 + 2afde79 commit 684d7b1
Show file tree
Hide file tree
Showing 25 changed files with 421 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: transformation_plan_vm_finished
inherits:
description:
fields:
- execute:
value: task_finished(object => 'service_template_transformation_plan_task',
message => 'VM Migrated Successfully' )
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: TransformationPlanComplete
inherits:
description:
fields:
- owner:
value: "${/#miq_request.requester}"
- to:
value: "${/#miq_request.get_option(:owner_email)} || ${/#miq_request.requester.email}"
- sendmail:
value: "#stop_email"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: TransformationPlanRequestApproverApproved
inherits:
description:
fields:
- owner:
value: "${/#miq_request.requester}"
- to:
value: "${/#miq_request.get_option(:owner_email)} || ${/#miq_request.requester.email}"
- subject:
value: Request ID ${/#miq_request.id} - Transformation Plan Request received
from ${/#miq_request.requester.email} was Approved.
- body:
value: 'Approver,<br><br>Transformation Plan Request received from ${/#miq_request.requester.email}
was Approved.<br><br>Approvers reason: ${/#miq_request.reason}<br><br>To view
this Request go to: <a href=''http://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}''>http://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}</a><br><br>
Thank you,<br> ${#signature}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: TransformationPlanRequestApproverDenied
inherits:
description:
fields:
- owner:
value: "${/#miq_request.requester}"
- to:
value: "${/#miq_request.get_option(:owner_email)} || ${/#miq_request.requester.email}"
- subject:
value: Request ID ${/#miq_request.id} - Transformation Plan Request from <${/#miq_request.requester.email}>
was Denied.
- body:
value: 'Approver,<br><br>A Transformation Plan Request received from ${/#miq_request.requester.email}
was Denied.<br><br>Approvers notes: ${/#miq_request.reason}<br><br>For more
information you can go to: <a href=''http://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}''>http://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}</a><br><br>
Thank you<br> ${#signature}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: TransformationPlanRequestApproverPending
inherits:
description:
fields:
- owner:
value: "${/#miq_request.requester}"
- to:
value: "${/#miq_request.get_option(:owner_email)} || ${/#miq_request.requester.email}"
- subject:
value: Request ID ${/#miq_request.id} - Transformation Plan Request from <${/#miq_request.requester.email}>
is Pending Approval.
- body:
value: 'Approver,<br><br>A Transformation Plan Request received from ${/#miq_request.requester.email}
is Pending.<br><br>For more information you can go to: <a href=''http://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}''>http://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}</a><br><br>
Thank you<br> ${#signature}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: TransformationPlanRequestRequesterApproved
inherits:
description:
fields:
- owner:
value: "${/#miq_request.requester}"
- to:
value: "${/#miq_request.get_option(:owner_email)} || ${/#miq_request.requester.email}
\ "
- subject:
value: Request ID ${/#miq_request.id} - Your Transformation Plan Request was
Approved, pending Quota Validation.
- body:
value: 'Hello,<br><br>Your Transformation Plan Request was Approved. If Service
provisioning is successful you will be notified via email when the Service
is available.<br><br>Approvers notes: ${/#miq_request.reason}<br><br>To view
this Request go to: <a href=''https://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}''>https://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}</a><br><br>
Thank you,<br> ${#signature}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: TransformationPlanRequestRequesterDenied
inherits:
description:
fields:
- owner:
value: "${/#miq_request.requester}"
- to:
value: "${/#miq_request.get_option(:owner_email)} || ${/#miq_request.requester.email} "
- subject:
value: Request ID ${/#miq_request.id} - Your Transformation Plan Request was
Denied.
- body:
value: 'Hello,<br><br>Your Transformation Plan Request was Denied.<br><br>Approvers
notes: ${/#miq_request.reason}<br><br>For more information you can go to:
<a href=''http://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}''>http://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}</a><br><br>
Thank you<br> ${#signature}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: TransformationPlanRequestRequesterPending
inherits:
description:
fields:
- owner:
value: "${/#miq_request.requester}"
- to:
value: "${/#miq_request.get_option(:owner_email)} || ${/#miq_request.requester.email} "
- subject:
value: Request ID ${/#miq_request.id} - Your Transformation Plan Request is
Pending Approval.
- body:
value: 'Hello,<br><br>Please review your Transformation Plan Request and wait
for approval from an Administrator.<br><br>To view this Request go to: <a
href=''http://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}''>http://${/#miq_server.ipaddress}:3000/miq_request/show/${/#miq_request.id}</a><br><br>
Thank you<br> ${#signature}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: ServiceTemplateTransformationPlanRequest_approved
inherits:
description:
fields:
- rel5:
value: "/System/Notification/Email/TransformationPlanRequestRequesterApproved "
- rel6:
value: "/System/Notification/Email/TransformationPlanRequestApproverApproved "
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: ServiceTemplateTransformationPlanRequest_created
inherits:
description:
fields:
- guard:
value: "${/#miq_request.process}"
- rel6:
value: "/Transformation/StateMachines/TransformationPlanRequestApproval/Default"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: ServiceTemplateTransformationPlanRequest_denied
inherits:
description:
fields:
- rel5:
value: "/System/Notification/Email/TransformationPlanRequestRequesterDenied"
- rel6:
value: "/System/Notification/Email/TransformationPlanRequestApproverDenied"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: ServiceTemplateTransformationPlanRequest_pending
inherits:
description:
fields:
- rel5:
value: "/System/Notification/Email/TransformationPlanRequestRequesterPending"
- rel6:
value: "/System/Notification/Email/TransformationPlanRequestApproverPending"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: ServiceTemplateTransformationPlanRequest_starting
inherits:
description:
fields: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
object_type: class
version: 1.0
object:
attributes:
description:
display_name:
name: TransformationPlanRequestApproval
type:
inherits:
visibility:
owner:
schema:
- field:
aetype: attribute
name: approval_type
display_name:
datatype: string
priority: 1
owner:
default_value: auto
substitute: true
message: create
visibility:
collect:
scope:
description:
condition:
on_entry:
on_exit:
on_error:
max_retries:
max_time:
- field:
aetype: state
name: ValidateRequest
display_name:
datatype: string
priority: 2
owner:
default_value:
substitute: true
message: create
visibility:
collect:
scope:
description:
condition:
on_entry: validate_request
on_exit:
on_error: pending_request
max_retries: '100'
max_time:
- field:
aetype: state
name: ApproveRequest
display_name:
datatype: string
priority: 3
owner:
default_value:
substitute: true
message: create
visibility:
collect:
scope:
description:
condition:
on_entry: approve_request
on_exit:
on_error: pending_request
max_retries: '100'
max_time:
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Description: This method is executed when the provisioning request is auto-approved
#

# Auto-Approve request
$evm.log("info", "Checking for auto_approval")
approval_type = $evm.object['approval_type'].downcase
if approval_type == 'auto'
$evm.log("info", "AUTO-APPROVING")
$evm.root["miq_request"].approve("admin", "Auto-Approved")
else
$evm.log("info", "Not Auto-Approved")
exit MIQ_ABORT
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
object_type: method
version: 1.0
object:
attributes:
name: approve_request
display_name:
description:
scope: instance
language: ruby
location: inline
options: {}
inputs: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Description: This method is executed when the provisioning request is NOT auto-approved
#

# Get objects
msg = $evm.object['reason']
$evm.log('info', msg.to_s)

# Raise automation event: request_pending
$evm.root["miq_request"].pending
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
object_type: method
version: 1.0
object:
attributes:
name: pending_request
display_name:
description:
scope: instance
language: ruby
location: inline
options: {}
inputs: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Description: Placeholder for service request validation
#
prov = $evm.root['miq_request']
prov.source_vms.each { |vm| prov.approve_vm(vm) if prov.validate_vm(vm) }
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
object_type: method
version: 1.0
object:
attributes:
name: validate_request
display_name:
description:
scope: instance
language: ruby
location: inline
options: {}
inputs: []
Loading

0 comments on commit 684d7b1

Please sign in to comment.