What is the correct formatting for XML files when importing using the Spectrum Modeling Gateway
search cancel

What is the correct formatting for XML files when importing using the Spectrum Modeling Gateway

book

Article ID: 49069

calendar_today

Updated On:

Products

CA Spectrum

Issue/Introduction

What is the correct formatting for XML files when importing using the Spectrum Modeling Gateway

Environment

Release: Any
Component: SPCDIS

Resolution

In the examples below the desired result is to a have a container created, a sub-container within this, a further sub-container created within this, into which devices are to be created.

First is an example where you can see incorrect formatting used in the modeling gateway XML file and as a result 3 devices are not placed in the topology in the correct location. Only the first container in the XML file is created (topology or location container). The other devices are created on the top topology view.

After this you will see an example with the correct formatting resulting in the creation of the containers in the desired location and 2 devices within them.

Finally there is an explanation of why the first example is incorrect, and the changes made in the second example so that the containers, sub-containers and devices are created correctly.

Example 1 - Incorrect syntax

<?xml version="1.0" standalone="no"?>
<!DOCTYPE Import SYSTEM ".modelinggateway.dtd">
 
<Import>
 
                <!-- Topology view -->
 
                <Topology complete_topology="false">
                <Topology_Container model_type="Network" name="EMEA">
                        <Topology_Container model_type="Network" name="UNITED-KINGDOM">
                                <Topology_Container model_type="Network" name="LONDON">
                                        <Device ip_dnsname="xxx.xxx.xxx.xxx"
                                                model_name="<DEVICE1>"
                                                discover_connections="true"
                                                community_string="xxxxx"/>
                                </Topology_Container>
                        </Topology_Container>
                </Topology_Container>
                <Topology_Container model_type="Network" name="EMEA">
                        <Topology_Container model_type="Network" name="UNITED-KINGDOM">
                                <Topology_Container model_type="Network" name="LIVERPOOL">
                                        <Device ip_dnsname="xxx.xxx.xxx.xxx"
                                                model_name="<DEVICE2>"
                                                discover_connections="true"
                                                community_string="xxxxx"/>
                                </Topology_Container>
                        </Topology_Container>
                </Topology_Container>
                <Topology_Container model_type="Network" name="EMEA">
                        <Topology_Container model_type="Network" name="UNITED-KINGDOM">
                                <Topology_Container model_type="Network" name="MANCHESTER">
                                        <Device ip_dnsname="xxx.xxx.xxx.xxx"
                                               model_name="<DEVICE3>"
                                                discover_connections="true"
                                                community_string="xxxxx"/>
                                </Topology_Container>
                        </Topology_Container>
                </Topology_Container>    
                            
                </Topology>
 
</Import>

 

Example 2- Correct Syntax:

<Import>
 
                <!-- Topology view -->
                <Topology complete_topology="false">
                <Topology_Container model_type="Network" name="EMEA">
                        <Topology_Container model_type="Network" name="UNITED-KINGDOM">
                                <Topology_Container model_type="Network" name="LONDON">
                                        <Device ip_dnsname="xxx.xxx.xxx.xxx"
                                                model_name="<DEVICE1>"
                                                community_string="public"/>
                                </Topology_Container>
                        <Topology_Container model_type="Network" name="LIVERPOOL">
                                        <Device ip_dnsname="xxx.xxx.xxx.xxx"
                                                model_name="<DEVICE2>"
                                                community_string="public"/>
                </Topology_Container>
                                <Topology_Container model_type="Network" name="MANCHESTER">
                                        <Device ip_dnsname="xxx.xxx.xxx.xxx"
                                                community_string="public"/>
                </Topology_Container>
                                </Topology_Container>
                                </Topology_Container>
 
                </Topology>
 
</Import>

 

Explanation of example 1 and example 2:

  1. The XML file defines where you want to add devices in the topology view and what containers to add.

  2. Every time you have an entry adding a container, for example, <Topology_Container model_type="Network" name="EMEA"> it must be must be terminated with the end tag </Topology_Container>.

  3. However once you define a container you don't need to repeat it as is done in example 1.

  4. The aim was to create a container named EMEA with a sub-container, UNITED-KINGDOM, which in turn has its own sub-container, LONDON, in which you want to create a device <DEVICE1>.

  5. In example 1 there are incorrectly added three </Topology_Container> end tags which means that the statement is completely closed. It should only have one </Topology_Container> end tag so that you still have the EMEA container and its sub-container, UNITED-KINGDOM, still open with only the LONDON container closed.

  6. After this you would then define the next container, LIVERPOOL, and the device to be added making sure to have an end tag to terminate the statement for this container.

  7. This process is continued for MANCHESTER and device as required, and then once you have finished you need to add a termination for MANCHESTER then another one end tag termination to close the EMEA container.

See example 2 from the fixed and note there is no repetition of EMEA and UNITED-KINGDOM (highlighted in bold in example 1 where repeated).

Additional Information

Please reference the "Modeling Gateway Toolkit" section of the documentation for more information.