워크플로우에서 audit 함수를 호출하여 감사 레코드를 내보낼 수 있습니다. audit 함수의 유일한 인수는 감사 로그에 넣을 문자열입니다.
실행하는 데 다소 시간이 걸릴 수 있는 복잡한 워크플로우의 경우 워크플로우를 실행하는 사용자에게 명확한 진행 정보를 제공하면 유용할 수 있습니다. 워크플로우 실행이 이러한 방식으로 보고될 수 있도록 하려면 execute 멤버가 단계 배열을 반환해야 합니다. 각 배열 요소에는 다음 멤버가 포함되어야 합니다.
|
전체 워크플로우의 execute 함수와 마찬가지로 각 단계의 execute 멤버에는 워크플로우에 대한 매개변수를 포함하는 객체가 해당 인수로 사용됩니다.
예 24 워크플로우 실행 보고다음은 세 단계를 거쳐 새 프로젝트, 공유 및 감사 레코드를 만드는 워크플로우 예입니다.
var steps = [ { step: 'Checking for associated project', execute: function (params) { try { run('shares select ' + params.unit); } catch (err) { if (err.code != EAKSH_ENTITY_BADSELECT) throw (err); /* * We haven't yet created a project that corresponds to * this business unit; create it now. */ run('shares project ' + params.unit); set('mountpoint', '/export/' + params.unit); run('commit'); run('shares select ' + params.unit); } } }, { step: 'Creating share', execute: function (params) { run('filesystem ' + params.name); run('commit'); } }, { step: 'Creating audit record', execute: function (params) { audit('created "' + params.name + '" in "' + params.unit); } } ]; var workflow = { name: 'Create share', description: 'Creates a new share in a business unit', parameters: { name: { label: 'Name of new share', type: 'String' }, unit: { label: 'Business unit', type: 'ChooseOne', options: [ 'development', 'finance', 'qa', 'sales' ], optionlabels: [ 'Development', 'Finance', 'Quality Assurance', 'Sales/Administrative' ], } }, validate: function (params) { try { run('shares select ' + params.unit); run('select ' + params.name); } catch (err) { if (err.code == EAKSH_ENTITY_BADSELECT) return; } return ({ name: 'share already exists' }); }, execute: function (params) { return (steps); } };
메일 기능을 사용하면 워크플로에서 전자메일을 통해 워크플로의 특정 출력을 제공할 수 있습니다. 메일 기능에는 to 및 subject가 있는 객체와 messageBody 문자열 인수가 포함되어 있어야 합니다.
예 25 메일러를 사용하여 워크플로 실행var workflow = { name: 'email controller state', description: 'email controller state', execute: function () { // verify state of the controller var faulted = run('maintenance hardware "chassis-000" get faulted'); var messageBody = faulted; emailAddress = 'first.last@xyz.com'; subjectLine = 'Controller State'; mail({To: emailAddress, Subject: subjectLine}, messageBody); } };