You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Bk Lau <bk...@gmail.com> on 2013/07/31 17:10:36 UTC
NovaComputeService
Hi:
Is NovaComputeService currently intended to be used as below?
ctx=ContextBuilder.newBuilder("openstack-nova")//
.endpoint("....")//
.credentials("...", "....")//
.buildView(ComputeServiceContext.class);
NovaComputeService s=(NovaComputeService)ctx.getComputeService();
Thanks,
BK
RE: NovaComputeService
Posted by Andrew Phillips <an...@apache.org>.
> Seems your code is about the same, any issues with it?
Not quite sure what is meant by "any issues with it", but the code is
indeed slightly different: the CreateServer example uses the general
ComputeServiceContext (note that it does *not* reference
NovaComputeServiceContext anywhere!).
The example I gave *does* use Nova-specific calls and needs to access
the underlying Nova API to do this.
The general advice would be to stay with the general
ComputeServiceContext if you can, as this makes your code more portable.
Regards
ap
Re: NovaComputeService
Posted by Andrew Phillips <an...@apache.org>.
> But I always wanted to know what is the difference between a View and Api?
> Can I have different View other that ComputerServiceContext for a compute
> provider?
BK is correct in pointing out the difference between the general
ComputeService and the provider- or API-specific *Api classes: if you
stick to ComputeService where you can, your code will remain portable.
Use the API classes to access provider or API-specific features.
As regards Views and Apis: Apis are the actual, API- or
vendor-specific clients that talk directly to vendor-specific APIs to
"make things happen". If jclouds only offered Apis, it would be
useful, but you won't be able to write any portable code.
That's why jclouds also provides a number of abstraction layers *on
top of* Apis: ComputeService and BlobStore being the two most commonly
used ones, although there are others.
When you use a ComputeService or BlobStore in jclouds, of course the
actual calls eventually have to be made via the specific API of the
target provider you happen to be talking to. jclouds takes care of the
plumbing necessary to match the ComputeService or BlobStore methods to
the underlying APIs.
In that sense, ComputeService and BlobStore provide an "abstract view"
of an underlying "real" API or provider. The fundamental principle of
a View is that you can "reach in" to the view and get that actual API
"out". That's why ComputerService and BlobStore both extend View.
I hope that helps to explain why the question of "whether you can have
a View other than ComputeServiceContext for a compute provider"
doesn't make sense as stated: by definition, the whole purpose of
ComputeService (a ComputeServiceContext is just a "factory" for making
these) is to talk to a compute provider via that provider's API class
or classes.
But a provider's API class or classes can indeed implement *multiple*
abstractions, so you could "reach in" to a BlobStore and a
ComputeService and get *the same API* back.
Hope that helps!
ap
Re: NovaComputeService
Posted by Bk Lau <bk...@gmail.com>.
Kawan:
Seems that the "View" is a high-level abstraction that is "common" to all
providers i.e. a baseline to promote portability.
It also provides some convienient methods like runScripts...
OTOH, the richness of the full OpenStack NOVA API can only be accessed via
NovaApi.
So I guess for Nova-specific features use NovaApi and use ComputeService
to use features "common" to all.
That's how its supposed to work as pointed out to me.
On Wed, Jul 31, 2013 at 2:17 PM, Kavan Patil <ka...@gmail.com> wrote:
> I am no JClouds expert but :
>
> I tend to use this (and seems like this is encouraged):
>
> -------------
> NovaApi api =
> ContextBuilder.newBuilder(...)
> .credentials(...)
> .endpoint(...)
> .buildApi(NovaApi.class);
> ---------------
>
> than this:
>
> ---------------
>
> ctx=ContextBuilder.newBuilder(
> "openstack-nova")//
> .endpoint("....")//
> .credentials("...", "....")//
> .buildView(ComputeServiceContext.class);
>
> //RestContext use seems to be discouraged now as i see it is deprecated
> //RestContext<NovaApi, NovaAsyncApi> nova = ctx.unwrap()
> //nova.getApi()... // do something with NovaApi
>
> NovaApi novaApi = ctx.unwrapApi(NovaApi.class);
> ----------------
>
> But I always wanted to know what is the difference between a View and Api?
> Can I have different View other that ComputerServiceContext for a compute
> provider?
>
> Regards,
> Kavan
>
>
> On Wed, Jul 31, 2013 at 11:31 PM, Bk Lau <bk...@gmail.com> wrote:
>
>> Zack:
>> Not sure. I haven't got a Rackspace account to try it out yet.
>>
>>
>> On Wed, Jul 31, 2013 at 12:35 PM, Zack Shoylev <
>> zack.shoylev@rackspace.com> wrote:
>>
>>> I am looking at the examples I use (
>>> https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/CreateServer.java#L83)
>>> Seems your code is about the same, any issues with it?
>>>
>>>
>>>
>>> From: Bk Lau [mailto:bklau2006@gmail.com]
>>> Sent: Wednesday, July 31, 2013 10:11 AM
>>> To: user@jclouds.incubator.apache.org
>>> Subject: NovaComputeService
>>>
>>> Hi:
>>> Is NovaComputeService currently intended to be used as below?
>>>
>>> ctx=ContextBuilder.newBuilder("openstack-nova")//
>>> .endpoint("....")//
>>> .credentials("...", "....")//
>>> .buildView(ComputeServiceContext.class);
>>> NovaComputeService s=(NovaComputeService)ctx.getComputeService();
>>> Thanks,
>>> BK
>>>
>>
>>
>
Re: NovaComputeService
Posted by Kavan Patil <ka...@gmail.com>.
I am no JClouds expert but :
I tend to use this (and seems like this is encouraged):
-------------
NovaApi api =
ContextBuilder.newBuilder(...)
.credentials(...)
.endpoint(...)
.buildApi(NovaApi.class);
---------------
than this:
---------------
ctx=ContextBuilder.newBuilder(
"openstack-nova")//
.endpoint("....")//
.credentials("...", "....")//
.buildView(ComputeServiceContext.class);
//RestContext use seems to be discouraged now as i see it is deprecated
//RestContext<NovaApi, NovaAsyncApi> nova = ctx.unwrap()
//nova.getApi()... // do something with NovaApi
NovaApi novaApi = ctx.unwrapApi(NovaApi.class);
----------------
But I always wanted to know what is the difference between a View and Api?
Can I have different View other that ComputerServiceContext for a compute
provider?
Regards,
Kavan
On Wed, Jul 31, 2013 at 11:31 PM, Bk Lau <bk...@gmail.com> wrote:
> Zack:
> Not sure. I haven't got a Rackspace account to try it out yet.
>
>
> On Wed, Jul 31, 2013 at 12:35 PM, Zack Shoylev <zack.shoylev@rackspace.com
> > wrote:
>
>> I am looking at the examples I use (
>> https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/CreateServer.java#L83)
>> Seems your code is about the same, any issues with it?
>>
>>
>>
>> From: Bk Lau [mailto:bklau2006@gmail.com]
>> Sent: Wednesday, July 31, 2013 10:11 AM
>> To: user@jclouds.incubator.apache.org
>> Subject: NovaComputeService
>>
>> Hi:
>> Is NovaComputeService currently intended to be used as below?
>>
>> ctx=ContextBuilder.newBuilder("openstack-nova")//
>> .endpoint("....")//
>> .credentials("...", "....")//
>> .buildView(ComputeServiceContext.class);
>> NovaComputeService s=(NovaComputeService)ctx.getComputeService();
>> Thanks,
>> BK
>>
>
>
Re: NovaComputeService
Posted by Bk Lau <bk...@gmail.com>.
Zack:
Not sure. I haven't got a Rackspace account to try it out yet.
On Wed, Jul 31, 2013 at 12:35 PM, Zack Shoylev
<za...@rackspace.com>wrote:
> I am looking at the examples I use (
> https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/CreateServer.java#L83)
> Seems your code is about the same, any issues with it?
>
>
>
> From: Bk Lau [mailto:bklau2006@gmail.com]
> Sent: Wednesday, July 31, 2013 10:11 AM
> To: user@jclouds.incubator.apache.org
> Subject: NovaComputeService
>
> Hi:
> Is NovaComputeService currently intended to be used as below?
>
> ctx=ContextBuilder.newBuilder("openstack-nova")//
> .endpoint("....")//
> .credentials("...", "....")//
> .buildView(ComputeServiceContext.class);
> NovaComputeService s=(NovaComputeService)ctx.getComputeService();
> Thanks,
> BK
>
RE: NovaComputeService
Posted by Zack Shoylev <za...@RACKSPACE.COM>.
I am looking at the examples I use ( https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/CreateServer.java#L83 )
Seems your code is about the same, any issues with it?
From: Bk Lau [mailto:bklau2006@gmail.com]
Sent: Wednesday, July 31, 2013 10:11 AM
To: user@jclouds.incubator.apache.org
Subject: NovaComputeService
Hi:
Is NovaComputeService currently intended to be used as below?
ctx=ContextBuilder.newBuilder("openstack-nova")//
.endpoint("....")//
.credentials("...", "....")//
.buildView(ComputeServiceContext.class);
NovaComputeService s=(NovaComputeService)ctx.getComputeService();
Thanks,
BK
Re: NovaComputeService
Posted by Andrew Phillips <an...@apache.org>.
> Is NovaComputeService currently intended to be used as below?
>
> ctx=ContextBuilder.newBuilder("openstack-nova")//
> .endpoint("....")//
> .credentials("...", "....")//
> .buildView(ComputeServiceContext.class);
> NovaComputeService s=(NovaComputeService)ctx.getComputeService();
NovaComputeService is not going to give you access to any more
functions that ComputeService. If you want to access Nova-specific
calls, try the following (see [1]):
RestContext<NovaApi, NovaAsyncApi> nova = ctx.unwrap()
nova.getApi()... // do something with NovaApi
If you're on 1.7.0-SNAPSHOT, you can also do:
NovaApi novaApi = ctx.unwrapApi(NovaApi.class);
novaApi // do something with NovaApi
Don't forget to close the ctx when you're finished! ;-)
ap
[1]
https://github.com/jclouds/jclouds-examples/blob/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudservers/ServerMetadata.java#L84