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

Add created datetime to node #698

Merged
merged 1 commit into from Feb 12, 2016

Conversation

Projects
None yet
5 participants
@allardhoeve
Contributor

allardhoeve commented Feb 10, 2016

Instead of the implementation in #697, I'd like to propose this instead.

The problem with #697 is that when you want to find a list of old nodes when you have a list of Node objects, you'd need to write:

old_nodes = [n for n in nodes if n.driver.ex_creation_time(n) > too_old]

Yuk, why is that driver in there? Better would be to write:

old_nodes = [n for n in nodes if n.created > too_old]

I have implemented this code for OpenStack, Digital Ocean and EC2. Other drivers, I have no access to. In those cases, the behaviour is to have created be NoneType.

@allardhoeve

This comment has been minimized.

Show comment
Hide comment
Contributor

allardhoeve commented Feb 10, 2016

@tonybaloney

This comment has been minimized.

Show comment
Hide comment
@tonybaloney

tonybaloney Feb 11, 2016

Contributor

this is a good addition to the base class. I agree with you @allardhoeve it is a good design. 👍

Contributor

tonybaloney commented Feb 11, 2016

this is a good addition to the base class. I agree with you @allardhoeve it is a good design. 👍

Show outdated Hide outdated libcloud/compute/base.py
@@ -167,7 +167,7 @@ class Node(UuidMixin):
"""
def __init__(self, id, name, state, public_ips, private_ips,
driver, size=None, image=None, extra=None):
driver, size=None, image=None, created=None, extra=None):

This comment has been minimized.

@Kami

Kami Feb 11, 2016

Member

I would prefer the attribute to be called created_at.

@Kami

Kami Feb 11, 2016

Member

I would prefer the attribute to be called created_at.

@Kami

This comment has been minimized.

Show comment
Hide comment
@Kami

Kami Feb 11, 2016

Member

It's also worth noting that this is a backward incompatible change for any place which doesn't use keyword arguments so we need to make sure it doesn't break any of the existing drivers and document it in the upgrade notes.

Member

Kami commented Feb 11, 2016

It's also worth noting that this is a backward incompatible change for any place which doesn't use keyword arguments so we need to make sure it doesn't break any of the existing drivers and document it in the upgrade notes.

@allardhoeve

This comment has been minimized.

Show comment
Hide comment
@allardhoeve

allardhoeve Feb 11, 2016

Contributor

I could put the new keyword after the extra=None, that way it breaks nothing. But yes, it should be in the Changelog

Contributor

allardhoeve commented Feb 11, 2016

I could put the new keyword after the extra=None, that way it breaks nothing. But yes, it should be in the Changelog

@vdloo

This comment has been minimized.

Show comment
Hide comment
@vdloo

vdloo Feb 11, 2016

Member

I agree, this is better than using the driver and passing the node object in 👍

Member

vdloo commented Feb 11, 2016

I agree, this is better than using the driver and passing the node object in 👍

@allardhoeve

This comment has been minimized.

Show comment
Hide comment
@allardhoeve

allardhoeve Feb 12, 2016

Contributor

Okey, I changed the field name to created_at and the order of the named arguments. If everyone is on board, I'd like to commit this and revert #697.

Contributor

allardhoeve commented Feb 12, 2016

Okey, I changed the field name to created_at and the order of the named arguments. If everyone is on board, I'd like to commit this and revert #697.

@tonybaloney

This comment has been minimized.

Show comment
Hide comment
@tonybaloney

tonybaloney Feb 12, 2016

Contributor

👍 from me

Contributor

tonybaloney commented Feb 12, 2016

👍 from me

Nodes now have a `created_at` attribute
* Base Node object has `created_at` which indicates the `datetime` the
  node was launched/started/created.
* EC2, Digital Ocean, OpenStack fill this attribute.
* Nodes at drivers that do not (yet) support it have `NoneType` as date.
* Document changes.

closes #698

[GITHUB-698]

Signed-off-by: Allard Hoeve <allardhoeve@gmail.com>

@asfgit asfgit merged commit 72399b4 into apache:trunk Feb 12, 2016

1 of 2 checks passed

continuous-integration/travis-ci/push The Travis CI build is in progress
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@allardhoeve allardhoeve deleted the ByteInternet:add-created-datetime-to-node branch Feb 12, 2016

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