You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Zack Shoylev <no...@github.com> on 2014/03/01 03:32:31 UTC

[jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

You can merge this Pull Request by running:

  git pull https://github.com/rackerlabs/jclouds-examples add-userdata-example

Or you can view, comment on it, or merge it online at:

  https://github.com/jclouds/jclouds-examples/pull/32

-- Commit Summary --

  * Adds an example on how to use cloud-init with Nova and rackspace

-- File Changes --

    M rackspace/pom.xml (7)
    M rackspace/src/main/java/org/jclouds/examples/rackspace/SmokeTest.java (1)
    A rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/CreateServerWithUserData.java (169)

-- Patch Links --

https://github.com/jclouds/jclouds-examples/pull/32.patch
https://github.com/jclouds/jclouds-examples/pull/32.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
Dependency: https://github.com/jclouds/jclouds/pull/307

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36413614

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Everett Toews <no...@github.com>.
> +import org.jclouds.compute.options.RunScriptOptions;
> +import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
> +import org.jclouds.openstack.nova.v2_0.NovaApi;
> +import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
> +import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
> +import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
> +import org.jclouds.rest.RestContext;
> +import org.jclouds.scriptbuilder.ScriptBuilder;
> +import org.jclouds.scriptbuilder.domain.OsFamily;
> +
> +import com.google.common.collect.ImmutableSet;
> +import com.google.common.collect.Iterables;
> +import com.google.common.io.Closeables;
> +import com.google.inject.Module;
> +
> +import org.apache.commons.codec.binary.Base64;

This import is unused.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32/files#r10245015

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Everett Toews <no...@github.com>.
> @@ -125,5 +125,10 @@
>        <artifactId>mysql-connector-java</artifactId>
>        <version>5.1.25</version>
>      </dependency>
> +    <dependency>
> +      <groupId>commons-codec</groupId>
> +      <artifactId>commons-codec</artifactId>

This dep doesn't appear to be necessary.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32/files#r10245007

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Everett Toews <no...@github.com>.
Please go through the imports. I count 5 that are unnecessary.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36598318

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Andrew Phillips <no...@github.com>.
> +import com.google.common.collect.Iterables;
> +import com.google.common.io.Closeables;
> +import com.google.inject.Module;
> +
> +import org.apache.commons.codec.binary.Base64;
> +
> +/**
> + * Create a public key in the cloud and write the private key file to the local working directory. The public key and
> + * private key together are known as a key pair (see http://en.wikipedia.org/wiki/Public-key_cryptography). This
> + * is a security feature that allows you to login to a server using a private key file.
> + *
> + * Create a server with the public key, use the private key to login to it, and disable password authentication.
> + */
> +public class CreateServerWithUserData implements Closeable {
> +   private final ComputeService computeService;
> +   private final RestContext<NovaApi, NovaAsyncApi> novaContext;

Any reason to use the deprecated async API and not go straight for NovaApi here?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32/files#r10190684

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
Reverted in asf master

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36690635

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
Closed #32.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Andrew Phillips <no...@github.com>.
> @@ -22,7 +22,7 @@
>    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>
>    <properties>
> -    <jclouds.version>1.7.1</jclouds.version>
> +    <jclouds.version>1.8.0-SNAPSHOT</jclouds.version>

@everett-toews: From what I recall, you were trying to stick to released versions rather than snapshots for the examples..?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32/files#r10190674

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Andrew Phillips <no...@github.com>.
> +import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
> +import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
> +import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
> +import org.jclouds.rest.RestContext;
> +import org.jclouds.scriptbuilder.ScriptBuilder;
> +import org.jclouds.scriptbuilder.domain.OsFamily;
> +
> +import com.google.common.collect.ImmutableSet;
> +import com.google.common.collect.Iterables;
> +import com.google.common.io.Closeables;
> +import com.google.inject.Module;
> +
> +import org.apache.commons.codec.binary.Base64;
> +
> +/**
> + * Create a public key in the cloud and write the private key file to the local working directory. The public key and

"Creates...and writes..."? I.e. descriptive rather than imperative style? But more important to maintain consistency with the other examples. obviously.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32/files#r10190676

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Andrew Phillips <no...@github.com>.
> +                  " - httpd\r\n";
> +
> +      // The data will be base64 encoded.
> +      NovaTemplateOptions options = NovaTemplateOptions.Builder.userData(userData.getBytes()).configDrive(true);
> +
> +      ZoneAndId zoneAndId = ZoneAndId.fromZoneAndId(ZONE, "performance1-1");
> +      Template template = computeService.templateBuilder()
> +            .locationId(ZONE)
> +            .osDescriptionMatches(".*Ubuntu 12.04.*") // Only some images support cloud init!
> +            .hardwareId(zoneAndId.slashEncode())
> +            .options(options)
> +            .build();
> +
> +      // This method will continue to poll for the server status and won't return until this server is ACTIVE
> +      // If you want to know what's happening during the polling, enable logging.
> +      // See /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java

Make this a URL link? Or at least not an absolute local path?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32/files#r10190689

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
https://issues.apache.org/jira/browse/JCLOUDS-481

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36413610

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
merged

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-40763278

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Everett Toews <no...@github.com>.
@zack-shoylev Yes the configDrive change backport was merged but 1.7.2 hasn't been released yet. Examples are only to be merged when the corresponding code has been released. Examples must not depend on unreleased code. As it stands right now, this code doesn't compile if you follow the [Rackspace examples](https://github.com/jclouds/jclouds-examples/blob/master/rackspace/README.md). That's bad.

-1

Please revert. Sorry I didn't catch this earlier.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36684523

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Everett Toews <no...@github.com>.
> @@ -22,7 +22,7 @@
>    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>
>    <properties>
> -    <jclouds.version>1.7.1</jclouds.version>
> +    <jclouds.version>1.8.0-SNAPSHOT</jclouds.version>

Yes. @zack-shoylev please only use released versions in the examples.

If you have an example that depends on unreleased code then you’ll have to share it in a gist until it’s released.

On Mar 1, 2014, at 5:12 AM, Andrew Phillips <no...@github.com>> wrote:


In rackspace/pom.xml:

> @@ -22,7 +22,7 @@
>    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>
>    <properties>
> -    <jclouds.version>1.7.1</jclouds.version>
> +    <jclouds.version>1.8.0-SNAPSHOT</jclouds.version>


@everett-toews<https://github.com/everett-toews>: From what I recall, you were trying to stick to released versions rather than snapshots for the examples..?

—
Reply to this email directly or view it on GitHub<https://github.com/jclouds/jclouds-examples/pull/32/files#r10190674>.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32/files#r10201266

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Andrew Phillips <no...@github.com>.
> Reverted in asf master

You [beat me to it](https://git-wip-us.apache.org/repos/asf?p=jclouds-examples.git;a=commit;h=87107da7bd9604590d70fe8581a49ef5f3f18385) ;-) Thanks, @zack-shoylev!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36737872

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
I will keep this PR open then. @demobox how do you want to go about the revert?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36684953

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
Reopened #32.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Andrew Phillips <no...@github.com>.
> Unless I'm missing something, this needs to be reverted ASAP.

@everett-toews: Just to check...now that https://github.com/jclouds/jclouds/pull/307 has been merged, does your "revert" comment still apply? If so, please add a "-1" and I'll revert asap. Thanks!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36665927

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Everett Toews <no...@github.com>.
Wait. Why did this get merged?

The dependent code NovaTemplateOptions.configDrive() hasn't been released yet. Unless I'm missing something, this needs to be reverted ASAP.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36598230

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Andrew Phillips <no...@github.com>.
+1 - looks good to me. Thanks, @zack-shoylev!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-40762048

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
Closed #32.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
It seems this needs a rebase first...

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-40759739

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
This should be merged now.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-40759453

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
Rebased, ready to merge.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36590555

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Michael Bannister <no...@github.com>.
Can this example be reintroduced now? I've found it very helpful! :+1: 

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-57535652

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
About to merge

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-40759475

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
As @demobox pointed out, I merged this PR after the configDrive change backport was merged. Revert?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36673254

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
merged

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36590624

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
> +import org.jclouds.compute.options.RunScriptOptions;
> +import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
> +import org.jclouds.openstack.nova.v2_0.NovaApi;
> +import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
> +import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
> +import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
> +import org.jclouds.rest.RestContext;
> +import org.jclouds.scriptbuilder.ScriptBuilder;
> +import org.jclouds.scriptbuilder.domain.OsFamily;
> +
> +import com.google.common.collect.ImmutableSet;
> +import com.google.common.collect.Iterables;
> +import com.google.common.io.Closeables;
> +import com.google.inject.Module;
> +
> +import org.apache.commons.codec.binary.Base64;

Ah, good catch!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32/files#r10274001

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
The one way so far to ensure this works is to check /var/log/cloud-init.log (afaik).

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32#issuecomment-36413693

Re: [jclouds-examples] Adds an example on how to use cloud-init with Nova and rackspace (#32)

Posted by Zack Shoylev <no...@github.com>.
> @@ -22,7 +22,7 @@
>    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>
>    <properties>
> -    <jclouds.version>1.7.1</jclouds.version>
> +    <jclouds.version>1.8.0-SNAPSHOT</jclouds.version>

@everett-toews Yep absolutely. I will modify this back to 1.7.1 before merging. This is because this PR relies on the jclouds PR, and it just makes it more convenient to pull and test.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-examples/pull/32/files#r10215316