Forum Discussion

Richard_Ortiz's avatar
12 years ago

Dependencies or Parent/Child Relationships

Allow devices to be dependent on one another. If a router goes down, the switch behind it will most likely go down or have an error as well.

  • We are staring at the fishline Stuart. Hopefully last question and an example:

    1. (example): write a TopologySource that ties those ERIs together:  Any chance you could provide the TS configurations utilized to actually build the dependencies?

    Thank you again Stuart.

     

     

  • Anonymous's avatar
    Anonymous

    Sure. Normally the TS discovers the relationships by querying the device and asking "who is your neighbor" or something along those lines. For VMWare, the TS talks to the vCenter server to get the relationships. This is why ERIs are needed. When you talk to a system that knows about the nodes on the map, that system may have its own way of identifying those objects. The ERIs previously added serve as the multiple ways that third party systems might refer to those objects. Some, like the cam table in a router, refer to neighbors using MAC addresses. Some, like vCenter, may use a FQDN or some other ID. As long as the third party system responds with relationships between objects, and refers to those objects using an ERI that is on the device, the relationship can be mapped in LM. 

    Think of it this way, if I (as a TopologySource) am telling you that Bob (parent) has 3 sons, Andy (child), Stuart (child), and John (child), then you would need to make sure you know who those four people are, especially if you only know those four people by email address. You would need an external resource identifier (ERI) that maps Bob to Bob's email, Andy to Andy's email, etc.  That way, when I tell you about Bob's children, you can know who I'm talking about, definitively. 

    So, for a TS, you have two options: 1) query some system that knows which parents have which children or 2) manually hard code the relationship in the code. #1 is not likely an option, so you'll probably have to do #2, but let's discuss it anyway:

    If you have some system that identifies parental relationships to children, we have to make sure the ERIs we've set on each device in LM match the IDs that the system will use to identify the devices. So, if your third party system identifies things by FQDN, you'll need to write an ERISource that adds FQDN as an ERI. If your third party system identifies things by IP address, you'll need to write an ERISource that adds the IP address(es) as ERI(s).

    Then, it's just a matter of writing the TS that asks the system to list out the relationships. Your script would contact the system, make the request, then format the output. The output would be in this format:

    {
      "edges": [
        {
          "type": "Depends On",
          "from": "LMID_2",
          "to": "LMID_1"
        },
        {
          "type": "Depends On",
          "from": "LMID_3",
          "to": "LMID_1"
        }
      ]
    }

    You may want to parse through the data and make the relationship bidirectional, adding "Supports" relationships from the parent nodes to the children nodes, but it's not strictly required.

     

    If you're going to hard code the relationships in the code, it's just a simple print statement, outputting the mapping shown above. It might be a much longer print statement in your case.

  • What would the TS code be which generated the output above?......please.

  • Anonymous's avatar
    Anonymous
    println('{"edges":[{"type":"Depends On","from":"LMID_2","to":"LMID_1"},{"type":"Depends On","from":"LMID_3","to":"LMID_1"}]}')

    There are alternative ways, but this is the most straightforward. One alternative way is to build a Groovy map (similar to a Python dictionary) containing the entries. Then convert the Groovy map to json and print it out.

  • I take it ERIs are exact matches. Is there any way to use regex for the "to" side?

    For exampke, where I have a resource with ERI "ABC001-START", I want it to have edges with any other resource where the ERI matches regex ABC001-OTHER.*.  

        {
          "type": "Depends On",
          "from": "ABC001-START",
          "to": "ABC001-OTHER.*"
        },
  • Anonymous's avatar
    Anonymous
    47 minutes ago, Mosh said:

    I take it ERIs are exact matches. Is there any way to use regex for the "to" side?

    No way to wildcard either side as far as i'm aware.

  • 6 hours ago, Stuart Weenig said:

    No way to wildcard either side as far as i'm aware.

    I suspected not, but thought I'd ask anyway ?

    In my use case the "ABC001-OTHER..." resources are typically sequentially numbered, e.g."ABC001-OTHER01", "ABC001-OTHER02", "ABC001-OTHER03", etc. so I can work around it by simply using a loop in the code to generate entries in the edges collection for resources that may not yet exist, but if they came into existence then they would fall into place.  

     

  • Anonymous's avatar
    Anonymous
    5 hours ago, Mosh said:

    I can work around it by simply using a loop in the code to generate entries in the edges collection for resources that may not yet exist

    Exactly what I'd do.

  • Stuart....I wanted to thank you again for your guidance....and patience... with this manual mapping. I was able to get the functionality to work on a small scale.

    Thank you!