nacx commented on this pull request.


>           checkArgument(!iterator.hasNext(),
                "Error: Please specify only one network/subnetwork in 
TemplateOptions when using GCE.");
       }
 
       String region = ZONE == location.getScope() ? 
location.getParent().getId() : location.getId();
-      Optional<Subnetwork> subnet = 
subnetworksMap.getUnchecked(fromRegionAndName(region, networkName));
+      Optional<Subnetwork> subnet;
+
+      subnet = isFullURI ? 
Optional.fromNullable(resources.subnetwork(URI.create(net))) : 
subnetworksMap.getUnchecked(fromRegionAndName(region, networkName));

Ok. The main issue here is that the cache key is `RegionAndName`. What about 
creating a different class to be used with these loaders that can cache shared 
resources, say `RegionAndNameInProject`? In the case of shared resources we can 
build it from the full URI, and for others we can just get injected the current 
project (we already have the project bound to the Guice contecxt as 
`@Named(PROJECT_NAME) String currentProject`) and build it too. This way we can 
still have backwards compatibility and properly cache all subnets whether they 
are shared or not, saving unnecessary repeated API calls. WDYT?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1236#discussion_r214312128

Reply via email to