Introduction to TQL Lesson # 8 HP UCMDB 8.0 Essentials © 2008 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice About this Chapter Lesson Objectives In this lesson, you will learn how to: • Describe the purpose and use of Topology Query Language (TQL) • Describe the applications and systems that use TQL • Create a basic TQL query • Use Attribute conditions on a TQL to filter the results • Use Cardinality conditions on a TQL to filter the results • Use Element ID conditions on a TQL to filter the results • Use the Include Subtypes property • Create a query to extract information from the CMDB to solve business problems 2 Topology Query Language Overview Introduction to TQL TQL stands for Topology Query Language TQL is a graphical language composed of nodes and links TQL is the method for finding data in the CMDB TQL is a constraint language, like Prolog or SQL TQL queries are composed of assertions. TQL queries return objects which match the criteria 3 Topology Query Language Overview TQL Dependant Subsystems 4 Topology Query Language Overview TQL Query Process 5 Topology Query Language Overview TQL Query Example TQL result TQL Query CMDB data 6 Topology Query Language Overview Building a TQL Query Add nodes and relationships • Graphical expression of nodes and links • Defines the data to be returned from the CMDB Filter the resulting TQL • Constraints to limit the CIs returned from the CMDB • TQL node condition • TQL relationship condition 7 Topology Query Language Overview Constraint Types CIT Instance Attributes • Specific value or a range of values of an attribute – Host IP must begin with “192.168.*” – Host OS must equal Linux Relationships among CIT instances • Cardinality of linked nodes – A host should have exactly two network interfaces 8 Topology Query Language Overview Attribute Constraints Constraints based on an intrinsic characteristic of an object May be chained using Boolean logic (A and B or C) Available constraints are based on the SQL “where clause” query syntax Constraints include =, !=, <. >, NULL, NOT NULL, LIKE, NOT LIKE & LIKE ignore case Example: • Host object with a DNS Name of “foo.bar.com” • Host with operating system like %Windows 2003% 9 Topology Query Language Overview Relationship Constraints Cardinality • Constraint based on relationships between instances • Can be applied to one or both ends of a link between two nodes • May be used in combination with other constraints Examples • 1..* -- At least one to one, possibly to many • 0..* -- Optional • 0..0 -- Must not be there • 7..14 -- Must be in the range 7 to 14 10 Topology Query Language Overview Common Cardinality Constraints 0..* • Indicates none or more • The CI may or may not exist • The CI is optional 0..0 • Indicates that the CI has no CIs linked to it • None may exist 1..* • Indicates that the CI has at least one CI linked to it • 1 to many 11 TQL DISCOVERY: ACTIVITY Single Object Discovery Assume the CMDB is populated with the following basic geometric shapes. Each shape represents a component of the environment. What does this TQL select from the CMDB? TQL 12 TQL DISCOVERY: ACTIVITY Multiple Object Discovery What does this TQL select from the CMDB? TQL 13 TQL DISCOVERY: ACTIVITY Complex Discovery What does this TQL select from the CMDB? TQL 14 TQL DISCOVERY: ACTIVITY Discovery Filter How would we modify this TQL to return all squares, and also any circles attached to squares? TQL 0..* 1..* 15 Topology Query Language Overview TQL Usage Across the Modeling Managers 16 Topology Query Language Overview New TQL Overview Defines the name, type and properties of the TQL TQL Types • View • Report • Correlation • Enrichment • Integration • Discovery Structure to hold the links and nodes 17 Identity Topology Query Language Overview Creating a New TQL 18 Topology Query Language Overview Nodes and Relationships Overview Defines the query in a graphical expression of nodes and links Defines the CITs and relationships whose instances will be returned from the CMDB Identity 19 Topology Query Language Overview Adding Nodes to a TQL 20 Topology Query Language Overview Defining Relationships Between Nodes 21 Topology Query Language Examples Basic Query: all Unix hosts TQL Query for all Unix hosts with CPU? 22 Topology Query Language Examples Basic Query: Unix hosts with Apache TQL for all networks with Unix hosts with their IP Addresses? 23 Topology Query Language Examples Basic Query: Unix host resources Where can you verify the relationship type between two CIT’s? 24 Topology Query Language Overview Attribute Conditions Review Places conditions on the query to constrain the results Filters the CIs returned to the view Constrains by the value of an attribute 25 Identity Topology Query Language Overview TQL Node Properties Dialog 26 Topology Query Language Overview TQL Node Attribute Conditions Host Operating System Equal ignore case "windows 2003" AND Host Operating System Release Equal "5" 27 Topology Query Language Overview Adding Attribute Conditions 28 Topology Query Language Overview Fixed Value Parameterized Conditions 29 Topology Query Language Examples Example - Windows 2003 Servers TQL Definition Result Set 30 Topology Query Language Examples Example - Unix Host with OS other than Linux TQL Definition Result Set 31 Topology Query Language Overview Identity Conditions Overview Places conditions on the query to constrain the results Filters the CIs returned to the view Constrains by a CIT instance 32 Identity Topology Query Language Overview Defining an Identity (Select Identities) 33 Topology Query Language Overview All Hosts on the 10.168.11.0 Subnet TQL 34 Topology Query Language Overview Cardinality Conditions Review Places conditions on the query to constrain the results Filters the CIs returned to the view Constrains by the number of relationships from one CI to another 35 Identity Topology Query Language Overview Defining Relationship Cardinality 36 Topology Query Language Overview Adding Relationship Cardinality 37 Topology Query Language Example Unix Hosts and their CPUs What would be displayed for 0..* cardinality from CPU to Unix? 38 Topology Query Language Example Unix Hosts with CPUs 39 Topology Query Language Examples Unix Hosts with 2 or more CPUs 40 Topology Query Language Overview Include Subtypes Property Overview A node or relationship condition selected by default When selected the TQL results include the CI Type instances and instances of all subtypes • Host CIT returns Hosts, Unix, Windows, etc. When deselected the TQL results include the CI Type instances but none of the instances of any of the subtypes • Host CIT returns Hosts only 41 Topology Query Language Overview Editing Include Subtypes Properties 42 Topology Query Language Overview Using Include Subtype Properties 43 INTRODUCTION TO TQL Review Questions 44 1. What are the different types of TQLs? Why do we need different types of TQLs? 2. List one major difference between SQL and TQL. 3. How is SQL syntax used by TQL? 4. What is the purpose of an Attribute condition? 5. When might an Identity condition be used in a View TQL? 6. What property specifies relationships between instances retrieved by the TQL? 7. When defining cardinality, what does * indicate? Chapter Summary Summary Key points in this lesson: • A TQL query provides a graphical or tabular representation of nodes and relationships between the nodes • A TQL may be built in any of the Modeling managers except IT Universe Manager and CI Type Manager • A TQL query consists of nodes and relationships along with their conditions • A TQL can be edited by adding/subtracting nodes and setting attribute, element id and cardinality conditions • All TQL types can be created in Query Manager but only integration and discovery TQLs can be edited in Query Manager 45 INTRODUCTION TO TQL Exercises Please complete the lesson review questions and exercises in your book. After everyone is finished, the instructor will review the answers. 46 47