tibco.tea Module

The tibco.tea module gives you access to the members and methods 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 methods 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. The following is an example of the product list generated by the command:
>>> tea.products
{'tomcat': <tomcat_7_0_42_tomcat object at 0x00000000037E59E8>,
 'HelloWorldTopLevelType': <HelloWorldAgent_1_0_HelloWorldTopLevelType object at 0x00000000037E85F8>}
>>>
The output shows Tomcat as the product registered. The command help(tea.products['tomcat']) lists the methods supported by the Tomcat product.
>>> help(tea.products['tomcat'])
Help on tomcat_7_0_42_tomcat in module builtins object:

class tomcat_7_0_42_tomcat(tibco.tea.TeaObject)
 |  Tomcat Tea Agent
 |
 |  Method resolution order:
 |      tomcat_7_0_42_tomcat
 |      tibco.tea.TeaObject
 |      object
 |
 |  Methods defined here:
 |
 |  cleanup(self, agentId=None)
 |      Remove all server instances
 |
 |  createserver(self, name, port, ajpport=-1, shutdownport=-1, agentId=None)
 |      Create a tomcat server instance
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  type_descr = {'agentTypeId': 'tomcat:7.0.42', 'concept': 'TOP_LEVEL', ...
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from tibco.tea.TeaObject:
 |
 |  __init__(self, tea, obj_descr)
 |
 |  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(['HelloWorldTopLevelType', 'tomcat'])
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 methods:
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.
Note: 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.