확장성 작업을 사용하여 Automation Assembler와 ServiceNow를 통합하는 방법
Automation Assembler
와 ServiceNow를 통합하는 방법확장성 작업을 사용하면
Automation Assembler
를 ServiceNow 같은 Enterprise ITSM과 통합할 수 있습니다.
- 이 통합을 구성하기 전에 조건부 클라우드 템플릿 속성event.data["customProperties"]["enable_servicenow"] === "true"를 사용하여 모든 이벤트 구독을 필터링합니다.이 속성은 ServiceNow 통합이 필요한 클라우드 템플릿에 있습니다.
- Python을 다운로드하고 설치합니다.
구독 필터링에 대한 자세한 내용은 확장성 구독 생성 항목을 참조하십시오.

엔터프라이즈 사용자는 규정 준수를 위해 일반적으로 Cloud Management Platform을 ITSM(IT 서비스 관리) 및 CMDB(구성 관리 데이터베이스) 플랫폼과 통합합니다. 이 예시를 사용하면 확장성 작업 스크립트를 사용하여 CMDB 및 ITSM을 위해
Automation Assembler
를 ServiceNow와 통합할 수 있습니다. 또한
Automation Orchestrator 클라이언트
워크플로를 사용하여 ServiceNow를 Automation Assembler
와 통합할 수도 있습니다. 워크플로를 사용하여 ServiceNow를 통합하는 방법에 대한 자세한 내용은 Automation Orchestrator 클라이언트 워크플로를 사용하여 ITSM용 Automation Assembler와 ServiceNow를 통합하는 방법 항목을 참조하십시오. 이 통합을 생성하기 위해 4개의 확장성 작업 스크립트를 사용합니다. 처음 3개의 스크립트는 프로비저닝 중에 순차적으로 시작됩니다(프로비저닝 후 계산 이벤트). 4번째 스크립트는 제거 후 계산 이벤트 시점에 트리거됩니다.
이벤트 항목에 대한 자세한 내용은 Automation Assembler에서 제공되는 이벤트 항목 항목을 참조하십시오.

VM 세부 정보 가져오기
VM 세부 정보 가져오기 스크립트는 CI 생성에 필요한 페이로드 세부 정보 및
Amazon Web Services
Systems Manager(SSM) Parameter Store에 저장되어 있는 ID 토큰을 가져옵니다. 또한 이 스크립트는 나중에 사용하기 위해 추가적인 속성으로 customProperties
를 업데이트합니다. ServiceNow CMDB CI 생성
ServiceNow CMDB CI 생성 스크립트는 ServiceNow 인스턴스 URL을 입력으로 전달하고, 보안 요구 사항을 충족하도록 SSM에 인스턴스를 저장합니다. 이 스크립트는 ServiceNow CMDB 고유 레코드 ID 응답(sys_id)도 읽습니다. 이 스크립트는 이를 출력으로 전달하고 생성 시 사용자 지정 속성
serviceNowSysId
를 씁니다. 이 값은 인스턴스가 삭제될 때 CI를 회수된 것으로 표시하는 데 사용됩니다. Lambda가 SSM Parameter Store에 액세스할 수 있도록
VMware Aria Automation 서비스
Amazon Web Services
역할에 추가적인 사용 권한을 할당해야 할 수도 있습니다. ServiceNow 변경 사항 생성
이 스크립트는 ServiceNow 인스턴스 URL을 입력으로 전달하고 보안 요구 사항을 충족하기 위해 ServiceNow 자격 증명을 SSM으로 저장하여 ITSM 통합을 완료합니다.
ServiceNow 변경 사항 생성
ServiceNow CMDB CI 회수 스크립트는 ServiceNow 중지 메시지를 표시하고, 생성 스크립트에 생성된 사용자 지정 속성
serviceNowSysId
에 기반하여 CI를 회수된 것으로 표시합니다. - 가상 시스템에서 명령줄 프롬프트를 엽니다.
- VM 세부 정보 가져오기 스크립트를 실행합니다.from botocore.vendored import requests import json import boto3 client = boto3.client('ssm','ap-southeast-2') def handler(context, inputs): baseUri = inputs['url'] casToken = client.get_parameter(Name="casToken",WithDecryption=True) url = baseUri + "/iaas/login" headers = {"Accept":"application/json","Content-Type":"application/json"} payload = {"refreshToken":casToken['Parameter']['Value']} results = requests.post(url,json=payload,headers=headers) bearer = "Bearer " bearer = bearer + results.json()["token"] deploymentId = inputs['deploymentId'] resourceId = inputs['resourceIds'][0] print("deploymentId: "+ deploymentId) print("resourceId:" + resourceId) machineUri = baseUri + "/iaas/machines/" + resourceId headers = {"Accept":"application/json","Content-Type":"application/json", "Authorization":bearer } resultMachine = requests.get(machineUri,headers=headers) print("machine: " + resultMachine.text) print( "serviceNowCPUCount: "+ json.loads(resultMachine.text)["customProperties"]["cpuCount"] ) print( "serviceNowMemoryInMB: "+ json.loads(resultMachine.text)["customProperties"]["memoryInMB"] ) #update customProperties outputs = {} outputs['customProperties'] = inputs['customProperties'] outputs['customProperties']['serviceNowCPUCount'] = int(json.loads(resultMachine.text)["customProperties"]["cpuCount"]) outputs['customProperties']['serviceNowMemoryInMB'] = json.loads(resultMachine.text)["customProperties"]["memoryInMB"] return outputs
- CMDB 구성 항목 생성 작업을 실행합니다.from botocore.vendored import requests import json import boto3 client = boto3.client('ssm','ap-southeast-2') def handler(context, inputs): snowUser = client.get_parameter(Name="serviceNowUserName",WithDecryption=False) snowPass = client.get_parameter(Name="serviceNowPassword",WithDecryption=True) table_name = "cmdb_ci_vmware_instance" url = "https://" + inputs['instanceUrl'] + "/api/now/table/{0}".format(table_name) headers = {'Content-type': 'application/json', 'Accept': 'application/json'} payload = { 'name': inputs['customProperties']['serviceNowHostname'], 'cpus': int(inputs['customProperties']['serviceNowCPUCount']), 'memory': inputs['customProperties']['serviceNowMemoryInMB'], 'correlation_id': inputs['deploymentId'], 'disks_size': int(inputs['customProperties']['provisionGB']), 'location': "Sydney", 'vcenter_uuid': inputs['customProperties']['vcUuid'], 'state': 'On', 'sys_created_by': inputs['__metadata']['userName'], 'owned_by': inputs['__metadata']['userName'] } results = requests.post( url, json=payload, headers=headers, auth=(snowUser['Parameter']['Value'], snowPass['Parameter']['Value']) ) print(results.text) #parse response for the sys_id of CMDB CI reference if json.loads(results.text)['result']: serviceNowResponse = json.loads(results.text)['result'] serviceNowSysId = serviceNowResponse['sys_id'] print(serviceNowSysId) #update the serviceNowSysId customProperty outputs = {} outputs['customProperties'] = inputs['customProperties'] outputs['customProperties']['serviceNowSysId'] = serviceNowSysId; return outputs
- 생성 작업 스크립트를 실행합니다.from botocore.vendored import requests import json import boto3 client = boto3.client('ssm','ap-southeast-2') def handler(context, inputs): snowUser = client.get_parameter(Name="serviceNowUserName",WithDecryption=False) snowPass = client.get_parameter(Name="serviceNowPassword",WithDecryption=True) table_name = "change_request" url = "https://" + inputs['instanceUrl'] + "/api/now/table/{0}".format(table_name) headers = {'Content-type': 'application/json', 'Accept': 'application/json'} payload = { 'short_description': 'Provision CAS VM Instance' } results = requests.post( url, json=payload, headers=headers, auth=(snowUser['Parameter']['Value'], snowPass['Parameter']['Value']) ) print(results.text)
Automation Assembler
가 ITSM ServiceNow와 통합되었습니다.
필요한 경우, CMDB 구성 항목 회수 작업을 사용하여 CI를 회수할 수 있습니다.
from botocore.vendored import requests import json import boto3 client = boto3.client('ssm','ap-southeast-2') def handler(context, inputs): snowUser = client.get_parameter(Name="serviceNowUserName",WithDecryption=False) snowPass = client.get_parameter(Name="serviceNowPassword",WithDecryption=True) tableName = "cmdb_ci_vmware_instance" sys_id =inputs['customProperties']['serviceNowSysId'] url = "https://" + inputs['instanceUrl'] + "/api/now/"+tableName+"/{0}".format(sys_id) headers = {'Content-type': 'application/json', 'Accept': 'application/json'} payload = { 'state': 'Retired' } results = requests.put( url, json=payload, headers=headers, auth=(inputs['username'], inputs['password']) ) print(results.text)