如何使用
Automation Orchestrator 用戶端
工作流程將
Automation Assembler
與 ServiceNow 整合以符合 ITSM

使用
Automation Orchestrator 用戶端
主控的工作流程,可以將
Automation Assembler
與 ServiceNow 整合以實現 ITSM 符合性。
ServiceNow 整合流程經過幾個 Cloud Assembly、vSphere、vRealize Orchestrator 以及 ServiceNow 服務和 API。
企業使用者通常會將其雲端管理平台與 IT 服務管理 (ITSM) 和設定管理資料庫 (CMDB) 平台整合以實現符合性。按照此範例,您可以使用
Automation Orchestrator 用戶端
主控的工作流程將
Automation Assembler
與適用於 CMDB 和 ITSM 的 ServiceNow 整合。使用
Automation Orchestrator 用戶端
整合和工作流程時,如果您有不同環境的多個執行個體,則功能標籤特別有用。如需有關功能標籤的詳細資訊,請參閱在 Automation Assembler 中使用功能標籤
還可以使用擴充性動作指令碼將 ServiceNow 與
Automation Assembler
整合。如需使用擴充性動作指令碼整合 ServiceNow 的相關資訊,請參閱如何使用擴充性動作將 Automation Assembler 與 ServiceNow 整合
在此範例中,ServiceNow 整合由三個頂層工作流程組成。每個工作流程都有自己的訂閱,以便您可以單獨更新和逐一查看每個元件。
  • 事件訂閱進入點 - 基本記錄,識別申請使用者和 vCenter 虛擬機器 (如果適用)。
  • 整合工作流程 - 分隔技術工作流程的物件和摘要輸入,處理記錄、內容和輸出更新。
  • 技術工作流程 - 下游系統整合,可供 ServiceNow API 建立具有除裝載以外的其他虛擬機器內容的 CMDB CI、CR 和
    Automation Assembler
    IaaS API。
  1. Automation Orchestrator 用戶端
    中建立和儲存包含多個工作流程中常用的組態的組態檔。
  2. Automation Assembler
    API Token 儲存到與步驟 1 中的組態檔相同的位置。
    Automation Assembler
    API Token 會到期。
  3. Automation Orchestrator 用戶端
    中建立具有提供的指令碼元素的工作流程。此指令碼將參考並尋找 REST 主機。此指令碼還會標準化使用 Token 的選擇性參數的 REST 動作,該參數新增為額外的授權標頭。
    var configPath = "CS" var configName = "environmentConfig" var attributeName = "CASRestHost" //get REST Host from configuration element var restHost = System.getModule("au.com.cs.example").getRestHostFromConfig(configPath,configName,attributeName) var ConfigurationElement = System.getModule("au.com.cs.example").getConfigurationElementByName(configName,configPath); System.debug("ConfigurationElement:" + ConfigurationElement); var casToken = ConfigurationElement.getAttributeWithKey("CASToken")["value"] if(!casToken){ throw "no CAS Token"; } //REST Template var opName = "casLogin"; var opTemplate = "/iaas/login"; var opMethod = "POST"; // create the REST operation: var opLogin = System.getModule("au.com.cs.example").createOp(restHost,opName,opMethod,opTemplate); //cas API Token var contentObject = {"refreshToken":casToken} postContent = JSON.stringify(contentObject); var loginResponse = System.getModule("au.com.cs.example").executeOp(opLogin,null,postContent,null) ; try{ var tokenResponse = JSON.parse(loginResponse)['token'] System.debug("token: " + tokenResponse); } catch (ex) { throw ex + " No valid token"; } //REST Template Machine Details var opName = "machineDetails"; var opTemplate = "/iaas/machines/" + resourceId; var opMethod = "GET"; var bearer = "Bearer " + tokenResponse; var opMachine = System.getModule("au.com.cs.example").createOp(restHost,opName,opMethod,opTemplate); // (Rest Operation, Params, Content, Auth Token) var vmResponse = System.getModule("au.com.cs.example").executeOp(opMachine,null,"",bearer) ; try{ var vm = JSON.parse(vmResponse); } catch (ex) { throw ex + " failed to parse vm details" } System.log("cpuCount: " + vm["customProperties"]["cpuCount"]); System.log("memoryInMB: " + vm["customProperties"]["memoryInMB"]); cpuCount = vm["customProperties"]["cpuCount"]; memoryMB = vm["customProperties"]["memoryInMB"];
    此指令碼將輸出
    cpuCount
    memoryMB
    傳送至父系工作流程,並更新現有
    customProperties
    內容。建立 CMDB 時,可以在後續工作流程中使用這些值。
  4. 將「建立 ServiceNow CMDB CI」指令碼元素新增至工作流程。此元素使用組態項目尋找 ServiceNow REST 主機,為
    cmdb_ci_vmware_instance
    資料表建立 REST 作業,根據 post 資料的工作流程輸入建立一系列內容物件,並輸出傳回的
    sys_id
    var configPath = "CS" var configName = "environmentConfig" var attributeName = "serviceNowRestHost" var tableName = "cmdb_ci_vmware_instance" //get REST Host from configuration element var restHost = System.getModule("au.com.cs.example").getRestHostFromConfig(configPath,configName,attributeName) //REST Template var opName = "serviceNowCreatCI"; var opTemplate = "/api/now/table/" + tableName; var opMethod = "POST"; // create the REST operation: var opCI = System.getModule("au.com.cs.example").createOp(restHost,opName,opMethod,opTemplate); //cmdb_ci_vm_vmware table content to post; var contentObject = {}; contentObject["name"] = hostname; contentObject["cpus"] = cpuTotalCount; contentObject["memory"] = MemoryInMB; contentObject["correlation_id"]= deploymentId contentObject["disks_size"]= diskProvisionGB contentObject["location"] = "Sydney"; contentObject["vcenter_uuid"] = vcUuid; contentObject["state"] = "On"; contentObject["owned_by"] = owner; postContent = JSON.stringify(contentObject); System.log("JSON: " + postContent); // (Rest Operation, Params, Content, Auth Token) var ciResponse = System.getModule("au.com.cs.example").executeOp(opCI,null,postContent,null) ; try{ var cmdbCI = JSON.parse(ciResponse); } catch (ex) { throw ex + " failed to parse ServiceNow CMDB response"; } serviceNowSysId = cmdbCI['result']['sys_id'];
  5. 使用來自子系工作流程的輸出,透過現有
    customProperties
    建立一個內容物件並使用來自 ServiceNow 的值覆寫
    serviceNowSysId
    內容。此唯一識別碼在 CMDB 中用於將執行個體標記為銷毀時淘汰。
Automation Assembler
已成功與 ITSM ServiceNow 整合。