#name Set preferred DC for AD domain
1 messages · Page 1 of 1 (latest)
This is not a command but an API. We have two different modules:
- na_ontap_rest_cli, which expects a command with a bit of translation. In the previous example PATCH with vserver/services/name-service/ns-switch stands for vserver services name-service ns-switch modify
- na_ontap_restit which allows to call a REST API directly.
I would actually recommend to use restit over rest_cli if a dedicated API exists. And to use a specialized module over restit if one exists 🙂
With 'protocols/cifs/domains/{{ svm_uuid }}/preferred-domain-controllers' you would need to use na_ontap_restit.
Initially the command was :
command: ['vserver', 'cifs', 'domain', 'preferred-dc', 'add', '-vserver', 'vs_{{ target }}', '-domain', '{{ nas_ad_domain }}', '-preferred-dc', "{{ nas_infra_servers[site].dc | join(',') }}"]
with na_ontap_command
So i tried to convert to rest_cli
I did the same for all vserver commands
This one is only one remaining
But this seems a different use case.
Yesterday, I used :
- name: run ontap REST API command
netapp.ontap.na_ontap_rest_cli:
command: 'vserver/services/name-service/ns-switch'
verb: 'PATCH'
params: {'vserver': 'ansibleSVM', 'database': 'namemap'}
body: {'sources': ['files']}
This would be something like vserver/cifs/domain or vserver/cifs/domain/preferred_dc
for a vserver command also
Yes, I tried vserver/cifs/domain/preferred_dc and many others
But I get :
TASK [ds-role-nas_CRUD : Set preferred DC for AD domain] ************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error: {'message': 'API not found', 'code': '3'}"}
Isn't there a missing API for netapp.ontap.na_ontap_rest_cli module
?
I tried with :
command: 'vserver/cifs/domain/preferred-dc'
#command: 'vserver/cifs/domain/preferred-domain-controllers'
#command: "protocols/cifs/domains"
#command: "vserver/cifs/domain"
based on swagger API
No, they will translate it to the CLI command. So if the CLI command exists, it should be possible to translate it into private/cli.
If you have the exact CLI command, the folks on #┊・ontap-api should be able to help.
The initial command was :
['vserver', 'cifs', 'domain', 'preferred-dc', 'add', '-vserver', 'vs_{{ target }}', '-domain', '{{ nas_ad_domain }}', '-preferred-dc', "{{ nas_infra_servers[site].dc | join(',') }}"]
One thing is that the swagger API does not provide the command to use with rest_cli
So we have somehow to guess the REST CLI command based on the native CLI command
Because each command is different. They give a few rules. And then it's trial and error.
I see.
Is the REST CLI an interim module used to migrate to a full API with restit and rest_info
?
From what I understand, the module may use either REST or CLI.
Not interim, but it is a stop gap or last resort solution when a REST API does not exist for a feature. This is why I was saying restit should be preferred. But there is some effort to map a command to a REST API too.
No. The na_ontasp_rest_cli module is using api/private/cli to call the CLI. But api/private/cli expects the command to match REST semantics. And the output is returned in JSON format.
This is why, in order of abstraction:
- use our specialized modules
- if a feature is missing in a module, use na_ontap_restit to call the specialized API. (And tell us)
- if a feature is not implemented in REST, use na_ontap_rest_cli.
Ok
For na_ontap_rest_info, if anything is missing, do let us know. It's pretty easy to add any missing show command.