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 <[email protected]>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
>>
>>