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
try { | |
Set<String> zones = nova.getApi().getConfiguredZones(); | |
String zone = Iterables.getFirst(zones, null); | |
String provider = compute.getContext().toString().contains("rackspace") ? | |
"Rackspace CloudServers" : "Openstack Nova"; | |
// Use jclouds to check if security groups are supported for this provider | |
Optional<? extends SecurityGroupApi> securityGroupExt = | |
nova.getApi().getSecurityGroupExtensionForZone(zone); |
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 { | |
if("demo:demo".equals(user)) { | |
// Devstack not configured for public IPs | |
address = node.getPrivateAddresses().iterator().next(); | |
// GOTCHA: The cirros image is missing a lot of features. It is mostly only viable for testing. | |
// No bash-shopt: jclouds can't run scripts on it | |
// No yum/apt/etc... can't install | |
// No toolchain... can't build | |
// Very fast boots and good for testing! |
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); | |
OlderNewer