Utilizzando i workflow di Automation Orchestrator, è possibile integrare Automation Assembler con ServiceNow per la conformità ITSM.

Il flusso di integrazione di ServiceNow passa attraverso diversi servizi e API di Cloud Assembly, vSphere, vRealize Orchestrator e ServiceNow.

In genere gli utenti aziendali integrano la propria piattaforma di gestione del cloud con una piattaforma di gestione dei servizi IT (ITSM, IT Service Management) e un database di gestione della configurazione (CMDB, Configuration Management Database) a scopo di conformità. Seguendo questo esempio è possibile integrare Automation Assembler con ServiceNow per CMDB e ITSM utilizzando i workflow di Automation Orchestrator. Quando si utilizzano le integrazioni e i workflow di Automation Orchestrator, i tag di funzionalità sono particolarmente utili se si dispone di più istanze per ambienti diversi. Per ulteriori informazioni sui tag di funzionalità, vedere Utilizzo di tag di funzionalità in Automation Assembler.
Nota: È inoltre possibile integrare ServiceNow con Automation Assembler utilizzando gli script dell'azione di estendibilità. Per informazioni sull'integrazione di ServiceNow utilizzando gli script dell'azione di estendibilità, vedere Come integrare Automation Assembler con ServiceNow utilizzando le azioni di estendibilità.

In questo esempio, l'integrazione di ServiceNow è composta da tre workflow di livello principale. Ogni workflow dispone delle proprie sottoscrizioni in modo che sia possibile aggiornare e iterare ciascun componente singolarmente.

  • Punto di ingresso della sottoscrizione dell'evento - Registrazione di base, identifica l'utente richiedente e la macchina virtuale di vCenter, se applicabile.
  • Workflow di integrazione - Separa gli oggetti e inserisce gli input nel workflow tecnico, gestisce gli aggiornamenti della registrazione, delle proprietà e dell'output.
  • Workflow tecnico - Integrazione di sistema a valle per l'API di ServiceNow per creare l'API di CI CMDB, CR e Automation Assembler IaaS con altre proprietà della macchina virtuale esterne al payload.

Prerequisiti

Procedura

  1. Creare e salvare un file di configurazione in Automation Orchestrator che contenga una configurazione comune utilizzata in più workflow.
  2. Salvare il token dell'API Automation Assembler nella stessa posizione del file di configurazione del passaggio 1.
    Nota: Il token dell'API Automation Assembler ha una scadenza.
  3. Creare un workflow in Automation Orchestrator con l'elemento script specificato. Questo script fa riferimento a un host REST e lo individua. Inoltre, standardizza le azioni REST che utilizzano un parametro facoltativo di un token, aggiunto come ulteriore intestazione di autorizzazione.
    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"];

    Questo script invia l'output cpuCount e memoryMB al workflow principale e aggiorna le proprietà customProperties esistenti. Questi valori possono essere utilizzati nei workflow successivi durante la creazione di CMDB.

  4. Aggiungere l'elemento script Crea CI di CMDB ServiceNow al workflow. Questo elemento individua l'host REST ServiceNow utilizzando l'elemento di configurazione, crea un'operazione REST per la tabella cmdb_ci_vmware_instance, crea una stringa di oggetto contenuto in base agli input del workflow per i dati di pubblicazione e restituisce il valore 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. Mediante l'output del workflow secondario, creare un oggetto proprietà utilizzando il valore customProperties esistente e sovrascrivere la proprietà serviceNowSysId con il valore di ServiceNow. Questo ID univoco viene utilizzato in CMDB per contrassegnare un'istanza come ritirata dopo l'eliminazione.

risultati

Automation Assembler è stato integrato correttamente con ITSM ServiceNow. Per ulteriori informazioni su come utilizzare i workflow per integrare ServiceNow in Automation Assembler, vedere Estensione di Cloud Assembly con l'integrazione di vRealize Orchestrator per ServiceNow.