brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [1/2] git commit: Deploy app using URL to a blueprint
Date Tue, 03 Jun 2014 12:15:13 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 17ee8c779 -> 9a468e202


Deploy app using URL to a blueprint

Changes the behaviour of the "Create App" YAML tab to allow the user to
present a URL that contains the actual blueprint. The URL is fetched and
the content is used as a YAML blueprint.

Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/059943ae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/059943ae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/059943ae

Branch: refs/heads/master
Commit: 059943aeb1ffb0461440ef73dc8a9fd75c1a61d6
Parents: cc08309
Author: Richard Downer <richard.downer@cloudsoftcorp.com>
Authored: Sat May 31 16:20:09 2014 +0100
Committer: Richard Downer <richard.downer@cloudsoftcorp.com>
Committed: Tue Jun 3 00:07:05 2014 +0200

----------------------------------------------------------------------
 .../rest/resources/ApplicationResource.java       | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/059943ae/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
b/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
index b270773..d93b38a 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
@@ -4,14 +4,18 @@ import static com.google.common.base.Preconditions.checkNotNull;
 import static javax.ws.rs.core.Response.created;
 import static javax.ws.rs.core.Response.status;
 import static javax.ws.rs.core.Response.Status.ACCEPTED;
+
+import brooklyn.util.ResourceUtils;
 import io.brooklyn.camp.brooklyn.spi.creation.BrooklynAssemblyTemplateInstantiator;
 import io.brooklyn.camp.spi.Assembly;
 import io.brooklyn.camp.spi.AssemblyTemplate;
 import io.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
 
+import java.io.IOException;
 import java.io.Reader;
 import java.io.StringReader;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
@@ -213,6 +217,20 @@ public class ApplicationResource extends AbstractBrooklynRestResource
implements
   
   @Override
   public Response createFromYaml(String yaml) {
+      // First of all, see if it's a URL
+      URI uri;
+      try {
+          uri = new URI(yaml);
+      } catch (URISyntaxException e) {
+          // It's not a URI then...
+          uri = null;
+      }
+      if (uri != null) {
+          log.debug("Input to createFromYaml might be a URL: " + uri);
+          yaml = ResourceUtils.create(mgmt()).getResourceAsString(uri.toString());
+          log.debug("Continuing using the contents of the URL: {}", yaml);
+      }
+
       log.debug("Creating app from yaml");
       Reader input = new StringReader(yaml);
       AssemblyTemplate at = camp().pdp().registerDeploymentPlan(input);


Mime
View raw message