> +        if (image != null) {
> +            logger.trace(">> found image [%s].", image.properties().name());
> +            return image;
> +        }
> +        // try search snapshots
> +        logger.trace("<< not found from images. searching for snapshot with 
> id=%s", id);
> +        Snapshot snapshot = api.snapshotApi().get(id);
> +        if (snapshot != null) {
> +            logger.trace(">> found snapshot [%s]", 
> snapshot.properties().name());
> +            return snapshot;
> +        }
> +        throw new ResourceNotFoundException("No image/snapshot with id '" + 
> id + "' was found");
> +    }
> +
> +    @Override
> +    public Iterable<DataCenter> listLocations() {

Sure. Have a look at 
https://github.com/jclouds/jclouds/commit/7202e0557f620c272feaca3e9a49b6e45a77a791
 . That commit configures the compute service to get the locations from the 
properties defined in the provider metadata. The important bits there are:

* The jclouds location properties configured in the provider metadata.
* The type for the locations in the generics of the adapter changes from 
DataCenter to the jclouds Location.
* The `LocationsFromComputeServiceAdapterModule` must be removed from the 
compute module. This will make the default jclouds location suppliers active 
and return the locations from the configured properties. You no longer need the 
listLocations method, so you can safely make it throw an exception.
* Since ProfitBricks needs a Datacenter, that commit declares a custom 
`CreateNodesInGroupThenAddToSet` strategy to take care of creating the 
datacenter if none exists in the selected location *before* creating any node. 
You can have a look at the binding and copy most of the code in that strategy 
(if not all).
* To let the datacenter be created *before* the adapter is called, that commit 
introduces an internal class that adds the created DataCenter to the jclouds 
Template, so it can be directly passed to the adapter, removing the need to 
perform additional calls.

Feel free to ask if you have any doubts or need some more guidance!

-- 
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-labs/pull/292/files/9251ab7434bcafb1dcbec5a718acc3c24517c94d#r76685558

Reply via email to