Add ability to set tags in network modules

This adds the `tags` parameter to the network,
subnet, and router modules.

Change-Id: I704b40c44c733a3d4ec93a95d8efcb7ecf6e2a32
Signed-off-by: Austin Jamias <ajamias@redhat.com>
This commit is contained in:
Austin Jamias
2025-11-07 19:06:37 -05:00
parent a178493281
commit dbc6f7d44a
6 changed files with 125 additions and 1 deletions

View File

@@ -112,6 +112,11 @@ options:
choices: ['present', 'absent']
default: present
type: str
tags:
description:
- A list of tags to set on the network
type: list
elements: str
extends_documentation_fragment:
- openstack.cloud.openstack
'''
@@ -326,6 +331,7 @@ class RouterModule(OpenStackModule):
network=dict(),
project=dict(),
state=dict(default='present', choices=['absent', 'present']),
tags=dict(type='list', elements='str'),
)
module_kwargs = dict(
@@ -603,6 +609,7 @@ class RouterModule(OpenStackModule):
name = self.params['name']
network_name_or_id = self._get_external_gateway_network_name()
project_name_or_id = self.params['project']
tags = self.params['tags']
if self.params['external_fixed_ips'] and not network_name_or_id:
self.fail(
@@ -686,6 +693,12 @@ class RouterModule(OpenStackModule):
self._update_ifaces(router, to_add, to_remove,
missing_internal_ports)
if tags is not None:
old_tags = self.conn.network.get_tags(router)
if set(old_tags) != set(tags):
self.conn.network.set_tags(router, tags)
changed = True
self.exit_json(changed=changed,
router=router.to_dict(computed=False))