Skip to content

Commit

Permalink
REST stuff and removing old docs fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolenz committed Dec 16, 2024
1 parent 33a8afe commit 7df66e5
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 233 deletions.
111 changes: 0 additions & 111 deletions plugins/doc_fragments/vmware.py

This file was deleted.

68 changes: 0 additions & 68 deletions plugins/doc_fragments/vmware_rest_client.py

This file was deleted.

33 changes: 1 addition & 32 deletions plugins/module_utils/vmware_rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
except ImportError:
HAS_URLLIB3 = False

from ansible.module_utils.basic import env_fallback, missing_required_lib
from ansible.module_utils.basic import missing_required_lib
from ansible.module_utils._text import to_native


Expand Down Expand Up @@ -102,37 +102,6 @@ def check_required_library(self):
url='https://code.vmware.com/web/sdk/7.0/vsphere-automation-python'),
exception=VSPHERE_IMP_ERR)

@staticmethod
def vmware_client_argument_spec():
return dict(
hostname=dict(type='str',
fallback=(env_fallback, ['VMWARE_HOST'])),
username=dict(type='str',
fallback=(env_fallback, ['VMWARE_USER']),
aliases=['user', 'admin']),
password=dict(type='str',
fallback=(env_fallback, ['VMWARE_PASSWORD']),
aliases=['pass', 'pwd'],
no_log=True),
port=dict(type='int',
default=443,
fallback=(env_fallback, ['VMWARE_PORT'])),
protocol=dict(type='str',
default='https',
choices=['https', 'http']),
validate_certs=dict(type='bool',
fallback=(env_fallback, ['VMWARE_VALIDATE_CERTS']),
default=True),
proxy_host=dict(type='str',
required=False,
default=None,
fallback=(env_fallback, ['VMWARE_PROXY_HOST'])),
proxy_port=dict(type='int',
required=False,
default=None,
fallback=(env_fallback, ['VMWARE_PROXY_PORT'])),
)

def connect_to_vsphere_client(self):
"""
Connect to vSphere API Client with Username and Password
Expand Down
6 changes: 4 additions & 2 deletions plugins/modules/vmware_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
type: list
elements: str
extends_documentation_fragment:
- community.vmware.vmware_rest_client.documentation
- community.vmware.base_options
- community.vmware.additional_rest_options
'''

Expand Down Expand Up @@ -157,6 +158,7 @@
from ansible.module_utils.compat.version import LooseVersion
from ansible_collections.community.vmware.plugins.module_utils.vmware import connect_to_api
from ansible_collections.community.vmware.plugins.module_utils.vmware_rest_client import VmwareRestClient
from ansible_collections.community.vmware.plugins.module_utils.vmware_argument_spec import rest_compatible_argument_spec

try:
from pyVmomi.VmomiSupport import XMLNS_VMODL_BASE
Expand Down Expand Up @@ -354,7 +356,7 @@ def get_all_categories(self):


def main():
argument_spec = VmwareRestClient.vmware_client_argument_spec()
argument_spec = rest_compatible_argument_spec()
argument_spec.update(
category_name=dict(type='str', required=True),
category_description=dict(type='str', default='', required=False),
Expand Down
6 changes: 4 additions & 2 deletions plugins/modules/vmware_category_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
requirements:
- vSphere Automation SDK
extends_documentation_fragment:
- community.vmware.vmware_rest_client.documentation
- community.vmware.base_options
- community.vmware.additional_rest_options
'''

Expand Down Expand Up @@ -81,6 +82,7 @@

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.vmware.plugins.module_utils.vmware_rest_client import VmwareRestClient
from ansible_collections.community.vmware.plugins.module_utils.vmware_argument_spec import rest_compatible_argument_spec


class VmwareCategoryInfoManager(VmwareRestClient):
Expand Down Expand Up @@ -108,7 +110,7 @@ def get_all_tag_categories(self):


def main():
argument_spec = VmwareRestClient.vmware_client_argument_spec()
argument_spec = rest_compatible_argument_spec()
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)

vmware_category_info = VmwareCategoryInfoManager(module)
Expand Down
7 changes: 5 additions & 2 deletions plugins/modules/vmware_content_deploy_ovf_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
type: str
default: 'thin'
choices: [ thin, thick, eagerZeroedThick, eagerzeroedthick ]
extends_documentation_fragment: community.vmware.vmware_rest_client.documentation
extends_documentation_fragment:
- community.vmware.base_options
- community.vmware.additional_rest_options
'''

EXAMPLES = r'''
Expand Down Expand Up @@ -133,6 +135,7 @@
from ansible.module_utils.basic import AnsibleModule, env_fallback
from ansible.module_utils._text import to_native
from ansible_collections.community.vmware.plugins.module_utils.vmware_rest_client import VmwareRestClient
from ansible_collections.community.vmware.plugins.module_utils.vmware_argument_spec import rest_compatible_argument_spec
from ansible_collections.community.vmware.plugins.module_utils.vmware import PyVmomi

HAS_VAUTOMATION = False
Expand Down Expand Up @@ -337,7 +340,7 @@ def _exit(self):


def main():
argument_spec = VmwareRestClient.vmware_client_argument_spec()
argument_spec = rest_compatible_argument_spec()
argument_spec.update(
log_level=dict(
type='str',
Expand Down
6 changes: 4 additions & 2 deletions plugins/modules/vmware_content_deploy_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
default: 'present'
choices: [ 'present', 'poweredon' ]
extends_documentation_fragment:
- community.vmware.vmware_rest_client.documentation
- community.vmware.base_options
- community.vmware.additional_rest_options
'''

Expand Down Expand Up @@ -155,6 +156,7 @@

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.vmware.plugins.module_utils.vmware_rest_client import VmwareRestClient
from ansible_collections.community.vmware.plugins.module_utils.vmware_argument_spec import rest_compatible_argument_spec
from ansible_collections.community.vmware.plugins.module_utils.vmware import PyVmomi
from ansible.module_utils._text import to_native

Expand Down Expand Up @@ -347,7 +349,7 @@ def _exit(self):


def main():
argument_spec = VmwareRestClient.vmware_client_argument_spec()
argument_spec = rest_compatible_argument_spec()
argument_spec.update(
log_level=dict(
type='str',
Expand Down
6 changes: 4 additions & 2 deletions plugins/modules/vmware_content_library_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
type: str
required: false
extends_documentation_fragment:
- community.vmware.vmware_rest_client.documentation
- community.vmware.base_options
- community.vmware.additional_rest_options
'''

Expand Down Expand Up @@ -85,6 +86,7 @@

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.vmware.plugins.module_utils.vmware_rest_client import VmwareRestClient
from ansible_collections.community.vmware.plugins.module_utils.vmware_argument_spec import rest_compatible_argument_spec


class VmwareContentLibInfo(VmwareRestClient):
Expand Down Expand Up @@ -149,7 +151,7 @@ def get_content_lib_details(self, library_id):


def main():
argument_spec = VmwareRestClient.vmware_client_argument_spec()
argument_spec = rest_compatible_argument_spec()
argument_spec.update(
library_id=dict(type='str', required=False),
)
Expand Down
6 changes: 4 additions & 2 deletions plugins/modules/vmware_content_library_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
default: 'present'
choices: [ 'present', 'absent' ]
extends_documentation_fragment:
- community.vmware.vmware_rest_client.documentation
- community.vmware.base_options
- community.vmware.additional_rest_options
'''
EXAMPLES = r'''
Expand Down Expand Up @@ -159,6 +160,7 @@
import uuid
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.vmware.plugins.module_utils.vmware_rest_client import VmwareRestClient
from ansible_collections.community.vmware.plugins.module_utils.vmware_argument_spec import rest_compatible_argument_spec
from ansible_collections.community.vmware.plugins.module_utils.vmware import PyVmomi

HAS_VAUTOMATION_PYTHON_SDK = False
Expand Down Expand Up @@ -410,7 +412,7 @@ def state_destroy_library(self):


def main():
argument_spec = VmwareRestClient.vmware_client_argument_spec()
argument_spec = rest_compatible_argument_spec()
argument_spec.update(
library_name=dict(type='str', required=True),
library_description=dict(type='str', required=False),
Expand Down
Loading

0 comments on commit 7df66e5

Please sign in to comment.