-
Notifications
You must be signed in to change notification settings - Fork 141
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
Rest API - Put/Patch/Post Logic Causes Failures #422
Comments
Hello I confirm the bug. I've change ansible-for-nsxt/plugins/modules/nsxt_rest.py Lines 214 to 224 in 9245e16
into def execute(self):
if self.method == "get" or self.method == "post":
resp = self.operate_nsxt(method=self.method)
self.module.exit_json(changed=False, body=resp)
if self.method == "put" or self.method == "patch":
before_resp = self.operate_nsxt(method="get", ignore_errors=True)
if before_resp:
before_revision = before_resp["_revision"]
else:
before_revision = "" |
@steve-sander-chtr |
I’ll did download a newer version recently – I just pushed in with the native Ansible API module.
I’ll be able to confirm next week when my lab is available again.
Steve
From: Samuel MESGUICH ***@***.***>
Reply-To: vmware/ansible-for-nsxt ***@***.***>
Date: Wednesday, November 23, 2022 at 9:15 AM
To: vmware/ansible-for-nsxt ***@***.***>
Cc: "Sander, Steve A" ***@***.***>, Mention ***@***.***>
Subject: [EXTERNAL] Re: [vmware/ansible-for-nsxt] Rest API - Put/Patch/Post Logic Causes Failures (Issue #422)
CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.
@steve-sander-chtr<https://github.com/steve-sander-chtr>
Are you running NSX-T under 3.2 ? We are affected by this bug in 3.1.2.
The _revision setting is available in 3.2 on affected request.
—
Reply to this email directly, view it on GitHub<#422 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AYJJRTS5BL4YECD77ENQTUTWJY7KTANCNFSM5RCCXX3A>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
On my side, I confirm that this bug is not present in NSX-T 3.2. So on my side, VMware should not announced that the ansible collection tagged NSX-T 3.2 IS NOT fully compatible back in 3.1 |
Correction : Issue PERSIST in NSX-T 3.2. Workaround mentioned in #422 (comment) still work |
@steve-sander-chtr : can you confirm that this code correct you issues ? |
Describe the bug
Lines in code 219 - 234 it looks like the module is attempting to determine the current version prior to issuing the requested put/post/patch operation by sending a GET to the target URL (with payload). Since not every URL supports GET ( or errors on the payload), the requested action of put/post/patch is not completed. Maybe use try logic here - so if the GET fails, then the requested action is still performed ?
Reproduction steps
Expected behavior
Both API calls should succeed:
PLAY [127.0.0.1] ***********************************************************************************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************************************************************************
ok: [127.0.0.1]
TASK [Create Cluster IP] ***************************************************************************************************************************************************************
ok: [127.0.0.1]
TASK [Cluster IP Rest] *****************************************************************************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "error_code: 405, error_message: Method is not allowed."}
PLAY RECAP *****************************************************************************************************************************************************************************
127.0.0.1 : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
The 405 error is on the preceding GET ( method not allowed ). And the post is never issued.
Additional context
Other URL which failed with REST API:
POST - /policy/api/v1/aaa/role-bindings
PUT - /api/v1/node/services/snmp ( GET with payload not supported )
POST - /api/v1/node/services/syslog/exporters
The text was updated successfully, but these errors were encountered: