You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Jayant Kaushal <aw...@gmail.com> on 2014/01/09 21:15:49 UTC

Error Creating Key Pairs on OpenStack

I am trying to fetch the existing key pairs from jclouds api.
but the private key comes null from server.

KeyPairApi keyPairApi =
getNovaApi(computeService).getKeyPairExtensionForZone(regionName).get();
    FluentIterable<? extends KeyPair> keyPairsList = keyPairApi.list();

    keyPairsList = keyPairApi.list();
    if(keyPairsList != null && keyPairsList.size() > 0) {
      for(KeyPair keys : keyPairsList) {
       keys.privateKey() // prints as null.
        }
      }
    }

Any Help

Regards
Jayant Kaushal

Re: Error Creating Key Pairs on OpenStack

Posted by Everett Toews <ev...@RACKSPACE.COM>.
Hi Jayant,

I just wrote an example that covers Key Pairs called CreateServerWithKeyPair [1]. It shows you how to write the private key to disk.

The example runs on Rackspace but the code is exactly the same. The only thing you need to change is some config for the context and the region.

e.g. As in the OpenStack Quick Start Nova example [2]

ComputeServiceContext context = ContextBuilder.newBuilder("openstack-nova")
    .endpoint("http://172.16.0.1:5000/v2.0/")
    .credentials("tenantName:userName", "password")
    .modules(modules)
    .buildView(ComputeServiceContext.class);

If you want to know how to run the example on Rackspace, check out [3].

HTH,
Everett

[1] https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/CreateServerWithKeyPair.java
[2] http://jclouds.apache.org/documentation/quickstart/openstack/#nova-source
[3] https://github.com/jclouds/jclouds-examples/tree/master/rackspace


On Jan 9, 2014, at 2:19 PM, Jayant Kaushal wrote:

> I am using devstack instance and i created a keypair on openstack.
> now when i try to create a new keypair. where do i get the private key.
> 
> Any help is highly appreciated.
> 
> 
> 
> Regards
> Jayant Kaushal
> 
> 
> 
> On Fri, Jan 10, 2014 at 1:45 AM, Jayant Kaushal <aw...@gmail.com>wrote:
> 
>> I am trying to fetch the existing key pairs from jclouds api.
>> but the private key comes null from server.
>> 
>> KeyPairApi keyPairApi =
>> getNovaApi(computeService).getKeyPairExtensionForZone(regionName).get();
>>    FluentIterable<? extends KeyPair> keyPairsList = keyPairApi.list();
>> 
>>    keyPairsList = keyPairApi.list();
>>    if(keyPairsList != null && keyPairsList.size() > 0) {
>>      for(KeyPair keys : keyPairsList) {
>>       keys.privateKey() // prints as null.
>>        }
>>      }
>>    }
>> 
>> Any Help
>> 
>> Regards
>> Jayant Kaushal
>> 
>> 


Re: Error Creating Key Pairs on OpenStack

Posted by Jayant Kaushal <aw...@gmail.com>.
I am using devstack instance and i created a keypair on openstack.
now when i try to create a new keypair. where do i get the private key.

Any help is highly appreciated.



Regards
Jayant Kaushal



On Fri, Jan 10, 2014 at 1:45 AM, Jayant Kaushal <aw...@gmail.com>wrote:

> I am trying to fetch the existing key pairs from jclouds api.
> but the private key comes null from server.
>
> KeyPairApi keyPairApi =
> getNovaApi(computeService).getKeyPairExtensionForZone(regionName).get();
>     FluentIterable<? extends KeyPair> keyPairsList = keyPairApi.list();
>
>     keyPairsList = keyPairApi.list();
>     if(keyPairsList != null && keyPairsList.size() > 0) {
>       for(KeyPair keys : keyPairsList) {
>        keys.privateKey() // prints as null.
>         }
>       }
>     }
>
> Any Help
>
> Regards
> Jayant Kaushal
>
>

Re: Error Creating Key Pairs on OpenStack

Posted by Andrew Phillips <an...@apache.org>.
> Just to be clear: does the 'keyPairList' in your example contain the
> correct *public* keys? Or are no keys returned at all?

Looking at the relevant OpenStack doc [1], I'm suspecting that perhaps  
only the public key is returned? At least, both the '/os-keypairs' and  
'/os-keypairs/​{keypair_name}​' result examples could indicate that.

One of the Rackspace experts on this list will hopefully be able to  
shed more light on that...

ap

[1] http://api.openstack.org/api-ref-compute-ext.html

Re: Error Creating Key Pairs on OpenStack

Posted by Everett Toews <ev...@RACKSPACE.COM>.
Hi Jayant,

I just wrote an example that covers Key Pairs called CreateServerWithKeyPair [1]. It shows you how to write the private key to disk.

The example runs on Rackspace but the code is exactly the same. The only thing you need to change is some config for the context and the region.

e.g. As in the OpenStack Quick Start Nova example [2]

ComputeServiceContext context = ContextBuilder.newBuilder("openstack-nova")
   .endpoint("http://172.16.0.1:5000/v2.0/")
   .credentials("tenantName:userName", "password")
   .modules(modules)
   .buildView(ComputeServiceContext.class);

If you want to know how to run the example on Rackspace, check out [3].

HTH,
Everett

[1] https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/CreateServerWithKeyPair.java
[2] http://jclouds.apache.org/documentation/quickstart/openstack/#nova-source
[3] https://github.com/jclouds/jclouds-examples/tree/master/rackspace

P.S. I meant to reply to the user@ list. Let's continue the discussion here instead of dev@. Thanks.


On Jan 9, 2014, at 7:06 PM, Andrew Phillips wrote:

> [moving this question to the user@ list...]
> 
> Just to be clear: does the 'keyPairList' in your example contain the correct *public* keys? Or are no keys returned at all?
> 
> ap
> 
> Quoting Jayant Kaushal <aw...@gmail.com>:
> 
>> I am trying to fetch the existing key pairs from jclouds api.
>> but the private key comes null from server.
>> 
>> KeyPairApi keyPairApi =
>> getNovaApi(computeService).getKeyPairExtensionForZone(regionName).get();
>>    FluentIterable<? extends KeyPair> keyPairsList = keyPairApi.list();
>> 
>>    keyPairsList = keyPairApi.list();
>>    if(keyPairsList != null && keyPairsList.size() > 0) {
>>      for(KeyPair keys : keyPairsList) {
>>       keys.privateKey() // prints as null.
>>        }
>>      }
>>    }
>> 
>> Any Help
>> 
>> Regards
>> Jayant Kaushal


Re: Error Creating Key Pairs on OpenStack

Posted by Andrew Phillips <an...@apache.org>.
[moving this question to the user@ list...]

Just to be clear: does the 'keyPairList' in your example contain the  
correct *public* keys? Or are no keys returned at all?

ap

Quoting Jayant Kaushal <aw...@gmail.com>:

> I am trying to fetch the existing key pairs from jclouds api.
> but the private key comes null from server.
>
> KeyPairApi keyPairApi =
> getNovaApi(computeService).getKeyPairExtensionForZone(regionName).get();
>     FluentIterable<? extends KeyPair> keyPairsList = keyPairApi.list();
>
>     keyPairsList = keyPairApi.list();
>     if(keyPairsList != null && keyPairsList.size() > 0) {
>       for(KeyPair keys : keyPairsList) {
>        keys.privateKey() // prints as null.
>         }
>       }
>     }
>
> Any Help
>
> Regards
> Jayant Kaushal