libcloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Soren Hansen <so...@ubuntu.com>
Subject [PATCH 1/2] Make NodeImage accept an extra dict
Date Mon, 30 Nov 2009 21:49:21 GMT
Just like a Node, there are cases where it's useful to be able to tack
on extra information to a NodeImage.

This patch adds this capability with semantics identical to those of the
extra dict for Node.
---
 libcloud/base.py      |    6 +++++-
 libcloud/interface.py |    1 +
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/libcloud/base.py b/libcloud/base.py
index c99e1ca..764fd93 100644
--- a/libcloud/base.py
+++ b/libcloud/base.py
@@ -73,10 +73,14 @@ class NodeImage(object):
     interface.implements(INodeImage)
     interface.classProvides(INodeImageFactory)
 
-    def __init__(self, id, name, driver):
+    def __init__(self, id, name, driver, extra=None):
         self.id = id
         self.name = name
         self.driver = driver
+        if not extra:
+            self.extra = {}
+        else:
+            self.extra = extra
     def __repr__(self):
         return (('<NodeImage: id=%s, name=%s, driver=%s  ...>')
                 % (self.id, self.name, self.driver.name))
diff --git a/libcloud/interface.py b/libcloud/interface.py
index 22d4853..77cd18b 100644
--- a/libcloud/interface.py
+++ b/libcloud/interface.py
@@ -83,6 +83,7 @@ class INodeImage(Interface):
     id = Attribute("""Unique ID provided by the provider (ami-abcd1234, etc)""")
     name = Attribute("""Name provided by the provider (Ubuntu 8.1)""")
     driver = Attribute("""The NodeDriver that belongs to this Image""")
+    extra = Attribute("""Dict containing provider specific data""")
 
 
 class INodeImageFactory(Interface):
-- 
1.6.5


Mime
View raw message