Skip to content

Instantly share code, notes, and snippets.

View etoews's full-sized avatar

Everett Toews etoews

View GitHub Profile
@etoews
etoews / Test.java
Created August 7, 2012 17:48
jclouds resize broken (Rackspace)
package com.rackspace;
import java.lang.Thread.UncaughtExceptionHandler;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeMetadata.Status;
import org.jclouds.compute.domain.NodeMetadataBuilder;
import org.jclouds.enterprise.config.EnterpriseConfigurationModule;
@etoews
etoews / install.sh
Created August 15, 2012 15:18
Getting started with jclouds
$ mkdir jclouds-test
$ cd jcloud-test
$ curl -o lein.sh https://raw.github.com/technomancy/leiningen/stable/bin/lein
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9905 100 9905 0 0 13005 0 --:--:-- --:--:-- --:--:-- 31444
$ chmod u+x lein.sh
$ echo '(defproject deps "1" :dependencies [[org.jclouds/jclouds-all "1.5.1"] [org.jclouds.driver/jclouds-sshj "1.5.1"]])' > project.clj
$ ./lein.sh deps
<output omitted>
@etoews
etoews / JCloudsTest.java
Created August 15, 2012 15:27
Getting started with jclouds
import java.util.Set;
import java.lang.Thread.UncaughtExceptionHandler;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ComputeMetadata;
public class JCloudsTest {
private ComputeService compute;
@etoews
etoews / compile.sh
Created August 15, 2012 15:30
Getting started with jclouds
$ pwd
/Users/phymata/test/jclouds-test
$ ls
JCloudsTest.java lein.sh lib project.clj
$ javac -cp ".:lib/*" JCloudsTest.java
$ ls
JCloudsTest$1.class JCloudsTest.class JCloudsTest.java lein.sh lib project.clj
$ java -cp ".:lib/*" JCloudsTest
Calling listNodes...
Total Number of Nodes = 1
@etoews
etoews / token.sh
Created August 17, 2012 16:24
Get a token from the Rackspace Open Cloud
$ TOKEN=`curl -s -X POST https://identity.api.rackspacecloud.com/v2.0/tokens -d '{"auth": {"passwordCredentials": {"username":"MY_USERNAME", "password":"MY_PASSWORD"}}}' -H "Content-type: application/json" | python -c 'import json,sys; response=json.loads(sys.stdin.read()); print response["access"]["token"]["id"]'`
$ echo $TOKEN
9d1dc8da-d306-4e39-b9c2-f39a127341f1
@etoews
etoews / JCloudsLoggingExample.java
Created August 18, 2012 18:28
Logging with jclouds
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Set;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import com.google.common.collect.ImmutableSet;
@etoews
etoews / compile.sh
Created August 18, 2012 18:33
Logging with jclouds
$ javac -cp ".:lib/*" JCloudsLoggingExample.java
$ java -cp ".:lib/*" JCloudsLoggingExample
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Calling listNodes...
Total Number of Nodes = 1
@etoews
etoews / logback.xml
Created August 18, 2012 19:17
Logging with jclouds
<?xml version="1.0"?>
<configuration scan="false">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>- %m%n</pattern>
</encoder>
</appender>
<logger name="jclouds.wire">
<level value="DEBUG" />
@etoews
etoews / run.sh
Created August 18, 2012 19:32
Logging with jclouds
$ pwd
/Users/phymata/test/jclouds-test
$ ls
JCloudsLoggingExample$1.class JCloudsTest.java
JCloudsLoggingExample.class lein.sh
JCloudsLoggingExample.java lib
JCloudsTest$1.class logback.xml
JCloudsTest.class project.clj
@etoews
etoews / log.java
Created August 29, 2012 22:07
jclouds log
17:00:49,672 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
17:00:49,676 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
17:00:49,676 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/Users/ever5257/dev/everett-toews/jclouds/apis/openstack-keystone/target/test-classes/logback.xml]
17:00:49,682 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.
17:00:49,682 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [file:/Users/ever5257/dev/everett-toews/jclouds/apis/openstack-keystone/target/test-classes/logback.xml]
17:00:49,682 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [file:/Users/ever5257/dev/everett-toews/jclouds/compute/target/test-classes/logback.xml]
17:00:49,770 |-INFO in ch.qos.logback.classic.joran.ac