archi-contribs / snow-import-plugin

Service Now import plugin
Other
14 stars 5 forks source link

Relationships #2

Closed javichu1991 closed 5 years ago

javichu1991 commented 5 years ago

Good morning again Herve91,

I have already managed to pass the objects from Service Now to Archi. Thank you very much!

Now, I am trying to pass the service now relations to Archi and I have some doubts.

1- How should the relationships included in Service Now be so that Archi can read them?

2- Where do you get the id of each relationship? For example: 0454da4c6f7e9940f0721cef8d3ee4b9

3- Do you have to do a mapping for each relationship?

It would be very helpful if you could explain to me the relationship part of the serviceNow.ini file with an example of a Service Now table. You can do it?

Many thanks again and I await your comments.

Greetings, Javier.

herve91 commented 5 years ago

Hi Javier,

In fact, you do not need to adapt your ServiceNow relationships to my plugin, but rather adapt my plugin to your ServiceNow database.

My plugin ini file indicates how to convert ServiceNow relationships to Archi relationships.

As for elements, you may configure general parameter, and relationship specific mappings.

Let's consider the following lines:

archi.relations.id = sys_id archi.relations.source = child archi.relations.target = parent

For all relationships, the plugin will use the "sys_id" field of the ServiceNow relationship as the Archi relationship ID, the ServiceNow "child" field as the Archi relationship's source, and "parent" field as target.

Now, let's consider the following lines:

archi.relations.a8aab4c26f395900f0721cef8d3ee44a.mapping = AssignmentRelationship archi.relations.a8aab4c26f395900f0721cef8d3ee44a.name = "Is hosted on" archi.relations.a8aab4c26f395900f0721cef8d3ee44a.source = parent archi.relations.a8aab4c26f395900f0721cef8d3ee44a.target = child

This indicates that the "a8aab4c26f395900f0721cef8d3ee44a" ServiceNow relationships will be mapped in Archi as AssignmentRelationships, that the Archi relationship's name will be "Is hosted on", and that for those specific relationships, the order of source and target are inverted from what was specified in the global parameters.

The "parent" and "child" fileds in serviceNow are the ServiceNow IDs of the elements. So the relationships will be imported if, and only if, your elements have got the same ID between ServiceNow and Archi.

So if you imported your elements with the plugin, then the relationships can be imported. If you created your elements manually, you cannot import the relationships.

As stated previously, I did not use my plugin for a while now. Archi and ServiceNow evolved since I wrote my plugin, so my plugin may need to be adapted for relationships as it needed to be adapted for relationships.

So if you fail to do what you wish, please do not hesitate to tell me and I will have a closer look.

Best regards Hervé

javichu1991 commented 5 years ago

Thank you very much for the explanation.

I'm trying to get access to a Service Now that contains the relationships to see how they are configured and try to pass those relationships to Archi.

When I have access and see how the relationships are defined, I tell you.

As for the Archi id, surely, for the Service Now objects, as you comment, we will use the Service Now IDs to be able to use the relationships later.

Thanks and best regards, Javier.

herve91 commented 5 years ago

you're welcome.

javichu1991 commented 5 years ago

Hello Herve, Reviewing the code, when you are evaluating whether the relationships exist, on line 499 it is written:

IArchimateElement target = (IArchimateElement) ArchimateModelUtils.getObjectByID (model, getJsonField (jsonNode, this.iniProperties.getProperty ("archi.relations.dest")));

I understand that this sentence collects each of the target of each relationship, but it catches my attention "archi.relations.dest" should not it be "archi.relations.target"? In the file ServiceNow.ini it is declared as "archi.relations.target = parent"

Also, I believe that the "Update" counter is always 0, because it is not updated in any of the steps in the relations part.

this.updated = this.totalUpdated = 0; --line 480 this.logger.info("Imported " + (this.created+this.updated) + " relations from "+count+" relations received from ServiceNow ("+this.created + " created + " + this.updated + " updated)."); --line 526

Thanks and best regards, Javier.

herve91 commented 5 years ago

How could I missed this :-(

Thanks a lot for pointing me this issue. I just release the version 1.2.2. which replaced "archi.relations.dest" by "archi.relations.target".

Please let me know if it works better ...

herve91 commented 5 years ago

By the way, for your information, I will probably start a version 2 of the plugin which will be much more flexible. I was thinking of something like showing ServiceNow content, and allow the user to find and select the elements and relationships he wishes to download and then find a way to automatically match ServiceNow components with Archi components.

So please do not hesitate to send me your requirement or any ideas on how you would like things to work as nothing has started yet ... and you'll have to be patient because I already planned updates on my other plugins and I only have got 2 hands :-)

javichu1991 commented 5 years ago

Thanks for making the change.

If I find another problem, I'll tell you. By the way, have you seen the problem of the variable "update" in the relations part? I think it's always 0. In the elements part, this variable it's fine.

At the moment, as I indicated a few days ago, I am waiting to have access to the BD to know how the relationships are configured. It is the only part I have left, since my project consists solely of transferring the elements and relationships of Service Now to Archi. As soon as I have news, I will try to pass the relationships and if I have any problems I will write to you in case you can help me.

Thank you very much, Javier.

herve91 commented 5 years ago

I'm sorry but at this stage, the plugin is able to create relationships, not update them ...

I've got a todo regarding this point line 525 // TODO: verify what is done when relation already exists. Eventually, create method createOrReplaceArchiRelation

javichu1991 commented 5 years ago

Hello again Herve,

I'm almost finishing the project and all thanks to your plugin. These days I have been doing tests and I have detected some things. Can you help me?

1 - When importing the relations, I put it in the following way: archi.relations.6afd799338a02000c18673032c71b87b.name = "Runs" archi.relations.6afd799338a02000c18673032c71b87b.mapping = AssignmentRelationship

But when I see the name of the relationship, it appears empty. Why? "Runs" should appear, right?

image

2 - I have several elements with properties that in Service Now are of type "Reference". Is there any way that archi shows the value of the field and not the Service Now reference?

For example, the "Owner" field is a reference type field in Service Now. The name of the owner should appear in Archi but the field reference appears instead.

image

Thank you very much and greetings, Javier

herve91 commented 5 years ago

Hi Javier,

1) yes it should, but I must admit that it doesn't ... In fact, I've got a bug in my code ... Nest release will sove this point.

2) my plugin voluntarily ask ServiceNow to not follow the reference IDs (I add "?sysparm_exclude_reference_link=true" in the webservice request), else the volume of data will be very big (My ServiceNow database has got more than 30000 CIs in a single table and getting only few properties already takes more than 1 hour).

The issue here is that once I've got the ID (like the propietario property), I've lost the table name that contains that ID. So I do not have the ability to retreive the name of the owner with a second request.

So what I suggest is that I will add a flag somewhere that will allow to switch on or switch off the following of the reference ID. When it is switched off, il will reduce the volume of data transfered and therefore accelerate the download, and when it is switched on, I will allow to specify the field of the referenced link to consider. Something like:

archi.relations.propietario = owner#name

which would take the "name" field of the "owner" property.

I believe this would suits your need.

3) As I already told you, this plugin is the first I wrote and my knowledge of Archi, of Java and of the Eclipse framework was very little. I grew up on these and I am myself in the need of re-use my ServiceNow plugin, so I will work back on it to enhence its functionalities. So if you've got some ideas on what the plugin should do, please do not hesitate to tell me.

What I'm thinking of (with no preference order - yet):

Please do not hesitate to complete the list :)

Best regards Hervé

javichu1991 commented 5 years ago

Thank you very much for the quick response. I will investigate what more options you can include in your add-on.

Regarding point 2, will it be available in a new version? Would it be possible for you to give me a quick solution for the "references"?

I need to deliver a proof of the Service Now - Archi integration this week and this is a big problem for us.

As you said, I show you an example of my cmdb_ci_server table:

With true (https://sarebqa.service-now.com//api/now/table/cmdb_ci_server?sysparm_exclude_reference_link=true):

image

With false (https://sarebqa.service-now.com//api/now/table/cmdb_ci_server?sysparm_exclude_reference_link=false ):

image

As you see, the "owned by" field is a reference field and shows that its value is in the sys_user table. I also have other reference fields like "Assigned to". Is it possible that you give me a solution with your plugin for my last problem? ?

Thank you very much again for the collaboration.

Greetings, Javier.

herve91 commented 5 years ago

As you see, the information is not directly available in the json result:

So I need to update my code to allow th switch the sysparm parameter on and off, then I need to make a separate call to the link provided by ServiceNow, and finally I need to parse the result to get a specific field.

I started to develop the functionnality, but this will take some time.

herve91 commented 5 years ago

Hi Javier,

Just to keep you informed ... I'm working very hard for you ...

As of today in my dev version, you can specify a property like archi.elements.cmdb_ci_aix_server.property.processor = processor#display_name

The plugin will automatically switch the request to "sysparm_exclude_reference_link=false" and will get the "display_name" from the link fiven in the "processor" field.

I'm currently implementing the possibility to follow several reference links like archi.elements.cmdb_ci_aix_server.property.pvus_per_core = processor#processor_mapping#pvus_per_core

After that, I need to fix few issues on the relations side.

So you won't have the functionality this week I'm afraid.

Best regards Hervé

herve91 commented 5 years ago

Dear Javier,

I've been working very hard to provide your the ability to follow links. the version 1.3 allows this.

Please pay attention, to increase this delivery speed; I've been obliged to change few things in the ini file. To ease the migration between the old and new syntax, I added a lot of details in the comments.

Please do not hesitate to drop me a line should you require some help.

Best regards Hervé

javichu1991 commented 5 years ago

Dear Hervé

 After change the properties of the ini file, I test the new release and it's work quite well. 

Thank you very much

Best regards, Javier.

herve91 commented 5 years ago

You're welcome.

I close this case. Please do not hesitate to open a new one if required ...

And if you find a way to determine the operational status of ServiceNow relations, I'm interested to know.

Best regards Hervé