Skip to content

Commit

Permalink
Merge pull request #888 from mturley/885-download-wrapper-log
Browse files Browse the repository at this point in the history
[#885] Add Virt-v2v-wrapper log download menu item
  • Loading branch information
mturley authored Mar 5, 2019
2 parents e8713e2 + 5180bab commit 55ee3b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 8 additions & 5 deletions app/javascript/react/screens/App/Plan/PlanActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const resetPlanStateAction = () => ({
type: RESET_PLAN_STATE
});

export const downloadLogAction = task => dispatch => {
export const downloadLogAction = (task, logType = 'v2v') => dispatch => {
dispatch({
type: DOWNLOAD_LOG_CLICKED,
payload: task.id
Expand All @@ -170,18 +170,21 @@ export const downloadLogAction = task => dispatch => {
type: FETCH_V2V_MIGRATION_TASK_LOG,
payload: new Promise((resolve, reject) => {
http
.get(`/migration_log/download_migration_log/${task.id}`)
.get(`/migration_log/download_migration_log/${task.id}?log_type=${logType}`)
.then(response => {
resolve(response);
dispatch({
type: DOWNLOAD_LOG_COMPLETED,
payload: task.id
});
const v2vLogFileName = `${task.vmName}.log`;
let filenameSuffix = '';
if (logType === 'v2v') filenameSuffix = 'virt-v2v';
if (logType === 'wrapper') filenameSuffix = 'virt-v2v-wrapper';
const v2vLogFileName = `${task.vmName}-${filenameSuffix}.log`;
if (response.data.status === 'Ok') {
const file = new File([response.data.log_contents], v2vLogFileName, { type: 'text/plain;charset=utf-8' });
saveAs(file);
const successMsg = sprintf(__('"%s" download successful'), `${task.vmName}.log`);
const successMsg = sprintf(__('"%s" download successful'), v2vLogFileName);
dispatch({
type: V2V_NOTIFICATION_ADD,
message: successMsg,
Expand All @@ -191,7 +194,7 @@ export const downloadLogAction = task => dispatch => {
} else {
const failureMsg = sprintf(
__('Failed to download "%s". Reason - "%s"'),
`${task.vmName}.log`,
v2vLogFileName,
parseComplexErrorMessages(response.data.status_message)
);
dispatch({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class PlanRequestDetailList extends React.Component {
onSelect = (eventKey, task) => {
const { downloadLogAction, fetchOrchestrationStackUrl, fetchOrchestrationStackAction } = this.props;
if (eventKey === 'migration') {
downloadLogAction(task);
downloadLogAction(task, 'v2v');
} else if (eventKey === 'wrapper') {
downloadLogAction(task, 'wrapper');
} else {
fetchOrchestrationStackAction(fetchOrchestrationStackUrl, eventKey, task);
}
Expand Down Expand Up @@ -416,6 +418,12 @@ class PlanRequestDetailList extends React.Component {
>
{__('Migration log')}
</MenuItem>
<MenuItem
eventKey="wrapper"
disabled={downloadLogInProgressTaskIds && downloadLogInProgressTaskIds.indexOf(task.id) > -1}
>
{__('Virt-v2v-wrapper log')}
</MenuItem>
{task.options.postPlaybookComplete && (
<MenuItem
eventKey="postMigration"
Expand Down

0 comments on commit 55ee3b8

Please sign in to comment.