@@ -380,6 +380,23 @@ private String getOsAccordingToCloudProvider(CloudProviderType cloudProviderType
380380 }
381381 }
382382
383+ private boolean filterOsWithVersionAccordingToCloudProvider (CloudProviderType cloudProviderType ,
384+ JSONObject osAsJson ) throws IllegalArgumentException {
385+ switch (cloudProviderType ) {
386+ case AWS_EC2 :
387+ return true ;
388+ case OPENSTACK :
389+ return true ;
390+ case AZURE :
391+ return true ;
392+ case GCE :
393+ return osAsJson .get ("family" ).toString ().toLowerCase ().equals ("ubuntu" ) &&
394+ osAsJson .get ("version" ).toString ().startsWith ("22" );
395+ default :
396+ throw new IllegalArgumentException ("The infrastructure " + cloudProviderType + " is not handled yet." );
397+ }
398+ }
399+
383400 public void saveNodeCandidates (List <String > newCloudIds ) {
384401 newCloudIds .forEach (newCloudId -> {
385402 PACloud paCloud = repositoryService .getPACloud (newCloudId );
@@ -398,10 +415,12 @@ public void saveNodeCandidates(List<String> newCloudIds) {
398415 Map <Pair <String , String >, List <JSONObject >> consolidatedImagesGrouped = images .toList ()
399416 .parallelStream ()
400417 .map (NodeCandidateUtils ::convertObjectToJson )
401- .filter (record -> record .get ("location" )
402- .toString ()
403- .isEmpty () ||
404- !blacklistedRegions .contains (record .get ("location" )))
418+ .filter (image -> (image .get ("location" )
419+ .toString ()
420+ .isEmpty () ||
421+ !blacklistedRegions .contains (image .get ("location" ))) &&
422+ filterOsWithVersionAccordingToCloudProvider (paCloud .getCloudProvider (),
423+ (JSONObject ) image .get ("operatingSystem" )))
405424 .collect (Collectors .groupingBy (image -> {
406425 // Retrieve the region
407426 String region = image .optString ("location" );
0 commit comments