Skip to content

Commit

Permalink
ref: PG affinity_type, is_strict -> placement_group_type, placement_g…
Browse files Browse the repository at this point in the history
…roup_policy (#540)

* PG affinity_type, is_strict -> placement_group_type, placement_group_policy

* Re-render docs

* Bump linode-api4 -> 5.19
  • Loading branch information
lgarber-akamai authored Jul 24, 2024
1 parent 30a951c commit 022ff7b
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 54 deletions.
4 changes: 2 additions & 2 deletions docs/modules/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ Manage Linode Instances, Configs, and Disks.
"placement_group": {
"id": 123,
"label": "test",
"affinity_type": "anti_affinity:local",
"is_strict": true
"placement_group_type": "anti_affinity:local",
"placement_group_policy": "strict"
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/instance_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ Get info about a Linode Instance.
"placement_group": {
"id": 123,
"label": "test",
"affinity_type": "anti_affinity:local",
"is_strict": true
"placement_group_type": "anti_affinity:local",
"placement_group_policy": "strict"
}
}
```
Expand Down
12 changes: 6 additions & 6 deletions docs/modules/placement_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ NOTE: Placement Groups may not currently be available to all users.
linode.cloud.placement_group:
label: my-pg
region: us-east
affinity_type: anti_affinity:local
is_strict: True
placement_group_type: anti_affinity:local
placement_group_policy: flexible
state: present
```
Expand Down Expand Up @@ -58,8 +58,8 @@ NOTE: Placement Groups may not currently be available to all users.
| `id` | <center>`int`</center> | <center>Optional</center> | The unique ID of the placement group. |
| `label` | <center>`str`</center> | <center>Optional</center> | The label of the Placement Group. This field can only contain ASCII letters, digits and dashes. |
| `region` | <center>`str`</center> | <center>Optional</center> | The region that the placement group is in. |
| `affinity_type` | <center>`str`</center> | <center>Optional</center> | The affinity policy for Linodes in a placement group. |
| `is_strict` | <center>`bool`</center> | <center>Optional</center> | Whether Linodes must be able to become compliant during assignment. **(Default: `False`)** |
| `placement_group_type` | <center>`str`</center> | <center>Optional</center> | The type of this placement group. |
| `placement_group_policy` | <center>`str`</center> | <center>Optional</center> | The policy for assigning Linodes to this placement group. **(Choices: `flexible`, `strict`)** |

## Return Values

Expand All @@ -71,8 +71,8 @@ NOTE: Placement Groups may not currently be available to all users.
"id": 123,
"label": "my-pg",
"region": "eu-west",
"affinity_type": "anti_affinity:local",
"is_strict": true,
"placement_group_type": "anti_affinity:local",
"placement_group_policy": "flexible",
"is_compliant": true,
"members": [
{
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/placement_group_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Get info about a Linode Placement Group.
"id": 123,
"label": "test",
"region": "eu-west",
"affinity_type": "anti_affinity:local",
"is_strict": true,
"placement_group_type": "anti_affinity:local",
"placement_group_policy": "strict",
"is_compliant": true,
"members": [
{
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/placement_group_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ List and filter on Placement Groups.
"id": 123,
"label": "test",
"region": "eu-west",
"affinity_type": "anti_affinity:local",
"is_strict": true,
"placement_group_type": "anti_affinity:local",
"placement_group_policy": "strict",
"is_compliant": true,
"members": [
{
Expand Down
4 changes: 2 additions & 2 deletions plugins/module_utils/doc_fragments/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
"placement_group": {
"id": 123,
"label": "test",
"affinity_type": "anti_affinity:local",
"is_strict": true
"placement_group_type": "anti_affinity:local",
"placement_group_policy": "strict"
}
}''']

Expand Down
8 changes: 4 additions & 4 deletions plugins/module_utils/doc_fragments/placement_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
linode.cloud.placement_group:
label: my-pg
region: us-east
affinity_type: anti_affinity:local
is_strict: True
placement_group_type: anti_affinity:local
placement_group_policy: flexible
state: present''', '''
- name: Update a Linode placement group label
linode.cloud.placement_group:
Expand All @@ -28,8 +28,8 @@
"id": 123,
"label": "my-pg",
"region": "eu-west",
"affinity_type": "anti_affinity:local",
"is_strict": true,
"placement_group_type": "anti_affinity:local",
"placement_group_policy": "flexible",
"is_compliant": true,
"members": [
{
Expand Down
4 changes: 2 additions & 2 deletions plugins/module_utils/doc_fragments/placement_group_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"id": 123,
"label": "test",
"region": "eu-west",
"affinity_type": "anti_affinity:local",
"is_strict": true,
"placement_group_type": "anti_affinity:local",
"placement_group_policy": "strict",
"is_compliant": true,
"members": [
{
Expand Down
4 changes: 2 additions & 2 deletions plugins/module_utils/doc_fragments/placement_group_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"id": 123,
"label": "test",
"region": "eu-west",
"affinity_type": "anti_affinity:local",
"is_strict": true,
"placement_group_type": "anti_affinity:local",
"placement_group_policy": "strict",
"is_compliant": true,
"members": [
{
Expand Down
19 changes: 12 additions & 7 deletions plugins/modules/placement_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@
type=FieldType.string,
description=["The region that the placement group is in."],
),
"affinity_type": SpecField(
"placement_group_type": SpecField(
type=FieldType.string,
description=["The affinity policy for Linodes in a placement group."],
description=["The type of this placement group."],
),
"is_strict": SpecField(
type=FieldType.bool,
default=False,
"placement_group_policy": SpecField(
type=FieldType.string,
description=[
"Whether Linodes must be able to become compliant during assignment."
"The policy for assigning Linodes to this placement group."
],
choices=["flexible", "strict"],
),
}

Expand All @@ -76,7 +76,12 @@
},
)

CREATE_FIELDS = {"label", "region", "affinity_type", "is_strict"}
CREATE_FIELDS = {
"label",
"region",
"placement_group_type",
"placement_group_policy",
}
# Fields that can be updated on an existing placement group
MUTABLE_FIELDS = {"label"}

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
linode-api4>=5.18.0
linode-api4>=5.19.0
polling>=0.3.2
types-requests==2.32.0.20240712
ansible-specdoc>=0.0.15
21 changes: 11 additions & 10 deletions tests/integration/targets/instance_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- name: Create a Linode instance without a root password
linode.cloud.instance:
label: 'ansible-test-nopass-{{ r }}'
region: us-ord
region: '{{ pg_region }}'
type: g6-standard-1
image: linode/ubuntu22.04
private_ip: true
Expand All @@ -32,7 +32,7 @@
- name: Create a Linode instance with additional ips and without a root password
linode.cloud.instance:
label: 'ansible-test-additional-ips-nopass-{{ r }}'
region: us-ord
region: '{{ pg_region }}'
type: g6-standard-1
image: linode/ubuntu22.04
private_ip: true
Expand All @@ -53,7 +53,7 @@
- name: Update the instance region and type
linode.cloud.instance:
label: '{{ create.instance.label }}'
region: us-ord
region: '{{ pg_region }}'
group: funny
type: g6-standard-2
image: linode/ubuntu22.04
Expand All @@ -66,7 +66,7 @@
- name: Update label with invalid string
linode.cloud.instance:
label: '!!Invalid!!'
region: us-ord
region: '{{ pg_region }}'
group: funny
type: g6-standard-2
image: linode/ubuntu22.04
Expand All @@ -79,7 +79,7 @@
- name: Attempt to add additional ips to an instance
linode.cloud.instance:
label: '{{ create_additional_ips.instance.label }}'
region: us-ord
region: '{{ pg_region }}'
type: g6-standard-1
image: linode/ubuntu22.04
private_ip: true
Expand All @@ -95,7 +95,7 @@
- name: Attempt to remove additional ips from an instance
linode.cloud.instance:
label: '{{ create_additional_ips.instance.label }}'
region: us-ord
region: '{{ pg_region }}'
type: g6-standard-1
image: linode/ubuntu22.04
private_ip: true
Expand All @@ -108,7 +108,7 @@
- name: Update the instance
linode.cloud.instance:
label: '{{ create.instance.label }}'
region: us-ord
region: '{{ pg_region }}'
group: funny
type: g6-standard-1
image: linode/ubuntu22.04
Expand All @@ -130,7 +130,7 @@
assert:
that:
- info_id.instance.ipv4|length > 1
- info_id.instance.region == 'us-ord'
- info_id.instance.region == pg_region
- info_id.configs|length == 1
- info_id.networking.ipv4.public[0].address != None

Expand All @@ -143,14 +143,15 @@
assert:
that:
- info_label.instance.ipv4|length > 1
- info_label.instance.region == 'us-ord'
- info_label.instance.region == pg_region
- info_label.configs|length == 1

- name: Create a Linode placement group
linode.cloud.placement_group:
label: 'ansible-test-{{ r }}'
region: '{{ pg_region }}'
affinity_type: anti_affinity:local
placement_group_type: anti_affinity:local
placement_group_policy: flexible
state: present
register: pg_created

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
linode.cloud.placement_group:
label: 'ansible-test-{{ r }}'
region: '{{ region }}'
affinity_type: anti_affinity:local
placement_group_type: anti_affinity:local
placement_group_policy: flexible
state: present
register: pg_created

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
linode.cloud.placement_group:
label: 'ansible-test-{{ r }}'
region: '{{ region }}'
affinity_type: anti_affinity:local
placement_group_type: anti_affinity:local
placement_group_policy: flexible
state: present
register: pg_created

- name: Assert placement group is created
assert:
that:
- pg_created.placement_group.region == region
- pg_created.placement_group.affinity_type == 'anti_affinity:local'
- pg_created.placement_group.is_strict == false
- pg_created.placement_group.placement_group_type == 'anti_affinity:local'
- pg_created.placement_group.placement_group_policy == 'flexible'

- name: Update a Linode placement group label
linode.cloud.placement_group:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
linode.cloud.placement_group:
label: 'ansible-test-{{ r }}'
region: '{{ region }}'
affinity_type: anti_affinity:local
is_strict: True
placement_group_type: anti_affinity:local
placement_group_policy: strict
state: present
register: pg_created

Expand All @@ -29,8 +29,8 @@
that:
- pg_created.placement_group.label == pg.placement_group.label
- pg_created.placement_group.region == pg.placement_group.region
- pg_created.placement_group.affinity_type == pg.placement_group.affinity_type
- pg_created.placement_group.is_strict == pg.placement_group.is_strict
- pg_created.placement_group.placement_group_type == pg.placement_group.placement_group_type
- pg_created.placement_group.placement_group_policy == pg.placement_group.placement_group_policy

- name: Delete a placement group by id
linode.cloud.placement_group:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
linode.cloud.placement_group:
label: 'ansible-test-{{ r }}'
region: '{{ region }}'
affinity_type: anti_affinity:local
is_strict: True
placement_group_type: anti_affinity:local
placement_group_policy: strict
state: present
register: pg_created

Expand All @@ -31,8 +31,8 @@
that:
- pg_list.placement_groups[0].label == pg_created.placement_group.label
- pg_list.placement_groups[0].region == pg_created.placement_group.region
- pg_list.placement_groups[0].affinity_type == pg_created.placement_group.affinity_type
- pg_list.placement_groups[0].is_strict == pg_created.placement_group.is_strict
- pg_list.placement_groups[0].placement_group_type == pg_created.placement_group.placement_group_type
- pg_list.placement_groups[0].placement_group_policy == pg_created.placement_group.placement_group_policy

- name: Delete a placement group
linode.cloud.placement_group:
Expand Down

0 comments on commit 022ff7b

Please sign in to comment.