archi-contribs / snow-import-plugin

Service Now import plugin
Other
14 stars 5 forks source link

INI Configuration #1

Closed javichu1991 closed 5 years ago

javichu1991 commented 6 years ago

Buenos días herve,

necesito integrar Service Now con Archi. He instalado el plugin para Archi 4 pero tengo probelmas para entender el archivo .ini. ¿podrías echarme una mano para configurar el archivo?

Gracias y un saludo, Javier.

javichu1991 commented 6 years ago

Good morning, Herve,

I need to integrate Service Now with Archi. I have installed the plugin for Archi 4 but I have problems to understand the .ini file. Could you give me a hand to set up the file?

Thanks and best regards, Javier.

herve91 commented 6 years ago

Hi Javier,

To be honest, the ServiceNow plugin has not been used by a lot of people. It may not be very useful for you as it has been developed to map full ServiceNow tables to Archi and it was more than 2 years ago. I do not know if the plugin still works with the actual datamodel of ServiceNow.

This said, the ini file has got comments that explain the different fields to fill in.

So could you be a bit more explicit about the help you require and I'll do my best to assist you.

Best regards Hervé

javichu1991 commented 6 years ago

Good Morning, I want to load a Service Now table in Archi. The table is cmdb_ci_database. To do that, I only have the following in the .ini file. Then I give "File / import / import from service now" but it gives me an error. Could you tell me what the error is?

Thanks and best regards, Javier.

javichu1991 commented 6 years ago

SNowPlugin.version = 1.1

log4j.rootLogger = ALL, SNowPlugin

log4j.appender.SNowPlugin = org.apache.log4j.FileAppender log4j.appender.SNowPlugin.ImmediateFlush = true log4j.appender.SNowPlugin.Append = false log4j.appender.SNowPlugin.encoding = UTF-8 log4j.appender.SNowPlugin.File = C:\archimate-import_servicenow.log log4j.appender.SNowPlugin.layout = org.apache.log4j.PatternLayout log4j.appender.SNowPlugin.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %-5p : %m%n

servicenow.site = https://dev64799.service-now.com/ servicenow.user = admin servicenow.pass = Vz3BOzWVge8z

archi.elements.id = sys_id archi.elements.name = name archi.elements.documentation = short_description archi.elements.folder = sys_class_name

##
## Generic Archi elements properties
##

archi.elements..sys_id = sys_id archi.elements..sys_class_name = sys_class_name

## mapping between ServiceNow CI and Archi elements

## SystemSoftware

archi.elements.cmdb_ci_database.mapping = "SystemSoftware" archi.elements.cmdb_ci_database.folder = "Business"

javichu1991 commented 5 years ago

I have managed to connect to the Service Now Database.

I commented: I have a table called "x_252969_test_cmdb_ci_database". In that table I have 6 records. The columns are: Active, Number, Name, Description, Type, Version. How do I have to put this in the .ini code so that I get the properties in ARCHI.

With the following code I only load the 6 objects of type "SystemSoftware" and in the properties only the sys_class_name and sys_id. How do I have to put it so that I put all the properties?

I put only the code part of the properties

Thanks and best regards, Javier.

javichu1991 commented 5 years ago

.... .... ...

archi.elements.id = sys_id archi.elements.name = name archi.elements.documentation = short_description archi.elements.folder = sys_class_name

##
## Generic Archi elements properties
##

archi.elements.x_252969_prueba_cmdb_ci_database.sys_id = sys_id archi.elements.x_252969_prueba_cmdb_ci_database.sys_class_name = sys_class_name

## mapping between ServiceNow CI and Archi elements

## Locations

archi.elements.x_252969_prueba_cmdb_ci_database.mapping = "SystemSoftware" archi.elements.x_252969_prueba_cmdb_ci_database.folder = "prueba"

herve91 commented 5 years ago

Hi,

The plugin is effectively a bit too old to work with the latest version of Archi (4.2):

I recompiled a new 1.2 version with these 2 changes and it works with my ServiceNow access :-)

Please note that you also need to double the backslash in your log filename (i.e. C:\archimate-import_servicenow.log).

Best regards Hervé

javichu1991 commented 5 years ago

Thank you very much for the help Herve91,

Regarding the .log file: • Regarding the .log file, do not believe me and yes I have put the double bar, is it necessary to have created the .log previously? • Yes, I have the double the backslash

Regarding the behavior of the .ini I have some doubts. If you can connect to my instance in Service Now:

servicenow.site = https://dev64799.service-now.com/
servicenow.user = admin servicenow.pass = Everis01

You can see that I have an application called test and in it a table called "x_252969_prueba_cmdb_ci_database" with the following fields: Active, Number, Name, Description, Type, Version, etc.

These fields do load me in the properties of the objects, putting it in the following way:

image

The problem comes when you create the objects, you create them all with the name "System Software". How do I have to do it so that I put the names and the documentation in each one of the objects? I do not mean in the "propierties" tab but in the "main" tab of each object.

image

Could you give me your email and we talk better? Would be a great help

I hope you have explained me well.

Thanks and best regards, Javier.

javichu1991 commented 5 years ago

I do not need a proxy. The code of the servicenow.ini that I use is the following:

SNowPlugin.version = 1.1

##
## logfile properties
## ------------------
## Used to manage the log file. All the Log4J properties may be used.
##

log4j.rootLogger = ALL, SNowPlugin

log4j.appender.SNowPlugin = org.apache.log4j.FileAppender log4j.appender.SNowPlugin.ImmediateFlush = true log4j.appender.SNowPlugin.Append = false log4j.appender.SNowPlugin.encoding = UTF-8 log4j.appender.SNowPlugin.File = C:\\archimate-import_servicenow.log log4j.appender.SNowPlugin.layout = org.apache.log4j.PatternLayout log4j.appender.SNowPlugin.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %-5p : %m%n

##
## ServiceNow properties
## ---------------------
## Used to specify how to retrieve data from theServiceNow website.
##      servicenow.site = URL                      spécifies the URL of ServiceNow web site
##      servicenow.user = username                 spécifies the credentials to send to ServiceNow
##      servicenow.pass = password
##      servicenow.sysparm_limit = nb              specifies the maximum number of CIs to retrieve
##                                                    if not specified or if zero, then ServiceNow
##                                                    limits to 10.000 objects
##

servicenow.site = https://dev64799.service-now.com/ servicenow.user = admin servicenow.pass = Everis01

servicenow.sysparm_limit = 50000

##
## Archi elements properties
## -------------------------
## Used to map ServiceNow objects (CI) to Archi elements
## The following properties allow to specify the ServiceNow column that contains the desired value.
## One may use double quote to specify a constant or slashes to specify a path.
##
##      archi.elements.id                          default ID of the Archi element
##      archi.elements.name                        default name of the the Archi element
##      archi.elements.documentation               default documentation of the Archi element
##      archi.elements.folder                      default folder where the Archi element will be created
##
##      archi.elements.<SNow table>.mapping        Type of the Archi element to create for each CI in the ServiceNow table
##      archi.elements.<SNow table>.id             ID of the Archi element
##      archi.elements.<SNow table>.name           Name of the the Archi element
##      archi.elements.<SNow table>.documentation  Documentation of the Archi element
##      archi.elements.<SNow table>.folder         Folder where the Archi element will be created.
##
## All the other properties will be mapped to Archi properties
## <Snow table> may be replaced by a star '*' to be used for all the ServiceNow tables.
##

archi.elements.id = sys_id archi.elements.name = name archi.elements.documentation = short_description archi.elements.folder = sys_class_name

##
## Generic Archi elements properties
##

archi.elements.x_252969_prueba_cmdb_ci_database.sys_id = sys_id archi.elements.x_252969_prueba_cmdb_ci_database.sys_class_name = sys_class_name archi.elements.x_252969_prueba_cmdb_ci_database.active = u_active archi.elements.x_252969_prueba_cmdb_ci_database.numero = u_numero archi.elements.x_252969_prueba_cmdb_ci_database.nombre = u_nombre archi.elements.x_252969_prueba_cmdb_ci_database.descripcion = u_descripcion archi.elements.x_252969_prueba_cmdb_ci_database.tipo = u_tipo archi.elements.x_252969_prueba_cmdb_ci_database.version = u_version archi.elements.x_252969_prueba_cmdb_ci_database.propietario = u_propiedad_de archi.elements.x_252969_prueba_cmdb_ci_database.grupo_propietario = u_grupo_propietario archi.elements.x_252969_prueba_cmdb_ci_database.aprobador = u_aprobador archi.elements.x_252969_prueba_cmdb_ci_database.grupo_aprobacion = u_grupo_aprobacion archi.elements.x_252969_prueba_cmdb_ci_database.grupo_soporte = u_grupo_de_soporte archi.elements.x_252969_prueba_cmdb_ci_database.grupo_soporte2 = u_grupo_de_soporte_2 archi.elements.x_252969_prueba_cmdb_ci_database.grupo_soporte3 = u_grupo_de_soporte_3 archi.elements.x_252969_prueba_cmdb_ci_database.creado = u_aprobador archi.elements.x_252969_prueba_cmdb_ci_database.actualizado = u_actualizado

## mapping between ServiceNow CI and Archi elements

## SystemSoftware

archi.elements.x_252969_prueba_cmdb_ci_database.mapping = "SystemSoftware" archi.elements.x_252969_prueba_cmdb_ci_database.folder = "prueba"

herve91 commented 5 years ago

Hi,

My apologies for this late answer, I just came back from holidays and spent a lot of time on roads these last days.

Basically, the ini file maps ServiceNow tables content to Archi components.

To check your ServiceNow structure, you may retrieve the following web service: https://dev64799.service-now.com/api/now/table/x_252969_prueba_cmdb_ci_database?sysparm_exclude_reference_link=true

Then you can see that there is no "name" property, so the mapping "archi.elements.name = name" lead to elements having no name, which is not permitted in Archi so the name defaults to the elements class.

In the opposite, you can see that there is a property called "u_nombre" which should be what you are searching for. So I believe you should replace the previous mapping by "archi.elements.name = u_nombre".

And same for "archi.elements.documentation = u_descripcion"

Hope this helps

Best regards Hervé

javichu1991 commented 5 years ago

Good morning Herve, Thank you very much for the contribution. You are saving my life! All objects are already created correctly.

Doing tests, I think I have detected an error.

If you modify the properties of the object in Archi, for example, I modify the properties "Active", "Descripcion" and "Tipo" of the object "0prueba_borrar",

image image

and then import again from Service Now (File-> Import-> Import from Service Now); it only modifies the "Active" property (false-> true), because it is the first property in alphabetical order. It does not modify either the "Description" property or the "Type" property.

image

Reviewing the code, I think the error may be in this loop on line 308, since it seems that in this loop it takes the properties and checks without having to update them or not, and apparently only takes the first property in alphabetical order.

for (Iterator i = element.getProperties().iterator(); i.hasNext(); ) { IProperty elementProperty = i.next(); if ( elementProperty.getKey().equals(propertyName) ) { if ( propertyValue.equals(elementProperty.getValue()) ) logger.trace(" existing property " + propertyName + " is not updated as value \"" + propertyValue + "\" is unchanged."); else if ( isSet(propertyValue) ) { logger.trace(" existing property " + propertyName + " is updated from value \"" + elementProperty.getValue() + "\" to value \"" + propertyValue + "\""); elementProperty.setValue(propertyValue); } else logger.trace(" existing property " + propertyName + " is not updated from value \"" + elementProperty.getValue() + "\" to empty value."); break nextProperty; } }

If I modify some property in Archi, it must be modified according to the properties of Service Now.

Can you help me? Thanks for the support.

Greetings, Javier.

javichu1991 commented 5 years ago

Another doubt ... is there any way to recognize the accents in the properties? For example, in the "aprobador" property, it should be: “José Manuel Gómez Rodríguez” but write “José Manuel Gómez Rodríguez”

image

herve91 commented 5 years ago

Hi,

I effectively found the property update and solved it. I let you check the 1.2.1 version. Please note that you'll have to update the property "SNowPlugin.version" to "1.2.1" at the top of the ini file.

As for the accents, this is not related to my plugin but to Archi. You need to run Archi in UTF-8, adding the following line to the archi.ini file (in Archi's folder): -Dfile.encoding=UTF-8

I close this case. Please do not hesitate to open a new one if you discover other issues.

Best regards Hervé