Managing application templates
Application template methods enable the creation, modification, deletion, and retrieval of application templates and rules.
Important: This API is deprecated for TADDM 7.3 and later. The GroupingPatternAPI can be
used to manage Business Services. This API provides methods for creation, modification and deletion
of Grouping Patterns. For more information, see Managing grouping patterns.
Application templates specify the MQL rules that
are periodically applied to the TADDM database to define business
applications or collections. Each template specifies one or more rules
with the following attributes:
- MQLRuleName
- The name of the MQL rule. This attribute is required.
- FunctionalGroupName
- The object the functional group contains that the MQL query returns. This attribute is required for any rule that defines a business application. It is not used for collections that rules define.
- MQLQuery
- The MQL query to run. The objects the query returns are added to the business application or collection.
Table 1 describes the application template methods that you can use.
Method | Description |
---|---|
createAppTemplate(String name, String type, boolean removeNonMembers, MQLRule[] operators) | Creates a template with the specified rules.
The following parameters are available:
|
updateAppTemplate(String name, String type, boolean removeNonMembers, MQLRule[] operators) | Updates a template with the specified rules.
The following parameters are available:
|
getAllAppTemplates() | Retrieves all application templates. |
getAppTemplate(String name, int type) | Retrieves the application template for specified name and type. |
removeAppTemplate(String name, int type) | Removes the application template for specified name and type. |
removeMQLRule(String name) | Removes an MQL rule. A rule can be removed only if it is not associated with any application templates. |
Creating a business application template
To
create an application template for a business application, complete
the following steps:
- Create a business application and set the name of the new business
application to the name passed on the command line, for example,
TADDM - Production
. Get the GUID returned. - Set the name of the application template using the following format:
For example,business_app_GUID:business_app_name
AA0A20EE5BBD336481279CA664FB380A:TADDM - Production
- Prefix the rule names with the GUID of the business application,
but ensure that you do not include a colon in the rule name, for example
AA0A20EE5BBD336481279CA664FB380Adatabase
Example: Creating a business application template
The following example creates a business application template, the MQL rules, and the associated business application:
# create Business Application with name "TADDM - Production"
BAname = "TADDM - Production"
# get guid of Business Application
myBA = ModelFactory.newInstance(Class.forName
("com.collation.platform.model.topology.app.Application"))
myBA.setName(BAname)
appGuid = api.update(myBA,None)
MQLRuleClass = Class.forName("com.collation.platform.model.apptemplate.MQLRule")
rules = [ModelObjectFactory.newInstance(MQLRuleClass)]
# create required by TADDM MQLRule name like AA0A20EE5BBD336481279CA664FB380Adatabase
rulename = "database"
RuleName= str(appGuid) + rulename
asQuery="select * from AppServer "
rules[0].setMQLRuleName(RuleName)
rules[0].setFunctionalGroupName("App Servers")
rules[0].setMQLQuery(asQuery)
# create required by TADDM AppTemplate name like
AA0A20EE5BBD336481279CA664FB380A:TADDM - Production
appTemplateName= str(appGuid) + ":" + BAname
appTemplate = api.createAppTemplate(appTemplateName, "APPLICATION", True,
jarray.array(rules,MQLRuleClass));
Example: Listing business applications
The following example lists business applications:
query = "select * from Application"
data = api.executeQuery(query, None, None)
while (data.next()):
print data.getXML(4)
Example: Removing a business application template
The following example removes an application template, the MQL rules, and the associated business application.
# Get application template
appTemplate = api.getAppTemplate(nameBA, 0)
# Get rules of the application template
rules = appTemplate.getMQLRules()
# Remove application template -> removes just AppTemplate object
api.removeAppTemplate(appTemplate.getAppTemplateName(), appTemplate.getAppTemplateType())
# Remove all rules
for rule in rules:
rule = api.find(rule.getGuid(), 1, None)
api.removeMQLRule(rule.getMQLRuleName())
# Remove business application
businessApp = api.find("Select * from Application where name =='" +
appTemplate.getAppTemplateName()+ "'", False, None, None)
api.delete(businessApp, None)