Skip Navigation Links
Exit Print View
| Oracle Solaris Cluster Data Services Developer's Guide Oracle Solaris Cluster 4.1

Search Scope:

- This Document
- Entire Library

## `Validate` Method

The purpose of the `Validate` callback method of a resource type implementation is to check that the proposed resource settings (as specified by the proposed property settings on the resource) are acceptable to the resource type.

The `Validate` method of a resource type implementation is called by the Resource Group Manager (RGM) under one of the following two conditions:

- A new resource of the resource type is being created

- A property of the resource or resource group is being updated

These two scenarios can be distinguished by the presence of the command-line option `-c` (create) or `-u` (update) that is passed to the `Validate` method of the resource.

The `Validate` method is called on each node of a set of nodes, where the set of nodes is defined by the value of the resource type property `Init_nodes`. If `Init_nodes` is set to `RG_PRIMARIES`, `Validate` is called on each node that can host (be a primary of) the resource group that contains the resource. If `Init_nodes` is set to `RT_INSTALLED_NODES`, `Validate` is called on each node where the resource type software is installed, typically all nodes in the cluster.

The default value of `Init_nodes` is `RG_PRIMARIES` (see the `rt_reg`(4) man page). At the point the `Validate` method is called, the RGM has not yet created the resource (in the case of creation callback) or has not yet applied the updated values of the properties that are being updated (in the case of update callback).

Note - If you are using local file systems that are managed by the `HAStoragePlus` resource type, you use the `scds_hasp_check()` function to check the state of that resource type. This information is obtained from the state (online or otherwise) of all `SUNW.HAStoragePlus` resources on which the resource depends. See the `scds_hasp_check`(3HA) man page for a complete list of status codes that are returned by the `scds_hasp_check()` function.

The DSDL function `scds_initialize()` handles these situations in the following manner:

- If the resource is being created, `scds_initialize()` parses the proposed resource properties, as they are passed on the command line. The proposed values of resource properties are therefore available to you as though the resource was already created in the system.

- If the resource or resource group is being updated, the proposed values of the properties that are being updated by the cluster administrator are read in from the command line. The remaining properties (whose values are not being updated) are read in from Oracle Solaris Cluster by using the Resource Management API. If you are using the DSDL, you do not need to concern yourself with these tasks. You can validate a resource as if all the properties of the resource were available.

Suppose the function that implements the validation of a resource's properties is called `svc_validate()`, which uses the `scds_get_`name`()` family of functions to look at the property to be validated. Assuming that an acceptable resource setting is represented by a 0 return code from this function, the `Validate` method of the resource type can thus be represented by the following code fragment:

    int
    main(int argc, char *argv[])
    {
       scds_handle_t handle;
       int rc;

       if (scds_initialize(&handle, argc, argv)!= SCHA_ERR_NOERR) {
       return (1);   /* Initialization Error */
       }
       rc = svc_validate(handle);
       scds_close(&handle);
       return (rc);
    }

The validation function should also log the reason why the validation of the resource failed. However, by leaving out that detail (Chapter 8, Sample DSDL Resource Type Implementation contains a more realistic treatment of a validation function), you can implement a simpler example `svc_validate()` function, as follows:

    int
    svc_validate(scds_handle_t handle)
    {
       scha_str_array_t *confdirs;
       struct stat    statbuf;
       confdirs = scds_get_confdir_list(handle);
       if (stat(confdirs->str_array[0], &statbuf) == -1) {
       return (1);   /* Invalid resource property setting */
       }
       return (0);   /* Acceptable setting */
    }

Thus, you must concern yourself with only the implementation of the `svc_validate()` function.

Copyright © 2000, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices |