Freigeben über


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

  1. Get a handle to the original resource by calling OpenClusterResource.

  2. Get the resource type of the original resource. Call ClusterResourceControl with the CLUSCTL_RESOURCE_GET_RESOURCE_TYPE control code.

  3. 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.

  4. Duplicate the original resource's read/write properties:

    1. Retrieve the original resource's read/write common properties into a property list by using CLUSCTL_RESOURCE_GET_COMMON_PROPERTIES.
    2. 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.
    3. Retrieve the original's read/write private properties into a property list using CLUSCTL_RESOURCE_GET_PRIVATE_PROPERTIES.
    4. 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.
  5. If the original resource has registry and crypto checkpoints, do the following:

    1. Retrieve the original's crypto checkpoints using CLUSCTL_RESOURCE_GET_CRYPTO_CHECKPOINTS.
    2. Use the data obtained in the previous step and the Crypto API to create crypto keys for the new resource.
    3. Checkpoint the crypto keys created in the previous step using CLUSCTL_RESOURCE_ADD_CRYPTO_CHECKPOINT.
    4. Retrieve the original's registry checkpoints using CLUSCTL_RESOURCE_GET_REGISTRY_CHECKPOINTS.
    5. Use the registry functions to create registry keys for the new resource.
    6. Checkpoint the registry keys created in the previous step using CLUSCTL_RESOURCE_ADD_REGISTRY_CHECKPOINT.
  6. Enumerate the dependencies of the original resource. See Enumerating Objects.

  7. Repeat steps 2 through 6 for each dependency until the entire dependency tree has been copied.