Skip to content

Commit

Permalink
fixing version numbers in modules
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemorency committed Aug 15, 2024
1 parent 8e5dabc commit 37c49a6
Show file tree
Hide file tree
Showing 135 changed files with 270 additions and 245 deletions.
47 changes: 37 additions & 10 deletions config/copy_old_return_blocks.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env python
import os
import yaml


SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
OLD_MODULE_PATH = f"{SCRIPT_DIR}/../plugins/modules"
OLD_MODULE_PATH = f"{SCRIPT_DIR}/../../temp/vmware.vmware_rest/plugins/modules"
NEW_MODULE_PATH = f"{SCRIPT_DIR}/output/plugins/modules"
GALAXY_PATH = f"{SCRIPT_DIR}/../galaxy.yml"


def read_examples_and_return_blocks(module_file_path):
Expand All @@ -26,38 +28,63 @@ def read_examples_and_return_blocks(module_file_path):
return content


def inject_examples_and_return_blocks(module_file_path, inject_lines):
def read_version_added(old_module_file_path):
with open(old_module_file_path, "r") as f:
lines = f.readlines()

for line in lines:
if line.startswith('version_added:'):
return line

return None


def format_new_content(module_file_path, example_and_return_blocks, version_added):
with open(module_file_path, "r") as f:
lines = f.readlines()

with open(GALAXY_PATH, "r") as f:
_galaxy_contents = yaml.safe_load(f)
default_version = _galaxy_contents['version']

new_content = []
added_content = False
open_block = False
for line in lines:
if line.startswith('EXAMPLES = r"""') or line.startswith('RETURN = r"""'):
if example_and_return_blocks and (line.startswith('EXAMPLES = r"""') or line.startswith('RETURN = r"""')):
open_block = True
if not added_content:
new_content += inject_lines
new_content += example_and_return_blocks
added_content = True
continue

if open_block and line.startswith('"""'):
open_block = False
continue

if line.startswith('version_added'):
if version_added:
new_content += [version_added]
else:
new_content += [f'version_added: {default_version}\n']
continue

new_content += [line]

return new_content


if __name__ == "__main__":
for module in os.listdir(OLD_MODULE_PATH):
for module in os.listdir(NEW_MODULE_PATH):
old_module = os.path.join(OLD_MODULE_PATH, module)
new_module = old_module.replace(OLD_MODULE_PATH, NEW_MODULE_PATH)
new_module = os.path.join(NEW_MODULE_PATH, module)
blocks = []
version_added = None
if os.path.isfile(old_module):
blocks = read_examples_and_return_blocks(old_module)
new_content = inject_examples_and_return_blocks(new_module, blocks)
version_added = read_version_added(old_module)

with open(new_module, "w") as f:
for line in new_content:
f.write(f"{line}")
new_content = format_new_content(new_module, blocks, version_added)
with open(new_module, "w") as f:
for line in new_content:
f.write(f"{line}")
2 changes: 1 addition & 1 deletion plugins/modules/appliance_access_consolecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_access_consolecli_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_access_dcui.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_access_dcui_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_access_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_access_shell_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_access_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_access_ssh_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_health_applmgmt_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_health_database_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_health_databasestorage_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_health_load_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_health_mem_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_health_softwarepackages_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_health_storage_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_health_swap_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_health_system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_infraprofile_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_infraprofile_configs_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_localaccounts_globalpolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
type: int
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_localaccounts_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_monitoring_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_monitoring_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/appliance_networking_dns_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down Expand Up @@ -111,8 +111,8 @@

# This structure describes the format of the data expected by the end-points
PAYLOAD_FORMAT = {
"add": {"query": {}, "body": {"domain": "domain"}, "path": {}},
"set": {"query": {}, "body": {"domains": "domains"}, "path": {}},
"add": {"query": {}, "body": {"domain": "domain"}, "path": {}},
} # pylint: disable=line-too-long

from ansible.module_utils.basic import env_fallback
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_networking_dns_domains_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/appliance_networking_dns_hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down Expand Up @@ -103,8 +103,8 @@

# This structure describes the format of the data expected by the end-points
PAYLOAD_FORMAT = {
"test": {"query": {}, "body": {"name": "name"}, "path": {}},
"set": {"query": {}, "body": {"name": "name"}, "path": {}},
"test": {"query": {}, "body": {"name": "name"}, "path": {}},
} # pylint: disable=line-too-long

from ansible.module_utils.basic import env_fallback
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_networking_dns_hostname_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
6 changes: 3 additions & 3 deletions plugins/modules/appliance_networking_dns_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down Expand Up @@ -142,9 +142,9 @@

# This structure describes the format of the data expected by the end-points
PAYLOAD_FORMAT = {
"test": {"query": {}, "body": {"servers": "servers"}, "path": {}},
"add": {"query": {}, "body": {"server": "server"}, "path": {}},
"set": {"query": {}, "body": {"mode": "mode", "servers": "servers"}, "path": {}},
"add": {"query": {}, "body": {"server": "server"}, "path": {}},
"test": {"query": {}, "body": {"servers": "servers"}, "path": {}},
} # pylint: disable=line-too-long

from ansible.module_utils.basic import env_fallback
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/appliance_networking_dns_servers_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 1.0.0
version_added: 2.0.0
requirements:
- vSphere 7.0.3 or greater
- python >= 3.6
Expand Down
Loading

0 comments on commit 37c49a6

Please sign in to comment.