This sample demonstrates how to Add/List/Modify/Delete the rules for an
existing SDRS cluster.
url                       [required]: url of the web service.
username                  [required]: username for the authentication
Password                  [required]: password for the authentication
podname                   [required]: StoragePod name.
option                    [required]:  valid option are "addVmAntiAffinity",
"addVmdkAntiAffinity", "list", "modifyVmAntiAffinity",
"modifyVmdkAntiAffinity", "deleteVmAntiAffinity" and
rulename                  Rule name.
vmlist                    Comma separated, list of VM name. It is required while
adding VmAntiAffinity Rule.
newrulename               New name for rule while modifying
enable                    Flag to indicate whether or not the rule is enabled.
vmname                    virtual machine name.

Sample usage:
addVmAntiAffinity Rule:
run.bat --url [URLString] --username [User] --password
[Password] --option addVmAntiAffinity --podname [podname] --rulename [rulename]
--enable [enable] --vmlist [vmlist]

addVmdkAntiAffinity Rule:
run.bat --url [URLString] --username [User] --password
[Password] --option addVmdkAntiAffinity --podname [podname] --rulename [rulename]
--enable [enable] --vmname [vmname]

List Rules:
run.bat --url [URLString] --username [User] --password
[Password] --option list --podname [podname]

modifyVmAntiAffinity Rule:
run.bat --url [URLString] --username [User] --password
[Password] --option modifyVmAntiAffinity  --podname [podname]  --rulename [rulename]
--enable [enable] --vmname [vmname] --newrulename [newrulename]

modifyVmdkAntiAffinity Rule:
run.bat --url [URLString] --username [User] --password
[Password] --option modifyVmdkAntiAffinity --podname [podname] --rulename [rulename]
--enable [enable] --newrulename [newrulename]

deleteVmAntiAffinity Rule:
run.bat --url [URLString] --username [User] --password
[Password] --option deleteVmAntiAffinity --podname [podname] --rulename [rulename]

deleteVmdkAntiAffinity Rule:
run.bat --url [URLString] --username [User] --password
[Password] --option deleteVmdkAntiAffinity  --podname [podname] --rulename [rulename]

NOTE: All the virtual disks will be added while adding Vmdk AntiAffinity Rule.

VMware vSphere Web Services Java Samples

This sample was originally released as a part of vSphere 6.0 under license terms that contained a provision that disallowed redistribution in source form. In order to encourage growth of community around VMware samples, these samples are being re-released under a commercially friendly open source license (BSD 3-Clause). See the file header for details.

The samples themselves are identical to the official release version with the exception of a changed copyright and license header on each file.

If you wish to run this sample, please download the official SDK from and follow the provided instructions.

These samples are provided for reference with no warranty expressed or implied.

Sign in to be able to add comments.

Comments 0