New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue LIBCLOUD-471: Add Get Console Output #209

Closed
wants to merge 3 commits into
base: trunk
from

Conversation

Projects
None yet
2 participants
@cderamus
Contributor

cderamus commented Dec 26, 2013

No description provided.

@Kami

View changes

Show outdated Hide outdated libcloud/compute/drivers/ec2.py
response = self.connection.request(self.path, params=params).object
return {'instance_id': findattr(element=response,

This comment has been minimized.

@Kami

Kami Dec 26, 2013

Member

Hm, you already need to have the instance id to retrieve the output (node.id) so I'm not sure how value does it add to return a dict here.

Unless timestamp is really crucial, I would prefer the method to directly return the console output (str).

@Kami

Kami Dec 26, 2013

Member

Hm, you already need to have the instance id to retrieve the output (node.id) so I'm not sure how value does it add to return a dict here.

Unless timestamp is really crucial, I would prefer the method to directly return the console output (str).

This comment has been minimized.

@cderamus

cderamus Dec 26, 2013

Contributor

I would have a hard time arguing that it's crucial :). I actually just thought it would be a nicety to have available if someone wanted it. If you want me to make that change I certainly can do that.

@cderamus

cderamus Dec 26, 2013

Contributor

I would have a hard time arguing that it's crucial :). I actually just thought it would be a nicety to have available if someone wanted it. If you want me to make that change I certainly can do that.

This comment has been minimized.

@Kami

Kami Dec 26, 2013

Member

After thinking about it some more, I actually think it would be useful to have access to timestamp here, so you should leave it as it is.

One use case I had in mind is determining if node is "stuck". If you have access to timestamp it makes it easier to do that. You can just periodically call this function and check if timestamp attribute has changed.

To make it more clear and useful, you should do two things:

  • Update the docstring and document which keys the return dict will always contain
  • Parse the timestamp and return a datetime object (libcloud.utils.iso8601.parse_date should do the trick)
@Kami

Kami Dec 26, 2013

Member

After thinking about it some more, I actually think it would be useful to have access to timestamp here, so you should leave it as it is.

One use case I had in mind is determining if node is "stuck". If you have access to timestamp it makes it easier to do that. You can just periodically call this function and check if timestamp attribute has changed.

To make it more clear and useful, you should do two things:

  • Update the docstring and document which keys the return dict will always contain
  • Parse the timestamp and return a datetime object (libcloud.utils.iso8601.parse_date should do the trick)
@Kami

View changes

Show outdated Hide outdated libcloud/compute/drivers/ec2.py
'timestamp': findattr(element=response,
xpath='timestamp',
namespace=NAMESPACE),
'output': findattr(element=response,

This comment has been minimized.

@Kami

Kami Dec 26, 2013

Member

To make it more user-friendly and useful, this function should also decode base64 encoded output and return a raw string.

base64.b64decode(b(base64_string))

Should do the trick.

@Kami

Kami Dec 26, 2013

Member

To make it more user-friendly and useful, this function should also decode base64 encoded output and return a raw string.

base64.b64decode(b(base64_string))

Should do the trick.

This comment has been minimized.

@cderamus

cderamus Dec 26, 2013

Contributor

I originally had that in there, but didn't know if you would want to bring in additional imports into the driver. I agree it's a good idea to decode. I'll update that now.

@cderamus

cderamus Dec 26, 2013

Contributor

I originally had that in there, but didn't know if you would want to bring in additional imports into the driver. I agree it's a good idea to decode. I'll update that now.

@cderamus

This comment has been minimized.

Show comment
Hide comment
@cderamus

cderamus Dec 26, 2013

Contributor

Good to go!

Contributor

cderamus commented Dec 26, 2013

Good to go!

@Kami

This comment has been minimized.

Show comment
Hide comment
@Kami

Kami Dec 26, 2013

Member

I've made two changes and merged patch into trunk:

  1. Removed obsolete comment from the docstring and clarified which keys the returned dictionary contains. The docstring you have provided didn't help much because you would still need to check the code to see which keys the dictionary contains.
  2. Fixed test failure on Python 3.3. base64.b64decode returns bytes in Python 3 and you need to call .decode on it to get a string back.
Member

Kami commented Dec 26, 2013

I've made two changes and merged patch into trunk:

  1. Removed obsolete comment from the docstring and clarified which keys the returned dictionary contains. The docstring you have provided didn't help much because you would still need to check the code to see which keys the dictionary contains.
  2. Fixed test failure on Python 3.3. base64.b64decode returns bytes in Python 3 and you need to call .decode on it to get a string back.
@cderamus

This comment has been minimized.

Show comment
Hide comment
@cderamus

cderamus Dec 26, 2013

Contributor

Great, thanks!

Contributor

cderamus commented Dec 26, 2013

Great, thanks!

@cderamus cderamus closed this Dec 26, 2013

@cderamus cderamus deleted the DivvyCloud:LIBCLOUD-471_Add_Get_Console_Output branch Dec 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment