This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>rackspace</groupId> | |
<artifactId>rackspace</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<build> | |
<plugins> | |
<plugin> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.0</version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jclouds.examples.rackspace; | |
import static com.google.common.io.Closeables.closeQuietly; | |
import java.io.Closeable; | |
import java.util.Set; | |
import org.jclouds.ContextBuilder; | |
import org.jclouds.compute.ComputeService; | |
import org.jclouds.compute.ComputeServiceContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<!-- | |
Licensed to the Apache Software Foundation (ASF) under one | |
or more contributor license agreements. See the NOTICE file | |
distributed with this work for additional information | |
regarding copyright ownership. The ASF licenses this file | |
to you under the Apache License, Version 2.0 (the | |
"License"); you may not use this file except in compliance | |
with the License. You may obtain a copy of the License at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<!-- | |
Licensed to the Apache Software Foundation (ASF) under one or more | |
contributor license agreements. See the NOTICE file distributed with | |
this work for additional information regarding copyright ownership. | |
The ASF licenses this file to You under the Apache License, Version 2.0 | |
(the "License"); you may not use this file except in compliance with | |
the License. You may obtain a copy of the License at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jclouds.workshop; | |
import static com.google.common.base.Charsets.UTF_8; | |
import static java.util.concurrent.TimeUnit.SECONDS; | |
import static org.jclouds.compute.predicates.NodePredicates.inGroup; | |
import static org.jclouds.scriptbuilder.domain.Statements.exec; | |
import static org.jclouds.util.Predicates2.retry; | |
import java.io.BufferedReader; | |
import java.io.Closeable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jclouds.workshop; | |
import static com.google.common.base.Charsets.UTF_8; | |
import static java.util.concurrent.TimeUnit.SECONDS; | |
import static org.jclouds.compute.predicates.NodePredicates.inGroup; | |
import static org.jclouds.scriptbuilder.domain.Statements.exec; | |
import static org.jclouds.util.Predicates2.retry; | |
import java.io.BufferedReader; | |
import java.io.Closeable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get credentials from a file, if it exists. First line should be "user;password" | |
if( (new File("credentials.txt")).exists() ) { | |
BufferedReader br = null; | |
try { | |
br = (new BufferedReader(new FileReader("credentials.txt"))); | |
String[] credentials = br.readLine().split(";"); | |
user = credentials[0]; | |
password = credentials[1]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
// Use jclouds to generate a keypair | |
Map<String,String> keys = SshKeys.generate(); | |
// Get the private key from the keypair map | |
privateKey = keys.get("private"); | |
Files.write(privateKey, new File("jclouds.pem"), UTF_8); | |
// Uses security groups if available (determines right approach automatically) to enable SSH and HTTP | |
TemplateOptions options = compute.templateOptions().inboundPorts(22, 80); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
zone = nova.getApi().getConfiguredZones().iterator().next(); | |
System.out.println("Zone: " + zone); | |
Map<String,String> keys = SshKeys.generate(); | |
privateKey = keys.get("private"); | |
Files.write(privateKey, new File("jclouds.pem"), UTF_8); | |
KeyPairApi kpa = nova.getApi().getKeyPairExtensionForZone(zone).get(); | |
kpa.delete("jclouds"); | |
kpa.createWithPublicKey("jclouds", keys.get("public")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget http://uec-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img | |
glance image-create --name ubuntu --disk-format=raw --container-format=bare --file precise-server-cloudimg-amd64-disk1.img | |
nova boot jclouds-vm --flavor 1 --image <image id> --key-name jclouds --security-groups jclouds-workshop --poll |
OlderNewer