Affinity-or-anti-affinity groups may be defined in the VNF descriptor, in the `df` section, under `affinity-or-anti-affinity-group`.
The type may be `affinity` or `anti-affinity`, and the scope must be `nfvi-node`. VDU profiles may reference one of the defined affinity-or-anti-affinity-group. Notice that, in Openstack, only one group is allowed. The following example shows a VNF with two VDU, both assigned to the same affinity-group `affinity-group-1`. Both virtual machines will be then instantiated in the same host.
```yaml
vnfd:
description:A basic VNF descriptor w/ two VDUs and an affinity group
df:
-id:default-df
instantiation-level:
-id:default-instantiation-level
vdu-level:
-number-of-instances:1
vdu-id:affinity_basic-VM-1
-number-of-instances:1
vdu-id:affinity_basic-VM-2
vdu-profile:
-id:affinity_basic-VM-1
min-number-of-instances:1
affinity-or-anti-affinity-group:
-id:affinity-group-1
-id:affinity_basic-VM-2
min-number-of-instances:1
affinity-or-anti-affinity-group:
-id:affinity-group-1
affinity-or-anti-affinity-group:
-id:affinity-group-1
type:affinity
scope:nfvi-node
```
An existing server-group may be passed as an instantiation parameter to be used as affinity-or-anti-affinity-group. In this case, the server-group will not be created, but reused, and will not be deleted when the Network Service instance is deleted. The following example shows the syntax
Where the `id` of the `affinity-or-anti-affinity-group` is the one in the descriptor, and the `vim-affinity-group-id` is the guid of the existing server-group in Openstack to be used (instead of being created).