http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/WindowsInstanceStarter.java ---------------------------------------------------------------------- diff --git a/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/WindowsInstanceStarter.java b/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/WindowsInstanceStarter.java deleted file mode 100644 index a641348..0000000 --- a/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/WindowsInstanceStarter.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.examples.ec2.windows; - -import com.google.common.base.Predicate; -import com.google.common.base.Strings; -import com.google.common.collect.Iterables; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.RunNodesException; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.Template; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.compute.domain.PasswordDataAndPrivateKey; -import org.jclouds.ec2.compute.functions.WindowsLoginCredentialsFromEncryptedData; -import org.jclouds.ec2.domain.PasswordData; -import org.jclouds.logging.Logger; -import org.jclouds.predicates.RetryablePredicate; - -import javax.annotation.Nullable; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -/** - * FIXME - */ -public class WindowsInstanceStarter { - private final Arguments arguments; - private final Logger logger; - private final ComputeServiceContext context; - private final AWSEC2Client ec2Client; - private final ComputeService computeService; - - public WindowsInstanceStarter(Arguments arguments, ComputeServiceContext context) { - this.arguments = arguments; - this.context = context; - - logger = context.getUtils().getLoggerFactory().getLogger(WindowsInstanceStarter.class.getName()); - ec2Client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()); - computeService = context.getComputeService(); - } - - public void run() { - final String region = arguments.getRegion(); - - // Build a template - Template template = computeService.templateBuilder() - .locationId(region) - .imageNameMatches(arguments.getImageNamePattern()) - .hardwareId(arguments.getInstanceType()) - .build(); - logger.info("Selected AMI is: %s", template.getImage().toString()); - template.getOptions().inboundPorts(3389); - - // Create the node - logger.info("Creating node and waiting for it to become available"); - Set<? extends NodeMetadata> nodes = null; - try { - nodes = computeService.createNodesInGroup("basic-ami", 1, template); - } catch (RunNodesException e) { - logger.error(e, "Unable to start nodes; aborting"); - return; - } - NodeMetadata node = Iterables.getOnlyElement(nodes); - - // Wait for the administrator password - logger.info("Waiting for administrator password to become available"); - - // This predicate will call EC2's API to get the Windows Administrator - // password, and returns true if there is password data available. - Predicate<String> passwordReady = new Predicate<String>() { - @Override - public boolean apply(@Nullable String s) { - if (Strings.isNullOrEmpty(s)) return false; - PasswordData data = ec2Client.getWindowsServices().getPasswordDataInRegion(region, s); - if (data == null) return false; - return !Strings.isNullOrEmpty(data.getPasswordData()); - } - }; - - // Now wait, using RetryablePredicate - final int maxWait = 600; - final int period = 10; - final TimeUnit timeUnit = TimeUnit.SECONDS; - RetryablePredicate<String> passwordReadyRetryable = new RetryablePredicate<String>(passwordReady, maxWait, period, timeUnit); - boolean isPasswordReady = passwordReadyRetryable.apply(node.getProviderId()); - if (!isPasswordReady) { - logger.error("Password is not ready after %s %s - aborting and shutting down node", maxWait, timeUnit.toString()); - computeService.destroyNode(node.getId()); - return; - } - - // Now we can get the password data, decrypt it, and get a LoginCredentials instance - PasswordDataAndPrivateKey dataAndKey = new PasswordDataAndPrivateKey( - ec2Client.getWindowsServices().getPasswordDataInRegion(region, node.getProviderId()), - node.getCredentials().getPrivateKey()); - WindowsLoginCredentialsFromEncryptedData f = context.getUtils().getInjector().getInstance(WindowsLoginCredentialsFromEncryptedData.class); - LoginCredentials credentials = f.apply(dataAndKey); - - // Send to the log the details you need to log in to the instance with RDP - String publicIp = Iterables.getFirst(node.getPublicAddresses(), null); - logger.info("IP address: %s", publicIp); - logger.info("Login name: %s", credentials.getUser()); - logger.info("Password: %s", credentials.getPassword()); - - // Wait for Enter on the console - logger.info("Hit Enter to shut down the node."); - InputStreamReader converter = new InputStreamReader(System.in); - BufferedReader in = new BufferedReader(converter); - try { - in.readLine(); - } catch (IOException e) { - logger.error(e, "IOException while reading console input"); - } - - // Tidy up - logger.info("Shutting down"); - computeService.destroyNode(node.getId()); - } -}
http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/ec2-windows/src/main/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/ec2-windows/src/main/resources/log4j.properties b/ec2-windows/src/main/resources/log4j.properties deleted file mode 100644 index 48e17e4..0000000 --- a/ec2-windows/src/main/resources/log4j.properties +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Set root logger level to DEBUG and its only appender to A1. -log4j.rootLogger=INFO, A1 - -# A1 is set to be a ConsoleAppender. -log4j.appender.A1=org.apache.log4j.ConsoleAppender - -# A1 uses PatternLayout. -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%-5p %t %c %x/ %m%n - -# Full logging from the example itself -log4j.logger.org.jclouds.examples.ec2.windows=TRACE - -# Optional: increase jclouds logging -#log4j.logger.jclouds=DEBUG -#log4j.logger.org.jclouds=DEBUG - -# Optional: decrease jclouds logging a bit after increasing it! -#log4j.logger.org.jclouds.rest.internal.AsyncRestClientProxy=INFO -#log4j.logger.org.jclouds.http.internal.JavaUrlHttpCommandExecutorService=INFO http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/glacier/pom.xml ---------------------------------------------------------------------- diff --git a/glacier/pom.xml b/glacier/pom.xml index bb05486..9af4df2 100644 --- a/glacier/pom.xml +++ b/glacier/pom.xml @@ -22,16 +22,21 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.apache.jclouds.examples</groupId> <artifactId>glacier-examples</artifactId> - <version>1.8.0</version> + <version>2.1.0</version> <name>glacier-examples</name> + <properties> + <jclouds.version>2.1.0</jclouds.version> + </properties> + <dependencies> <dependency> <groupId>org.apache.jclouds.labs</groupId> <artifactId>glacier</artifactId> - <version>${project.version}</version> + <version>${jclouds.version}</version> </dependency> </dependencies> + <build> <finalName>${project.artifactId}</finalName> <plugins> http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/google-lb/pom.xml ---------------------------------------------------------------------- diff --git a/google-lb/pom.xml b/google-lb/pom.xml index 04a2152..4dc6734 100644 --- a/google-lb/pom.xml +++ b/google-lb/pom.xml @@ -22,12 +22,12 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.apache.jclouds.examples</groupId> <artifactId>google-lb</artifactId> - <version>1.9.0</version> + <version>2.1.0</version> <name>google-lb</name> <description>jclouds-labs-google example that shows using the compute specific api and constructing a load balancer.</description> <properties> - <jclouds.version>1.9.0</jclouds.version> + <jclouds.version>2.1.0</jclouds.version> </properties> <dependencies> @@ -37,7 +37,7 @@ <version>${jclouds.version}</version> </dependency> <dependency> - <groupId>org.apache.jclouds.labs</groupId> + <groupId>org.apache.jclouds.provider</groupId> <artifactId>google-compute-engine</artifactId> <version>${jclouds.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/google-lb/src/main/java/org/jclouds/examples/google/lb/MainApp.java ---------------------------------------------------------------------- diff --git a/google-lb/src/main/java/org/jclouds/examples/google/lb/MainApp.java b/google-lb/src/main/java/org/jclouds/examples/google/lb/MainApp.java index c38abca..e8f97b2 100644 --- a/google-lb/src/main/java/org/jclouds/examples/google/lb/MainApp.java +++ b/google-lb/src/main/java/org/jclouds/examples/google/lb/MainApp.java @@ -61,7 +61,7 @@ import com.google.inject.Injector; */ public class MainApp { - public static enum Action { + public enum Action { CREATE, REQUEST, DESTROY, DELETE_STARTUP_SCRIPT } @@ -144,7 +144,12 @@ public class MainApp { // Make requests to create instances. ArrayList<Operation> operations = new ArrayList<Operation>(); for (int i = 0; i < NUM_INSTANCES; i++){ - Operation o = instanceApi.create(NewInstance.create("jclouds-lb-instance-" + i, machineTypeURL, networkURL, DEFAULT_IMAGE_URL)); + Operation o = instanceApi.create(NewInstance.create( + "jclouds-lb-instance-" + i, + machineTypeURL, + networkURL, + null, + DEFAULT_IMAGE_URL)); System.out.println(" - instance"); operations.add(o); } http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/minecraft-compute/README.md ---------------------------------------------------------------------- diff --git a/minecraft-compute/README.md b/minecraft-compute/README.md deleted file mode 100755 index 968a8d0..0000000 --- a/minecraft-compute/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# minecraft-compute - -This is a simple example command line client that creates a node in a [ComputeService](http://code.google.com/p/jclouds/wiki/ComputeGuide) provider and starts a [Minecraft](http://www.minecraft.net/) server on it. - -Note there are handy commands including add, list, pids, and destroy. - -## Build - -Ensure you have maven 3.02 or higher installed, then execute 'mvn install' to build the example. Note you also need an ssh key setup in your home directory. - -If you don't already have ~/.ssh/id_rsa present, generate a key with the command 'ssh-keygen -t rsa' and leave the passphrase blank. - -## Run - -Invoke the jar, passing the name of the cloud provider you with to access (ex. aws-ec2, gogrid), identity (ex. accesskey, username), credential (ex. secretkey, password), then the name of the group you'd like to add the node to, running minecraft. - -java -jar target/minecraft-compute-jar-with-dependencies.jar provider identity credential mygroup add - -java -jar target/minecraft-compute-jar-with-dependencies.jar provider identity credential mygroup add - -java -jar target/minecraft-compute-jar-with-dependencies.jar provider identity credential mygroup destroy - -Ex. for GleSYS - -java -jar target/minecraft-compute-jar-with-dependencies.jar glesys user apikey mygroup add - -Ex. for Amazon EC2 - -java -jar target/minecraft-compute-jar-with-dependencies.jar aws-ec2 accesskey secretkey mygroup add - -## Playing - -Open Minecraft, go to Multiplayer, Direct Connect, and enter the ip address of your cloud node. - -## Notes - -If you have a firewall blocking the remote ip:25565, you will need to port forward your local 25565 (probably over ssh) - -Ex. if my cloud servers' ip is 15.185.168.16 -ssh 15.185.168.16 -L 25565:15.185.168.16:22 - -## License - -Copyright (C) 2009-2014 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 - http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/minecraft-compute/pom.xml ---------------------------------------------------------------------- diff --git a/minecraft-compute/pom.xml b/minecraft-compute/pom.xml deleted file mode 100644 index 1ffa956..0000000 --- a/minecraft-compute/pom.xml +++ /dev/null @@ -1,171 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.jclouds.examples</groupId> - <artifactId>minecraft-compute</artifactId> - <version>1.0-beta.6</version> - <name>minecraft-compute</name> - <description>starts a minecraft server using the ComputeService api</description> - - <dependencies> - <dependency> - <groupId>org.jclouds</groupId> - <artifactId>jclouds-compute</artifactId> - <version>1.6.0</version> - </dependency> - <dependency> - <groupId>org.jclouds</groupId> - <artifactId>jclouds-allcompute</artifactId> - <version>1.6.0</version> - </dependency> - <dependency> - <groupId>org.jclouds.labs</groupId> - <artifactId>joyentcloud</artifactId> - <version>1.6.0</version> - </dependency> - <!-- note that if you want a smaller distribution - remove the above dependency and place something - like below --> - <!-- - <dependency> - <groupId>org.jclouds.provider</groupId> - <artifactId>gogrid</artifactId> - <version>1.6.0</version> - </dependency> - --> - <dependency> - <groupId>org.bouncycastle</groupId> - <artifactId>bcprov-jdk16</artifactId> - <version>1.46</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.jclouds.driver</groupId> - <artifactId>jclouds-bouncycastle</artifactId> - <version>1.6.0</version> - <exclusions> - <!-- bouncy castle is a provider, so - it must be signed and used as-is. - we are doing this to prevent its - classes from getting into the - jar-with-dependencies --> - <exclusion> - <groupId>org.bouncycastle</groupId> - <artifactId>bcprov-jdk16</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.jclouds.driver</groupId> - <artifactId>jclouds-sshj</artifactId> - <version>1.6.0</version> - </dependency> - <dependency> - <groupId>org.jclouds.driver</groupId> - <artifactId>jclouds-enterprise</artifactId> - <version>1.6.0</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>1.0.0</version> - </dependency> - </dependencies> - <build> - <finalName>${project.artifactId}</finalName> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <encoding>${project.build.sourceEncoding}</encoding> - <source>1.6</source> - <target>1.6</target> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifest> - <mainClass>org.jclouds.examples.minecraft.MainApp</mainClass> - </manifest> - </archive> - </configuration> - </plugin> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <version>2.3</version> - <configuration> - <descriptors> - <descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor> - </descriptors> - <archive> - <manifest> - <mainClass>org.jclouds.examples.minecraft.MainApp</mainClass> - </manifest> - <manifestEntries> - <Class-Path>bcprov-jdk16.jar</Class-Path> - </manifestEntries> - </archive> - </configuration> - <executions> - <execution> - <id>make-assembly</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <version>2.4</version> - <executions> - <execution> - <id>copy</id> - <phase>package</phase> - <goals> - <goal>copy</goal> - </goals> - <configuration> - <artifactItems> - <artifactItem> - <groupId>org.bouncycastle</groupId> - <artifactId>bcprov-jdk16</artifactId> - <overWrite>false</overWrite> - <destFileName>bcprov-jdk16.jar</destFileName> - </artifactItem> - </artifactItems> - <outputDirectory>${project.build.directory}</outputDirectory> - <overWriteReleases>false</overWriteReleases> - <overWriteSnapshots>true</overWriteSnapshots> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/minecraft-compute/src/main/assembly/jar-with-dependencies.xml ---------------------------------------------------------------------- diff --git a/minecraft-compute/src/main/assembly/jar-with-dependencies.xml b/minecraft-compute/src/main/assembly/jar-with-dependencies.xml deleted file mode 100644 index aaa208c..0000000 --- a/minecraft-compute/src/main/assembly/jar-with-dependencies.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - <!-- copied from jar-with-dependencies (http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies) --> - <id>jar-with-dependencies</id> - <formats> - <format>jar</format> - </formats> - <includeBaseDirectory>false</includeBaseDirectory> - <containerDescriptorHandlers> - <containerDescriptorHandler> - <handlerName>metaInf-services</handlerName> - </containerDescriptorHandler> - </containerDescriptorHandlers> - <dependencySets> - <dependencySet> - <outputDirectory>/</outputDirectory> - <useProjectArtifact>true</useProjectArtifact> - <unpack>true</unpack> - <scope>runtime</scope> - </dependencySet> - </dependencySets> -</assembly> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/ConfigureMinecraftDaemon.java ---------------------------------------------------------------------- diff --git a/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/ConfigureMinecraftDaemon.java b/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/ConfigureMinecraftDaemon.java deleted file mode 100644 index 6e15f68..0000000 --- a/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/ConfigureMinecraftDaemon.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.examples.minecraft; - -import static java.lang.String.format; -import static org.jclouds.scriptbuilder.domain.Statements.exec; -import static org.jclouds.scriptbuilder.domain.Statements.saveHttpResponseTo; - -import java.net.URI; - -import javax.inject.Named; - -import org.jclouds.scriptbuilder.InitScript; - -import com.google.inject.AbstractModule; -import com.google.inject.Provides; - -public class ConfigureMinecraftDaemon extends AbstractModule { - - @Override - protected void configure() { - - } - - @Provides - InitScript configureMinecraftDaemon(@Named("minecraft.url") String url, @Named("minecraft.ms") int minHeap, - @Named("minecraft.mx") int maxHeap) { - return InitScript.builder().name("minecraft") - .init(saveHttpResponseTo(URI.create(url), "${INSTANCE_HOME}", "minecraft_server.jar")) - .run(exec(format("java -Xms%sm -Xmx%sm -jar minecraft_server.jar", minHeap, maxHeap))).build(); - } - - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/MainApp.java ---------------------------------------------------------------------- diff --git a/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/MainApp.java b/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/MainApp.java deleted file mode 100644 index 1b075f9..0000000 --- a/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/MainApp.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.examples.minecraft; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.Iterables.contains; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.jclouds.ContextBuilder; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.Apis; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.events.StatementOnNodeCompletion; -import org.jclouds.compute.events.StatementOnNodeFailure; -import org.jclouds.compute.events.StatementOnNodeSubmission; -import org.jclouds.enterprise.config.EnterpriseConfigurationModule; -import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.Providers; -import org.jclouds.scriptbuilder.domain.OsFamily; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; -import com.google.common.eventbus.AllowConcurrentEvents; -import com.google.common.eventbus.Subscribe; -import com.google.common.net.HostAndPort; -import com.google.inject.Module; - -/** - * Demonstrates control of Minecraft. - * <p/> - * Usage is: - * {@code java MainApp provider identity credential groupName (add|list|tail|pids|destroy)} - */ -public class MainApp { - public static final Map<String, ApiMetadata> allApis = Maps.uniqueIndex( - Apis.viewableAs(ComputeServiceContext.class), Apis.idFunction()); - - public static final Map<String, ProviderMetadata> appProviders = Maps.uniqueIndex( - Providers.viewableAs(ComputeServiceContext.class), Providers.idFunction()); - - public static final Set<String> allKeys = ImmutableSet.copyOf(Iterables.concat(appProviders.keySet(), - allApis.keySet())); - - public static enum Action { - ADD, LIST, TAIL, PIDS, DESTROY; - } - - public static int PARAMETERS = 5; - public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: provider identity credential groupName (add|list|tail|pids|destroy)"; - - public static void main(String[] args) { - if (args.length < PARAMETERS) - throw new IllegalArgumentException(INVALID_SYNTAX); - - String provider = args[0]; - String identity = args[1]; - String credential = args[2]; - String groupName = args[3]; - Action action = Action.valueOf(args[4].toUpperCase()); - - // note that you can check if a provider is present ahead of time - checkArgument(contains(allKeys, provider), "provider %s not in supported list: %s", provider, allKeys); - - MinecraftController controller = initController(provider, identity, credential, groupName); - - System.out.printf(">> initialized controller %s%n", controller); - - try { - switch (action) { - case ADD: - System.out.printf(">> adding a server to group %s%n", groupName); - HostAndPort server = controller.add(); - System.out.printf("<< server %s%n", server); - break; - case LIST: - System.out.printf(">> listing servers in group %s%n", groupName); - Iterable<HostAndPort> servers = controller.list(); - System.out.printf("<< servers %s%n", servers); - break; - case TAIL: - System.out.printf(">> tailing all servers in group %s%n", groupName); - Map<HostAndPort, String> output = controller.tail(); - System.out.printf("<< output %s%n", output); - break; - case PIDS: - System.out.printf(">> getting pids of all servers in group %s%n", groupName); - Map<HostAndPort, String> pids = controller.pids(); - System.out.printf("<< pids %s%n", pids); - break; - case DESTROY: - System.out.printf(">> destroying group %s%n", groupName); - Iterable<HostAndPort> destroyed = controller.destroy(); - System.out.printf("<< destroyed servers %s%n", destroyed); - break; - } - } catch (RuntimeException e) { - error = 1; - e.printStackTrace(); - } finally { - controller.close(); - System.exit(error); - } - } - - static int error = 0; - - private static MinecraftController initController(String provider, String identity, String credential, String group) { - Properties properties = new Properties(); - properties.setProperty("minecraft.port", "25565"); - properties.setProperty("minecraft.group", group); - properties.setProperty("minecraft.ms", "1024"); - properties.setProperty("minecraft.mx", "1024"); - properties.setProperty("minecraft.url", - "https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar"); - if ("aws-ec2".equals(provider)) { - // since minecraft download is in s3 on us-east, lowest latency is from - // there - properties.setProperty(PROPERTY_REGIONS, "us-east-1"); - properties.setProperty("jclouds.ec2.ami-query", "owner-id=137112412989;state=available;image-type=machine"); - properties.setProperty("jclouds.ec2.cc-ami-query", ""); - } - - // example of injecting a ssh implementation - Iterable<Module> modules = ImmutableSet.<Module> of( - new SshjSshClientModule(), - new SLF4JLoggingModule(), - new EnterpriseConfigurationModule(), - // This is extended stuff you might inject!! - new ConfigureMinecraftDaemon()); - - ContextBuilder builder = ContextBuilder.newBuilder(provider) - .credentials(identity, credential) - .modules(modules) - .overrides(properties); - - System.out.printf(">> initializing %s%n", builder.getApiMetadata()); - ComputeServiceContext context = builder.buildView(ComputeServiceContext.class); - - context.utils().eventBus().register(ScriptLogger.INSTANCE); - return context.utils().injector().getInstance(MinecraftController.class); - } - - static enum ScriptLogger { - INSTANCE; - - Logger logger = LoggerFactory.getLogger(MainApp.class); - - @Subscribe - @AllowConcurrentEvents - public void onStart(StatementOnNodeSubmission event) { - logger.info(">> running {} on node({})", event.getStatement(), event.getNode().getId()); - if (logger.isDebugEnabled()) { - logger.debug(">> script for {} on node({})\n{}", new Object[] { event.getStatement(), event.getNode().getId(), - event.getStatement().render(OsFamily.UNIX) }); - } - } - - @Subscribe - @AllowConcurrentEvents - public void onFailure(StatementOnNodeFailure event) { - logger.error("<< error running {} on node({}): {}", new Object[] { event.getStatement(), event.getNode().getId(), - event.getCause().getMessage() }, event.getCause()); - } - - @Subscribe - @AllowConcurrentEvents - public void onSuccess(StatementOnNodeCompletion event) { - ExecResponse arg0 = event.getResponse(); - if (arg0.getExitStatus() != 0) { - logger.error("<< error running {} on node({}): {}", new Object[] { event.getStatement(), event.getNode().getId(), - arg0 }); - } else { - logger.info("<< success executing {} on node({}): {}", new Object[] { event.getStatement(), - event.getNode().getId(), arg0 }); - } - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/MinecraftController.java ---------------------------------------------------------------------- diff --git a/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/MinecraftController.java b/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/MinecraftController.java deleted file mode 100644 index aa13a2e..0000000 --- a/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/MinecraftController.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.examples.minecraft; - -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.collect.Iterables.transform; -import static com.google.common.io.Closeables.closeQuietly; -import static org.jclouds.examples.minecraft.Utils.firstPublicAddressToHostAndPort; -import static org.jclouds.util.Maps2.transformKeys; - -import java.io.Closeable; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.lifecycle.Closer; -import org.jclouds.logging.Logger; -import org.jclouds.scriptbuilder.InitScript; - -import com.google.common.net.HostAndPort; - -@Singleton -public class MinecraftController implements Closeable { - - @Resource - protected Logger logger = Logger.NULL; - - private final Closer closer; - private final NodeManager nodeManager; - private final Provider<InitScript> daemonFactory; - private final int port; - private final String group; - private final int maxHeap; - - @Inject - MinecraftController(Closer closer, NodeManager nodeManager, Provider<InitScript> daemonFactory, - @Named("minecraft.port") int port, @Named("minecraft.group") String group, @Named("minecraft.mx") int maxHeap) { - this.closer = closer; - this.nodeManager = nodeManager; - this.daemonFactory = daemonFactory; - this.port = port; - this.group = group; - this.maxHeap = maxHeap; - } - - public Iterable<HostAndPort> list() { - return transformToHostAndPort(nodeManager.listRunningNodesInGroup(group)); - } - - public Iterable<HostAndPort> transformToHostAndPort(Set<? extends NodeMetadata> nodes) { - return transform(nodes, firstPublicAddressToHostAndPort(port)); - } - - public HostAndPort add() { - return firstPublicAddressToHostAndPort(port).apply(createNodeWithMinecraft()); - } - - private NodeMetadata createNodeWithMinecraft() { - int javaPlusOverhead = maxHeap + 256; - NodeMetadata node = nodeManager.createNodeWithAdminUserAndJDKInGroupOpeningPortAndMinRam(group, port, - javaPlusOverhead); - nodeManager.startDaemonOnNode(daemonFactory.get(), node.getId()); - return node; - } - - public Map<HostAndPort, String> tail() { - return mapHostAndPortToStdoutForCommand("/tmp/init-minecraft tail"); - } - - public Map<HostAndPort, String> mapHostAndPortToStdoutForCommand(String cmd) { - return transformKeys(nodeManager.stdoutFromCommandOnGroup(cmd, group), firstPublicAddressToHostAndPort(port)); - } - - public Map<HostAndPort, String> pids() { - return mapHostAndPortToStdoutForCommand("/tmp/init-minecraft status"); - } - - public Iterable<HostAndPort> destroy() { - return transformToHostAndPort(nodeManager.destroyNodesInGroup(group)); - } - - @Override - public void close() { - closeQuietly(closer); - } - - @Override - public String toString() { - return toStringHelper("").add("nodeManager", nodeManager).add("group", group).add("port", port).toString(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/NodeManager.java ---------------------------------------------------------------------- diff --git a/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/NodeManager.java b/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/NodeManager.java deleted file mode 100644 index e13c613..0000000 --- a/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/NodeManager.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.examples.minecraft; - -import static com.google.common.base.Predicates.not; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.collect.Iterables.getOnlyElement; -import static com.google.common.collect.Maps.transformValues; -import static com.google.common.collect.Sets.filter; -import static org.jclouds.compute.predicates.NodePredicates.TERMINATED; -import static org.jclouds.compute.predicates.NodePredicates.all; -import static org.jclouds.compute.predicates.NodePredicates.inGroup; -import static org.jclouds.compute.predicates.NodePredicates.runningInGroup; -import static org.jclouds.examples.minecraft.Utils.asCurrentUser; -import static org.jclouds.examples.minecraft.Utils.getStdout; -import static org.jclouds.scriptbuilder.domain.Statements.newStatementList; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.RunNodesException; -import org.jclouds.compute.RunScriptOnNodesException; -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.Template; -import org.jclouds.logging.Logger; -import org.jclouds.scriptbuilder.InitScript; -import org.jclouds.scriptbuilder.domain.Statement; -import org.jclouds.scriptbuilder.statements.java.InstallJDK; -import org.jclouds.scriptbuilder.statements.login.AdminAccess; - -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableMap; - -@Singleton -public class NodeManager { - @Resource - private Logger logger = Logger.NULL; - - private final ComputeService compute; - - @Inject - NodeManager(ComputeService compute) { - this.compute = compute; - } - - @SuppressWarnings("unchecked") - public Map<NodeMetadata, String> stdoutFromCommandOnGroup(String command, String group) { - try { - return transformValues((Map<NodeMetadata, ExecResponse>) compute.runScriptOnNodesMatching( - runningInGroup(group), command, asCurrentUser().wrapInInitScript(false)), getStdout()); - } catch (RunScriptOnNodesException e) { - throw propagate(e); - } - } - - public ExecResponse startDaemonOnNode(InitScript daemon, String nodeId) { - return compute.runScriptOnNode(nodeId, daemon, asCurrentUser().blockOnComplete(false)); - } - - public Set<? extends NodeMetadata> listRunningNodesInGroup(String group) { - return filter(compute.listNodesDetailsMatching(all()), runningInGroup(group)); - } - - public Set<? extends NodeMetadata> destroyNodesInGroup(String group) { - return compute.destroyNodesMatching(Predicates.<NodeMetadata> and(inGroup(group), not(TERMINATED))); - } - - public RuntimeException destroyBadNodesAndPropagate(RunNodesException e) { - for (Entry<? extends NodeMetadata, ? extends Throwable> nodeError : e.getNodeErrors().entrySet()) - compute.destroyNode(nodeError.getKey().getId()); - throw propagate(e); - } - - public NodeMetadata createNodeWithAdminUserAndJDKInGroupOpeningPortAndMinRam(String group, int port, int minRam) { - ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("Name", group); - - // we want everything as defaults except ram - Template defaultTemplate = compute.templateBuilder().build(); - Template minecraft = compute.templateBuilder().fromTemplate(defaultTemplate).minRam(minRam).build(); - - // setup the template to customize the node with jdk, etc. also opening ports. - Statement bootstrap = newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK()); - minecraft.getOptions().inboundPorts(22, port).userMetadata(userMetadata).runScript(bootstrap); - - // example of using a cloud-specific hook - if (minecraft.getOptions() instanceof AWSEC2TemplateOptions) - minecraft.getOptions().as(AWSEC2TemplateOptions.class).enableMonitoring(); - - logger.info(">> creating node type(%s) in group %s, opening ports 22, %s with admin user and jdk", minecraft - .getHardware().getId(), group, port); - - try { - - NodeMetadata node = getOnlyElement(compute.createNodesInGroup(group, 1, minecraft)); - - logger.info("<< available node(%s) os(%s) publicAddresses%s", node.getId(), node.getOperatingSystem(), - node.getPublicAddresses()); - return node; - } catch (RunNodesException e) { - throw destroyBadNodesAndPropagate(e); - } - } - - @Override - public String toString() { - return String.format("connection(%s)", compute.getContext().unwrap()); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/Utils.java ---------------------------------------------------------------------- diff --git a/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/Utils.java b/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/Utils.java deleted file mode 100644 index 621aa1c..0000000 --- a/minecraft-compute/src/main/java/org/jclouds/examples/minecraft/Utils.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.examples.minecraft; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.collect.Iterables.get; -import static org.jclouds.compute.options.TemplateOptions.Builder.runAsRoot; - -import java.io.File; -import java.io.IOException; - -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.domain.LoginCredentials; - -import com.google.common.base.Function; -import com.google.common.io.Files; -import com.google.common.net.HostAndPort; - -public class Utils { - public static Function<ExecResponse, String> getStdout() { - return new Function<ExecResponse, String>() { - - @Override - public String apply(ExecResponse input) { - return input.getOutput(); - } - }; - } - - public static Function<NodeMetadata, HostAndPort> firstPublicAddressToHostAndPort(final int port) { - return new Function<NodeMetadata, HostAndPort>() { - - @Override - public HostAndPort apply(NodeMetadata input) { - return HostAndPort.fromParts(get(input.getPublicAddresses(), 0), port); - } - - @Override - public String toString() { - return "firstPublicAddressToHostAndPort(" + port + ")"; - } - - }; - } - - public static TemplateOptions asCurrentUser() { - return runAsRoot(false).overrideLoginCredentials(currentUser()); - } - - public static LoginCredentials currentUser() { - String privateKeyKeyFile = System.getProperty("user.home") + "/.ssh/id_rsa"; - String privateKey; - try { - privateKey = Files.toString(new File(privateKeyKeyFile), UTF_8); - } catch (IOException e) { - throw propagate(e); - } - assert privateKey.startsWith("-----BEGIN RSA PRIVATE KEY-----") : "invalid key:\n" + privateKey; - return LoginCredentials.builder().user(System.getProperty("user.name")).privateKey(privateKey).build(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/minecraft-compute/src/main/resources/logback.xml ---------------------------------------------------------------------- diff --git a/minecraft-compute/src/main/resources/logback.xml b/minecraft-compute/src/main/resources/logback.xml deleted file mode 100644 index 690a944..0000000 --- a/minecraft-compute/src/main/resources/logback.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<configuration> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>- %msg%n</pattern> - </encoder> - </appender> - <root level="info"> - <appender-ref ref="STDOUT"/> - </root> - <logger name="jclouds.compute" level="info"/> - <logger name="org.jclouds.examples.minecraft" level="info"/> - <logger name="net.schmizz" level="warn"/> -<!-- - <logger name="jclouds.wire" level="debug"/> - <logger name="jclouds.headers" level="debug"/> - <logger name="jclouds.ssh" level="debug"/> ---> -</configuration> http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/openstack/pom.xml ---------------------------------------------------------------------- diff --git a/openstack/pom.xml b/openstack/pom.xml index 74403a7..5bd40fd 100644 --- a/openstack/pom.xml +++ b/openstack/pom.xml @@ -22,11 +22,11 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.apache.jclouds.examples</groupId> <artifactId>openstack-examples</artifactId> - <version>2.0.0</version> + <version>2.1.0</version> <name>openstack-examples</name> <properties> - <jclouds.version>2.0.0</jclouds.version> + <jclouds.version>2.1.0</jclouds.version> </properties> <dependencies> @@ -73,7 +73,7 @@ <version>${jclouds.version}</version> </dependency> <dependency> - <groupId>org.apache.jclouds.labs</groupId> + <groupId>org.apache.jclouds.api</groupId> <artifactId>openstack-neutron</artifactId> <version>${jclouds.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/.gitignore ---------------------------------------------------------------------- diff --git a/play-compute/.gitignore b/play-compute/.gitignore deleted file mode 100644 index f6ca7ab..0000000 --- a/play-compute/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -logs -project/project -project/target -target -tmp -.history -dist \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/README ---------------------------------------------------------------------- diff --git a/play-compute/README b/play-compute/README deleted file mode 100644 index 6373f4a..0000000 --- a/play-compute/README +++ /dev/null @@ -1,4 +0,0 @@ -This is your new Play 2.0 application -===================================== - -This file will be packaged with your application, when using `play dist`. http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/app/controllers/Application.java ---------------------------------------------------------------------- diff --git a/play-compute/app/controllers/Application.java b/play-compute/app/controllers/Application.java deleted file mode 100644 index 875559e..0000000 --- a/play-compute/app/controllers/Application.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package controllers; - -import play.*; -import play.mvc.*; - -import views.html.*; - -import com.google.common.collect.ImmutableSet; -import org.jclouds.apis.Apis; - -public class Application extends Controller { - - public static Result index() { - return ok(index.render("available apis: " + ImmutableSet.copyOf(Apis.all()))); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/app/views/index.scala.html ---------------------------------------------------------------------- diff --git a/play-compute/app/views/index.scala.html b/play-compute/app/views/index.scala.html deleted file mode 100644 index 144a401..0000000 --- a/play-compute/app/views/index.scala.html +++ /dev/null @@ -1,28 +0,0 @@ -@**************************************************************** - * * - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - * * - ****************************************************************@ - -@(message: String) - -@main("Welcome to Play 2.0") { - - @play20.welcome(message, style = "Java") - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/app/views/main.scala.html ---------------------------------------------------------------------- diff --git a/play-compute/app/views/main.scala.html b/play-compute/app/views/main.scala.html deleted file mode 100644 index f24fb43..0000000 --- a/play-compute/app/views/main.scala.html +++ /dev/null @@ -1,36 +0,0 @@ -@**************************************************************** - * * - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - * * - ****************************************************************@ - -@(title: String)(content: Html) - -<!DOCTYPE html> - -<html> - <head> - <title>@title</title> - <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")"> - <link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")"> - <script src="@routes.Assets.at("javascripts/jquery-1.7.1.min.js")" type="text/javascript"></script> - </head> - <body> - @content - </body> -</html> http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/conf/application.conf ---------------------------------------------------------------------- diff --git a/play-compute/conf/application.conf b/play-compute/conf/application.conf deleted file mode 100644 index 05224f2..0000000 --- a/play-compute/conf/application.conf +++ /dev/null @@ -1,74 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# This is the main configuration file for the application. -# ~~~~~ - -# Secret key -# ~~~~~ -# The secret key is used to secure cryptographics functions. -# If you deploy your application to several instances be sure to use the same key! -application.secret="g33@Xe@>:s_1c6K6h1SENr[8VdwyMlAV?]<sf:Y1t]=N<AwPjOcQ5OS1lUwF`p8E" - -# The application languages -# ~~~~~ -application.langs="en" - -# Global object class -# ~~~~~ -# Define the Global object class for this application. -# Default to Global in the root package. -# global=Global - -# Database configuration -# ~~~~~ -# You can declare as many datasources as you want. -# By convention, the default datasource is named `default` -# -db.default.driver=org.h2.Driver -db.default.url="jdbc:h2:mem:play" -db.default.user=sa -#db.default.password= -# -# You can expose this datasource via JNDI if needed (Useful for JPA) -# db.default.jndiName=DefaultDS - -# Evolutions -# ~~~~~ -# You can disable evolutions if needed -# evolutionplugin=disabled - -# Ebean configuration -# ~~~~~ -# You can declare as many Ebean servers as you want. -# By convention, the default server is named `default` -# -ebean.default="models.*" - -# Logger -# ~~~~~ -# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory . - -# Root logger: -logger.root=ERROR - -# Logger used by the framework: -logger.play=INFO - -# Logger provided to your application: -logger.application=DEBUG - http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/conf/routes ---------------------------------------------------------------------- diff --git a/play-compute/conf/routes b/play-compute/conf/routes deleted file mode 100644 index d45d434..0000000 --- a/play-compute/conf/routes +++ /dev/null @@ -1,26 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Routes -# This file defines all application routes (Higher priority routes first) -# ~~~~ - -# Home page -GET / controllers.Application.index() - -# Map static resources from the /public folder to the /assets URL path -GET /assets/*file controllers.Assets.at(path="/public", file) http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/project/Build.scala ---------------------------------------------------------------------- diff --git a/play-compute/project/Build.scala b/play-compute/project/Build.scala deleted file mode 100644 index f77a739..0000000 --- a/play-compute/project/Build.scala +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import sbt._ -import Keys._ -import PlayProject._ - -object ApplicationBuild extends Build { - - val appName = "play-compute" - val appVersion = "1.0-SNAPSHOT" - - val appDependencies = Seq( - "com.google.guava" % "guava" % "12.0", - "org.jclouds" % "jclouds-compute" % "1.5.0-alpha.6", - "org.reflections" % "reflections" % "0.9.7.RC1" - //If using the securesocial module you may need to do the following to make jclouds run: - //"securesocial" %% "securesocial" % "2.0.12" excludeAll(ExclusionRule(organization="org.ow2.spec.ee"), ExclusionRule(organization="com.cedarsoft")) - ) - - val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings( - resolvers += "Maven central" at "http://repo1.maven.org/maven2/", - resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots" - ) - -} http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/project/build.properties ---------------------------------------------------------------------- diff --git a/play-compute/project/build.properties b/play-compute/project/build.properties deleted file mode 100644 index 7d01e8f..0000000 --- a/play-compute/project/build.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -sbt.version=0.11.2 http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/project/plugins.sbt ---------------------------------------------------------------------- diff --git a/play-compute/project/plugins.sbt b/play-compute/project/plugins.sbt deleted file mode 100644 index eb5700e..0000000 --- a/play-compute/project/plugins.sbt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// Comment to get more information during initialization -logLevel := Level.Warn - -// The Typesafe repository -resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" - -// Use the Play sbt plugin for Play projects -addSbtPlugin("play" % "sbt-plugin" % "2.0") http://git-wip-us.apache.org/repos/asf/jclouds-examples/blob/934cdb08/play-compute/public/images/favicon.png ---------------------------------------------------------------------- diff --git a/play-compute/public/images/favicon.png b/play-compute/public/images/favicon.png deleted file mode 100644 index c7d92d2..0000000 Binary files a/play-compute/public/images/favicon.png and /dev/null differ
