deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dario Garcia Gasulla <dar...@lsi.upc.edu>
Subject Re: Java REST Client
Date Mon, 31 Dec 2012 12:18:24 GMT
Thanks Andre and Mario, your explanations were quite useful.
The approach you use to create and manage instances is quite simple and
intuitive (much better than what I was trying to do).

I found one more problem, I'll tell you about it to see if you know what
I'm doing wrong:

When launching an instance

     /   instance = client.createInstance(image.getId());/

there's no way to specify the pem key the instance is supposed to
accept. The second create method does not accept key id either:

        /createInstance(String name, String imageId, String profileId,
String realmId, String memory, String storage)/

Unfortunately, if the key is not provided on launch time, the instance
will only be accessible through <user,pass> (says Amazon).
I've tried to set it before and then launch it:/
        instance.setKeyId("pem_key_file");
//        instance = client.createInstance(image.getId());/

But it does not work, and the created instance has no key associated
once created. Image doesn't accept keys either.
I haven't found any other method for defining the key before creating
the instance.
Is there a way to do this?

Thanks again, and happy new year!
Dario.

El 27/12/12 10:39, marios@redhat.com escribió:
> Andre - thanks very much for your very useful input
> Dario - minor point on clarification inline:
>
> On 22/12/12 12:34, André Dietisheim wrote:
>> Hi Dario
>> .
>>> Right now there are several things I wonder about the code. I've been
>>> capable of figuring out some of them, but not all. If you could help me
>>> out with the first one, that would be great.
>>>
>>>      -When performing an Action, I set the name (e.g., STOP_NAME) and the
>>> url from the instance to stop (e.g., instance.getPublicAddress().get(0)).
>>> This url is of the form: "ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com",
>>> however I get the following error:
> the URL you are getting from "instance.getPublicAddress().get(0)" is
> literally the public address of the ec2 instance. This is the address
> you would use to (for example) connect to the running instance using an
> (external) ssh client.
>
> Actions are invoked on the actual instance object - as shown clearly in
> the link below (Andre's test suite):
>
> <quote>
>
> 1. public void canShutdownInstance() throws DeltaCloudClientException {
> 2. Instance testInstance = testSetup.getTestInstance();
> 3. DeltaCloudClient client = testSetup.getClient();
> 4. testInstance.stop(client);
> 5. testInstance = client.listInstances(testInstance.getId()); // reload!
> 6. assertEquals(State.STOPPED, testInstance.getState());
> }
>
> </quote>
>
> so on line 2 we get a reference to the instance, and on line 4 call the
> stop action.
>
> marios
>
>
>>>              Could not connect to
>>> "ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com". The url is invalid.
>>>              Caused by: java.net.MalformedURLException: no protocol:
>>> ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com
>>> What protocol does this library use? Should I concatenate it at the
>>> beginning of the url? The address is ok, since I can ping it.
>>>
>> There's a test that I wrote back then to integration-test if the client
>> can stop a running instance:
>>
>> https://github.com/adietish/deltacloud/blob/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/InstanceMockIntegrationTest.java#L204
>>
>>
>> The test is running against a local DC which is running with a mock
>> driver. The url you'd have to pass to the client is a fully fledged URL
>> (with protocol):
>> https://github.com/adietish/deltacloud/blob/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/context/MockIntegrationTestContext.java#L50
>>
>>
>> Afair this was because:
>> 1) to allow you to run DC server on what proto you want (http, https, etc.)
>> 2) is good REST practice anyhow, you should not have some resource url
>> building logic. Links to resources within responses should be absolute
>> links
>>
>>>      -When calling the method to perform an Action, it returns an
>>> InputStream. What is that stream used for?
>>>
>> Afaik the stream holds the server response. You can see it in the client
>> impl when it performs a request and then unmarshalls the response:
>> <https://github.com/adietish/deltacloud/blob/trunk/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClientImpl.java#L84>https://github.com/adietish/deltacloud/blob/trunk/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClientImpl.java#L87
>>
>>
>>>      -Why is Action<OWNER> defined as Raw type?
>> Afaik because Actions operate on different resources. The OWNER is the
>> resource the Action operatea on. You see this in
>> https://github.com/adietish/deltacloud/blob/trunk/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/StateAware.java
>>
>>
>> Actions may be operated on any class that knows states, that extends
>> StateAware<OWNER>. Ex.
>>
>> *Instance extends StateAware<Instance>:
>> https://github.com/adietish/deltacloud/blob/trunk/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Instance.java
>>
>>
>> * Key extends StateAware<Key>:
>> https://github.com/adietish/deltacloud/blob/trunk/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Key.java
>>
>>
>> Actions change the state of a resource if they're executed successfully.
>>
>>
>>>
>>> Regarding marios question:
>>>
>>> interesting... how are you tackling the issue of pricing for example?
>>> Like many clouds don't expose pricing info via the API (aws only started
>>> supporting this recently if i recall correctly) - will you be
>>> maintaining some kind of persistence layer with pricing info?
>>>
>>>
>>> We are not currently working on the pricing, but eventually we'll have
>>> to.
>>> The idea was to define some scheduler with AI heuristics on it which can
>>> choose at each time the most cost-efficient provider for each job. I'm
>>> an AI PhD student after all.
>>> If we can get that information from an API we'll have to store it
>>> manually and provide an interface to update that information (we can't
>>> do anything else, can we?). But that's still a few months away.
>>>
>>>
>>> Thanks for your time,
>>> Dario.
>>>
>>>> Cheers
>>>> André
>>>>
>>>> On 12/20/2012 11:07 AM, marios@redhat.com wrote:
>>>>> Hi Dario:
>>>>>
>>>>> On 20/12/12 11:50, Dario Garcia Gasulla wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I'm Dario Garcia, a researcher from the Technical University of
>>>>>> Catalonia (UPC). In a research project we are developing together
with
>>>>>> other partners we are using deltacloud to manage connections to
>>>>>> various
>>>>>> IaaS providers. For this we require a java REST client which can
>>>>>> automate the requests to deltacloud.
>>>>> awesome - is there any more info on the project (e.g. do you have a
>>>>> website somewhere?)?
>>>>>
>>>>>> I've been looking for Java REST clients, and there is not a single
>>>>>> library which seems to be particularly appropriate. I also noticed
>>>>>> that
>>>>>> there's a client developed within the deltacloud project:
>>>>>> https://github.com/apache/deltacloud/tree/master/clients/java
>>>>>>
>>>>>> I've already downloaded this client and I'm currently testing it.
>>>>>> However, any information and help I could get about it would be most
>>>>>> useful.
>>>>>> My question mainly is, what is the state of this client? Which
>>>>>> functionalities work in the latest version?
>>>>>>
>>>>> wrt to the 'state' - I believe the last anyone worked on this client
is
>>>>> close to 2 years ago (that brave soul was Andre Dietisheim - I cc him
>>>>> here for any input/pointers he could give if he has the time these
>>>>> days).
>>>>>
>>>>> So I'm not quite sure what does/doesn't work there. My suggestion for
>>>>> now is to try it out. For those things that aren't working, file jira
>>>>> tickets [1] so they can be addressed. Even better, if you are able to
>>>>> implement the fixes yourself, we will be very happy to help you on your
>>>>> way (here/irc) ;) - on anything ranging from 'how to make patches' [2]
>>>>> to 'the layout of the deltacloud code' etc
>>>>>
>>>>> marios
>>>>>
>>>>>
>>>>> [1] https://issues.apache.org/jira/browse/DTACLOUD
>>>>> [2]
>>>>> http://www.youtube.com/watch?feature=player_embedded&v=cUC96SdQjaE#t=1827s
>>>>>
>>>>>
>>>>>
>>>>>> If I can get to use this client I could provide bugs reports and
usage
>>>>>> examples.
>>>>>>
>>>>>> Thanks in advance,
>>>>>> Dario.
>>>>>>
>>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message