HPE Morpheus Enterprise Software
1856696 Members
46716 Online
104114 Solutions
New Discussion

Filter down networks available based upon cloud/group

 
Not applicable

Filter down networks available based upon cloud/group

Hi,

I’m currently testing deploying to two VMware clouds.

I’m using the networks REST option list do pull down the available networks using this translation script:

if (input.selectedCloud && input.selectedGroup) {
for(x in data.networks){
if (data.networks.dhcpServer == (true))
{
results.push({name:data.networks.name, value:data.networks.id});
}}}

Which works for displaying dhcp subnets, however it’s showing all entries. Rather only showing entries for the selected cloud.

For the input to this network optionlist I have added the dependant field as selectedCloud which is the fieldname for the cloud, but has not helped.

Any ideas what I need to tweak to only pull down the the networks for the cloud selected?

Cheers
Jon

6 REPLIES 6
Not applicable

Re: Filter down networks available based upon cloud/group

Hopefully I understand you, I have changed to:

for(x in data.networks){
if (data.networks.dhcpServer == (true))
{
results.push({name:data.networks.name, value:data.networks.id});
}}

But it still lists everything

Ollie-Phillips
HPE Pro

Re: Filter down networks available based upon cloud/group

Try this, I’ve mocked it up based on the apidocs network response:

Edit: I note, there’s only 1 network in the data set but you can change input.selectedCloud on line 102 to validate that it is picked up only if there is a id match.



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Ollie-Phillips
HPE Pro

Re: Filter down networks available based upon cloud/group

Yes, that was an artifact of the test code. Glad you are sorted :+1:



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Ollie-Phillips
HPE Pro

Re: Filter down networks available based upon cloud/group

Adding the code from that demo here too. Just in case of links policies

let results = [];
for (let x=0; x< data.networks.length; x++){
	if (data.networks[x].zone.id == input.selectedCloud){
			results.push({name: data.networks[x].name, value:data.networks[x].id})
	}
}


I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Not applicable

Re: Filter down networks available based upon cloud/group

Thanks Ollie,

I had to get rid of
let results = ;
As it complains there were too many results, but this works and the networks are filtered

Ollie-Phillips
HPE Pro

Re: Filter down networks available based upon cloud/group

I think you need an additional conditional test. In the for loop you don’t check that input.selectedCloud (id) equals the networks cloud id before pushing to the results, which is why you’re getting everything. If you apply that test, it will provide the filtering



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo