Sample CMDB Syncmapping to add LoadBalancer Service IP's to the CMDB

Version 2
    Share This:

    See:  Re: Is Load Balancer Service IP:Port # synched to CMDB?


    Duncan Grisby explains:


    Unfortunately, IP address information for LoadBalancerServices cannot be synchronized into the CMDB. The BMC_IPEndpoint CI has to be related with a BMC_HostedAccessPoint relationship to a subclass of BMC_System. The LoadBalancerService is mapped to a BMC_LogicalSystemComponent, which is not a subclass of BMC_System.


    The name attribute contains the configured name of the service. You could choose to populate Name, ShortDescription or Description of the BMC_LogicalSystemComponent CI with the IP address and port instead, but there is unfortunately no good place to put the information separately.



    One way around the limitation is to use a BMC_Dependency relationship instead of BMC_LogicalSystemComponent relationship.


    If you want these IP's in your CMDB, and are willing to accept BMC_Dependency as the relationship between your LoadBalancerService (BMC_LogicalSystemComponent) and the BMC_IPEndpoint, then try this Sample pattern, attached.



    If you use this mechanism (using BMC_Dependency relationships), the BMC_IPEndpoint CIs are considered "orphans" in the CMDB and show up in reports of orphaned CIs.

    If you choose the "exclude orphaned CIs" option in reconciliation, they will be skipped during reconciliation.



         Compatible with Discovery 11.3.

         Tested with Discovery 11.3.

         How to change for other versions:

             To be compatible with other versions, the "import" statement version may need to be revised to be consistent with the base syncmapping versions:

    from CMDB.LoadBalancerInstance import LoadBalancerInstance 2.3;

    from CMDB.NetworkDevice_ComputerSystem import NetworkDevice_ComputerSystem 2.1;



    Base Pattern:

            module:  CMDB.LoadBalancerInstance

            file:  LoadBalancerInstance.tpl


    Custom Pattern:

    // Community-shared pattern


    tpl 1.12 module CMDB.LoadBalancer_Instance_extend;



        origin := "Customer";

        tree_path := "Custom", "CMDB Sync", "LoadBalancerInstance_augment_IPs";

    end metadata;


    from CMDB.LoadBalancerInstance import LoadBalancerInstance 2.3;

    from CMDB.NetworkDevice_ComputerSystem import NetworkDevice_ComputerSystem 2.1;


    syncmapping LoadBalancerInstance_augment_IPs 1.0


        LoadBalancer Services IP addresses mapped to BMC_IPEndpoint, related to BMC_LogicalSystemComponent



            tags CMDB, Extension;

        end overview;


        mapping from LoadBalancerInstance.lb_service as lb_service

                ip_ep -> BMC_IPEndpoint;

        end mapping;



            log.debug("lb_service_ip 0: in the custom pattern");


            service_ci := LoadBalancerInstance.service_ci;

            computersystem := NetworkDevice_ComputerSystem.device_cs;


            log.debug("lb_service_ip 1:Process Load Balancer details for");

            log.debug("lb_service_ip 1.6: service_ci:  %service_ci%");

            log.debug("lb_service_ip 2.1: LogicalSystemComponent:  key=%service_ci.key%  name=%service_ci.Name%");

            log.debug("lb_service_ip 2.2: LogicalSystemComponent:  key=%lb_service.key%");


            ip_addr := lb_service.ip_addr;

            log.debug("lb_service_ip 3: ip_addr=%ip_addr%");


            if ip_addr and not ip_addr matches "" then

                log.debug("lb_service_ip 3.5: ip address is good.  Continuing. ip_addr=%ip_addr%");

                address_type  := 1; // IPv4

                protocol_type := 2; // IPv4


                if ip_addr has substring ":" then

                    address_type  := 2; // IPv6

                    protocol_type := 3; // IPv6

                end if;


                ip_ep := sync.BMC_IPEndpoint(

                            key               := "%lb_service.key%/IP/%ip_addr%",

                            Name              := ip_addr,

                            NameFormat        := "IP",

                            ShortDescription  := "ip_addr for LB service",

                            Description       := "ip_addr for LB service",

                            AddressType       := address_type,

                            Address           := ip_addr,

    //                      DNSHostName       := fqdn,

                            ManagementAddress := 0,     //ip_addr = scanned_via,

                            ProtocolType      := protocol_type,

    //                      PrefixLength      := ip_node.prefix_length,

    //                      SubnetMask        := ip_node.subnet_mask,

                            Company           := service_ci.Company,

                            Category          := "Network",

                            Type              := "Address",

                            Item              := "IP Address"


                log.debug("lb_service_ip 4: ip_ep.Name=%ip_ep.Name%");



                            Source          := service_ci,

                            Destination     := ip_ep,

                            Impacted        := service_ci,

                            Name            := "LOADBALANCERSERVICE_IP"



                log.debug("lb_service_ip 5: created relationship");

            end if;

        end body;

    end syncmapping;



    Result in the CMDB in BMC.CORE:BMC_LogicalSystemComponent relationships form:


    Below is the BMC_LogicalSystemComponent which represents a Load Balancer Service:


    The new BMC_Dependency relationship for the BMC_IPEndpoint is highlighted below: