ComputedFactContext

Provides access to the evaluation context. See Example below.

Description

The context contains the grid objects that the constraint engine uses to evaluate constraints.If they are available in the current context, the ComputedFactContext provides access to the current job instance, deployed job, user, resource, VM host, and repository grid objects.

The VM host and repository grid objects are only in the context for the evaluation of the provisioning constraints such as vmHost. The job and job instance objects are only in the context for a resource or allocation constraint evaluation.

Methods

Detail:

jobInfo getJob()

Retrieves the JobInfo grid object from the context for a computed fact evaluation.

The returned grid object allows read-only access to its factset. For example, when a computed fact is evaluated in the context of a Start constraint, the returned JobInfo grid object provides access to the factset of the deployed job.

Returns: JobInfo grid object for this computed fact evaluation or None if the object is not in the context.

JobInstanceInfo getJobInstance()

Retrieves the JobInstanceInfo grid object from the context for a computed fact evaluation.

The returned grid object allows read-only access to its factset. For example, when a computed fact is evaluated in the context of a Start constraint, the returned JobInstanceInfo grid object provides access to the factset of the current job instance.

Returns: JobInstanceInfo representing a job instance for this computed fact evaluation or None if the object is not in the context.

RepositoryInfo getRepository()

Retrieves the RepositoryInfo grid object from the context for a computed fact evaluation.

The returned grid object allows read-only access to its factset. For example, when a computed fact is evaluated in the context of a repository constraint, the returned RepositoryInfo grid object provides access to the factset of a repository.

Returns: RepositoryInfo representing a repository instance for this computed fact evaluation or None if the object is not in the context.

ResourceInfo getResource()

Retrieves the ResourceInfo grid object from the context for a computed fact evaluation.

The returned grid object allows read-only access to its factset. For example, when a computed fact is evaluated in the context of a resource constraint, the returned ResourceInfo grid object provides access to the factset of the resource.

Returns: ResourceInfo grid object for this computed fact evaluation or None if the object is not in the context.

UserInfo getUser()

Retrieves the UserInfo grid object from the context for a computed fact evaluation.

The returned grid object allows read-only access to its factset. For example, when a computed fact is evaluated in the context of a Start constraint, the returned UserInfo grid object provides access to the factset of the user who started the job.

Returns: UserInfo grid object for this computed fact evaluation or None if object is not in the context.

VMHostInfo getVmHost()

Retrieves the VmHostInfo grid object from the context for a Computed Fact evaluation.

The returned grid object allows read-only access to its factset. For example, when a computed fact is evaluated in the context of a vm host constraint, the returned VmHostInfo grid object provides access to the factset of a vm host.

Returns: UserInfo grid object for this computed fact evaluation or None if object is not in the context.

Example

How to retrieve the current job instance in which a computed fact is being executed during a resource constraint:

      class myComputedFact(ComputedFact):
          def compute(self):
              ctx = self.getContext()
              if ctx == None:
                  print "No context"
                  ...
              else:
                  jobInstance = ctx.getJobInstance()
                  if jobInstance == None:
                      print "No job instance in context"
                      ...
                  else:
                      print "jobInstance.id=%s" % (jobInstance.getFact("jobinstance.id"))

See Also