Fetch the Cluster Info from PE | Nutanix Community
Skip to main content

Hi Team,

I am trying to export cluster info with the below code which I got from the internet (do not remember where I got this). but the below script runs fine and able to export the data required except for Cluster name and its IP address.

As per my understanding it is able to export only the content of “NTNXHost” but not the content of “NTNXClusterInfo” and “NTNXVM”

$report = @()
$NTNXHost = Get-NTNXHost | Select-Object name,hypervisorAddress,clusterUuid,serviceVMId,serviceVMExternalIP,ipmiAddress,serial,blockSerial,blockModel,blockModelName,cpuModel,numCpuCores,numCpuThreads,numCpuSockets,cpuFrequencyInHz,cpuCapacityInHz,memoryCapacityInBytes,hypervisorFullName,hypervisorType
$report+=$NTNXHost
$NTNXClusterInfo = Get-NTNXClusterInfo | Select-Object name,clusterExternalIPAddress
$report+=$NTNXClusterInfo
$report += "`r`n"
$NTNXVM  = Get-NTNXVM -SearchString "VM is a Nutanix CVM" | ft vmname,ipAddresses
$report+=$NTNXVM
$report | Export-Csv -Path C:\temp\ClusterInfo.csv -NoTypeInformation -UseCulture

 

Hence request you to fix this so that I can export the data along with the Cluster Name & Cluster IP?

 

Note: Before running the above script I am using the below commands to connect to the cluster.

 

$credentials = Get-Credential -Message "**Enter your Nutanix Admin credentials here**"
$username = $credentials.username
$password = ConvertTo-SecureString $($credentials.GetNetworkCredential().password) -AsPlainText -Force

Connect-NTNXCluster -Server ClusterFQDN -UserName admin -AcceptInvalidSSLCerts -ForcedConnection

Hi Nim,

Thank you for the response. I will check and get back to you on this.


Hey @Nagarjunb, it seems something is broken on dev.nutanix site. But your API call should be correct. We will look into this.

 

If you have a Linux machine, you can curl the same information.

In the section where you put in the parameter details, if you click on ‘Code Generation’, you can see the request sent out. Just copy it out and run it from any Linux or even a CVM.


So the request would look like this - 
 

curl -k --request GET --url https://<PE_IP_ADDRESS>:9440/api/nutanix/v2.0/cluster --header 'authorization: Basic xyz'

 

Notice I added a ‘-k’ in the curl request to create an insecure connection. I would not recommend in production clusters.


Can anyone suggest me how to add the Cluster name and IP to the above code?


Hi Tapati,

 

It seems like something which I am missing here or its broken. I am getting an error as “Error sending request Get : unsupported protocol scheme "

 

I am new to this API environment. 

 

I also tried inputting my PE details in the host, username & password, it still doesn’t work. Anymore changes do I need to do before proceeding to the request? 

 

“Error sending request Get https://PEName.net/api/nutanix/v2.0/cluster: dial tcp: lookup PEname.net on 127.0.0.11:53: no such host”


Hi Tapati,

Thank you for the quick response and sharing the link. I will check and get back to you on this.


Hello @Nagarjunb 

You can have a look into these below links which have got some good content that might help you.

https://developer.nutanix.com/ 

 https://www.nutanix.dev/reference/prism_element/v2/api/clusters/get-clusters-id-getcluster/ 

 Please let me know how it goes. 

Thanks