Resource Type Definitions
The types.cf file contains definitions of standard VCS resource types. The example shown in the following paragraph is for a standard VCS resource type, FileOnOff. A custom resource type definition should be placed in a file called ResourcetypeTypes.cf.
Example Resource Type Definition: FileOnOff Resource
The FileOnOff agent is designed to manage simple files. Each FileOnOff resource manages one file. For example, when VCS wants to online the FileOnOff resource, the FileOnOff agent calls the online entry point to create a file of a specific name in a specific location. To monitor the FileOnOff resource, the agent calls the monitor entry point to verify the existence of the file. When VCS wants the FileOnOff resource taken offline, the agent calls the offline entry point to remove the file.
The following shows the definition for the FileOnOff resource type. It applies to all resources of the FileOnOff type:
type FileOnOff (
static str ArgList[] = { PathName }
str PathName
)
This definition is included in the VCS types.cf file. Note the following points about the FileOnOff type definition:
- The keyword "type" is followed by the name of the resource type, in this case, FileOnOff.
- The ArgList attribute includes the names of the attributes, listing them in the order they are sent to the entry points. In the case of this example, the FileOnOff resource type contains only one attribute, PathName, the pathname for the file.
- The PathName attribute is defined as a "str," or string variable. The data type for each attribute must be defined.
The FileOnOff Resource: an Example in the main.cf File
In the VCS configuration file, main.cf, a specific resource of the FileOnOff resource type may resemble:
include types.cf
.
.
.
FileOnOff temp_file01 (
PathName = "/tmp/test"
)
The include statement at the beginning of the main.cf file names the types.cf file, which includes the FileOnOff resource type definition. The resource defined in the main.cf file specifies:
- The resource type: FileOnOff
- The unique name of the resource, temp_file01
- The value for the PathName attribute: "/tmp/test"
The agent creates a file "test" in the directory "/tmp."
How the FileOnOff Agent Uses Configuration Information
This information in the VCS configuration is passed by the engine to the FileOnOff agent when the agent starts up. The information passed to the agent includes: resource names, the corresponding resource attributes, and the values of the attributes for all of the resources of that type.
Thereafter, to bring the resource online, for example, VCS can provide the agent with the name of the entry point (online) and the name of the resource (temp_file01). The agent then calls the entry point and provides the resource name and values for the attributes in the ArgList. The entry point performs its tasks.
|