-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated Workflows for POC implementation
- Loading branch information
Showing
31 changed files
with
908 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class WorkflowController < ApplicationController | ||
before_action :check_privileges | ||
before_action :get_session_data | ||
|
||
after_action :cleanup_action | ||
after_action :set_session_data | ||
|
||
include Mixins::GenericListMixin | ||
include Mixins::GenericSessionMixin | ||
include Mixins::GenericShowMixin | ||
include Mixins::BreadcrumbsMixin | ||
|
||
def self.model | ||
ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook | ||
#ManageIQ::Providers::Workflows::AutomationManager::Workflow | ||
end | ||
|
||
def show_list | ||
assert_privileges('embedded_workflow_view') | ||
super | ||
end | ||
|
||
def show | ||
assert_privileges('embedded_workflow_view') | ||
end | ||
|
||
def breadcrumbs_options | ||
{ | ||
:breadcrumbs => [ | ||
{:title => _("Automation")}, | ||
{:title => _("Embedded Workflow")}, | ||
{:title => _("Workflows"), :url => controller_url}, | ||
], | ||
} | ||
end | ||
|
||
menu_section :embedded_workflow | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class WorkflowCredentialController < ApplicationController | ||
before_action :check_privileges | ||
before_action :get_session_data | ||
|
||
after_action :cleanup_action | ||
after_action :set_session_data | ||
|
||
include Mixins::GenericListMixin | ||
include Mixins::GenericSessionMixin | ||
include Mixins::GenericShowMixin | ||
include Mixins::BreadcrumbsMixin | ||
|
||
def self.model | ||
ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook | ||
end | ||
|
||
def show_list | ||
assert_privileges('embedded_workflow_credential_view') | ||
super | ||
end | ||
|
||
def show | ||
assert_privileges('embedded_workflow_credential_view') | ||
end | ||
|
||
def breadcrumbs_options | ||
{ | ||
:breadcrumbs => [ | ||
{:title => _("Automation")}, | ||
{:title => _("Embedded Workflow")}, | ||
{:title => _("Credentials"), :url => controller_url}, | ||
], | ||
} | ||
end | ||
|
||
menu_section :embedded_workflow | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class WorkflowRepositoryController < ApplicationController | ||
before_action :check_privileges | ||
before_action :get_session_data | ||
|
||
after_action :cleanup_action | ||
after_action :set_session_data | ||
|
||
include Mixins::GenericListMixin | ||
include Mixins::GenericSessionMixin | ||
include Mixins::GenericShowMixin | ||
include Mixins::BreadcrumbsMixin | ||
|
||
def self.model | ||
ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook | ||
end | ||
|
||
def show_list | ||
assert_privileges('embedded_workflow_repository_view') | ||
super | ||
end | ||
|
||
def show | ||
assert_privileges('embedded_workflow_repository_view') | ||
end | ||
|
||
def breadcrumbs_options | ||
{ | ||
:breadcrumbs => [ | ||
{:title => _("Automation")}, | ||
{:title => _("Embedded Workflow")}, | ||
{:title => _("Repositories"), :url => controller_url}, | ||
], | ||
} | ||
end | ||
|
||
menu_section :embedded_workflow | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
"Comment": "An example of the Amazon States Language using a choice state.", | ||
"StartAt": "FirstState", | ||
"States": { | ||
"FirstState": { | ||
"Type": "Task", | ||
"Resource": "docker://agrare/hello-world:latest", | ||
"Retry": [ | ||
{ | ||
"ErrorEquals": [ "States.Timeout" ], | ||
"IntervalSeconds": 3, | ||
"MaxAttempts": 2, | ||
"BackoffRate": 1.5 | ||
} | ||
], | ||
"Catch": [ | ||
{ | ||
"ErrorEquals": [ "States.ALL" ], | ||
"Next": "FailState" | ||
} | ||
], | ||
"Next": "ChoiceState" | ||
}, | ||
|
||
"ChoiceState": { | ||
"Type" : "Choice", | ||
"Choices": [ | ||
{ | ||
"Variable": "$.foo", | ||
"NumericEquals": 1, | ||
"Next": "FirstMatchState" | ||
}, | ||
{ | ||
"Variable": "$.foo", | ||
"NumericEquals": 2, | ||
"Next": "SecondMatchState" | ||
}, | ||
{ | ||
"Variable": "$.foo", | ||
"NumericEquals": 3, | ||
"Next": "SuccessState" | ||
} | ||
], | ||
"Default": "FailState" | ||
}, | ||
|
||
"FirstMatchState": { | ||
"Type" : "Task", | ||
"Resource": "docker://agrare/hello-world:latest", | ||
"Next": "PassState" | ||
}, | ||
|
||
"SecondMatchState": { | ||
"Type" : "Task", | ||
"Resource": "docker://agrare/hello-world:latest", | ||
"Next": "NextState" | ||
}, | ||
|
||
"PassState": { | ||
"Type": "Pass", | ||
"Result": { | ||
"foo": "bar", | ||
"bar": "baz" | ||
}, | ||
"ResultPath": "$.result", | ||
"Next": "NextState" | ||
}, | ||
|
||
"FailState": { | ||
"Type": "Fail", | ||
"Error": "FailStateError", | ||
"Cause": "No Matches!" | ||
}, | ||
|
||
"SuccessState": { | ||
"Type": "Succeed" | ||
}, | ||
|
||
"NextState": { | ||
"Type": "Task", | ||
"Resource": "docker://agrare/hello-world:latest", | ||
"End": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { Loading } from 'carbon-components-react'; | ||
import MiqDataTable from '../miq-data-table'; | ||
import { workflowsList } from './workflows-dummy-data'; | ||
|
||
const WorkflowList = () => { | ||
const [data, setData] = useState({ isLoading: true, list: {} }); | ||
|
||
// TODO: Change the url when the GET automated worflow list api is available. | ||
useEffect(() => { | ||
API.get('/api/workflows/?expand=resources') | ||
.then((response) => { | ||
setData({ | ||
isLoading: false, | ||
list: workflowsList(response), | ||
}); | ||
}); | ||
}, []); | ||
|
||
/** Function to handle a row's click event. */ | ||
const onSelect = (selectedItemId) => { | ||
miqSparkleOn(); | ||
window.location.href = `/workflow/show/${selectedItemId}`; | ||
}; | ||
if (data.isLoading) { | ||
return ( | ||
<div className="loadingSpinner"> | ||
<Loading active small withOverlay={false} className="loading" /> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<MiqDataTable | ||
headers={data.list.headers} | ||
rows={data.list.rows} | ||
onCellClick={(selectedRow) => onSelect(selectedRow.id)} | ||
showPagination={false} | ||
truncateText={false} | ||
mode="automated-workflow-list" | ||
gridChecks={[]} | ||
/> | ||
); | ||
}; | ||
|
||
export default WorkflowList; |
Oops, something went wrong.