Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module generated with changes to ansible.content_builder #416

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions plugins/modules/appliance_access_consolecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# template: header.j2
# This module is autogenerated by vmware_rest_code_generator.
# See: https://github.com/ansible-collections/vmware_rest_code_generator
# This module is autogenerated using the ansible.content_builder.
# See: https://github.com/ansible-community/ansible.content_builder
from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down Expand Up @@ -88,6 +88,7 @@
enabled: false
"""


RETURN = r"""
# content generated by the update_return_section callback# task: Disable the Console CLI
value:
Expand All @@ -102,8 +103,8 @@
"set": {"query": {}, "body": {"enabled": "enabled"}, "path": {}}
} # pylint: disable=line-too-long

import json
import socket
import json # pylint: disable=unused-import
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather prefer the generator to import only required modules

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree!

Copy link
Contributor Author

@GomathiselviS GomathiselviS May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a single header template file, which is rendered into all the module files. Some module files use the imported libraries and some do not. The usage is not common across all module files. You can see the pylint errors here. From what I see the errors due to unused imports are not the same for all module files. It is better to import all libraries in the template file and skip pylint test for the libraries, that are seen in the pylint errors. What are your thoughts?

import socket # pylint: disable=unused-import
from ansible.module_utils.basic import env_fallback

try:
Expand All @@ -117,6 +118,8 @@
AnsibleModule.collection_name = "vmware.vmware_rest"
except ImportError:
from ansible.module_utils.basic import AnsibleModule

# pylint: disable=unused-import
from ansible_collections.vmware.vmware_rest.plugins.module_utils.vmware_rest import (
build_full_device_list,
exists,
Expand All @@ -134,10 +137,14 @@
def prepare_argument_spec():
argument_spec = {
"vcenter_hostname": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_HOST"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_HOST"]),
),
"vcenter_username": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_USER"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_USER"]),
),
"vcenter_password": dict(
type="str",
Expand Down Expand Up @@ -204,7 +211,6 @@ def build_url(params):


async def entry_point(module, session):

if module.params["state"] == "present":
if "_create" in globals():
operation = "create"
Expand Down
18 changes: 12 additions & 6 deletions plugins/modules/appliance_access_consolecli_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# template: header.j2
# This module is autogenerated by vmware_rest_code_generator.
# See: https://github.com/ansible-collections/vmware_rest_code_generator
# This module is autogenerated using the ansible.content_builder.
# See: https://github.com/ansible-community/ansible.content_builder
from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down Expand Up @@ -90,8 +90,8 @@
"get": {"query": {}, "body": {}, "path": {}}
} # pylint: disable=line-too-long

import json
import socket
import json # pylint: disable=unused-import
import socket # pylint: disable=unused-import
from ansible.module_utils.basic import env_fallback

try:
Expand All @@ -105,6 +105,8 @@
AnsibleModule.collection_name = "vmware.vmware_rest"
except ImportError:
from ansible.module_utils.basic import AnsibleModule

# pylint: disable=unused-import
from ansible_collections.vmware.vmware_rest.plugins.module_utils.vmware_rest import (
build_full_device_list,
exists,
Expand All @@ -122,10 +124,14 @@
def prepare_argument_spec():
argument_spec = {
"vcenter_hostname": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_HOST"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_HOST"]),
),
"vcenter_username": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_USER"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_USER"]),
),
"vcenter_password": dict(
type="str",
Expand Down
19 changes: 12 additions & 7 deletions plugins/modules/appliance_access_dcui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# template: header.j2
# This module is autogenerated by vmware_rest_code_generator.
# See: https://github.com/ansible-collections/vmware_rest_code_generator
# This module is autogenerated using the ansible.content_builder.
# See: https://github.com/ansible-community/ansible.content_builder
from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down Expand Up @@ -102,8 +102,8 @@
"set": {"query": {}, "body": {"enabled": "enabled"}, "path": {}}
} # pylint: disable=line-too-long

import json
import socket
import json # pylint: disable=unused-import
import socket # pylint: disable=unused-import
from ansible.module_utils.basic import env_fallback

try:
Expand All @@ -117,6 +117,8 @@
AnsibleModule.collection_name = "vmware.vmware_rest"
except ImportError:
from ansible.module_utils.basic import AnsibleModule

# pylint: disable=unused-import
from ansible_collections.vmware.vmware_rest.plugins.module_utils.vmware_rest import (
build_full_device_list,
exists,
Expand All @@ -134,10 +136,14 @@
def prepare_argument_spec():
argument_spec = {
"vcenter_hostname": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_HOST"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_HOST"]),
),
"vcenter_username": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_USER"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_USER"]),
),
"vcenter_password": dict(
type="str",
Expand Down Expand Up @@ -202,7 +208,6 @@ def build_url(params):


async def entry_point(module, session):

if module.params["state"] == "present":
if "_create" in globals():
operation = "create"
Expand Down
18 changes: 12 additions & 6 deletions plugins/modules/appliance_access_dcui_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# template: header.j2
# This module is autogenerated by vmware_rest_code_generator.
# See: https://github.com/ansible-collections/vmware_rest_code_generator
# This module is autogenerated using the ansible.content_builder.
# See: https://github.com/ansible-community/ansible.content_builder
from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down Expand Up @@ -90,8 +90,8 @@
"get": {"query": {}, "body": {}, "path": {}}
} # pylint: disable=line-too-long

import json
import socket
import json # pylint: disable=unused-import
import socket # pylint: disable=unused-import
from ansible.module_utils.basic import env_fallback

try:
Expand All @@ -105,6 +105,8 @@
AnsibleModule.collection_name = "vmware.vmware_rest"
except ImportError:
from ansible.module_utils.basic import AnsibleModule

# pylint: disable=unused-import
from ansible_collections.vmware.vmware_rest.plugins.module_utils.vmware_rest import (
build_full_device_list,
exists,
Expand All @@ -122,10 +124,14 @@
def prepare_argument_spec():
argument_spec = {
"vcenter_hostname": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_HOST"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_HOST"]),
),
"vcenter_username": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_USER"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_USER"]),
),
"vcenter_password": dict(
type="str",
Expand Down
19 changes: 12 additions & 7 deletions plugins/modules/appliance_access_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# template: header.j2
# This module is autogenerated by vmware_rest_code_generator.
# See: https://github.com/ansible-collections/vmware_rest_code_generator
# This module is autogenerated using the ansible.content_builder.
# See: https://github.com/ansible-community/ansible.content_builder
from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down Expand Up @@ -123,8 +123,8 @@
}
} # pylint: disable=line-too-long

import json
import socket
import json # pylint: disable=unused-import
import socket # pylint: disable=unused-import
from ansible.module_utils.basic import env_fallback

try:
Expand All @@ -138,6 +138,8 @@
AnsibleModule.collection_name = "vmware.vmware_rest"
except ImportError:
from ansible.module_utils.basic import AnsibleModule

# pylint: disable=unused-import
from ansible_collections.vmware.vmware_rest.plugins.module_utils.vmware_rest import (
build_full_device_list,
exists,
Expand All @@ -155,10 +157,14 @@
def prepare_argument_spec():
argument_spec = {
"vcenter_hostname": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_HOST"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_HOST"]),
),
"vcenter_username": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_USER"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_USER"]),
),
"vcenter_password": dict(
type="str",
Expand Down Expand Up @@ -224,7 +230,6 @@ def build_url(params):


async def entry_point(module, session):

if module.params["state"] == "present":
if "_create" in globals():
operation = "create"
Expand Down
18 changes: 12 additions & 6 deletions plugins/modules/appliance_access_shell_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# template: header.j2
# This module is autogenerated by vmware_rest_code_generator.
# See: https://github.com/ansible-collections/vmware_rest_code_generator
# This module is autogenerated using the ansible.content_builder.
# See: https://github.com/ansible-community/ansible.content_builder
from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down Expand Up @@ -95,8 +95,8 @@
"get": {"query": {}, "body": {}, "path": {}}
} # pylint: disable=line-too-long

import json
import socket
import json # pylint: disable=unused-import
import socket # pylint: disable=unused-import
from ansible.module_utils.basic import env_fallback

try:
Expand All @@ -110,6 +110,8 @@
AnsibleModule.collection_name = "vmware.vmware_rest"
except ImportError:
from ansible.module_utils.basic import AnsibleModule

# pylint: disable=unused-import
from ansible_collections.vmware.vmware_rest.plugins.module_utils.vmware_rest import (
build_full_device_list,
exists,
Expand All @@ -127,10 +129,14 @@
def prepare_argument_spec():
argument_spec = {
"vcenter_hostname": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_HOST"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_HOST"]),
),
"vcenter_username": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_USER"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_USER"]),
),
"vcenter_password": dict(
type="str",
Expand Down
19 changes: 12 additions & 7 deletions plugins/modules/appliance_access_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# template: header.j2
# This module is autogenerated by vmware_rest_code_generator.
# See: https://github.com/ansible-collections/vmware_rest_code_generator
# This module is autogenerated using the ansible.content_builder.
# See: https://github.com/ansible-community/ansible.content_builder
from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down Expand Up @@ -103,8 +103,8 @@
"set": {"query": {}, "body": {"enabled": "enabled"}, "path": {}}
} # pylint: disable=line-too-long

import json
import socket
import json # pylint: disable=unused-import
import socket # pylint: disable=unused-import
from ansible.module_utils.basic import env_fallback

try:
Expand All @@ -118,6 +118,8 @@
AnsibleModule.collection_name = "vmware.vmware_rest"
except ImportError:
from ansible.module_utils.basic import AnsibleModule

# pylint: disable=unused-import
from ansible_collections.vmware.vmware_rest.plugins.module_utils.vmware_rest import (
build_full_device_list,
exists,
Expand All @@ -135,10 +137,14 @@
def prepare_argument_spec():
argument_spec = {
"vcenter_hostname": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_HOST"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_HOST"]),
),
"vcenter_username": dict(
type="str", required=True, fallback=(env_fallback, ["VMWARE_USER"]),
type="str",
required=True,
fallback=(env_fallback, ["VMWARE_USER"]),
),
"vcenter_password": dict(
type="str",
Expand Down Expand Up @@ -203,7 +209,6 @@ def build_url(params):


async def entry_point(module, session):

if module.params["state"] == "present":
if "_create" in globals():
operation = "create"
Expand Down
Loading