idmgr
index
/home/parag/workspace/samgrid/V7/JIMSUITE/xmldb_client/src/python/idmgr.py

This python script is a xmldb wrapper for ID  Management

 
Modules
       
sys
traceback
xmldb

 
Classes
       
xmldb.xmldb
idmgr

 
class idmgr(xmldb.xmldb)
    This class provides API to manage Job IDs
 
  Methods defined here:
AddElement(self, Id, select, str)
Add an element to a node
Id = Id of the node
select = XPath expression
str = XML string
return the status of the opertation
AddTimestamp(self, str)
Time stamp gets inserted to the root element
of the XML structure"
str - XML string
returns the status of the operation
CreateClusterJob(self, gId, cId, cName, elements='')
Create a Cluster Job entry inside "/global_job"
Optionally more elements could be added
gId = Global Job Id
cId = Cluster Job Id
cName = Cluster Name
elements = Optional node(s) that goes inside this cluster_job
returns status of the operation
CreateGlobalJob(self, gId, elements=None, owner=None, jobtype='Unknown', facility='Unknown')
Create a new document with node "global_job"
with attribues "Id" and "created"
Optionally elements could be added"
gId = Global Job Id
elements = Optional node(s) that goes inside this global_job
owner = "Optional (owner of the job)
returns status of the operation
CreateLocalJob(self, gId, cId, lId, elements='')
Create a Local Job document which has
gridId and clusterId as elements
Optionally more elements could be added"
gId = Global Job Id
cId = Cluster Job Id
lId = Local job Id
elements = Optional node(s) that goes inside this local_job 
returns status of the operation
GetApiVersion(self)
Returns API name & Version
GetClusterJob(self, gId, cId)
Returns the cluster element for a
given cluster Id
gId - Global Id
cId - Cluster Id
GetClusterJobList(self, gId)
Returns a list of the cluster job ids for a
given global Id
gId - Global Id
GetConf(self)
Return the URL & Collection information
GetGlobalJob(self, gId)
Get the global job document 
gId = Global Id        
returns Global Job Document
GetLatestLocalJobStatus(self, gId, cId, lId)
Returns a tuple containing 2 string:
(the latest job status, its epoch time) 
gId - Global Id 
cId - Cluster Id
cId - Local Id
GetLatestLocalJobTargetedResource(self, gId, cId, lId)
Returns a tuple containing 2 string:
(the latest job targeted resource, its epoch time) 
gId - Global Id 
cId - Cluster Id
cId - Local Id
GetLocalJob(self, gId, cId, lId)
Returns the local job element for a
given cluster Id and Global Id
gId - Global Id - retained for backward compatibility
cId - Cluster Id -retained for backward compatibility
lId - Local Id
GetLocalJobList(self, gId, cId)
Returns a list of the local job ids for a
given cluster Id and global Id
gId - Global Id
cId - Cluster Id
QueryJob(self, Id, query)
Query Jobs with XPath string
Query- XPath expression string
Id - If Id is given, only that document will be queried
If nothing is passed, then the query would be run against
the collection.
returns  the query results
QueryJobs(self, query)
Query Jobs with XPath string
Query- XPath expression string
returns  the query results
RemoveClusterJob(self, gId, cId)
Removes a Cluster Job from a Global Job
gId = Global Job Id
cId = Cluster Job Id
returns status of the operation
RemoveElement(self, Id, select)
Remove an element from a document
gId = Id       
select = XPath expression
return the status of the opertation
RemoveGlobalJob(self, gId)
Remove a Global Job document
gId = Global Id        
returns status of the operation
RemoveLocalJob(self, gId, cId, lId)
Removes a Cluster Job from a Global Job
gId = Global Job Id
cId = Cluster Job Id
lId = Local Job Id
returns status of the operation
UpdateCluster(self, action, gId, cId, xml_str, path='')
Action on a Cluster Job
action - xmldb:update action
gid - Global JobId
cId - Cluster JobId
xml_str - XML string to append
UpdateGlobal(self, action, gId, xml_str, path='')
Action on a Global Job
action - xmldb:update action
gId- Global JobId
xml_str - XML String to append
path - Optional extra path  to append
UpdateJob(self, action, DocName, select, str='')
Update Job with XUpdate string
DocName - the document to be updated
If nothing is passed, then the XUpdate would be run against
the collection.
action - xmldb:Update operation
select - XPath string
str - XML string
returns  the update results
UpdateJobs(self, action, select, str='')
Update Jobs with XUpdate string
 
THIS METHOD IS OBSOLETE: IT IS NOW A NO-OP
 
action - xmldb:Update operation
select - XPath string
str - XML string
returns  the update results
UpdateLocal(self, action, gId, cId, lId, xml_str, path='')
Action on a Local Job
action - xmldb:update action
gid - Global JobId - retained for backward compatability
cId - Cluster JobId- retained for backward compatability
lid - Local JobId
xml_str - XML string to append
UpdateLocalJobStatus(self, gId, cId, lId, st)
Adds the job status on a Local Job
gid - Global JobId 
cId - Cluster JobId
lid - Local JobId
st  - Status string (active, done,...)
UpdateLocalJobTargetedResource(self, gId, cId, lId, resource)
Adds the job status on a Local Job
gid - Global JobId
cId - Cluster JobId
lid - Local JobId
st  - Status string (active, done,...)
__init__(self, url=None, globalDocumentURI=None)
This class creates a DB instance and
Checks if jobs collection already exist
Else create one & Create a new index
based on Global Job Id
getCurEpochTime(self)
getCurTime(self)

Methods inherited from xmldb.xmldb:
AppendToDocument(self, collection, name, Xpath, appendstring)
Paeend arbitary xml string to a document
 
collection   - Collection name
Xpath        - XPath to parent tag 
sppendstring - XML String to append
return Update status
CreateCollection(self, collection, name, filer=None)
Create a Collection
 
collection -  Collection Context
name - Collection Name to be created
filer - Specific filer. Default HashFiler
return collection list
CreateIndexer(self, collection, name, pattern)
Create a Indexer for a Collection
 
collection -  Collection Name
name - Indexer name to be created
pattern -
Pattern          Description
========         =============
elem             The value of the named element
elem@attr        The value of the attribute for the named element
*                The value of all elements
*@attr           The value of the named attribute for all elements
elem@*           The value of all attributes for the named element
*@*              The value of all attributes for all elements        
return Operation status
GetCollectionCount(self, collection)
Get the Collection count in a given Collection
 
collection -  Collection Name
return Collection count
GetDocument(self, collection, name)
Get a  document 
 
collection -  collection 
name - Name (or) Key associated with the document
return Document string
NOW deprecated !!! use GetResource instead
GetDocumentCount(self, collection)
Get the Document count in a given Collection
 
collection -  Collection Name
return Collection count
GetResource(self, collection, name)
Get a  document 
 
collection -  collection 
name - Name (or) Key associated with the document
return Document string
GetServerVersion(self)
Print the Server Version 
 
result = self.xdbServer.run ({"message":"GetServerVersion"})
return Server version
GetUrl(self)
Retrieves current url of the XML DB server
InsertDocument(self, collection, name, document)
Insert document in a Collection
 
collection -  Collection 
name - Name (or) Key associated with the document
document - Document String
return Status of the operation
IsCollection(self, collection)
Returns positive if a collection exist
 
collection - Collection Name
return 1 if collection exist (or) 0 otherwise
IsDocument(self, collection, document)
Returns positive if a document exist in the collection
 
collection - Collection Name
document - Name of the document
return 1 if document exist (or) 0 otherwise
ListCollections(self, collection)
List of the Collections
 
collection -  Collection Context
return list of collections
ListDocuments(self, collection)
List of Documents 
 
collection -  Collection context
return list of Documents
ListIndexers(self, collection)
List the Indexers in a given Collection
 
collection -  Collection Name
return List of Indexers
Query(self, collection, type, query, name=None, namespaces={})
Query (or) Update a document (or) collection
 
collection -  Collection
type - XPath (or) XUpdate
query - Query String for XPath type and Modification string for XUpdate
name - Name (or) Key associated with the document; None - if query is for a collection
namespaces - 
return Query result
QueryCollection(self, collection, query)
Query a collection
 
collection -  Collection name
query - XPath query
return Query result
QueryDocument(self, collection, name, query)
Query a document
 
collection -  Collection name
name - Name (or) Key associated with the document
query - XPath query
return Query result
RemoveCollection(self, collection, name)
Delete a Collection
 
collection -  Collection Context
name - Collection Name to be deleted
return Status of operation
RemoveDocument(self, collection, name)
Delete document in a Collection
 
collection -  Collection 
name - Name (or) Key associated with the document
return Status of the operation
RemoveIndexer(self, collection, name)
Remove a Indexer for a Collection
 
collection -  Collection Name
name - Indexer name to be deleted
return Operation status
UpdateCollection(self, collection, mod_string)
Update a collection
 
collection -  Collection name
mod_string - XUpdate Modification String
return Update status
UpdateDocument(self, collection, name, mod_string)
Update a document
 
collection -  Collection name
name - Name (or) Key associated with the document
mod_string - XUpdate Modification String
return Update status

Data and other attributes inherited from xmldb.xmldb:
XmldbException = <class xmldb.XmldbException>

 
Functions
       
getCollectionFromURI(globalDocumentURI)
Given an unique identifier for a global JID, returns an XMLDB collection
where the document can be stored
getLocalDocName(gId, cId, lId)
Returns the name of the XML document where the local JID info are stored
gmtime(...)
gmtime([seconds]) -> (tm_year, tm_mon, tm_day, tm_hour, tm_min,
                       tm_sec, tm_wday, tm_yday, tm_isdst)
 
Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.
GMT).  When 'seconds' is not passed in, convert the current time instead.
localtime(...)
localtime([seconds]) -> (tm_year,tm_mon,tm_day,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst)
 
Convert seconds since the Epoch to a time tuple expressing local time.
When 'seconds' is not passed in, convert the current time instead.
strftime(...)
strftime(format[, tuple]) -> string
 
Convert a time tuple to a string according to a format specification.
See the library reference manual for formatting codes. When the time tuple
is not present, current time as returned by localtime() is used.
test1()
time(...)
time() -> floating point number
 
Return the current time in seconds since the Epoch.
Fractions of a second may be present if the system clock provides them.