Previous Topic: Load a Spreadsheet that Does Not Contain mdr_name or tenantNext Topic: Example: Load a Spreadsheet Using Embedded Relationships


Example: Load a Spreadsheet that Rejects Bad Data

Use GRLoader to load a spreadsheet that rejects bad data by using a translation rule. In the following example, the name column begins on row C5 in Sheet9 of grloader_sample_spreadsheet.xls:

name

class

skip

ip address

server1

Server

 

 

server2

Server

yes

 

server3

ACD

1

 

server4

ACD

 

bad

server5

ACD

 

bad

server6

ACD

 

 

Before you run GRLoader, create a translation file named Sheet9.rul that contains the following XML:

<ruleset>
<rule><attribute>skip</attribute><from>1</from>
      <reject>yes</reject><rulename>rule1</rulename></rule>             
<rule><attribute>skip</attribute><from>yes</from>
      <reject>yes</reject><rulename>rule2</rulename></rule>
<rule><attribute>alarm_id</attribute><from>bad</from>
      <reject>yes</reject><rulename>rule3</rulename></rule>
<rule><attribute>attributename</attribute>
      <from>ip address</from><to>alarm_id</to>
      <rulename>rule4</rulename></rule>
</ruleset>

After you create this XML file, load the data with GRLoader by executing the following command:

grloader -u username -p password -s http://sdm-host:8080 -i grloader_sample_spreadsheet.xls -sss Sheet9 -ssfr 6 -tf Sheet9.rul -n

Based on the translation rule, GRLoader completes the following actions:

  1. GRLoader loads two CIs: server1 and server6.
  2. GRLoader rejects server2 because the skip column is set to yes (rulename rule2).
  3. GRLoader rejects server3 because the skip column is set to 1 (rulename rule1).
  4. GRLoader rejects server4 and server5 because of bad IP addresses for these CIs (rulename rule3).

Note: The attribute name translation (rule4) occurs before value translation, so the value translation rules must specify the translated attribute name. Even though the spreadsheet contained a column heading of ip address, the rule to reject the bad ip addresses (rule 3) must specify alarm_id.