diff --git a/README.md b/README.md index f93e6e52..82163f79 100644 --- a/README.md +++ b/README.md @@ -6,66 +6,42 @@ This repository contains various examples of using - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - -
projectdescription
Cloudwatch Basics (Java)Example code to get the total metrics stored for each of your instances within the past 24 hours and shows avg/max/min CPU utilization for each instance when possible.
Compute Basics (Java)Example code to add nodes to a group and execute commands on them using the portable ComputeService API
Compute Basics (Clojure)Example code using compute2 to create a node, execute a command and destroy the node.
Start a Minecraft Server (Java)Example code to add nodes to a group and start Minecraft servers on them using the portable ComputeService API
BlobStore Basics (Java) Example code to create a container, blob, and list your blobs using the portable BlobStore API
BlobStore Basics (Clojure)Example code using blobstore2 to create a container, and list your containers.
BlobStore Basics (Scala)Example code to create a container and blob using the filesystem BlobStore APILarge Blob support (Java)Example code to create a container and use a parallel strategy to upload a large blob, the portable BlobStore API
BlobStore via Karaf ShellExample to read and write to a blobstore from inside the Apache Karaf Shell.Blob Uploader (Java)Example code to upload many small to medium sized files to a provider supported by jclouds.
Use EC2 Extensions in ComputeService (Java)Example code to create a spot instance on EC2 using ComputeService API extensionsChef Basics (Java)Example code to add nodes to a group and execute Chef cookbooks on them using Chef Solo or a standard or Hosted Chef Server.
EC2 Create LAMP (Java)Example code to create a LAMP server on EC2 using the provider-specific EC2ClientCompute Basics (Java)Example code to add nodes to a group and execute commands on them using the portable ComputeService API
Deploy a webapp (ant)Example code to deploy a web application to the cloud using Cargo and the jclouds ant pluginAWS Glacier (Java)Example code that uses jclouds to manage using the Glacier provider and BlobStore..
Large Blob support (Java)Example code to create a container and use a parallel strategy to upload a large blob, the portable BlobStore APIGoogle LoadBalancer (Java)Example code that uses jclouds to manage Google [Network Load Balancing](https://cloud.google.com/compute/docs/load-balancing/network/).
Camel notificationsExample code that uses jclouds from inside Apache Camel routes. The example provides routes that poll the compute provider for running nodes and sends notifications via email. OpenStack (Java)Example code that uses jclouds to perform common tasks on the OpenStack.
Rackspace (Java) Example code that uses jclouds to perform common tasks on the Rackspace Cloud.
Chef Basics (Java)Example code to add nodes to a group and execute Chef cookbooks on them using Chef Solo or a standard or Hosted Chef Server.
diff --git a/blobstore-basics/pom.xml b/blobstore-basics/pom.xml index 4a635680..9da345e7 100644 --- a/blobstore-basics/pom.xml +++ b/blobstore-basics/pom.xml @@ -22,12 +22,12 @@ 4.0.0 org.apache.jclouds.examples blobstore-basics - 2.0.0 + 2.1.0 blobstore-basics jclouds blobstore example that creates a container, then displays the size of each container - 2.0.0 + 2.1.0 @@ -41,11 +41,6 @@ jclouds-allblobstore ${jclouds.version} - - org.apache.jclouds.labs - google-cloud-storage - ${jclouds.version} - diff --git a/blobstore-clojure/README.md b/blobstore-clojure/README.md deleted file mode 100644 index 74b5729c..00000000 --- a/blobstore-clojure/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# blobstore-clojure - -Basic blobstore usage example including creating a container and then listing all containers in your account. - -## Build - -Ensure you have [Leiningen](http://github.com/technomancy/leiningen) installed, then execute 'lein deps' to grab the jclouds dependencies. - -## Run - - bash$ lein repl - user> (use 'create-list.containers) - user> (create-and-list "transient" "foo" "bar" "mycontainer") - or for a real blobstore like S3 - user> (create-and-list "aws-s3" accesskey secret "mybucket") - -## License - -Copyright (C) 2009-2014 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 - diff --git a/blobstore-hdfs/README.md b/blobstore-hdfs/README.md deleted file mode 100755 index 183c0c7a..00000000 --- a/blobstore-hdfs/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# blobstore-hdfs - -This is a simple example which shows how we can extends the Payload to have HDFS for using with Blobstore. -Then the application layer is using an upload from HDFS. -The reason why such kind of HDFS payload currently is considered only an example application is that -people are using different versions of Hadoop, thus the adequate version needs to be matched exactly -which is not a simple decision in general case. As an example, it is the simplest way to present it. - -Note that, if you run this example and you will see an exception showing incompatible version between -your hdfs client and the running server's hdfs version, then switch the version of hadoop-core from -0.20.2-cdh3u0 to your used version. - -## Build - -Ensure you have maven 3.02 or higher installed, then execute 'mvn install' to build the example. - -## Run - -First of all, you need some Hadoop running in distributed or pseudo distributed mode. -The easiest way to test it, just install it a CDH3 version of Cloudera Hadoop as it is -described here: https://ccp.cloudera.com/display/CDHDOC/CDH3+Deployment+in+Pseudo-Distributed+Mode - -Invoke the jar, passing the name of the cloud provider you with to access (aws-s3 is currently tested), identity (ex. accesskey, username), credential (ex. secretkey, password), the filename you want to upload from hfds (for example hdfs://localhost:8020/user/yourusername/yourfile), then the name of the container you'd like to create, then the object name and eventually the optional parameters plainhttp or securehttp and a number representing the number of threads. - -Ex. for Amazon S3 - -"plainhttp" "5" are the two optional parameters. Default values are securehttp and 4 threads. - -The hdfs input file size has to be at least 32Mbytes size to be used multipart upload. Below this size it will fall back to simple upload. - -## License - -Copyright (C) 2009-2014 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 diff --git a/blobstore-hdfs/pom.xml b/blobstore-hdfs/pom.xml deleted file mode 100644 index 85cd2da1..00000000 --- a/blobstore-hdfs/pom.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - 4.0.0 - org.jclouds.examples - blobstore-hdfs - 1.0.0 - blobstore-hdfs - demonstrates how we can build hfds payloads as an extension to the current payloads in blobstore - - - - jboss-public-releases - https://repository.jboss.org/nexus/content/groups/public-jboss - - true - - - false - - - - cloudera-public-releases - https://repository.cloudera.com/content/repositories/releases/ - - true - - - false - - - - - - - org.jclouds - jclouds-blobstore - 1.1.0 - - - org.jclouds - jclouds-allblobstore - 1.1.0 - - - org.jclouds.driver - jclouds-netty - 1.1.0 - - - org.jboss.netty - netty - 3.2.4.Final - - - org.jclouds.driver - jclouds-apachehc - 1.1.0 - - - org.jclouds.driver - jclouds-slf4j - 1.1.0 - - - org.jclouds.driver - jclouds-log4j - 1.1.0 - - - - - org.apache.hadoop - hadoop-core - 0.20.2-cdh3u0 - - - - ${project.artifactId} - - - - org.apache.maven.plugins - maven-jar-plugin - - - - org.jclouds.examples.blobstore.hdfs.MainApp - - - - - - - maven-assembly-plugin - - - jar-with-dependencies - - - - org.jclouds.examples.blobstore.hdfs.MainApp - - - - - - make-assembly - package - - single - - - - - - - - - diff --git a/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/MainApp.java b/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/MainApp.java deleted file mode 100755 index 3ee6bc5d..00000000 --- a/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/MainApp.java +++ /dev/null @@ -1,182 +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.blobstore.hdfs; - -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.blobstore.options.PutOptions.Builder.multipart; -import static org.jclouds.location.reference.LocationConstants.ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; - -import java.io.IOException; -import java.util.Properties; - -import javax.ws.rs.core.MediaType; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.conf.Configured; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.jclouds.aws.domain.Region; -import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; -import org.jclouds.blobstore.domain.Blob; -import org.jclouds.blobstore.util.BlobStoreUtils; -import org.jclouds.examples.blobstore.hdfs.config.HdfsModule; -import org.jclouds.examples.blobstore.hdfs.io.payloads.HdfsPayload; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.inject.Module; - -/** - * Demonstrates the use of {@link BlobStore} to upload from HDFS to a blob container - * - * Usage is: java MainApp \"provider\" \"identity\" \"credential\" \"hdfsUrl\" - * \"containerName\" \"objectName\" plainhttp threadcount - * - * \"plainhttp\" and \"threadcound\" is optional if all the rest of parameters are omitted - */ -public class MainApp extends Configured { - - public static int PARAMETERS = 6; - public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: \"provider\" \"identity\" \"credential\" \"localFileName\" \"containerName\" \"objectName\" plainhttp threadcount"; - - public final static Properties PLAIN_HTTP_ENDPOINTS = new Properties(); - - static { - PLAIN_HTTP_ENDPOINTS.setProperty(PROPERTY_ENDPOINT, "http://s3.amazonaws.com"); - PLAIN_HTTP_ENDPOINTS.setProperty(PROPERTY_REGION + "." + Region.US_STANDARD + "." + ENDPOINT, - "http://s3.amazonaws.com"); - PLAIN_HTTP_ENDPOINTS.setProperty(PROPERTY_REGION + "." + Region.US_WEST_1 + "." + ENDPOINT, - "http://s3-us-west-1.amazonaws.com"); - PLAIN_HTTP_ENDPOINTS.setProperty(PROPERTY_REGION + "." + "EU" + "." + ENDPOINT, - "http://s3-eu-west-1.amazonaws.com"); - PLAIN_HTTP_ENDPOINTS.setProperty(PROPERTY_REGION + "." + Region.AP_SOUTHEAST_1 + "." + ENDPOINT, - "http://s3-ap-southeast-1.amazonaws.com"); - } - - final static Iterable HDFS_MODULES = - ImmutableSet.of(new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(), new HdfsModule()); - - static String getSpeed(long speed) { - if (speed < 1024) { - return "" + speed + " bytes/s"; - } else if (speed < 1048576) { - return "" + (speed / 1024) + " kbytes/s"; - } else { - return "" + (speed / 1048576) + " Mbytes/s"; - } - } - - static void printSpeed(String message, long start, long length) { - long sec = (System.currentTimeMillis() - start) / 1000; - if (sec == 0) - return; - long speed = length / sec; - System.out.print(message); - if (speed < 1024) { - System.out.print(" " + length + " bytes"); - } else if (speed < 1048576) { - System.out.print(" " + (length / 1024) + " kB"); - } else if (speed < 1073741824) { - System.out.print(" " + (length / 1048576) + " MB"); - } else { - System.out.print(" " + (length / 1073741824) + " GB"); - } - System.out.println(" with " + getSpeed(speed) + " (" + length + " bytes)"); - } - - - /** - * @param provider - * @param identity - * @param credential - * @param hdfsUrl - * @param containerName - * @param objectName - * @param plainhttp - * @param threadcount - * @throws IOException - */ - private void upload(String provider, String identity, - String credential, String hdfsUrl, String containerName, - String objectName, boolean plainhttp, String threadcount) - throws IOException { - // Init - Properties overrides = new Properties(); - if (plainhttp) - overrides.putAll(PLAIN_HTTP_ENDPOINTS); // default is https - if (threadcount != null) - overrides.setProperty("jclouds.mpu.parallel.degree", threadcount); // without setting, - // default is 4 threads - overrides.setProperty(provider + ".identity", identity); - overrides.setProperty(provider + ".credential", credential); - BlobStoreContext context = new BlobStoreContextFactory().createContext(provider, HDFS_MODULES, overrides); - - try { - long start = System.currentTimeMillis(); - Configuration conf = getConf(); - if (conf == null) { - conf = new Configuration(); - setConf(conf); - } - // Create Container - BlobStore blobStore = context.getBlobStore(); // it can be changed to sync - // BlobStore - blobStore.createContainerInLocation(null, containerName); - Blob blob = blobStore.blobBuilder(objectName).payload( - new HdfsPayload(new Path(hdfsUrl), conf)) - .contentType(MediaType.APPLICATION_OCTET_STREAM) - .contentDisposition(objectName).build(); - long length = blob.getPayload().getContentMetadata().getContentLength(); - blobStore.putBlob(containerName, blob, multipart()); - - printSpeed("Sucessfully uploaded", start, length); - - } finally { - // Close connection - context.close(); - } - } - - public static void main(String[] args) throws IOException { - - if (args.length < PARAMETERS) - throw new IllegalArgumentException(INVALID_SYNTAX); - - // Args - String provider = args[0]; - if (!Iterables.contains(BlobStoreUtils.getSupportedProviders(), provider)) - throw new IllegalArgumentException("provider " + provider + " not in supported list: " - + BlobStoreUtils.getSupportedProviders()); - String identity = args[1]; - String credential = args[2]; - String hdfsUrl = args[3]; - String containerName = args[4]; - String objectName = args[5]; - boolean plainhttp = args.length >= 7 && "plainhttp".equals(args[6]); - String threadcount = args.length >= 8 ? args[7] : null; - - MainApp app = new MainApp(); - app.upload(provider, identity, credential, hdfsUrl, containerName, - objectName, plainhttp, threadcount); - System.exit(0); - } -} diff --git a/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/config/HdfsModule.java b/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/config/HdfsModule.java deleted file mode 100644 index c356dfe1..00000000 --- a/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/config/HdfsModule.java +++ /dev/null @@ -1,31 +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.blobstore.hdfs.config; - -import org.jclouds.io.PayloadSlicer; - -import com.google.inject.AbstractModule; -import org.jclouds.examples.blobstore.hdfs.io.HdfsPayloadSlicer; - -public class HdfsModule extends AbstractModule { - - @Override - protected void configure() { - bind(PayloadSlicer.class).to(HdfsPayloadSlicer.class); - } - -} diff --git a/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/io/HdfsPayloadSlicer.java b/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/io/HdfsPayloadSlicer.java deleted file mode 100644 index f2ddc68f..00000000 --- a/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/io/HdfsPayloadSlicer.java +++ /dev/null @@ -1,72 +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.blobstore.hdfs.io; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.IOException; -import java.io.InputStream; - -import javax.inject.Singleton; - -import org.apache.hadoop.fs.FSDataInputStream; -import org.jclouds.examples.blobstore.hdfs.io.payloads.HdfsPayload; -import org.jclouds.io.Payload; -import org.jclouds.io.internal.BasePayloadSlicer; -import org.jclouds.io.payloads.InputStreamSupplierPayload; - -import com.google.common.io.Closeables; -import com.google.common.io.InputSupplier; -import com.google.common.io.LimitInputStream; - -@Singleton -public class HdfsPayloadSlicer extends BasePayloadSlicer { - - @Override - public Payload slice(Payload input, long offset, long length) { - checkNotNull(input); - checkArgument(offset >= 0, "offset is negative"); - checkArgument(length >= 0, "length is negative"); - Payload returnVal; - if (input instanceof HdfsPayload) { - returnVal = doSlice( - (FSDataInputStream) ((HdfsPayload) input).getInput(), offset, - length); - return copyMetadataAndSetLength(input, returnVal, length); - } else { - return super.slice(input, offset, length); - } - } - - protected Payload doSlice(final FSDataInputStream inputStream, - final long offset, final long length) { - return new InputStreamSupplierPayload(new InputSupplier() { - public InputStream getInput() throws IOException { - if (offset > 0) { - try { - inputStream.seek(offset); - } catch (IOException e) { - Closeables.closeQuietly(inputStream); - throw e; - } - } - return new LimitInputStream(inputStream, length); - } - }); - } -} diff --git a/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/io/payloads/HdfsPayload.java b/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/io/payloads/HdfsPayload.java deleted file mode 100644 index adbb0fa0..00000000 --- a/blobstore-hdfs/src/main/java/org/jclouds/examples/blobstore/hdfs/io/payloads/HdfsPayload.java +++ /dev/null @@ -1,62 +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.blobstore.hdfs.io.payloads; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.jclouds.io.payloads.BasePayload; - -import com.google.common.base.Throwables; - -public class HdfsPayload extends BasePayload { - - private Configuration configuration; - - public HdfsPayload(final Path content, final Configuration configuration) - throws IOException { - this(content, configuration, content.getFileSystem(configuration) - .getFileStatus(content).getLen()); - } - - public HdfsPayload(final Path content, final Configuration configuration, - final long length) throws IOException { - super(content); - this.configuration = configuration; - getContentMetadata().setContentLength(length); - } - - public InputStream getInput() { - try { - return content.getFileSystem(configuration).open(content); - } catch (IOException e) { - Throwables.propagate(e); - return null; - } - } - - public FileSystem getFileSystem() throws IOException { - return content.getFileSystem(configuration); - } - - public Configuration getConfiguration() { - return configuration; - } -} diff --git a/blobstore-hdfs/src/main/resources/log4j.xml b/blobstore-hdfs/src/main/resources/log4j.xml deleted file mode 100644 index 9db501e2..00000000 --- a/blobstore-hdfs/src/main/resources/log4j.xml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blobstore-karaf-shell/README.md b/blobstore-karaf-shell/README.md deleted file mode 100644 index c2dc9890..00000000 --- a/blobstore-karaf-shell/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# blobstore-karaf-shell - -This is a simple examples that demonstrates the using a [BlobStore](http://jclouds.apache.org/start/blobstore/) provider from within [Apache Karaf](http://karaf.apache.org/) Runtime. - -This example adds two osgi shell commands, that read and write to a blobstore. The context of the blobstore can be configured via OSGi Configuration Admin, which allows the switching blobstore contexts (providers, keys etc) "on the fly". -## Build - -The sample builds with maven 2.2.1 or higher (however its tested with 3.0.3). Execute 'mvn install' to build the example. - -## Run -From within Apache Karaf (2.2.0 or higher) type: -karaf@root>osgi:install -s mvn:org.jclouds.examples/blobstore-karaf-shell/1.0-SNAPSHOT - -Once the sample is install, create a new configuration named "org.jclouds.blobstore" and add the provider,the access key id and the secret key. - -karaf@root>config:edit org.jclouds.blobstore - -karaf@root>config:propset provider aws-s3 - -karaf@root>config:propset accessKeyId XXXXXX - -karaf@root>config:propset secretKey XXXXXX - -karaf@root>config:update - -An alternative is to create a cfg file with the key values listed above and throw it under karaf/etc. - -Now you can use the shell commands, for example: -karaf@root>jclouds:blobstore-write mybucket myblob JCloudsRocks! -karaf@root>jclouds:blobstore-read mybucket myblob -JCloudsRocks! - -## License - -Copyright (C) 2009-2014 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 diff --git a/blobstore-karaf-shell/pom.xml b/blobstore-karaf-shell/pom.xml deleted file mode 100644 index 6240132f..00000000 --- a/blobstore-karaf-shell/pom.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - 4.0.0 - - org.jclouds.examples - blobstore-karaf-shell - 1.0-SNAPSHOT - blobstore-karaf-shell - bundle - jclouds karaf example that uses a blobstore from the karaf shell - - - - !org.jclouds.examples*, - org.apache.felix.gogo*;version="[0.5,1)", - org.apache.karaf*;version="[2.1,4)", - org.jclouds*;version="[1.0,2)", - * - - org.jclouds.examples* - - - - - - org.apache.felix - maven-bundle-plugin - 2.3.4 - true - true - - - ${project.name} - ${project.artifactId} - ${osgi.export} - ${osgi.import} - ${osgi.dynamic.import} - ${osgi.private} - ${osgi.bundles} - ${osgi.activator} - - - jar - war - bundle - - true - - - - bundle-manifest - process-classes - - manifest - - - - - - - - - - - org.osgi - org.osgi.core - 4.2.0 - - - org.osgi - org.osgi.compendium - 4.2.0 - - - - - org.apache.karaf.shell - org.apache.karaf.shell.console - 2.2.5 - - - - org.jclouds - jclouds-blobstore - 1.5.0-alpha.6 - - - org.jclouds - jclouds-allblobstore - 1.5.0-alpha.6 - - - - diff --git a/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/BlobStoreService.java b/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/BlobStoreService.java deleted file mode 100644 index 76511aab..00000000 --- a/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/BlobStoreService.java +++ /dev/null @@ -1,39 +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.blobstore.osgi; - -import java.io.IOException; - -public interface BlobStoreService { - - /** - * Reads an Object from the Blob Store. - * @param bucket - * @param blobName - * @return - */ - Object read(String bucket, String blobName); - - /** - * Writes an {@link Object} to the Blob Store. - * @param bucket - * @param blobName - * @param object - */ - void write(String bucket, String blobName, Object object) throws IOException; - -} diff --git a/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/BlobStoreServiceImpl.java b/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/BlobStoreServiceImpl.java deleted file mode 100644 index ad69d647..00000000 --- a/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/BlobStoreServiceImpl.java +++ /dev/null @@ -1,144 +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.blobstore.osgi; - -import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextFactory; -import org.jclouds.blobstore.domain.Blob; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; - - -public class BlobStoreServiceImpl implements BlobStoreService { - - private static final Logger logger = LoggerFactory.getLogger(BlobStoreServiceImpl.class); - - private String accessKeyId; - private String secretKey; - private String provider; - - private BlobStoreContext context; - - /** - * Constructor - */ - public BlobStoreServiceImpl() { - - } - - public Object read(String bucket, String blobName) { - Object result = null; - ObjectInputStream ois = null; - context = new BlobStoreContextFactory().createContext(provider, accessKeyId, secretKey); - if (context != null) { - BlobStore blobStore = context.getBlobStore(); - blobStore.createContainerInLocation(null, bucket); - - InputStream is = blobStore.getBlob(bucket, blobName).getPayload().getInput(); - - try { - ois = new ObjectInputStream(is); - result = ois.readObject(); - } catch (IOException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } finally { - if (ois != null) { - try { - ois.close(); - } catch (IOException e) { - } - } - - if (is != null) { - try { - is.close(); - } catch (IOException e) { - } - } - } - } else logger.warn("Blob store context is null."); - return result; - } - - - public void write(String bucket, String blobName, Object object) { - context = new BlobStoreContextFactory().createContext(provider, accessKeyId, secretKey); - if (context != null) { - BlobStore blobStore = context.getBlobStore(); - Blob blob = blobStore.blobBuilder(blobName).build(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = null; - - try { - oos = new ObjectOutputStream(baos); - oos.writeObject(object); - blob.setPayload(baos.toByteArray()); - blobStore.putBlob(bucket, blob); - } catch (IOException e) { - logger.error("Error while writing blob", e); - } finally { - if (oos != null) { - try { - oos.close(); - } catch (IOException e) { - } - } - - if (baos != null) { - try { - baos.close(); - } catch (IOException e) { - } - } - } - } else logger.warn("Blob store context is null."); - } - - public String getSecretKey() { - return secretKey; - } - - public void setSecretKey(String secretKey) { - this.secretKey = secretKey; - } - - public String getAccessKeyId() { - return accessKeyId; - } - - public void setAccessKeyId(String accessKeyId) { - this.accessKeyId = accessKeyId; - } - - public String getProvider() { - return provider; - } - - public void setProvider(String provider) { - this.provider = provider; - } -} diff --git a/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/shell/BlobStoreCommandSupport.java b/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/shell/BlobStoreCommandSupport.java deleted file mode 100644 index c7a95a54..00000000 --- a/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/shell/BlobStoreCommandSupport.java +++ /dev/null @@ -1,33 +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.blobstore.osgi.shell; - -import org.apache.karaf.shell.console.OsgiCommandSupport; -import org.jclouds.examples.blobstore.osgi.BlobStoreService; - -public abstract class BlobStoreCommandSupport extends OsgiCommandSupport { - - protected BlobStoreService blobStoreService; - - public BlobStoreService getBlobStoreService() { - return blobStoreService; - } - - public void setBlobStoreService(BlobStoreService service) { - this.blobStoreService = service; - } -} diff --git a/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/shell/ReadCommand.java b/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/shell/ReadCommand.java deleted file mode 100644 index 95ad449c..00000000 --- a/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/shell/ReadCommand.java +++ /dev/null @@ -1,41 +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.blobstore.osgi.shell; - -import org.apache.felix.gogo.commands.Argument; -import org.apache.felix.gogo.commands.Command; - -@Command(scope = "jclouds", name = "blobstore-read", description = "Reads data from the blobstore") -public class ReadCommand extends BlobStoreCommandSupport { - - @Argument(index = 0, name = "bucketName", description = "The name of the bucket", required = true, multiValued = false) - String bucketName; - - @Argument(index = 1, name = "blobName", description = "The name of the blob", required = true, multiValued = false) - String blobName; - - @Override - protected Object doExecute() throws Exception { - if(blobStoreService != null) { - Object payload = blobStoreService.read(bucketName, blobName); - System.out.printf("%s\n", payload); - } else { - System.err.println("No blob store service configured."); - } - return null; - } -} diff --git a/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/shell/WriteCommand.java b/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/shell/WriteCommand.java deleted file mode 100644 index de121083..00000000 --- a/blobstore-karaf-shell/src/main/java/org/jclouds/examples/blobstore/osgi/shell/WriteCommand.java +++ /dev/null @@ -1,44 +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.blobstore.osgi.shell; - -import org.apache.felix.gogo.commands.Argument; -import org.apache.felix.gogo.commands.Command; - -@Command(scope = "jclouds", name = "blobstore-write", description = "Writes data from the blobstore") -public class WriteCommand extends BlobStoreCommandSupport { - - @Argument(index = 0, name = "bucketName", description = "The name of the bucket", required = true, multiValued = false) - String bucketName; - - @Argument(index = 1, name = "blobName", description = "The name of the blob", required = true, multiValued = false) - String blobName; - - @Argument(index = 2, name = "payload", description = "The payload", required = true, multiValued = false) - String payload; - - - @Override - protected Object doExecute() throws Exception { - if(blobStoreService != null) { - blobStoreService.write(bucketName,blobName,payload); - } else { - System.err.println("No blob store service configured."); - } - return null; - } -} diff --git a/blobstore-karaf-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/blobstore-karaf-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml deleted file mode 100644 index 8d6519cd..00000000 --- a/blobstore-karaf-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blobstore-largeblob/pom.xml b/blobstore-largeblob/pom.xml index eef23e8c..068f584e 100644 --- a/blobstore-largeblob/pom.xml +++ b/blobstore-largeblob/pom.xml @@ -22,12 +22,12 @@ 4.0.0 org.apache.jclouds.examples blobstore-largeblob - 1.8.0 + 2.1.0 blobstore-largeblob jclouds blobstore example that creates a container, then uploads a large file using parallel multipart upload - 1.9.0 + 2.1.0 diff --git a/blobstore-scala-filesystem/README.md b/blobstore-scala-filesystem/README.md deleted file mode 100644 index 25b34e19..00000000 --- a/blobstore-scala-filesystem/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# blobstore-scala-filesystem - -This is a simple example command line client that creates a container and test blob in a filesystem [BlobStore](http://jclouds.apache.org/start/blobstore/) using Scala. This example uses [scala-arm](https://github.com/jsuereth/scala-arm) to manage the [BlobStoreContext](http://javadocs.jclouds.cloudbees.net/org/jclouds/blobstore/BlobStoreContext.html) - -## Build - -Ensure that [sbt is installed](http://www.scala-sbt.org/release/docs/Getting-Started/Setup.html). Tested with 0.12.2 - -## Run - -Run `sbt` from the root of your project and invoke -``` -run -``` -where basedir is a directory in which the container will be created. E.g. if your basedir is `/home/blobstore` and you want to store _myblob_ in _mycontainer_, run -``` -run /home/blobstore mycontainer myblob -``` - -## License - -Copyright (C) 2009-2014 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 diff --git a/blobstore-scala-filesystem/build.sbt b/blobstore-scala-filesystem/build.sbt deleted file mode 100644 index c5a5c9f8..00000000 --- a/blobstore-scala-filesystem/build.sbt +++ /dev/null @@ -1,25 +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. - -name := "blobstore-scala-filesystem" - -scalaVersion := "2.10.2" - -version := "1.0-SNAPSHOT" - -libraryDependencies ++= Seq( "org.apache.jclouds.api" % "filesystem" % "1.6.1-incubating", - "com.google.code.findbugs" % "jsr305" % "1.3.+", - "com.jsuereth" %% "scala-arm" % "1.3" - ) diff --git a/blobstore-scala-filesystem/src/main/scala/Main.scala b/blobstore-scala-filesystem/src/main/scala/Main.scala deleted file mode 100644 index d8222fbf..00000000 --- a/blobstore-scala-filesystem/src/main/scala/Main.scala +++ /dev/null @@ -1,56 +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 org.jclouds.blobstore.BlobStoreContext -import org.jclouds.ContextBuilder -import org.jclouds.filesystem.reference.FilesystemConstants -import resource._ - -/** - * Demonstrates the use of the filesystem [[org.jclouds.blobstore.BlobStore]] in Scala - * - * Usage is: run <basedir> <containername> <blobname> - * - * @author adisesha - */ -object Main extends App { - require(args.length == 3, "Invalid number of parameters. Usage: run ") - - val basedir = args(0) - val containerName = args(1) - val blobname = args(2) - - val properties = new java.util.Properties() - properties.setProperty(FilesystemConstants.PROPERTY_BASEDIR, basedir) - - //Using scala-arm for context management. See https://github.com/jsuereth/scala-arm - managed(ContextBuilder.newBuilder("filesystem") - .overrides(properties) - .buildView(classOf[BlobStoreContext])) - .acquireAndGet(context => { - - val blobStore = context.getBlobStore - blobStore.createContainerInLocation(null, containerName) - - val blob = blobStore.blobBuilder(blobname).payload("testdata").build() - blobStore.putBlob(containerName, blob) - - val filePath = basedir + System.getProperty("file.separator") + containerName - println(s"Blob '$blobname' stored under '$filePath'") - }) -} diff --git a/blobstore-uploader/dependency-reduced-pom.xml b/blobstore-uploader/dependency-reduced-pom.xml index 2b3c3c64..2a895db8 100644 --- a/blobstore-uploader/dependency-reduced-pom.xml +++ b/blobstore-uploader/dependency-reduced-pom.xml @@ -1,55 +1,37 @@ - - - - 4.0.0 - blobstore-uploader - blob-uploader - 1.0-SNAPSHOT - - - - maven-shade-plugin - - - package - - shade - - - blobstore-uploader - - - - org.jclouds.examples.blobstore.BlobUploaderMain - 1 - - - - - - - - - - - 1.8.1 - - - + + + 4.0.0 + blobstore-uploader + blob-uploader + 2.1.0 + + + + maven-shade-plugin + + + package + + shade + + + blobstore-uploader + + + + org.jclouds.examples.blobstore.BlobUploaderMain + 1 + + + + + + + + + + + 2.1.0 + + + diff --git a/blobstore-uploader/pom.xml b/blobstore-uploader/pom.xml index d750210a..57f70141 100644 --- a/blobstore-uploader/pom.xml +++ b/blobstore-uploader/pom.xml @@ -24,11 +24,10 @@ blobstore-uploader blob-uploader - 1.0-SNAPSHOT - + 2.1.0 - 1.9.2 + 2.1.0 diff --git a/camel-notifications/Readme.txt b/camel-notifications/Readme.txt deleted file mode 100644 index 9eeefeea..00000000 --- a/camel-notifications/Readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Camel Notifier - -This simple examples demonstrates using Apache Camel with jclouds. -It starts a camel route which polls the cloud provider for running nodes. -If the clouds provider gives a possitive response it sends an email to the user notifying him, that there are nodes running. - -# Setup -The following properties need to be added the maven profile or to the project pom: - -jclouds.provider (ex. aws-ec2, hpcloud-compute, bluelock-vcloud-zone01) -jclouds.identity (ex. accesskey, tenant:accesskey, user@org) -jclouds.credential (ex. secretkey, password) - -smtp.username -smtp.password -smtp.server - -email.from (your email address) -email.to (who this is being sent to) - -# Running the sample - -from the command line just type: mvn camel:run diff --git a/camel-notifications/pom.xml b/camel-notifications/pom.xml deleted file mode 100644 index 203986f1..00000000 --- a/camel-notifications/pom.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - - - 4.0.0 - - org.jclouds.examples - camel-notifications - 1.0.1 - jar - jclouds camel example that uses a camel routes for sending email notifications, of the node states - - - jclouds Camel Notifier - - - 2.9.0 - 1.6.0 - - - - - - - org.apache.camel - camel-core - ${camel.version} - - - org.apache.camel - camel-spring - ${camel.version} - - - - org.apache.camel - camel-quartz - ${camel.version} - - - - org.apache.camel - camel-jclouds - ${camel.version} - - - - org.apache.camel - camel-mail - ${camel.version} - - - - org.apache.camel - camel-groovy - ${camel.version} - - - - - org.jclouds.driver - jclouds-slf4j - ${jclouds.version} - - - - org.jclouds - jclouds-compute - ${jclouds.version} - - - - org.jclouds - jclouds-allcompute - ${jclouds.version} - - - - - ch.qos.logback - logback-classic - 1.0.0 - - - - - install - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - - copy-resources - validate - - copy-resources - - - ${project.basedir}/target/classes - - - src/main/resources - true - - ** - - - - - - - - - - - org.apache.camel - camel-maven-plugin - ${camel.version} - - - - diff --git a/camel-notifications/src/main/resources/META-INF/spring/camel-context.xml b/camel-notifications/src/main/resources/META-INF/spring/camel-context.xml deleted file mode 100644 index d52a6946..00000000 --- a/camel-notifications/src/main/resources/META-INF/spring/camel-context.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - ${email.to} - - - ${email.from} - - - Running nodes in the cloud - - - ${body.size} != 0 - - request.body.collect { it.id } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.jclouds.compute.ComputeServiceContext - - - - - - diff --git a/camel-notifications/src/main/resources/logback.xml b/camel-notifications/src/main/resources/logback.xml deleted file mode 100644 index a7b2c962..00000000 --- a/camel-notifications/src/main/resources/logback.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - %msg%n - - - - - - - - - - diff --git a/camel-notifications/src/main/resources/org/jclouds/camel/notifier/camel.properties b/camel-notifications/src/main/resources/org/jclouds/camel/notifier/camel.properties deleted file mode 100644 index 22c754c2..00000000 --- a/camel-notifications/src/main/resources/org/jclouds/camel/notifier/camel.properties +++ /dev/null @@ -1,25 +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. -# - -jclouds.provider=${jclouds.provider} -jclouds.identity=${jclouds.identity} -jclouds.credential=${jclouds.credential} -smtp.username=${smtp.username} -smtp.server=${smtp.server} -smtp.password=${smtp.password} -email.from=${email.from} -email.to=${email.to} diff --git a/chef-basics/pom.xml b/chef-basics/pom.xml index 39853dc6..49fec29c 100644 --- a/chef-basics/pom.xml +++ b/chef-basics/pom.xml @@ -22,12 +22,12 @@ 4.0.0 org.apache.jclouds.examples chef-basics - 2.0.0 + 2.1.0 chef-basics jclouds chef example that adds a node to a group, then installs an Apache web server on all nodes - 2.0.0 + 2.1.0 diff --git a/cloudwatch-basics/README.md b/cloudwatch-basics/README.md deleted file mode 100755 index aa4a8b22..00000000 --- a/cloudwatch-basics/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# cloudwatch-basics - -This is a simple example command line client to get the total metrics stored for each of your instances the past 24 hours and shows avg/max/min CPU utilization for each instance when possible. - -## Build - -Ensure you have maven 3.02 or higher installed, then execute 'mvn install' to build the example. - -## Run - -Invoke the jar, passing your aws credentials. Here is an example: - -java -jar target/cloudwatch-basics-jar-with-dependencies.jar accessKeyId secretKey - -## License - -Copyright (C) 2009-2014 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 diff --git a/cloudwatch-basics/pom.xml b/cloudwatch-basics/pom.xml deleted file mode 100644 index 45a302ff..00000000 --- a/cloudwatch-basics/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - 4.0.0 - org.jclouds.examples - cloudwatch-basics - 1.0-SNAPSHOT - cloudwatch-basics - jclouds cloudwatch example - - - - org.jclouds.provider - aws-ec2 - 1.5.0-beta.3 - - - org.jclouds.provider - aws-cloudwatch - 1.5.0-beta.3 - - - - - ${project.artifactId} - - - - org.apache.maven.plugins - maven-jar-plugin - - - - org.jclouds.examples.cloudwatch.basics.MainApp - - - - - - - maven-assembly-plugin - 2.2.1 - - - src/main/assembly/jar-with-dependencies.xml - - - - org.jclouds.examples.cloudwatch.basics.MainApp - - - - - - make-assembly - package - - single - - - - - - - - - diff --git a/cloudwatch-basics/src/main/assembly/jar-with-dependencies.xml b/cloudwatch-basics/src/main/assembly/jar-with-dependencies.xml deleted file mode 100644 index aaa208c1..00000000 --- a/cloudwatch-basics/src/main/assembly/jar-with-dependencies.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - jar-with-dependencies - - jar - - false - - - metaInf-services - - - - - / - true - true - runtime - - - \ No newline at end of file diff --git a/cloudwatch-basics/src/main/java/org/jclouds/examples/cloudwatch/basics/MainApp.java b/cloudwatch-basics/src/main/java/org/jclouds/examples/cloudwatch/basics/MainApp.java deleted file mode 100644 index 06942798..00000000 --- a/cloudwatch-basics/src/main/java/org/jclouds/examples/cloudwatch/basics/MainApp.java +++ /dev/null @@ -1,245 +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.cloudwatch.basics; - -import com.google.common.collect.Iterators; -import org.jclouds.ContextBuilder; -import org.jclouds.aws.cloudwatch.AWSCloudWatchProviderMetadata; -import org.jclouds.aws.ec2.AWSEC2ProviderMetadata; -import org.jclouds.cloudwatch.CloudWatch; -import org.jclouds.cloudwatch.CloudWatchAsyncClient; -import org.jclouds.cloudwatch.CloudWatchClient; -import org.jclouds.cloudwatch.domain.Datapoint; -import org.jclouds.cloudwatch.domain.Dimension; -import org.jclouds.cloudwatch.domain.EC2Constants; -import org.jclouds.cloudwatch.domain.GetMetricStatistics; -import org.jclouds.cloudwatch.domain.GetMetricStatisticsResponse; -import org.jclouds.cloudwatch.domain.Namespaces; -import org.jclouds.cloudwatch.domain.Statistics; -import org.jclouds.cloudwatch.domain.Unit; -import org.jclouds.cloudwatch.features.MetricClient; -import org.jclouds.cloudwatch.options.ListMetricsOptions; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.domain.ComputeMetadata; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationScope; -import org.jclouds.rest.RestContext; - -import java.text.DecimalFormat; -import java.util.Date; -import java.util.Iterator; -import java.util.Set; - -/** - * Demonstrates the use of {@link org.jclouds.cloudwatch.features.MetricClient}. - */ -public class MainApp { - - public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: accesskeyid secretkey"; - public static int PARAMETERS = 2; - - public static void main(String[] args) { - - if (args.length < PARAMETERS) { - throw new IllegalArgumentException(INVALID_SYNTAX); - } - - // Arguments - String accessKeyId = args[0]; - String secretKey = args[1]; - - ComputeServiceContext awsEC2Context = null; - RestContext cloudWatchContext = null; - - try { - cloudWatchContext = ContextBuilder.newBuilder(new AWSCloudWatchProviderMetadata()) - .credentials(accessKeyId, secretKey) - .build(); - awsEC2Context = ContextBuilder.newBuilder(new AWSEC2ProviderMetadata()) - .credentials(accessKeyId, secretKey) - .build(ComputeServiceContext.class); - - // Get all nodes - Set allNodes = awsEC2Context.getComputeService().listNodes(); - - for (ComputeMetadata node : allNodes) { - String nodeId = node.getProviderId(); - String region = getRegion(node.getLocation()); - MetricClient metricClient = cloudWatchContext.getApi().getMetricClientForRegion(region); - int metricsCount = getMetricsCountForInstance(cloudWatchContext.getApi(), region, nodeId); - double[] cpuUtilization = getCPUUtilizationStatsForInstanceOverTheLast24Hours(metricClient, nodeId); - String cpuUtilizationHeader = " CPU utilization statistics: "; - DecimalFormat df = new DecimalFormat("#.##"); - - System.out.println(nodeId + " CloudWatch Metrics (Past 24 hours)"); - System.out.println(" Total metrics stored: " + metricsCount); - - if (cpuUtilization == null) { - System.out.println(cpuUtilizationHeader + "Unable to compute as there are no CPU utilization " + - "metrics stored."); - } else { - System.out.println(cpuUtilizationHeader + - df.format(cpuUtilization[0]) + "% (avg), " + - df.format(cpuUtilization[1]) + "% (max), " + - df.format(cpuUtilization[2]) + "% (min)"); - } - } - } finally { - if (awsEC2Context != null) { - awsEC2Context.close(); - } - if (cloudWatchContext != null) { - cloudWatchContext.close(); - } - } - - } - - /** - * Returns the count of metrics stored for the given nodeId and region. - * - * @param cloudWatchClient the cloud watch client (Will use MetricsClient when Issue 922 is fixed) - * @param region the region the instance is in - * @param nodeId the instance id - * - * @return the total count of metrics stored for the given instance id and region - */ - private static int getMetricsCountForInstance(CloudWatchClient cloudWatchClient, String region, String nodeId) { - // Uses CloudWatchClient+region instead of MetricsClient because the pagination helper only works with - // CloudWatchClient: http://code.google.com/p/jclouds/issues/detail?id=922 - return Iterators.size(CloudWatch.listMetrics(cloudWatchClient, - region, - ListMetricsOptions.builder() - // Only return metrics for the given instance - .dimension(new Dimension( - EC2Constants.Dimension.INSTANCE_ID, - nodeId)) - .build()).iterator()); - } - - /** - * Return an array of doubles with the CPUUtilization {@link EC2Constants.MetricName#CPU_UTILIZATION} - * average, maximum and minimum values in respective order over the last 24 hours. - * - * @param metricClient the {@link MetricClient} to use - * @param nodeId the instance id whose CPUUtilization statistics we're intersted in calculating - * - * @return the array of doubles describe above or null if there are no CPUUtilization metrics stored for the given - * instance id over the past 24 hours - */ - private static double[] getCPUUtilizationStatsForInstanceOverTheLast24Hours(MetricClient metricClient, - String nodeId) { - - Dimension instanceIdDimension = new Dimension(EC2Constants.Dimension.INSTANCE_ID, nodeId); - ListMetricsOptions lmOptions = ListMetricsOptions.builder() - // Only return metrics if they are CPUUtilization - .metricName(EC2Constants.MetricName.CPU_UTILIZATION) - // Only return metrics for the AWS/EC2 namespace - .namespace(Namespaces.EC2) - // Only return metrics for the given instance - .dimension(instanceIdDimension) - .build(); - - // Return null to indicate there are no CPUUtilization metrics stored for the given node id - if (Iterators.size(metricClient.listMetrics(lmOptions).iterator()) == 0) { - return null; - } - - Date endDate = new Date(); // Now - Date startDate = new Date(endDate.getTime() - (1000 * 60 * 60 * 24)); // One day ago - GetMetricStatistics statistics = GetMetricStatistics.builder() - // Specify the instance id you're interested in - .dimension(instanceIdDimension) - // Specify the metric name you're interested in - .metricName(EC2Constants.MetricName.CPU_UTILIZATION) - // Specify the namespace of the metric - .namespace(Namespaces.EC2) - // Populate the average statistic in the response - .statistic(Statistics.AVERAGE) - // Populate the maximum statistic in the response - .statistic(Statistics.MAXIMUM) - // Populate the minimum statistic in the response - .statistic(Statistics.MINIMUM) - // Specify the start time for the metric statistics you want - .startTime(startDate) - // Specify the end time for the metric statistics you want - .endTime(endDate) - // Specify the metric statistic granularity - .period(3600) - // Specify the unit the metric values should be in - .unit(Unit.PERCENT) - .build(); - GetMetricStatisticsResponse statisticsResponse = metricClient.getMetricStatistics(statistics); - double avg = 0d; - double max = 0d; - double min = 0d; - Iterator datapointIterator = statisticsResponse.iterator(); - - while(datapointIterator.hasNext()) { - Datapoint datapoint = datapointIterator.next(); - Double dAvg = datapoint.getAverage(); - Double dMax = datapoint.getMaximum(); - Double dMin = datapoint.getMinimum(); - - if (dAvg != null) { - avg = ((avg + dAvg) / 2); - } - if (dMax != null) { - if (dMax > max) { - max = dMax; - } - } - if (dMin != null) { - if (dMin < min) { - min = dMin; - } - } - } - - return new double[]{avg, max, min}; - - } - - /** - * Returns the region as string for the given {@link Location}. - * - * @param location the location - * - * @return the region or null if the region cannot be found - */ - private static String getRegion(Location location) { - - // Just to be safe - if (location == null) { - return null; - } - - String region = null; - while(region == null && location.getParent() != null) { - if (location.getScope() == LocationScope.REGION) { - region = location.getId(); - } else { - location = location.getParent(); - } - } - return region; - - } - -} diff --git a/compute-basics/pom.xml b/compute-basics/pom.xml index f814b6f9..088eb88e 100644 --- a/compute-basics/pom.xml +++ b/compute-basics/pom.xml @@ -22,12 +22,12 @@ 4.0.0 org.apache.jclouds.examples compute-basics - 2.0.0 + 2.1.0 compute-basics jclouds compute example that adds a node to a group, then executes "echo hello" on all nodes - 2.0.0 + 2.1.0 diff --git a/compute-clojure/README.md b/compute-clojure/README.md deleted file mode 100644 index 0372b449..00000000 --- a/compute-clojure/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# compute-clojure - -Basic usage of org.jclouds.compute2 to create a node, execute commands and destroy the node. The example below uses Amazon EC2 as provider. - -## Build - -Ensure you have [Leiningen](http://github.com/technomancy/leiningen) installed, then execute 'lein deps' to grab the jclouds dependencies. - -## Run - - bash$ lein repl - user> (use 'org.jclouds.compute2) - user> (use 'compute-clojure.compute-examples) - user> (def compute (compute-service "aws-ec2" "AMAZON-IDENTITY" "AMAZON-CREDENTIAL" :slf4j :sshj)) - user> (create compute "example-node-group") - user> (exec compute "echo hello" "example-node-group" (get-credentials)) - user> (destroy compute "example-node-group") - -## License - -Copyright (C) 2009-2014 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 diff --git a/compute-clojure/resources/logback.xml b/compute-clojure/resources/logback.xml deleted file mode 100644 index 46429a60..00000000 --- a/compute-clojure/resources/logback.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %msg%n - - - - - - - - - diff --git a/deploy-war-via-ant/README.md b/deploy-war-via-ant/README.md deleted file mode 100755 index 01286011..00000000 --- a/deploy-war-via-ant/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# deploy-war-via-ant - -This example uses the jclouds [ComputeService](http://code.google.com/p/jclouds/wiki/ComputeGuide) ant plugin to create a new virtual machine (node) and the [Cargo](http://cargo.codehaus.org/) plugin to deploy the web application. - -## Setup - -Ensure you have Ant 1.7.1 installed and in your path. Ex. - - wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.7.1-bin.zip - - jar -xf apache-ant-1.7.1-bin.zip - - chmod 755 apache-ant-1.7.1/bin/* - - export PATH=apache-ant-1.7.1/bin:$PATH - - -Ensure you have jsch 0.1.42 is in $ANT_HOME/lib. Ex. - - cd apache-ant-1.7.1/lib - - wget https://sourceforge.net/projects/jsch/files/jsch/jsch-0.1.42.jar - -## Run - -### Deploying to localhost -Invoke 'ant justplaincargo' and this should deploy the webapp to http://localhost:8080/sample - -### Deploying to the cloud -Invoke 'ant' and supply parameters when asked, or as system properties. - -= provider - cloud you want to deploy to (ex. aws-ec2, cloudservers-us) - -= identity - your account on the cloud provider (ex. accesskey, username) - -= credential - your password on that account (ex. secretkey, password) - -= group - what to name the node that runs your webapp (ex. cargo-webapp) - -Ex. for Bluelock - -ant -Dprovider=bluelock-vcdirector -Didentity=my@domain.com -Dcredential=password -Dgroup=cargo-webapp - -Ex. for Amazon EC2 - -ant -Dprovider=aws-ec2 -Didentity=accesskey -Dcredential=secretkey -Dgroup=cargo-webapp - - -Note that you should run 'ant destroy' to cleanup cloud nodes after you are finished. - -## License - -Copyright (C) 2009-2014 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 diff --git a/deploy-war-via-ant/build.xml b/deploy-war-via-ant/build.xml deleted file mode 100644 index 3871956b..00000000 --- a/deploy-war-via-ant/build.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/deploy-war-via-ant/runscript.sh b/deploy-war-via-ant/runscript.sh deleted file mode 100644 index 58d29825..00000000 --- a/deploy-war-via-ant/runscript.sh +++ /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. -# - -echo nameserver 208.67.222.222 >> /etc/resolv.conf -apt-get update -qq -apt-get upgrade -y -qq -apt-get install -y -qq wget -apt-get install -y -qq openjdk-6-jdk -wget -q http://mirrors.axint.net/apache/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.tar.gz -tar xzf apache-tomcat-6.0.32.tar.gz -mkdir -p /tmp/cargo/containers -chmod 1777 /tmp/cargo -mv apache-tomcat-6.0.32 /tmp/cargo/containers/tomcat6x diff --git a/ec2-computeservice-spot/README.md b/ec2-computeservice-spot/README.md deleted file mode 100755 index 994ebb9f..00000000 --- a/ec2-computeservice-spot/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# ec2-computeservice-spot - -This is a simple example command line client that creates a spot instance in [EC2](http://code.google.com/p/jclouds/wiki/EC2) using the ComputeService interface. - -## Build - -Ensure you have maven 3.02 or higher installed, then execute 'mvn install' to build the sample. - -Note you'll also need to ensure you have an ssh key in your home directory. - -## Run - -Invoke the jar, passing your aws credentials and the name you wish to create or destroy - -### Creating your Instance - -The create command will create a keypair, security group, and an instance in running state. - -java -jar target/ec2-computeservice-spot-jar-with-dependencies.jar accesskey secretkey groupname create - -### Destroying your Instance - -The destroy command will clear up the instance, key, and security group. - -java -jar target/ec2-computeservice-spot-jar-with-dependencies.jar accesskey secretkey groupname destroy - -## License - -Copyright (C) 2009-2014 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 diff --git a/ec2-computeservice-spot/pom.xml b/ec2-computeservice-spot/pom.xml deleted file mode 100644 index 4a2be310..00000000 --- a/ec2-computeservice-spot/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - 4.0.0 - org.jclouds.examples - ec2-computeservice-spot - 1.0.0 - ec2-computeservice-spot - jclouds ec2 example that creates a spot instance using the ComputeService - - - - org.jclouds.provider - aws-ec2 - 1.1.0 - - - - - ${project.artifactId} - - - - org.apache.maven.plugins - maven-jar-plugin - - - - org.jclouds.examples.ec2.spot.MainApp - - - - - - - maven-assembly-plugin - - - jar-with-dependencies - - - - org.jclouds.examples.ec2.spot.MainApp - - - - - - make-assembly - package - - single - - - - - - - - - diff --git a/ec2-computeservice-spot/src/main/java/org/jclouds/examples/ec2/spot/MainApp.java b/ec2-computeservice-spot/src/main/java/org/jclouds/examples/ec2/spot/MainApp.java deleted file mode 100755 index bf8b5481..00000000 --- a/ec2-computeservice-spot/src/main/java/org/jclouds/examples/ec2/spot/MainApp.java +++ /dev/null @@ -1,119 +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.spot; - -import java.io.File; -import java.io.IOException; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.compute.RunNodesException; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.predicates.NodePredicates; -import org.jclouds.net.IPSocket; -import org.jclouds.predicates.InetSocketAddressConnect; -import org.jclouds.predicates.RetryablePredicate; - -import com.google.common.base.Charsets; -import com.google.common.collect.Iterables; -import com.google.common.io.Files; - -/** - * This the Main class of an Application that demonstrates the use of the Amazon EC2 extensions by - * creating a small spot server. - * - * Usage is: java MainApp accesskeyid secretkey group command where command in create destroy - */ -public class MainApp { - - public static int PARAMETERS = 4; - public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: accesskeyid secretkey group command\nwhere command in create destroy"; - - public static void main(String[] args) { - - if (args.length < PARAMETERS) - throw new IllegalArgumentException(INVALID_SYNTAX); - - // Args - String accesskeyid = args[0]; - String secretkey = args[1]; - String group = args[2]; - String command = args[3]; - - // Init - ComputeService compute = new ComputeServiceContextFactory().createContext("aws-ec2", accesskeyid, secretkey) - .getComputeService(); - - // wait up to 60 seconds for ssh to be accessible - RetryablePredicate socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 60, - 1, 1, TimeUnit.SECONDS); - try { - if (command.equals("create")) { - - Template template = compute.templateBuilder().build(); - - template.getOptions().as(AWSEC2TemplateOptions.class) - // set the price as 3 cents/hr - .spotPrice(0.03f) - // authorize my ssh key - .authorizePublicKey( - Files.toString(new File(System.getProperty("user.home") + "/.ssh/id_rsa.pub"), - Charsets.UTF_8)); - - System.out.printf(">> running one spot node type(%s) with ami(%s) in group(%s)%n", template.getHardware() - .getProviderId(), template.getImage().getId(), group); - // run only a single node - NodeMetadata node = Iterables.getOnlyElement(compute.createNodesInGroup(group, 1, template)); - - System.out.printf("<< running node(%s)%n", node.getId()); - IPSocket socket = new IPSocket(Iterables.get(node.getPublicAddresses(), 0), node.getLoginPort()); - if (socketTester.apply(socket)) { - System.out.printf("<< socket ready [%s] node(%s)%n", socket, node.getId()); - System.out.printf("ssh to node with the following command:%n ssh %s@%s%n", - node.getCredentials().identity, socket.getAddress()); - System.exit(0); - } else { - System.out.printf("<< socket not ready [%s] node(%s)%n", socket, node.getId()); - } - } else if (command.equals("destroy")) { - System.out.printf(">> destroying nodes in group(%s)%n", group); - Set destroyed = compute.destroyNodesMatching(NodePredicates.inGroup(group)); - System.out.printf("<< destroyed(%d)%n", destroyed.size()); - System.exit(0); - } else { - System.err.println(INVALID_SYNTAX); - System.exit(1); - } - } catch (RunNodesException e) { - System.err.println(e.getMessage()); - for (NodeMetadata node : e.getNodeErrors().keySet()) - compute.destroyNode(node.getId()); - System.exit(1); - } catch (IOException e) { - System.err.println(e.getMessage()); - System.exit(1); - } finally { - compute.getContext().close(); - } - - } - -} diff --git a/ec2-createlamp/README.md b/ec2-createlamp/README.md deleted file mode 100755 index 943f7db8..00000000 --- a/ec2-createlamp/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# ec2-createlamp - -This is a simple example command line client that creates a lamp server and everything you need to do that in [EC2](http://code.google.com/p/jclouds/wiki/EC2) - -## Build - -Ensure you have maven 3.02 or higher installed, then execute 'mvn install' to build the sample. - -## Run - -Invoke the jar, passing your aws credentials and the name you wish to create or destroy - -### Creating your Instance - -The create command will create a keypair, security group, and an instance. It also blocks until the web server is running. - -java -jar target/ec2-createlamp-jar-with-dependencies.jar accesskey secretkey create adrianalmighty - -### Destroying your Instance - -The destroy command will clear up the instance, key, and security group. - -java -jar target/ec2-createlamp-jar-with-dependencies.jar accesskey secretkey destroy adrianalmighty - -## License - -Copyright (C) 2009-2014 The Apache Software Foundation - -Licensed under the Apache License, Version 2.0 diff --git a/ec2-createlamp/pom.xml b/ec2-createlamp/pom.xml deleted file mode 100644 index ab183429..00000000 --- a/ec2-createlamp/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - 4.0.0 - org.jclouds.examples - ec2-createlamp - 1.0.0 - ec2-createlamp - jclouds ec2 example that creates an instance and all you need to access it - - - - org.jclouds.provider - aws-ec2 - 1.5.0 - - - - ${project.artifactId} - - - - org.apache.maven.plugins - maven-jar-plugin - - - - org.jclouds.examples.ec2.createlamp.MainApp - - - - - - - maven-assembly-plugin - - - jar-with-dependencies - - - - org.jclouds.examples.ec2.createlamp.MainApp - - - - - - make-assembly - package - - single - - - - - - - - - diff --git a/ec2-createlamp/src/main/java/org/jclouds/examples/ec2/createlamp/MainApp.java b/ec2-createlamp/src/main/java/org/jclouds/examples/ec2/createlamp/MainApp.java deleted file mode 100755 index 6a947a15..00000000 --- a/ec2-createlamp/src/main/java/org/jclouds/examples/ec2/createlamp/MainApp.java +++ /dev/null @@ -1,234 +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.createlamp; - -import static org.jclouds.ec2.options.RunInstancesOptions.Builder.asType; -import static org.jclouds.scriptbuilder.domain.Statements.exec; - -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.jclouds.ContextBuilder; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.domain.InstanceState; -import org.jclouds.ec2.domain.InstanceType; -import org.jclouds.ec2.domain.IpProtocol; -import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.ec2.domain.Reservation; -import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.ec2.predicates.InstanceStateRunning; -import org.jclouds.predicates.InetSocketAddressConnect; -import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.rest.RestContext; -import org.jclouds.scriptbuilder.ScriptBuilder; -import org.jclouds.scriptbuilder.domain.OsFamily; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; -import com.google.common.net.HostAndPort; - -/** - * This the Main class of an Application that demonstrates the use of the EC2Client by creating a - * small lamp server. - * - * Usage is: java MainApp accesskeyid secretkey command name where command in create destroy - */ -public class MainApp { - - public static int PARAMETERS = 4; - public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: accesskeyid secretkey command name\nwhere command in create destroy"; - - public static void main(String[] args) throws TimeoutException { - - if (args.length < PARAMETERS) - throw new IllegalArgumentException(INVALID_SYNTAX); - - // Args - String accesskeyid = args[0]; - String secretkey = args[1]; - String command = args[2]; - String name = args[3]; - - // Init - RestContext context = ContextBuilder - .newBuilder("aws-ec2").credentials(accesskeyid, secretkey) - .build(); - - // Get a synchronous client - EC2Client client = context.getApi(); - - try { - if (command.equals("create")) { - - KeyPair pair = createKeyPair(client, name); - - RunningInstance instance = createSecurityGroupKeyPairAndInstance(client, name); - - System.out.printf("instance %s ready%n", instance.getId()); - System.out.printf("ip address: %s%n", instance.getIpAddress()); - System.out.printf("dns name: %s%n", instance.getDnsName()); - System.out.printf("login identity:%n%s%n", pair.getKeyMaterial()); - - } else if (command.equals("destroy")) { - destroySecurityGroupKeyPairAndInstance(client, name); - } else { - throw new IllegalArgumentException(INVALID_SYNTAX); - } - } finally { - // Close connecton - context.close(); - System.exit(0); - } - - } - - private static void destroySecurityGroupKeyPairAndInstance(EC2Client client, String name) { - try { - String id = findInstanceByKeyName(client, name).getId(); - System.out.printf("%d: %s terminating instance%n", System.currentTimeMillis(), id); - client.getInstanceServices().terminateInstancesInRegion(null, findInstanceByKeyName(client, name).getId()); - } catch (NoSuchElementException e) { - } catch (Exception e) { - e.printStackTrace(); - } - - try { - System.out.printf("%d: %s deleting keypair%n", System.currentTimeMillis(), name); - client.getKeyPairServices().deleteKeyPairInRegion(null, name); - } catch (Exception e) { - e.printStackTrace(); - } - - try { - System.out.printf("%d: %s deleting group%n", System.currentTimeMillis(), name); - client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, name); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static RunningInstance createSecurityGroupKeyPairAndInstance(EC2Client client, String name) - throws TimeoutException { - // create a new security group - createSecurityGroupAndAuthorizePorts(client, name); - - // create a new instance - RunningInstance instance = runInstance(client, name, name); - - // await for the instance to start - return blockUntilInstanceRunning(client, instance); - } - - static void createSecurityGroupAndAuthorizePorts(EC2Client client, String name) { - System.out.printf("%d: creating security group: %s%n", System.currentTimeMillis(), name); - client.getSecurityGroupServices().createSecurityGroupInRegion(null, name, name); - for (int port : new int[] { 80, 8080, 443, 22 }) { - client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null, name, IpProtocol.TCP, port, - port, "0.0.0.0/0"); - } - } - - static KeyPair createKeyPair(EC2Client client, String name) { - System.out.printf("%d: creating keypair: %s%n", System.currentTimeMillis(), name); - return client.getKeyPairServices().createKeyPairInRegion(null, name); - } - - static RunningInstance runInstance(EC2Client client, String securityGroupName, String keyPairName) { - String script = new ScriptBuilder() // lamp install script - .addStatement(exec("runurl run.alestic.com/apt/upgrade"))// - .addStatement(exec("runurl run.alestic.com/install/lamp"))// - .addStatement(exec("apt-get -y install openjdk-6-jdk"))// no license agreement! - .render(OsFamily.UNIX); - - System.out.printf("%d: running instance%n", System.currentTimeMillis()); - - Reservation reservation = client.getInstanceServices().runInstancesInRegion(null, - null, // allow ec2 to chose an availability zone - "ami-ccf615a5", // alestic ami allows auto-invoke of user data scripts - 1, // minimum instances - 1, // maximum instances - asType(InstanceType.M1_SMALL) // smallest instance size - .withKeyName(keyPairName) // key I created above - .withSecurityGroup(securityGroupName) // group I created above - .withUserData(script.getBytes())); // script to run as root - - return Iterables.getOnlyElement(reservation); - - } - - static RunningInstance blockUntilInstanceRunning(EC2Client client, RunningInstance instance) throws TimeoutException { - // create utilities that wait for the instance to finish - RetryablePredicate runningTester = new RetryablePredicate( - new InstanceStateRunning(client), 180, 5, TimeUnit.SECONDS); - - System.out.printf("%d: %s awaiting instance to run %n", System.currentTimeMillis(), instance.getId()); - if (!runningTester.apply(instance)) - throw new TimeoutException("timeout waiting for instance to run: " + instance.getId()); - - instance = findInstanceById(client, instance.getId()); - - RetryablePredicate socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 300, - 1, TimeUnit.SECONDS); - System.out.printf("%d: %s awaiting ssh service to start%n", System.currentTimeMillis(), instance.getIpAddress()); - if (!socketTester.apply(HostAndPort.fromParts(instance.getIpAddress(), 22))) - throw new TimeoutException("timeout waiting for ssh to start: " + instance.getIpAddress()); - - System.out.printf("%d: %s ssh service started%n", System.currentTimeMillis(), instance.getIpAddress()); - - System.out.printf("%d: %s awaiting http service to start%n", System.currentTimeMillis(), instance.getIpAddress()); - if (!socketTester.apply(HostAndPort.fromParts(instance.getIpAddress(), 80))) - throw new TimeoutException("timeout waiting for http to start: " + instance.getIpAddress()); - - System.out.printf("%d: %s http service started%n", System.currentTimeMillis(), instance.getIpAddress()); - return instance; - } - - private static RunningInstance findInstanceById(EC2Client client, String instanceId) { - // search my account for the instance I just created - Set> reservations = client.getInstanceServices() - .describeInstancesInRegion(null, instanceId); // last parameter (ids) narrows the - // search - - // since we refined by instanceId there should only be one instance - return Iterables.getOnlyElement(Iterables.getOnlyElement(reservations)); - } - - private static RunningInstance findInstanceByKeyName(EC2Client client, final String keyName) { - // search my account for the instance I just created - Set> reservations = client.getInstanceServices() - .describeInstancesInRegion(null); - - // extract all the instances from all reservations - Set allInstances = Sets.newHashSet(); - for (Reservation reservation : reservations) { - allInstances.addAll(reservation); - } - - // get the first one that has a keyname matching what I just created - return Iterables.find(allInstances, new Predicate() { - - public boolean apply(RunningInstance input) { - return input.getKeyName().equals(keyName) && input.getInstanceState() != InstanceState.TERMINATED; - } - - }); - } -} diff --git a/ec2-windows/README.md b/ec2-windows/README.md deleted file mode 100644 index f71fed7a..00000000 --- a/ec2-windows/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Amazon EC2 Windows example -This example demonstrates how to start a Windows Server instance on Amazon -EC2 and obtain its randomly-generated Administrator password. Once you have -this, you can log in to the server via RDP. - -## Usage -After building the example with `mvn assembly:assembly`, you can launch it like -this: - -``` -java -jar target/ec2-windows-jar-with-dependencies.jar --identity $AWS_API_KEY --credential $AWS_SECRET_KEY -``` - -Replace `$AWS_API_KEY` and `$AWS_SECRET_KEY` appropriately. - -The following optional arguments are recognized: - - * `--region ` - specify the EC2 region name to launch in - * `--instance-type ` - specify the EC2 instance type - defaults - to `m1.small` - * `--image-pattern ` - specify the pattern to select the image - - this defaults to a pattern that will match the base, English, version of - the current (or recent) Windows Server release. - -The example will start the Windows instance, wait for the encrypted password -to become available, and then decrypt it. It will display the public IP -address, user name (which is always Administrator) and password - you can -provide these to the Remote Desktop client and log in to the new instance. - -Once the instance is started, the example will wait for you to hit Enter on -the command line. After hitting Enter, the new instance will be shut down. diff --git a/ec2-windows/pom.xml b/ec2-windows/pom.xml deleted file mode 100644 index 2d2648a5..00000000 --- a/ec2-windows/pom.xml +++ /dev/null @@ -1,161 +0,0 @@ - - - - 4.0.0 - org.jclouds.examples - ec2-windows - 1.0-SNAPSHOT - ec2-windows - jclouds compute example starts a Windows node and returns the Administrator password - - - - org.jclouds - jclouds-compute - 1.5.0-beta.1 - - - org.jclouds.provider - aws-ec2 - 1.5.0-beta.1 - - - org.bouncycastle - bcprov-jdk16 - 1.46 - provided - - - org.jclouds.driver - jclouds-bouncycastle - 1.5.0-beta.1 - - - - org.bouncycastle - bcprov-jdk16 - - - - - org.jclouds.driver - jclouds-sshj - 1.5.0-beta.1 - - - org.jclouds.driver - jclouds-slf4j - 1.5.0-beta.1 - - - org.slf4j - slf4j-log4j12 - 1.6.1 - - - args4j - args4j - 2.0.16 - - - - ${project.artifactId} - - - maven-compiler-plugin - - ${project.build.sourceEncoding} - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-jar-plugin - - - - org.jclouds.examples.ec2.windows.MainApp - - - - - - maven-assembly-plugin - 2.2.1 - - - src/main/assembly/jar-with-dependencies.xml - - - - org.jclouds.examples.ec2.windows.MainApp - - - bcprov-jdk16.jar - - - - - - make-assembly - package - - single - - - - - - org.apache.maven.plugins - maven-dependency-plugin - 2.3 - - - copy - package - - copy - - - - - org.bouncycastle - bcprov-jdk16 - false - bcprov-jdk16.jar - - - ${project.build.directory} - false - true - - - - - - - - diff --git a/ec2-windows/src/main/assembly/jar-with-dependencies.xml b/ec2-windows/src/main/assembly/jar-with-dependencies.xml deleted file mode 100644 index 5857f6aa..00000000 --- a/ec2-windows/src/main/assembly/jar-with-dependencies.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - jar-with-dependencies - - jar - - false - - - metaInf-services - - - - - / - true - true - runtime - - - \ No newline at end of file diff --git a/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/Arguments.java b/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/Arguments.java deleted file mode 100644 index 70317a1e..00000000 --- a/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/Arguments.java +++ /dev/null @@ -1,92 +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 org.jclouds.ec2.domain.InstanceType; -import org.kohsuke.args4j.Option; - -/** - * A javabean that represents the application's command line arguments. - */ -public class Arguments { - private String identity; - private String credential; - private String region; - private static final String IMAGE_NAME_PATTERN_DEFAULT = "Windows_Server-2008-R2_SP1-English-64Bit-Base-"; - private String imageNamePattern = IMAGE_NAME_PATTERN_DEFAULT; - private static final String INSTANCE_TYPE_DEFAULT = InstanceType.M1_SMALL; - private String instanceType = INSTANCE_TYPE_DEFAULT; - private static final String AMI_OWNER_DEFAULT = "801119661308"; - private String amiOwner = AMI_OWNER_DEFAULT; - - public String getIdentity() { - return identity; - } - - public String getCredential() { - return credential; - } - - public String getRegion() { - return region; - } - - public String getImageNamePattern() { - return imageNamePattern; - } - - public String getInstanceType() { - return instanceType; - } - - public String getAmiOwner() { - return amiOwner; - } - - @Option(name = "--identity", aliases = "-i", required = true, usage = "your AWS access key ID") - public void setIdentity(String identity) { - this.identity = identity; - } - - @Option(name = "--credential", aliases = "-c", required = true, usage = "your AWS secret access key") - public void setCredential(String credential) { - this.credential = credential; - } - - @Option(name = "--region", aliases = "-r", required = true, usage = "AWS region name") - public void setRegion(String region) { - this.region = region; - } - - @Option(name = "--image-pattern", aliases = "-p", usage = "regular expression to select an AMI; default=" + IMAGE_NAME_PATTERN_DEFAULT) - public void setImageNamePattern(String imageNamePattern) { - this.imageNamePattern = imageNamePattern; - } - - @Option(name = "--instance-type", aliases = "-t", usage = "instance type; default=" + INSTANCE_TYPE_DEFAULT) - public void setInstanceType(String instanceType) { - this.instanceType = instanceType; - } - - @Option(name = "--ami-owner", aliases = "-o", usage = "AMI owner account ID; default=" + AMI_OWNER_DEFAULT) - public void setAmiOwner(String amiOwner) { - this.amiOwner = amiOwner; - } -} diff --git a/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/MainApp.java b/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/MainApp.java deleted file mode 100644 index 8aa200bd..00000000 --- a/ec2-windows/src/main/java/org/jclouds/examples/ec2/windows/MainApp.java +++ /dev/null @@ -1,109 +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.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; -import com.google.inject.Module; -import org.jclouds.ContextBuilder; -import org.jclouds.aws.ec2.reference.AWSEC2Constants; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.domain.Location; -import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule; -import org.jclouds.location.predicates.LocationPredicates; -import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; -import org.kohsuke.args4j.CmdLineException; -import org.kohsuke.args4j.CmdLineParser; - -import javax.annotation.Nullable; -import java.util.Properties; -import java.util.Set; - -/** - * The main application. This will parse and validate the command line - * arguments, initialize a jclouds context, and then jump to {@link - * WindowsInstanceStarter}. - */ -public class MainApp { - - private ComputeServiceContext context; - private ComputeService computeService; - private Arguments arguments; - - public MainApp(Arguments arguments) { - this.arguments = arguments; - } - - public static void main(String[] args) throws Exception { - Arguments arguments = new Arguments(); - CmdLineParser parser = new CmdLineParser(arguments); - try { - parser.parseArgument(args); - } catch (CmdLineException e) { - // handling of wrong arguments - System.err.println(e.getMessage()); - parser.printUsage(System.err); - System.exit(1); - } - new MainApp(arguments).run(); - } - - private void run() throws Exception { - Properties overrides = new Properties(); - overrides.put(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, "owner-id=" + arguments.getAmiOwner() + ";state=available;image-type=machine"); - - ImmutableSet modules = ImmutableSet.of( - new SLF4JLoggingModule(), // OverThere uses SLF4J so we will as well - new BouncyCastleCryptoModule() // needed to decrypt the password from EC2 - ); - context = ContextBuilder.newBuilder("aws-ec2") - .credentials(arguments.getIdentity(), arguments.getCredential()) - .overrides(overrides) - .modules(modules) - .build(ComputeServiceContext.class); - - try { - computeService = context.getComputeService(); - Set regions = Sets.newHashSet(Iterables.transform(Iterables.filter(computeService.listAssignableLocations(), LocationPredicates.isRegion()), new Function() { - @Override - public String apply(@Nullable Location location) { - return (location != null) ? location.getId() : null; - } - })); - - if (!regions.contains(arguments.getRegion())) { - System.err.println("Region \"" + arguments.getRegion() + "\" is not known. Known regions are:"); - for (String r : regions) { - System.err.println(" " + r); - } - System.exit(1); - } - - WindowsInstanceStarter app = new WindowsInstanceStarter(arguments, context); - app.run(); - } finally { - context.close(); - } - } - -} 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 a6413488..00000000 --- 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 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 passwordReady = new Predicate() { - @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 passwordReadyRetryable = new RetryablePredicate(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()); - } -} diff --git a/ec2-windows/src/main/resources/log4j.properties b/ec2-windows/src/main/resources/log4j.properties deleted file mode 100644 index 48e17e4a..00000000 --- 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 diff --git a/glacier/pom.xml b/glacier/pom.xml index bb054869..9af4df22 100644 --- a/glacier/pom.xml +++ b/glacier/pom.xml @@ -22,16 +22,21 @@ 4.0.0 org.apache.jclouds.examples glacier-examples - 1.8.0 + 2.1.0 glacier-examples + + 2.1.0 + + org.apache.jclouds.labs glacier - ${project.version} + ${jclouds.version} + ${project.artifactId} diff --git a/google-lb/pom.xml b/google-lb/pom.xml index 04a21520..4dc67342 100644 --- a/google-lb/pom.xml +++ b/google-lb/pom.xml @@ -22,12 +22,12 @@ 4.0.0 org.apache.jclouds.examples google-lb - 1.9.0 + 2.1.0 google-lb jclouds-labs-google example that shows using the compute specific api and constructing a load balancer. - 1.9.0 + 2.1.0 @@ -37,7 +37,7 @@ ${jclouds.version} - org.apache.jclouds.labs + org.apache.jclouds.provider google-compute-engine ${jclouds.version} 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 c38abca4..e8f97b20 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 @@ */ public class MainApp { - public static enum Action { + public enum Action { CREATE, REQUEST, DESTROY, DELETE_STARTUP_SCRIPT } @@ -144,7 +144,12 @@ public static void main(String[] args) { // Make requests to create instances. ArrayList operations = new ArrayList(); 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); } diff --git a/minecraft-compute/README.md b/minecraft-compute/README.md deleted file mode 100755 index 968a8d06..00000000 --- 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 - diff --git a/minecraft-compute/pom.xml b/minecraft-compute/pom.xml deleted file mode 100644 index 1ffa9563..00000000 --- a/minecraft-compute/pom.xml +++ /dev/null @@ -1,171 +0,0 @@ - - - - 4.0.0 - org.jclouds.examples - minecraft-compute - 1.0-beta.6 - minecraft-compute - starts a minecraft server using the ComputeService api - - - - org.jclouds - jclouds-compute - 1.6.0 - - - org.jclouds - jclouds-allcompute - 1.6.0 - - - org.jclouds.labs - joyentcloud - 1.6.0 - - - - - org.bouncycastle - bcprov-jdk16 - 1.46 - provided - - - org.jclouds.driver - jclouds-bouncycastle - 1.6.0 - - - - org.bouncycastle - bcprov-jdk16 - - - - - org.jclouds.driver - jclouds-sshj - 1.6.0 - - - org.jclouds.driver - jclouds-enterprise - 1.6.0 - - - ch.qos.logback - logback-classic - 1.0.0 - - - - ${project.artifactId} - - - maven-compiler-plugin - - ${project.build.sourceEncoding} - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-jar-plugin - - - - org.jclouds.examples.minecraft.MainApp - - - - - - maven-assembly-plugin - 2.3 - - - src/main/assembly/jar-with-dependencies.xml - - - - org.jclouds.examples.minecraft.MainApp - - - bcprov-jdk16.jar - - - - - - make-assembly - package - - single - - - - - - org.apache.maven.plugins - maven-dependency-plugin - 2.4 - - - copy - package - - copy - - - - - org.bouncycastle - bcprov-jdk16 - false - bcprov-jdk16.jar - - - ${project.build.directory} - false - true - - - - - - - - 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 aaa208c1..00000000 --- a/minecraft-compute/src/main/assembly/jar-with-dependencies.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - jar-with-dependencies - - jar - - false - - - metaInf-services - - - - - / - true - true - runtime - - - \ No newline at end of file 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 6e15f687..00000000 --- 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 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 1b075f9a..00000000 --- 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. - *

- * Usage is: - * {@code java MainApp provider identity credential groupName (add|list|tail|pids|destroy)} - */ -public class MainApp { - public static final Map allApis = Maps.uniqueIndex( - Apis.viewableAs(ComputeServiceContext.class), Apis.idFunction()); - - public static final Map appProviders = Maps.uniqueIndex( - Providers.viewableAs(ComputeServiceContext.class), Providers.idFunction()); - - public static final Set 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 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 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 pids = controller.pids(); - System.out.printf("<< pids %s%n", pids); - break; - case DESTROY: - System.out.printf(">> destroying group %s%n", groupName); - Iterable 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 modules = ImmutableSet. 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 }); - } - } - } -} 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 aa13a2e0..00000000 --- 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 daemonFactory; - private final int port; - private final String group; - private final int maxHeap; - - @Inject - MinecraftController(Closer closer, NodeManager nodeManager, Provider 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 list() { - return transformToHostAndPort(nodeManager.listRunningNodesInGroup(group)); - } - - public Iterable transformToHostAndPort(Set 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 tail() { - return mapHostAndPortToStdoutForCommand("/tmp/init-minecraft tail"); - } - - public Map mapHostAndPortToStdoutForCommand(String cmd) { - return transformKeys(nodeManager.stdoutFromCommandOnGroup(cmd, group), firstPublicAddressToHostAndPort(port)); - } - - public Map pids() { - return mapHostAndPortToStdoutForCommand("/tmp/init-minecraft status"); - } - - public Iterable 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(); - } -} 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 e13c6138..00000000 --- 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 stdoutFromCommandOnGroup(String command, String group) { - try { - return transformValues((Map) 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 listRunningNodesInGroup(String group) { - return filter(compute.listNodesDetailsMatching(all()), runningInGroup(group)); - } - - public Set destroyNodesInGroup(String group) { - return compute.destroyNodesMatching(Predicates. and(inGroup(group), not(TERMINATED))); - } - - public RuntimeException destroyBadNodesAndPropagate(RunNodesException e) { - for (Entry nodeError : e.getNodeErrors().entrySet()) - compute.destroyNode(nodeError.getKey().getId()); - throw propagate(e); - } - - public NodeMetadata createNodeWithAdminUserAndJDKInGroupOpeningPortAndMinRam(String group, int port, int minRam) { - ImmutableMap userMetadata = ImmutableMap. 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()); - } - -} 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 621aa1c2..00000000 --- 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 getStdout() { - return new Function() { - - @Override - public String apply(ExecResponse input) { - return input.getOutput(); - } - }; - } - - public static Function firstPublicAddressToHostAndPort(final int port) { - return new Function() { - - @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(); - } - -} diff --git a/minecraft-compute/src/main/resources/logback.xml b/minecraft-compute/src/main/resources/logback.xml deleted file mode 100644 index 690a944c..00000000 --- a/minecraft-compute/src/main/resources/logback.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - %msg%n - - - - - - - - - - diff --git a/openstack/pom.xml b/openstack/pom.xml index 74403a75..5bd40fd3 100644 --- a/openstack/pom.xml +++ b/openstack/pom.xml @@ -22,11 +22,11 @@ 4.0.0 org.apache.jclouds.examples openstack-examples - 2.0.0 + 2.1.0 openstack-examples - 2.0.0 + 2.1.0 @@ -73,7 +73,7 @@ ${jclouds.version} - org.apache.jclouds.labs + org.apache.jclouds.api openstack-neutron ${jclouds.version} diff --git a/play-compute/.gitignore b/play-compute/.gitignore deleted file mode 100644 index f6ca7ab3..00000000 --- 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 diff --git a/play-compute/README b/play-compute/README deleted file mode 100644 index 6373f4a1..00000000 --- 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`. diff --git a/play-compute/app/controllers/Application.java b/play-compute/app/controllers/Application.java deleted file mode 100644 index 875559e8..00000000 --- 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()))); - } - -} diff --git a/play-compute/app/views/index.scala.html b/play-compute/app/views/index.scala.html deleted file mode 100644 index 144a4013..00000000 --- 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 diff --git a/play-compute/app/views/main.scala.html b/play-compute/app/views/main.scala.html deleted file mode 100644 index f24fb432..00000000 --- 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) - - - - - - @title - - - - - - @content - - diff --git a/play-compute/conf/application.conf b/play-compute/conf/application.conf deleted file mode 100644 index 05224f20..00000000 --- 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?]").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="

"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; -f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() -{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/play-compute/public/stylesheets/main.css b/play-compute/public/stylesheets/main.css deleted file mode 100644 index a0fcb3cb..00000000 --- a/play-compute/public/stylesheets/main.css +++ /dev/null @@ -1,19 +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. - */ - diff --git a/pom.xml b/pom.xml index d26e1744..b2aa1834 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 4.0.0 org.apache.jclouds.examples jclouds-examples - 1.9.0 + 2.1.0 pom jclouds examples @@ -33,7 +33,7 @@ - 1.9.0 + 2.1.0 @@ -65,22 +65,12 @@ blobstore-uploader chef-basics compute-basics - google-lb glacier + google-lb openstack rackspace - + diff --git a/rackspace/pom.xml b/rackspace/pom.xml index 5dc1e984..2557e346 100644 --- a/rackspace/pom.xml +++ b/rackspace/pom.xml @@ -22,11 +22,11 @@ 4.0.0 org.apache.jclouds.examples rackspace-examples - 2.0.0 + 2.1.0 rackspace-examples - 2.0.0 + 2.1.0 @@ -98,7 +98,7 @@ ${jclouds.version} - org.apache.jclouds.labs + org.apache.jclouds.provider rackspace-cloudnetworks-us ${jclouds.version} @@ -149,7 +149,7 @@ ${jclouds.version} - org.apache.jclouds.labs + org.apache.jclouds.provider rackspace-cloudnetworks-uk ${jclouds.version} diff --git a/rackspace/src/main/java/org/jclouds/examples/rackspace/Authentication.java b/rackspace/src/main/java/org/jclouds/examples/rackspace/Authentication.java index 2b235cdf..3ca88fea 100644 --- a/rackspace/src/main/java/org/jclouds/examples/rackspace/Authentication.java +++ b/rackspace/src/main/java/org/jclouds/examples/rackspace/Authentication.java @@ -23,8 +23,8 @@ import java.util.Properties; import org.jclouds.ContextBuilder; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.keystone.auth.config.CredentialTypes; +import org.jclouds.openstack.keystone.config.KeystoneProperties; import org.jclouds.openstack.nova.v2_0.NovaApi; import com.google.common.io.Closeables; diff --git a/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudfiles/UploadObjectsWithServiceNet.java b/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudfiles/UploadObjectsWithServiceNet.java index cb77c6fd..68d95330 100644 --- a/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudfiles/UploadObjectsWithServiceNet.java +++ b/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudfiles/UploadObjectsWithServiceNet.java @@ -34,7 +34,7 @@ import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext; -import org.jclouds.openstack.v2_0.config.InternalUrlModule; +import org.jclouds.openstack.keystone.catalog.config.InternalUrlModule; import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi; import com.google.common.base.Charsets; diff --git a/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudnetworks/CreateSecurityGroup.java b/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudnetworks/CreateSecurityGroup.java index d3ba6793..e39cab32 100644 --- a/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudnetworks/CreateSecurityGroup.java +++ b/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudnetworks/CreateSecurityGroup.java @@ -30,7 +30,7 @@ import org.jclouds.openstack.neutron.v2.domain.RuleProtocol; import org.jclouds.openstack.neutron.v2.domain.SecurityGroup; -import org.jclouds.openstack.neutron.v2.extensions.SecurityGroupApi; +import org.jclouds.openstack.neutron.v2.features.SecurityGroupApi; import com.google.common.io.Closeables; /** @@ -68,12 +68,12 @@ public CreateSecurityGroup(String username, String apiKey) { } private void createSecurityGroup() { - SecurityGroupApi sgApi = neutronApi.getSecurityGroupApi(REGION).get(); + SecurityGroupApi sgApi = neutronApi.getSecurityGroupApi(REGION); Rule rule = null; SecurityGroup securityGroup = null; try { - sgApi = neutronApi.getSecurityGroupApi(REGION).get(); + sgApi = neutronApi.getSecurityGroupApi(REGION); securityGroup = sgApi.create( SecurityGroup.createBuilder().name("jclouds-test").description("jclouds test security group")