VMware Cloud Community
00rellana
Contributor
Contributor
Jump to solution

Anyone knows how I can authenticate to vRNI using curl command?

Greetings,

I am trying to automate some vRNi tasks like monitoring state of services.

Something similar to:  show-service-status from  CLI

But I am trying to do this using the REST API, something like : /api/ni/entieis/services

I am first trying to authenticate using a curl command:

url -d 'username=user_name@local&password=Secret_pwd&domain={domain_type=local}&submit=Login' --dump-header headershttps://$vrni_ip/api/ni/auth-token

Any tips and direction will be greatly appreciated  :- )

OaO

0 Kudos
1 Solution

Accepted Solutions
smitmartijn
VMware Employee
VMware Employee
Jump to solution

Hi,

Have a look at the public API Documentation that's built into the platform. It provides you with an overview and examples of all available API calls, including authentication:

Home_-_VMware_vRealize_Network_Insight__ni-platform_lab_lostdomain_local_and_Inbox_and_iMac_and_Screenshots.png

You'll see that you're using the wrong endpoint, as it's /api/ni/auth/token instead of auth-token, plus that you should provide the credentials in the body, not parameters.

Also, if you're into PowerShell, I'd encourage you to look into PowervRNI (link below), it has a lot of cmdlets already using the API, so you don't have to bother.

GitHub - PowervRNI/powervrni: PowervRNI: A PowerShell module to talk to the vRealize Network Insight...

Last also, be aware that the /api/ni/entities/services does not what you what it to do. It lists the tcp/udp/etc services that are in vRNI used for microsegmentation planning, it's not the status of the services within vRNI. There's currently no API call to get the status of the vRNI services.

View solution in original post

0 Kudos
3 Replies
smitmartijn
VMware Employee
VMware Employee
Jump to solution

Hi,

Have a look at the public API Documentation that's built into the platform. It provides you with an overview and examples of all available API calls, including authentication:

Home_-_VMware_vRealize_Network_Insight__ni-platform_lab_lostdomain_local_and_Inbox_and_iMac_and_Screenshots.png

You'll see that you're using the wrong endpoint, as it's /api/ni/auth/token instead of auth-token, plus that you should provide the credentials in the body, not parameters.

Also, if you're into PowerShell, I'd encourage you to look into PowervRNI (link below), it has a lot of cmdlets already using the API, so you don't have to bother.

GitHub - PowervRNI/powervrni: PowervRNI: A PowerShell module to talk to the vRealize Network Insight...

Last also, be aware that the /api/ni/entities/services does not what you what it to do. It lists the tcp/udp/etc services that are in vRNI used for microsegmentation planning, it's not the status of the services within vRNI. There's currently no API call to get the status of the vRNI services.

0 Kudos
00rellana
Contributor
Contributor
Jump to solution

Thank you @smitmartijn for pointing me in the right direction. I will take a close look at the API documentation and PowervRNI.  I will explore using ssh to query service status.

Regards,  Oscar.

0 Kudos
carvaled
Enthusiast
Enthusiast
Jump to solution

i built something to monitor this via SSH and send an email if the services are "not running"

Check out https://vman.ch/monitoring-vrni-services-using-a-powershell-script-and-posh-ssh/

0 Kudos