Go to main content

Oracle® ZFS Storage Appliance 관리 설명서, 릴리스 OS8.8.x

인쇄 보기 종료

업데이트 날짜: 2021년 8월
 
 

워크플로우 실행 감사 및 보고

워크플로우에서 audit() 함수를 호출하여 감사 레코드를 내보낼 수 있습니다. audit 함수의 유일한 인수는 감사 로그에 넣을 문자열입니다.

audit() 함수를 사용하면 setidfalse로 설정된 경우에만 워크플로우를 실행한 실제 사용자를 표시합니다. 하지만 루트에서 워크플로우를 소유하고 setidtrue로 설정된 경우 감사 로그에는 다른 사용자가 워크플로우를 실행한 경우에도 루트를 사용자로 표시합니다.

setid가 어떻게 설정되어 있는지와는 상관없이 워크플로우를 실행 중인 사용자를 확인하려면 whoami() 함수를 사용합니다.

예 13  워크플로우 테스트 whoami 함수
   var workflow = {
        name: "Test whoami",
        description: "Print current username",
        execute: function () {
                return ("Hello " + whoami());
        }
};

실행하는 데 다소 시간이 걸릴 수 있는 복잡한 워크플로우의 경우 워크플로우를 실행하는 사용자에게 명확한 진행 정보를 제공하면 유용할 수 있습니다. 워크플로우 실행이 이러한 방식으로 보고될 수 있도록 하려면 execute 멤버가 단계 배열을 반환해야 합니다. 각 배열 요소에는 다음 멤버가 포함되어야 합니다.

표 156  실행 보고의 필수 멤버
필수 멤버
유형
설명
step
문자열
실행 단계의 이름을 나타내는 문자열입니다.
execute
함수
워크플로우 단계를 실행하는 함수입니다.

전체 워크플로우의 execute 함수와 마찬가지로 각 단계의 execute 멤버에는 워크플로우에 대한 매개변수를 포함하는 객체가 해당 인수로 사용됩니다.

예 14  워크플로우 실행 보고

다음은 세 단계를 거쳐 새 프로젝트, 공유 및 감사 레코드를 만드는 워크플로우 예입니다.

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); }
};

메일 기능을 사용하면 워크플로에서 전자메일을 통해 워크플로의 특정 출력을 제공할 수 있습니다. 메일 기능에는 tosubject가 있는 객체와 messageBody 문자열 인수가 포함되어 있어야 합니다.

예 15  메일러를 사용하여 워크플로 실행
    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);

       }
};