faqts : Computers : Management Systems : TCSI : Catalant : Server Development : Python

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 1 people (100%) answered Yes

Entry

How can I build a setList in PyOsp?

Apr 10th, 2001 09:49
Engineer TCSI,


If you have an MOSU-defined operation that has an input parameter of 
type setList, how do you define its value?
A setList is a list (or tuple) of tuples, where the tuple has two 
elements, the name of the attribute (string), and the value (legal 
mapping for MOSU type).
The "rub" is that the attribute name MUST be a legal attribute name for
the instance you are invoking on, and the attribute value must be legal 
for the attribute type.
For example, consider pmService in PerformanceMgr.mosu:
unit PerformanceMgr:
class pmService {
   rc string[80] name;
   virtual selector GetDataSourceTypes(
      out oidList dataSourceTypes,
      in setList params ) % TCSI_language="Python";
};
When passing a setList in the "params" parameter, the attriubte names
and types for this class can only be:
   _oid       oid (tuple of 4 ints)
   _busy      int
   _locked    int
   name       string
Note that the values do not have to match the values of the AO itself; 
for example, I can pass any legal OID value as the attribute named _oid.
These restrictions are part of the PyOsp-Python-Tcl-C++ mapping; they 
have nothing to do with the provider side AO operation code. 
(If you look at the operation implementation in pmService.py, it does
not even check attr names, it just takes the value of the first atttr in 
the setList.)
Here is an example:
# Get the stub for the pmService object.
pmService = Osp.Find(PerformanceMgr.pmService)[0]
# Now get an AO to pass the OID in GetDataSourceTypes.
topoAO = Osp.Find(Topo.SUNWorkStation)[0]
setList = [("_oid", topoAO._oid), ("name", "Bob")]
answer = pmService.GetDataSourceTypes(setList)
Note that I must use "._oid" to go from a stub object to the numeric 
OID.