tibco.tea Module

The tibco.tea module gives you access to the members and functions that can be used to access the TIBCO Enterprise Administrator server, and all products that have agents registered with the server. With the help of this module, you can perform just about any activity that can be performed using the Shell commands or the Web UI.

The tibco.tea Module

The tibco.tea module is available as a built-in module. Before using this module, perform the steps specified in the Setting up Python Scripting section. To access the classes and members offered by tibco.tea, from the Python command line, run the following:
import tibco.tea
You can now create an instance of the Enterprise Administrator by using the following statement:
tea=tibco.tea.EnterpriseAdministrator()
The EnterpriseAdministrator() constructor can also take the following parameters:
  • url: The default URL is http://localhost:8777.
  • user: The default user is admin.
  • pwd: The default password is admin.

The object, tea, in this example refers to an instance of EnterpriseAdministrator. You can use any name for the object, but this example uses tea. This is the root object of the entire object hierarchy. You need this object to perform any activity on TIBCO Enterprise Administrator. After creating this object, you can use this to register agents, create users, view machines, and so on.

The Object Hierarchy

Using the tea object, created earlier in the example, you can get more information on the object hierarchy. Any reference to the tea object is a dictionary, such as tea.products, tea.agents and so on. Standard functions such as keys(), items(), and values() are available on all reference dictionaries. The standard help() function can be applied to any expression resolving to a TIBCO Enterprise Administrator object, to discover the functions available on that class of object.

tea.products
tea.products is a dictionary with a collection of (name,value) pairs. The tea.products command is used to list the products registered with the server that support Python binding. The following is an example of the product list generated by the command:
>>> tea.products
{'TIBCOSecurityServer': <'TIBCOSecurityServer','
:TIBCOSecurityServerAgent:1.0:TIBCOSecurityServer:
TIBCOSecurityServer'>, 'EMS
': <'EMS',':EMSAgent:1.0:EMS:EMS'>}
>>>
The output shows EMS as the product registered. The command help(tea.products['EMS']) lists the functions supported by the Tomcat product.
>>> help(tea.products['EMS'])
Help on EMSAgent_1_0_EMS in module builtins object:

EMS = class EMSAgent_1_0_EMS(tibco.tea.TeaObject)
 |  Agent to manage EMS Servers
 |  
 |  Method resolution order:
 |      EMSAgent_1_0_EMS
 |      tibco.tea.TeaObject
 |      object
 |  
 |  Methods defined here:
 |  
 |  registerEmsServer(self, serverName='MyEMSServer', URL='tcp://localhost:7222', 
 |  userName='admin', password='', agentId=None)
 |
 |      Register an EMS Fault Tolerance Server
 |      
 |      Parameters:
 |          serverName -- EMS server name (type str) (default MyEMSServer)
 |          URL -- URL (type str) (default tcp://localhost:7222)
 |          userName -- UserName (type str) (default admin)
 |          password -- Password (type str) (default )
 |          agentId -- Identifier for the agent (type agentId) (default None)
 |          
 |      Result Type: reference
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  module_ = None
 |  
 |  omitted_operations = []
 |  
 |  type_descr = {'agentTypeId': 'EMSAgent:1.0', 'concept': 'TOP_LEVEL', '...
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from tibco.tea.TeaObject:
 |  
 |  __init__(self, tea, obj_descr)
 |  
 |  __repr__(self)
 |  
 |  __str__(self)
 |  
 |  refresh_(self)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from tibco.tea.TeaObject:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)



>>>
tea.products.keys()
You can use tea.products.keys() to get a list of names of the products registered with the server.
>>> tea.products.keys()
dict_keys(['TIBCOSecurityServer', 'EMS'])
tea._products_with_provisional_apis
tea._products_with_provisional_apis is used to list the products registered with the server that have provisional apis. By default, the APIs exposed by the TIBCO Enterprise Administrator server do not support Python binding.
tea. product_with_provisional_api(name)
You can check whether or not a product has provisional apis by using the function, tea.product_with_provisional_api(name). Pass the product name as the parameter to the function. On finding the product in the tea._products_with_provisional_apis dictionary, the function returns the object of the product type along with a message that the Python API for the product is provisional. It is not supported but that is likely to change in future. If the product is not found in the tea._products_with_provisional_apis dictionary, the function returns None along with a message that the product does not have provisional apis. If the product name is not found in tea._products_with_provisional_apis or in tea.products, the function returns None along with a message that the product name is wrong.
tea. products_with_provisional_apis()
tea. products_with_provisional_apis() returns a list of names of the products having provisional API, along with a warning message that the Python API for these products are provisional. They are not supported and are likely to change in future.
<Product>.module_ or <Member>.module_
You can use module_ on a product or a member to get the modules of Plain Old Java Object (POJO) objects available on the product or member. module_ is attached to each top level or member object. For example, the following is an example of using module_ on a member:
tea._products_with_provisional_apis['Tomcat'].
members['Server 1'].module_
For products, we can use tea._products_with_provisional_apis['Tomcat'].module_ to retrieve the modules of POJOs on Tomcat. After obtaining the modules of POJO, you can pass a POJO as a parameter to a function in a Python script. For example:
# get an instance of the product as follows -
>>>prod = tea._products_with_provisional_apis['Tomcat']

# Module of POJOs is available on that product or member
 in variable "module_"
>>> mod = prod.module_
 
# Instantiate the POJO class in python as follows
>>> person = mod.Person("John Doe", 1)
 
# Invoke the TeaOperation with the python object in the earlier line
 as TeaParam and consume the POJO response as a Python Object
>>> response = prod.hw(person)
When you get an POJO as a return type, you can use the POJO like a regular Python object.
# Use the response as you use the regular python object
>>> response.name
'John Doe'
>>> response.i
1
tea.agents
You can use tea.agents to access the agents registered with the server. For example, tea.agents.agents.registerAgent(name,url,description) helps you register an agent with the server.tea.agents offers the following functions:
tea.users
You can use tea.users to create users, assign roles, groups to users. For example, you can create users using the tea.users.createUser(self, name, password, groups, roles) command.
tea.machines
You can use tea.machines to get more information about the machines on which the agents are running.
Caution: Different versions of Python handle i18n characters, such as Chinese and Japanese differently. Python 3 supports i18n characters, so the operations and parameters are visible in Python. If you are using Python 2, the following scenarios take effect:
  • If the operation name contains i18n characters, the name is considered invalid. The operation is not visible in Python.
  • If the parameter name contains i18n characters, but the operation name is valid, the operation is disabled. An exception occurs when you try to access such an operation.

The refresh_() Function

The refresh_() function is available to an instance of EnterpriseAdministrator() that helps get the latest state of the object from the remote server and agent. In this example, tea.refresh_() gets the latest state of the object. The following scenarios call for an explicit refresh:
  1. After registering the first agent, the products list gets refreshed automatically, but after registering the second agent, the products list does not refresh. Remember to explicitly refresh the products list of the second agent.
  2. After unregistering the agent, the agents dictionary must be refreshed explicitly.
  3. Recently updated agents, solutions, products, and dictionaries should be explicitly refreshed before accessing their members, keys, items, and other details.