create_drs_rule
Create VM-VM DRS rules to enforce affinity or anti-affinity, keeping specified VMs together or on separate hosts. Preview changes before confirming.
Instructions
[WRITE] Create a VM-VM DRS rule (affinity or anti-affinity) - preview/confirm gated.
rule_type "affinity" keeps the listed VMs together; "antiAffinity" keeps them apart (e.g. redundant appliance pairs on separate hosts). Requires >=2 distinct VMs, all members of the cluster. VM-Host rules hang off cluster VM/host groups and are not created here. Verify with list_drs_rules. Audited.
Returns: Preview dict (action="preview", would_create) or result dict (action="created", created incl. the assigned key). Errors return a dict with "error" + hint.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | No | vCenter target name from config.yaml; omit to use the default target. | |
| cluster | Yes | Exact cluster name. | |
| confirm | No | False (default) returns the blast radius and changes nothing. True creates it. Do not set True because the user asked earlier; they have not seen the preview yet. | |
| enabled | No | Create the rule enabled (default) or disabled. | |
| vm_names | Yes | VM names the rule governs (>=2, all in the cluster). | |
| rule_name | Yes | Name for the new rule; must be unique on the cluster. | |
| rule_type | Yes | "affinity" or "antiAffinity". |