List all Network domains using Morpheus API

We are trying to create dropdown to list all the network domain under the Infrastructure/Networks/Domains. We have got 4 domains including localdomain. We are able to list one domain but cannot list all the domains.

API Method
image

Translation Script:

for (var x = 0; x < data.length; x++) {  
  if(data[x].networkDomain['name'])
    results.push({name:data[x].networkDomain['name'], value:data[x].networkDomain['id']});
}

Request Script:

results.zoneId = input.cloud
results.siteId = input.group

But this is displaying only one domain instead of 3 domain, so we are not sure if this is right approach. Please advise.

Hi Suresh,
If you’re looking to list all the network domains under Infrastructure/Networks/Domains, then the recommended approach is to utilize the REST option by using the API endpoint /api/networks/domains?max=-1. You can find more details about this endpoint in the API documentation here:
Get all Network Domains with the translation script as below

for(var x=0;x < data.networkDomains.length; x++) {
 var domain = data.networkDomains[x].active
 if (domain==true){ //Only show active domains
  results.push({name: data.networkDomains[x].name,value:data.networkDomains[x].id});
  }
 }

The Morpheus API option list for networks will return the network domains attached to the networks. It seems that in your environment, a network domain has been attached to one network, which is why you’re seeing only one network domain from the Morpheus API option list.

Thanks
Velan

3 Likes

Thank you, this one worked. But this is not getting added to the hostname. How can we bind this domain to the server during provision via catalog. Any example or suggestions plz.

Do you mean its not being added to the domain?

If so you need to make sure to provide the domain ID in the “networkDomain” section of the catalog. (As well as make sure the Domain in Morpheus is configured correctly)
image

Or do you mean the hostname in Morpheus is not getting updated?
Remember the hostname of a VM and the display name is deferent. To see the hostname (not the instance or server display name) you would need to click into the server and look at “Hostname” in the “info” section.

1 Like

Hi Suresh,
If the VM is not domain-joined, it’s likely because the domain controller hasn’t been properly configured in the domain settings. Here’s a helpful documentation link that guides you through the process of configuring the domain controller in your domains:

https://docs.morpheusdata.com/en/latest/infrastructure/networks/domains.html#adding-domains

Thanks
Velan

1 Like