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?

2 of 6 people (33%) answered Yes
Recently 1 of 5 people (20%) answered Yes

Entry

Access to OMR Repository through Python

Apr 10th, 2001 09:42
Engineer TCSI,


In order to acess OMR Repository through python, import and initialize 
the OmrRepository module, 
     import OmrRepository
     OmrRepository.Init(('Cm',))
     failedUnits = OmrRepository.WaitForOmrInit()
The first statement is basic python. The Init() function initializes the 
internal OMR cache with information about the set of
named Units (MOSU Units). In the above example, only a single Unit 
('Cm') is initialized (note however, that it will initialize this
Unit as well as items inherited by this Unit). 
The initialization isn't complete until the call to WaitForOmrInit() 
returns. It may return a list of Units which failed to get
initialized. Trying to initialize a unit that does not exist may cause 
the operation hang. 
To traverse information in the OMR cache, we can get a list of all 
units, classes per unit, attributes & operations per class,
parameters per operation, and properties per element, as well as class 
inheritance information. 
 InitializeInit        (('Unit1', 'Unit2'))
                       WaitForOmrInit() 
 List all Units        GetAllUnits() 
 List all Classes      GetClasses('Unit') 
 List all Attributes   GetAttrs('Unit', 'Class')
 List all Operations   GetOps('Unit', 'Class') 
 List Parameters for an Operation
                       GetParams('Unit', 'Class', 'Op') 
 List all Properities  GetProps('Element') 
 List base classes     GetBaseClass('Unit', 'Class') 
 List child classes    GetChildClass('Unit', 'Class') 
 Add More Units        AddUnit(('Unit', 'Unit2'))
                       WaitForOmrAddUnit() 
 Remove all Units      CleanUp()
                       WaitForCleanup() 
OmrRepository.Init(<tuple of unit names>)
=========================================
This call initializes the repository. As part of this operation it 
populates the cache with metadata information pertaining to the
specified units. Once the initialization is complete 
OmrRepository.WaitForOmrInit() is called to receive the list of failed 
units. 
Parameters:
<tuple of unit names> 
     The list of units your want to register for 
Returns:
None 
Example:
   OmrRepository.Init(('MosuUnit', 'MosuUnit2'))
   failedUnits = OmrRepository.WaitForOmrInit()
OmrRepository.AddUnit(<tuple of unit names>)
============================================
Once the repository has been initialized, the user can request 
information on an additional unit in the cache using the
AddUnit() method. When the cache has been populated with metadata 
information on the new unit,
OmrRepository.WaitForOmrAddUnit() is called to receive a list of failed 
units. 
Parameters:
<tuple of unit names> 
     The list of units your want to register for 
Returns:
None 
Example:
   OmrRepository.AddUnit(('MosuUnit3', 'MosuUnit4'))
   failedUnits = OmrRepository.WaitForOmrAddUnit()
OmrRepository.CleanUp()
=======================
This call does a cleanup of the repository. As part of this operation it 
destroys all the information in the cache. When the
cleanup is complete OmrRepository.WaitForCleanUp() should be called to 
ensure the operations is complete 
Parameters:
None 
Returns:
None 
Example:
   OmrRepository.Cleanup()
   OmrRepository.WaitForOmrCleanUp();
OmrRepository.GetAllUnits()
===========================
This call returns a list of all the units in omr cache. 
Returns:
(unitNameList) 
     List of Unit names 
(unitOidList) 
     List of OIDs representing the Unit metadata (for internal use only) 
Example:
   allUnits = OmrRepository.GetAllUnits()
   print allUnits
   (('abCommon', 'Cm'), ((0, 0, 0, 0), (10, 263, 65532, 9888737232)))
OmrRepository.GetClasses(<unitName>)
====================================
This call gets a list of classes defined in the specified unit 
Parameters:
unitName 
     The unit for which list of classes is desired 
Returns:
(classNameList) 
     List of class names defined in the unit 
(classOidList) 
     List of OIDs representing the Class metadata (for internal use 
only) 
(classClassCodeList) 
     List of MOSU class codes for the listed classes 
(classIsAbstractList) 
     Enumeration for abstract ('1') or concrete ('0') class definition 
(classMemPolicyList) 
     Enumeration for memory policy (0=LRU, 1=Sticky or non-persistent) .
(classPolicySize) 
     Size of class cache in number of instances 
Example:
   classList = OmrRepository.GetClasses('Cm')
   print classList
   (('Link', 'NetworkElement'), ((10, 253, 6555123, 9879879373), (10, 
253, 6555523, 987498239)), (5008, 5000), (0, 0), (0, 0), (5000, 5000))
OmrRepository.GetAttrs(<unitName>, <className>)
===============================================
This call gets a list of attributes for a class 
Parameters:
unitName 
     Name of the unit where the class is defined 
className 
     Name of the class to be queried 
Returns:
(attrNamesList) 
     List of attribute name strings, including inherited attributes 
(attrOidList) 
     List of OID tuples representing the attribute metadata (for 
internal use only) 
(attrCodeList) 
     List of integer MOSU attribute codes 
(attrAccessList) 
     List of enumerations indicating accessibility (0=, 1=, 
2=read/write) 
(attrMaxLenList) 
     List of integers representing the maximum size of string attributes 
(0, if not a string attribute) 
(attrIsCachedList) 
     List of integers ????? 
(attrTypeNameList) 
     List of attribute type strings 
Example:
   attrList = OmrRepository.GetAttrs('Cm', 'Link')
   print attrList
   (('domain', 'name', 'aEndpoint', 'zEndpoint'),
    ((10, 237, 634234, 98987987), (10, 237, 6423, 98798794), (10, 237, 
654323, 908098745), (10, 237, 654321, 98798734)),
    (103, 102, 5008, 5007),
    (2, 1, 2, 2),
    (0, 80, 0, 0),
    (0, 0, 0, 0),
    ('oid', 'string', 'oid', 'oid'))
OmrRepository.GetOps(<unitName>, <className>)
=============================================
This call gets a list of operations for a class 
Parameters:
unitName 
     Name of the unit where the class is defined 
className 
     Name of the class to be queried 
Returns:
(opNamesList) 
     List of operation string names 
(opOidList) 
     List of OIDs for operation metadata (for internal use only) 
(opCodeList) 
     List of integer MOSU codes 
(opTypeList) 
     Enumeration of integer Operation Types (see table below) 
(opAccessList) 
     Enumeration of integer Operations Access (see table below) 
The following table maps the operation type, as defined in MOSU with the 
opTypeList and opAccessList enumerations
returned by this method. 
           Type Access 
  Creater    0    1 
  Deleter    1    1 
  Modifier   2    1 
  Selecter   2    0 
  Controller 2    2 
Example:
   ops = OmrRepository.GetOps('Cm', 'Link')
   print ops
   (('Get', 'Set', 'Delete', 'Create', 'Connect'),
    ((10, 248, 654234, 98798794), (10, 248, 634345, 98798747), (10, 248, 
652343, 98798798), (10, 248, 653443, 9879834758)),
    (4, 3, 2, 1, 5009),
    (2, 2, 1, 0, 2),
    (0, 1, 1, 1, 0))
OmrRepository.GetParams(<unitName>, <className>, <opName>)
============================================================
This call gets list of params for an operation 
Parameters
unitName 
     Name of the unit where the class is defined 
className> 
     Name of the class where the operation is defined 
opName 
     Name of the operation 
Returns
(paramNameList) 
     List of string parameter names 
(paramOidList) 
     List of OIDs representing the parameter metadata (for internal use 
only) 
(paramTypeList) 
     List of strings representing the parameter datatypes. 
(paramDirList) 
     List of strings representing the parameter direction ('in', 'out', 
or 'inout') 
Example:
   parms = OmrRepository.GetParams('Cm', 'MyClass', 'Create')
   print parms
   (('setResList', 'setList', 'newOid'),
    ((10, 244, 65342, 9879874), (10, 244, 64342, 98987433), (10, 244, 
64342, 9898774)),
    ('valMoSetResList', 'valMoSetList', 'valMoOid'), 
    ('out', 'in', 'out'))
OmrRepository.GetProps(<name>)
==============================
This call gets the properties of class/operation/attribute. Given the 
name it searches all units, and returns the first properities
for the first operation or attribute which matches the named parameter. 
This may not be desirable if you have attributes or
operations with the same name defined in multiple classes or units. 
Class properties are not retrievable. 
Parameters:
name 
     The name of class/operation/attribute 
Returns:
(propNameList) 
     List of string property names for the queried element 
(propOidList) 
     List of OIDs representing the property metadata (for internal use 
only) 
(propKindList) 
     Enumerated list of property types: 0=integer, 1=string 
(propValueList) 
     List of strings with property values. 
Example:
   props = OmrRepository.GetProps('temperature')
   print props
   (('startingValue',), ((10, 230, 655433, 965434554),), (0,), ('67',))
OmrRepository.GetBaseClass(<unitName>, <className>)
===================================================
This call gets a list of parent classes 
Parameters
unitName 
     Name of the unit where the class is defined 
className 
     Name of the class to be queried 
Returns:
(classNameList) 
     List of classes immediately inherited by the queried class 
(classOidList) 
     List of OIDs representing class metadata. (internal use only) 
(classCodeList) 
     List of integer MOSU class codes for inherited classes 
(classIsAbstractList) 
     List of enumerations indicating type of parent class (0=concrete, 
1=abstract) 
(classMemPolicyList) 
     List of enumerations indicting type of memory policy of parent 
class (0=LRU, 1=Sticky or non-persistent). Memory
     policy of a parent class has no effect on the memory policy of this 
class. 
(classPolicySize) 
     List of integers indicating the size of the parent class cache in 
number of instances. The policy size of a parent class has
     no effect on the policy size of this class. 
Example:
   bClasses = OmrRepository.GetBaseClass('Cm', 'Network')
   print bClasses
   (('abAppBase',), ((10, 253, 64343, 98456455),), (101,), (1,), (0,), 
(0,))
OmrRepository.GetChildClass(<unitName>, <className>)
====================================================
This call gets the list of child classes 
Parameters
unitName 
     Name of the unit where the calss is defined 
className 
     Name of the class to be queried 
Returns:
(classNameList) 
     List of all classes which immediately inherit from the queried 
class. 
(classOidList) 
     List of OIDs representing class metadata (for internal use only). 
(classCodeList) 
     List of integer MOSU class codes for the subclasses. 
(classIsAbstractList) 
     List of enumerations indicating if the subclass is abstract 
(1=abstract, 0=concrete) 
(classMemPolicyList) 
     List of enumerations indicating the memory policy of the 
subclasses. 
(classPolicySize) 
     List of itegers indicating the size of the subclass cache in number 
of instances. 
   sClasses = OmrRepository.GetChildClass('abCommon', 'abAppBase')
   print sClasses
   (('NetworkElement', 'Link'),
    ((10, 253, 646343, 9879843), (10, 253, 654345, 987987349)),
    (5009, 5006),
    (0, 0),
    (0, 0),
    (5000, 5000))