Copying Resource Configurations
Depending on the resource type of a resource, it may be possible to use an existing resource configuration as a template for a new resource configuration.
To Copy a Resource Configuration
Get a handle to the original resource by calling OpenClusterResource.
Get the resource type of the original resource. Call ClusterResourceControl with the CLUSCTL_RESOURCE_GET_RESOURCE_TYPE control code.
Create a resource of that type. (See Creating Resources.) Note that the name of the new resource cannot be the same as the original if it is created in the same cluster.
Duplicate the original resource's read/write properties:
- Retrieve the original resource's read/write common properties into a property list by using CLUSCTL_RESOURCE_GET_COMMON_PROPERTIES.
- Use the property list obtained in the previous step to set the new resource's read/write common properties with CLUSCTL_RESOURCE_SET_COMMON_PROPERTIES.
- Retrieve the original's read/write private properties into a property list using CLUSCTL_RESOURCE_GET_PRIVATE_PROPERTIES.
- Use the property list obtained in the previous step to set the new resource's read/write private properties with CLUSCTL_RESOURCE_SET_PRIVATE_PROPERTIES.
If the original resource has registry and crypto checkpoints, do the following:
- Retrieve the original's crypto checkpoints using CLUSCTL_RESOURCE_GET_CRYPTO_CHECKPOINTS.
- Use the data obtained in the previous step and the Crypto API to create crypto keys for the new resource.
- Checkpoint the crypto keys created in the previous step using CLUSCTL_RESOURCE_ADD_CRYPTO_CHECKPOINT.
- Retrieve the original's registry checkpoints using CLUSCTL_RESOURCE_GET_REGISTRY_CHECKPOINTS.
- Use the registry functions to create registry keys for the new resource.
- Checkpoint the registry keys created in the previous step using CLUSCTL_RESOURCE_ADD_REGISTRY_CHECKPOINT.
Enumerate the dependencies of the original resource. See Enumerating Objects.
Repeat steps 2 through 6 for each dependency until the entire dependency tree has been copied.