[
https://issues.apache.org/jira/browse/JCLOUDS-1108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15769936#comment-15769936
]
ASF GitHub Bot commented on JCLOUDS-1108:
-----------------------------------------
Github user duncangrant commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/501#discussion_r93614592
--- Diff:
locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
---
@@ -1484,6 +1493,48 @@ public Template buildTemplate(ComputeService
computeService, ConfigBag config, C
return template;
}
+
+ /**
+ * See {@link https://issues.apache.org/jira/browse/JCLOUDS-1108}.
+ *
+ * In jclouds 1.9.x and 2.0.0, google-compute-engine hardwareId must
be in the long form. For
+ * example {@code
https://www.googleapis.com/compute/v1/projects/jclouds-gce/zones/us-central1-a/machineTypes/n1-standard-1}.
+ * It is much nicer to support the short-form (e.g. {@code
n1-standard-1}), and to construct
+ * the long-form from this.
+ *
+ * The "zone" in the long-form needs to match the region (see {@link
#getRegion()}).
+ *
+ * The ideal would be for jclouds to do this. But that isn't available
yet - in the mean time,
+ * we can make life easier for our users with the code below.
+ *
+ * Second best would have been handling this in {@link
TemplateBuilderCustomizers#hardwareId()}.
+ * However, that code doesn't have enough context to know what to do
(easily!). It is passed
+ * {@code apply(TemplateBuilder tb, ConfigBag props, Object v)}, so
doesn't even know which
+ * provider it is being called for (without doing ugly/brittle digging
in the {@code props}
+ * that it is given).
+ *
+ * Therefore we do the transform here.
+ */
+ private String transformHardwareId(String hardwareId, ConfigBag
config) {
+ String provider = getProvider();
+ String region = getRegion();
+ if (Strings.isBlank(region)) region = config.get(CLOUD_REGION_ID);
+
+ if (!"google-compute-engine".equals(provider)) {
+ return hardwareId;
+ }
+ if (hardwareId == null ||
hardwareId.toLowerCase().startsWith("http") || hardwareId.contains("/")) {
--- End diff --
Should null check be separate? It presumably doesn't represent a long-form
id but rather a misuse of the function.
> GCE support for shorten hardwareId
> ----------------------------------
>
> Key: JCLOUDS-1108
> URL: https://issues.apache.org/jira/browse/JCLOUDS-1108
> Project: jclouds
> Issue Type: Improvement
> Reporter: Andrea Turli
> Assignee: Andrea Turli
>
> I'd like to slightly change the MachineTypeToHardware to support hadwareId
> like `f1-micro` instead of the entire URI.
> I've also noticed that location should not be mapped in the HardwareBuilder
> as it is needed only when a the hardware is available only on a particular
> location.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)