Package schrodinger :: Package application :: Package licensing :: Module licadmin :: Class LicenseResource
[hide private]
[frames] | no frames]

Class LicenseResource

object --+
         |
        LicenseResource

A LicenseResource object represents a single license file or license server (port@host). The object records how the resource was found and what the licenses it provides.

Instance Methods [hide private]
 
__init__(self, location, source=None)
The location may be either a pathname or the port@host address of a license server.
 
__unicode__(self)
 
__repr__(self)
repr(x)
 
errors(self)
 
outdated_server(self)
 
location(self)
 
pathname(self)
The pathname for the license file.
 
server_pathname(self)
The pathname to use if we're starting a license server for this license file.
 
server_version(self)
 
refresh(self)
 
is_server(self)
 
is_stub(self)
 
logfile(self)
 
server_hostid(self)
Returns the hostid for the SERVER line in the license file.
 
server_host_and_port(self)
Returns the hostname and port number for the server as a tuple (host, port).
 
schrod_port(self)
Returns the port number for the SCHROD daemon, as a string.
 
canonical_filename(self)
Returns the license object's cannonical filename
 
stub_license(self)
 
is_local_server(self)
Return true if this resource respresents a license server that is locked to the current machine.
 
start_server(self)
Start a license server for this license.
 
stop_server(self)
Stop the license server for this license, if it's a server license.
 
lmdiag(self)
Run lmdiag for this license resource.
 
lmstat(self)
Run lmstat for this license resource, if it represents a license server.
 
checkout(self, token, version=None, count=None, exists=False)
Try to check out the specified token from this license resource.
 
health(self)
Return a status code indicating the general "health" of this resource.
 
summary(self)
 
add_error(self, error)
 
_load_license_file(self, pathname)
Load the license file.
 
ident(self)
Return an identifier that can be used to decide whether two license resources are really the same.
 
priority(self)
Return a priority score for this resource.
 
_load_tokens(self)
Load the information about the total number of tokens available and the number currently in use.
 
tokens(self)
 
available_tokens(self)
Return a dict mapping feature names to the number of tokens available for each.
 
total_tokens(self)
Return a dict mapping feature names to the number of tokens provided by this resource for each.
 
_get_license_tokens(self)
Populate the tokens table from the license object.
 
_get_server_tokens(self)
Get license usage information from a server via "lmutil lmstat".
 
jobs(self, jobtypes=[])
Return a dict mapping each job type to the number of jobs that can be run given the available tokens.
 
_get_features(self)
Get license feature information via "lmutil lmdiag".
 
_check_features(self)
Check the results returned from lmdiag and record errors if there are expired fatures or similar problems.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, location, source=None)
(Constructor)

 

The location may be either a pathname or the port@host address of a license server. The source should be the name of the environment variable that specified this resource, or the pathname of the directory where it was found.

Overrides: object.__init__

__repr__(self)
(Representation operator)

 

repr(x)

Overrides: object.__repr__
(inherited documentation)

pathname(self)

 

The pathname for the license file. If the license file location isn't known, return the empty string.

server_pathname(self)

 

The pathname to use if we're starting a license server for this license file. If the file is in a licenses/ directory, we start the server using all of the license files in the directory, not just this one.

server_hostid(self)

 

Returns the hostid for the SERVER line in the license file. If there's more than one SERVER line, one of them is arbitrarily chosen, which probably isn't what we want.

server_host_and_port(self)

 

Returns the hostname and port number for the server as a tuple (host, port). (Both values are strings.) The port number may be an empty string, if it's not specified in the license. The host name will be empty if this license resource doesn't represent a server.

schrod_port(self)

 

Returns the port number for the SCHROD daemon, as a string. The empty string may be returned if the port number isn't specified in the license, or if this license resource doesn't represent a server.

start_server(self)

 

Start a license server for this license. It may take a few seconds for the server to start up and become responsive.

An AttributeError is raised if this is not a license-server resource.

A RuntimeError is raised if this is not the correct host for this server.

The LicenseResource is re-initialized after the command returns, this will cause the license file to be re-loaded and any errors reset. The _logfile attribute is updated with the name of the server logfile. The _serverstart attribute records the time at which the server was started.

stop_server(self)

 

Stop the license server for this license, if it's a server license. It may take a few seconds for the server to shut down.

An AttributeError is raised if this is not a license-server resource.

A RuntimeError is raised if the server is running on a different host.

The LicenseResource is re-initialized after the command returns, this will cause the license file to be re-loaded and any errors rest.

lmdiag(self)

 

Run lmdiag for this license resource. This is mainly useful for debugging.

The raw output from the command is returned.

lmstat(self)

 

Run lmstat for this license resource, if it represents a license server. This is mainly useful for debugging.

The raw output from the command is returned.

checkout(self, token, version=None, count=None, exists=False)

 

Try to check out the specified token from this license resource. A version number and token count can be specified, as well, but this shouldn't be necessary for most purposes.

If the exists argument is True, then an existence check is done instead of a checkout.

Returns True if the checkout succeeded, otherwise False.

health(self)

 

Return a status code indicating the general "health" of this resource. RESOURCE_OK means the resource can provide licenses. RESOURCE_PROBLEMS means all licenses that should be available aren't. RESOURCE_UNAVAILABLE means this resource is unable to provide licenses.

Because this evaluation requires executing lmdiag and lmstat, it may take a few seconds.

ident(self)

 

Return an identifier that can be used to decide whether two license resources are really the same.

Two server-based licenses are considered the same if the server hostnames are the same. (There can only be one server per host.) All non-server-based license files are considered unique.

priority(self)

 

Return a priority score for this resource. (Lower numbers indicate higher priority, with zero the highest priority.)

_load_tokens(self)

 

Load the information about the total number of tokens available and the number currently in use. For server based licenses, this will query the server.

The info is recorded in the tokens attribute, a dict that maps feature names to stat_info tuples.

_get_server_tokens(self)

 

Get license usage information from a server via "lmutil lmstat".

A dict mapping the token name to a named tuple recording the total tokens provided by this resource and the number currently checked out.

_get_features(self)

 

Get license feature information via "lmutil lmdiag".

A dict mapping the feature name to a list of LicenseFeature objects for that feature is stored in self._features. Errors in the found features are recorded in the list self._errors.

_check_features(self)

 

Check the results returned from lmdiag and record errors if there are expired fatures or similar problems.

TODO: distinguish between a resource that offers some features and one which is completely unusable.