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