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

Add API 7.0.3 spec #443

Closed
wants to merge 1 commit into from

Conversation

mariolenz
Copy link
Collaborator

python -m venv --clear ~/get-7.0.3-api-venv
source ~/get-7.0.3-api-venv/bin/activate
pip install pyVmomi
pip install -U https://github.com/vmware/vsphere-automation-sdk-python/archive/refs/tags/v8.0.1.0.tar.gz
python vmsgen.py -vc <vCenter IP> -o <output directory path> --oas 2
deactivate
rm -rf ~/get-7.0.3-api-venv

Copy link

codecov bot commented Nov 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (79e8a98) 35.67% compared to head (4bbbd35) 35.67%.
Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #443   +/-   ##
=======================================
  Coverage   35.67%   35.67%           
=======================================
  Files         143      143           
  Lines       11305    11305           
  Branches     2291     2291           
=======================================
  Hits         4033     4033           
- Misses       7197     7272   +75     
+ Partials       75        0   -75     
Flag Coverage Δ
sanity 35.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mariolenz
Copy link
Collaborator Author

mariolenz commented Nov 19, 2023

I wanted to generated the modules with the new spec like this:

pip install black==22.3.0 jsonschema jinja2==3.0.3 boto3 baron redbaron ruamel.yaml autoflake
ansible-galaxy collection install git+https://github.com/ansible-community/ansible.content_builder.git
git clone https://github.com/mariolenz/vmware.vmware_rest.git
cd vmware.vmware_rest
git checkout add_7.0.3_spec
cd -
mkdir -p /collections/ansible_collections/vmware/vmware_rest/tests
cp -r vmware.vmware_rest/tests/sanity /collections/ansible_collections/vmware/vmware_rest/tests
ansible-playbook build.yaml -e manifest_file=MANIFEST.yaml
cd vmware.vmware_rest/
git checkout -b 20231119-generate_7.0.3_modules
rm -rf plugins/modules/
cp -r /collections/ansible_collections/vmware/vmware_rest/plugins/modules/ plugins/
echo -e '---\nminor_changes:\n- "Generate 7.0.3 / vSphere 7.0 U3 modules."' > changelogs/fragments/regenerate_modules.yaml
git add --all
git commit -m "[DNM] Generate 7.0.3 / vSphere 7.0 U3 modules"
git push --set-upstream origin 20231119-generate_7.0.3_modules

build.yaml:

---
- hosts: localhost
  gather_facts: yes
  roles:
    - ansible.content_builder.run

MANIFEST.yaml:

---
collection:
  path: /collections/ansible_collections/vmware/vmware_rest
  namespace: vmware
  name: vmware_rest
plugins:
  - type: module_openapi
    name: "vmware_rest"
    content: cloud
    api_object_path: vmware.vmware_rest/config/api_specifications/7.0.3
    resource: vmware.vmware_rest/config
    action: generate_all
    unique_key: ""
    rm_swagger_json: ""
    module_version: "1.0.0"
    author: "Ansible Cloud Team"

But I ran into this problem:

No mapping for appliance.monitoring
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'appliance.monitoring'
fatal: [localhost]: FAILED! => {"msg": "Unexpected failure during module execution: 'appliance.monitoring'", "stdout": ""}

With -vvv ansible-playbook build.yaml -e manifest_file=MANIFEST.yaml says:

No mapping for appliance.monitoring
The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/ansible/executor/task_executor.py", line 165, in run
    res = self._execute()
  File "/usr/lib/python3.10/site-packages/ansible/executor/task_executor.py", line 660, in _execute
    result = self._handler.run(task_vars=vars_copy)
  File "/root/.ansible/collections/ansible_collections/ansible/content_builder/plugins/action/generate_cloud_modules.py", line 1358, in run
    eval(func)
  File "<string>", line 1, in <module>
  File "/root/.ansible/collections/ansible_collections/ansible/content_builder/plugins/action/generate_cloud_modules.py", line 1290, in generate_vmware_rest
    module.renderer(
  File "/root/.ansible/collections/ansible_collections/ansible/content_builder/plugins/action/generate_cloud_modules.py", line 943, in renderer
    gen_documentation(
  File "/root/.ansible/collections/ansible_collections/ansible/content_builder/plugins/action/generate_cloud_modules.py", line 316, in gen_documentation
    option["description"] = list(Description.normalize(description))
  File "/root/.ansible/collections/ansible_collections/ansible/content_builder/plugins/action/generate_cloud_modules.py", line 84, in normalize
    with_no_line_break = [cls.write_M(i) for i in with_no_line_break]
  File "/root/.ansible/collections/ansible_collections/ansible/content_builder/plugins/action/generate_cloud_modules.py", line 84, in <listcomp>
    with_no_line_break = [cls.write_M(i) for i in with_no_line_break]
  File "/root/.ansible/collections/ansible_collections/ansible/content_builder/plugins/action/generate_cloud_modules.py", line 180, in write_M
    module_name = mapping[resource_name]
KeyError: 'appliance.monitoring'
fatal: [localhost]: FAILED! => {
    "msg": "Unexpected failure during module execution: 'appliance.monitoring'",
    "stdout": ""
}

@mariolenz mariolenz closed this Nov 19, 2023
@mariolenz
Copy link
Collaborator Author

@alinabuzachis @GomathiselviS @jillr This collection is still based on the vSphere 7.0U2 (7.0.2) API. But vSphere 7.0U3, 8.0, 8.0U1 and 8.0U2 have been released meanwhile.

I think we should update this collection to a newer vSphere release, preferably to 7.0U3 as a first step. But I'm not sure how to get the API spec.

How did you get the spec for vSphere 7.0U2 / 7.0.2? Does what I did here looks correct to you?

@mariolenz
Copy link
Collaborator Author

No mapping for appliance.monitoring
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'appliance.monitoring'
fatal: [localhost]: FAILED! => {"msg": "Unexpected failure during module execution: 'appliance.monitoring'", "stdout": ""}

Using vmsgen.py with --deprecate-slash-rest might fix this.

@mariolenz mariolenz mentioned this pull request Nov 20, 2023
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Nov 22, 2023
Add 7.0 U3 API spec

Same as #443, but this time I've used the --deprecate-slash-rest and --fetch-authentication-metadata flags to generate the specs:
python vmsgen.py -vc <vCenter IP> -o <output directory path> --oas 2 --deprecate-slash-rest --fetch-authentication-metadata

Reviewed-by: Alina Buzachis
@mariolenz mariolenz deleted the add_7.0.3_spec branch November 22, 2023 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant