# Affinity Groups

HPE Morpheus VM Essentials Software offers two-way sync for affinity groups with integrated VMware vCenter Clouds. An affinity group contains a type (either Keep Together or Keep Separate) and a list of servers which should have the rule applied. Affinity groups created from HPE Morpheus VM Essentials create "Should" rules (soft rules) rather than "Must" rules (hard rules) in vCenter. Thus whenever possible, servers configured to "Keep Together" will run on the same cluster host while servers configured to "Keep Separate" will be balanced across cluster hosts to the maximum extent possible. These rules may be broken if necessary to balance resources or recover from failures.

TIP

It is possible to create an empty affinity group (that is, one with no servers selected) in HPE Morpheus VM Essentials even though this is not possible in vCenter. If such an affinity group is created, HPE Morpheus VM Essentials will hold it without syncing to vCenter until at least one server is added and the affinity group becomes compatible with the vCenter API.

Viewing Affinity Groups

Affinity groups are listed on the Resources tab of the Cloud detail page (Infrastructure > Clouds, then select the appropriate VMware Cloud). From the ACTIONS menu for each affinity group, they may be edited or deleted. By editing an affinity group, users may view or edit its enabled status (affinity groups which are not enabled will not be acted on).![A list of current-existing affinity groups.](https://support.hpe.com/hpesc/public/api/document/sd00007735en_us/GUID-7AD47077-8387-4499-9BDE-BBACFDDA2989-high.png)

Adding Affinity Groups

As mentioned in the previous section, affinity groups are listed on the Resources tab of the VMware Cloud detail page (Infrastructure > Clouds, then select the appropriate VMware Cloud). From here, to create a new affinity group, click + ADD. Configure the following:

- **NAME:** A name for the affinity group
- **TYPE:** Select either "Keep Together" or "Keep Separate" to indicate whether the selected servers should run on as few or as many servers as possible within the capabilities of the HVM Cluster
- **CLUSTER:** Select the vCenter cluster
- **ACTIVE:** When checked, the rules defined in the affinity group will be applied to the HVM Cluster
- **SERVERS:** Select as many servers as desired from the typeahead list

Once finished, click SAVE CHANGES. Following the next Cloud sync, the affinity rule will be applied and VMs will begin to migrate (if applicable).

![Adding a new affinity group.](https://support.hpe.com/hpesc/public/api/document/sd00007735en_us/GUID-C4C3EDB1-CA6E-4DEA-890C-B5C5B0E3DE13-high.png)

Adding Servers to Affinity Groups at Provision Time

In addition the adding servers from the affinity group, newly-provisioned servers may be added to an affinity group at provision time. From the CONFIGURE tab of the provisioning wizard, expand the Advanced Options section. Within Advanced Options, select an affinity group. The affinity group must be pre-existing and this list will be filtered to show only affinity groups that apply depending on other configuration parameters set on the new Instance.![Setting an affinity group on a new vmware instance at provision time](https://support.hpe.com/hpesc/public/api/document/sd00007735en_us/GUID-688F89C9-1444-4D3A-94B5-E8DFE9BDC066-high.png)
