Alert.png The wiki is deprecated and due to be decommissioned by the end of September 2022.
The content is being migrated to other supports, new updates will be ignored and lost.
If needed you can get in touch with EGI SDIS team using operations @ egi.eu.

GOCDB/Release4/XML Input

From EGIWiki
Jump to navigation Jump to search

<< Back to GOCDB/Documentation_Index

Overivew

The XML input module is used to insert gocdb object data into the database. The structure of an XML input file reflects the properties of those objects and of their relationships to other objects within the database (a hierarchical input file structure inserts data according to established parent-child object relationships). Data for many objects can be defined within a single input file.

XML Input File Formatting Rules

The formatting rules of an input XML document are as follows:

  • Element names and attribute values ARE case-sensitive.
  • The root element name is NOT significant (e.g. <results> is used for the Sample and Seed data).
  • The root element can contain one or more child Object elements.
  • An Object element MUST be named after an object that is already declared using the <object_type_name> value in the ‘$GOCDB_HOME/config/gocdb_schema.xml’ file. (In turn, the <abstract_class> that encloses the <object_type_name> is used to map the object directly to a database table – see ‘gocdb_schema.xml’ for more information).
  • Object elements MUST have a ‘gridID’ attribute of type integer. This value SHOULD always be ‘0’ to signify that the inserted object(s) belong to that grid. When inserting nested parent-child objects, the gridID value MUST be identical.
  • An Object element MUST contain one or more child elements that MUST be of the following type (ordering is NOT significant and multiples of both types ARE allowed):
    • A database Row element(s). This is a leaf element that MUST NOT nest child elements. The Row element’s name maps directly to an object’s attribute name (as established in ‘gocdb_schema.xml’ using <abstract_class><field><fname>). Row element value provides the value of the attribute. Row elements do NOT specify the ‘gridID’ attribute.
    • A nested child Object element(s).
  • A nested child Object element can only have a SINGLE parent element in that particular nesting hierarchy/branch. If an Object has many parents, each parent-child relationship needs to be defined directly beneath the root element as a new parent-child branch (a child object can only be enclosed by a single parent).
  • A Row element MAY define the key="primary" attribute to signify that this attribute value must NOT BE NULL and IS UNIQUE within the database (it effectively provides a primary key value). Important: If an object already exists in the database that defines the same attribute value, then ALL the attributes of that object will be updated with the new values of the input_xml Object’s attributes (rather than a new object being inserted).
  • An Object element MUST NOT define the key=”primary” attribute.

Worked Example

The XML input file example below demonstrates the rules defined above.

<?xml version="1.0" encoding="UTF-8"?>
<results> <!-- The root element name is not significant -->
    
    <!-- 
    'service_type' is an Object element. It refers to the value of an 
    <abstract_class><object_type_name> element that is defined in gocdb_schema.xml.
    Object elements have the 'grid_id' attribute. 
    -->
    <service_type grid_id="0">
        <!-- 
        The 'name' and 'description' leaf elements map to an object's attributes 
        (these elements have no children). 

        key="primary" signifies that the name attribute is NOT NULL and UNIQUE 
        in the database (it is a Primary key). If a 'service_type' object 
        already exists in the database with a name of 'Site-BDII', its 
        description will be updated and a new service_type will NOT be added. 
        -->
        <name key="primary">Site-BDII</name>
        <description>
            [Site service] This service collects and publishes site's data 
            for the Information System. All sites MUST install one Site-BDII. 
         </description>
    </service_type>
  
    <service_type grid_id="0">
        <name key="primary">CE</name>
        <description>
            [Site service] The LCG Compute Element. Currently the standard 
            CE within the gLite middleware stack. Soon to be replaced by the 
            CREAM CE. 
        </description>
    </service_type>
  
    <!-- 
    'group' is the name of the object used to define ROCs/NGIs.
    --> 
    <group grid_id="0">
        <!-- 
        'name' and 'email' are leaf elements that map to object attributes (see above).  
        -->
        <name key="primary">AsiaPacific</name>
        <email>contact@fakeemail.aproc.org</email>
        <!--
        Parent 'group' object is related to the child 'group_type' object. This 
        relationship is defined in gocdb_schema.xml file using the 
        <abstract_class> and <linktype> elements. 
        -->
        <group_type grid_id="0">
            <name key="primary">ROC</name>
            <description>Regional Operation Centre</description>
        </group_type>
        <!-- 
        A parent group (NGI) has a child 'site' object ('site' is nested in 'group'). 
        -->
        <site grid_id="0">
            <!-- The site's SHORT_NAME attribute uniquely identifies this site -->
            <SHORT_NAME key="primary">YAS-FTP</SHORT_NAME>
            <!-- A site can have one or more child 'service_endpoint' objects -->
            <service_endpoint grid_id="0">
                <!-- A service_endpoint has the following attributes -->
                <ENDPOINT key="primary">myce.myurl.comCE</ENDPOINT>
                <HOSTNAME>myce.myurl.com</HOSTNAME>
                <HOST_IP>111.222.333.441</HOST_IP>
                <HOST_OS>RH7</HOST_OS>
                <HOST_ARCH>86x32</HOST_ARCH>
                <HOST_DN>/C=AU/O=YAS/O=host/OU=FTP/CN=myce.myurl.com</HOST_DN>
                <DESCRIPTION>YAS-FTP Computing Element.</DESCRIPTION>
                <PRODUCTION_LEVEL>N</PRODUCTION_LEVEL>
                <IS_MONITORED>N</IS_MONITORED> 
                <!-- A 'service_endoint' object can define a child 'endpoint_location'. -->
                <endpoint_location grid_id="0">
                    <URL>http://some.endpoint.url.ac.uk/endpoint1</URL>
                    <WSDL>http://some.wsdl.url.ac.uk/wsdl_1</WSDL>
                </endpoint_location>
            </service_endpoint>
            <service_endpoint grid_id="0">
                <ENDPOINT key="primary">mysbdii.myurl.comSite-BDII</ENDPOINT>
                <HOSTNAME>mysbdii.myurl.com</HOSTNAME>
                <HOST_IP>111.222.333.442</HOST_IP>
                <HOST_DN>/C=AU/O=YAS/O=host/OU=FTP/CN=mysbdii.myurl.com</HOST_DN>
                <HOST_OS>RH7</HOST_OS>
                <HOST_ARCH>86x32</HOST_ARCH>
                <DESCRIPTION>YAS-FTP Site BDII</DESCRIPTION>
                <PRODUCTION_LEVEL>N</PRODUCTION_LEVEL>
                <IS_MONITORED>N</IS_MONITORED>                                
                <endpoint_location grid_id="0">
                    <URL>http://some.endpoint.url.ac.uk/endpoint2</URL>
                    <WSDL>http://some.wsdl.url.ac.uk/wsdl_2</WSDL>
                </endpoint_location>
                
            </service_endpoint>
        </site>
    </group>
    
    <!-- 
    If an Object has many parents, each parent-child relationship needs 
    to be defined directly beneath the root element as a new parent-child 
    branch (i.e. start a new nesting branch as a child object can only 
    be enclosed by a single parent). 
    
    In this example, 'service_type' is a parent to 'service_endpoint'. 
    We can't define this relationship in the nesting branch above because 
    'site' is defined as the parent. 
    -->
    <service_type grid_id="0">
        <name key="primary">CE</name>
        <service_endpoint grid_id="0">
            <ENDPOINT key="primary">myce.myurl.comCE</ENDPOINT>
        </service_endpoint>
    </service_type>
    
    
    <service_type grid_id="0">
        <name key="primary">Site-BDII</name>
        <service_endpoint grid_id="0">
            <ENDPOINT key="primary">mysbdii.myurl.comSite-BDII</ENDPOINT>
        </service_endpoint>
    </service_type>
    
   
</results>