API "/api/compute_resources/:compute_resource_id/available_clusters/:cluster_id/available_networks returning error

Problem: I am trying to get available networks of particular compute resource with API "API “/api/compute_resources/1/available_clusters/domain-s7/available_networks” in Foreman v2.1 but it is throwing error “Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug. There may be more information in the server’s log”. I had checked log and it is showing "Backtrace for ‘Action failed’ error (NoMethodError): undefined method network for nil:NilClass"

Expected outcome: List of available networks should be returned

Foreman and Proxy versions: 2.1 & 2.1.0-rc3

Foreman and Proxy plugin versions: 2.1 & 2.1.0-rc3

Distribution and version: CentOS v7.x86_64 & v2.1

@shiramax, @yifatmakias you might want to take a look at this.

The compute resource in this case is VMware provider.

can you please share the full stack trace from /var/log/production.log?

From what I checked so far it looks like this issue happens only in VMware compute resource. I will continue checking this.


foreman-log.log (9.0 KB)

Yes, I agree it is happening for VMware compute resource.

For VMware, you need to provide the cluster name, not id for those calls.

See also Bug #31874: API uses cluster_id inconsistently - Foreman


Thankyou, Your suggestion works for me.


@yifatmakias @shiramax is there a way we could make the API accept both? Like it does for oVirt?

Not easily unfortunately, vmware itself don’t understand the concept of ID much and it boils down to this method:

We probably could get all clusters and just .detect the one with appropriate ID, but we I’d rather if we move away from using IDs in vmware and just use paths as ids. But I’m really unsure what vmware prefers, that is just my guess from their api documentation and its ruby bindings.

But for other things (networks, datastores) it does want the ID when I deploy a VM. :confused:

What’s a path? Is that when clusters are nested? How does it look like?

you can nest all the objects in vmware into folders, so it coul look like RootFolderName/nestedfoler_name/cluster_name

We’ve done some nasty stuff for networks, but that’s broken for a lot of corner cases. I don’t think datastore takes ID though.