commit 4e6f9904262f10221a7ddaaee767591e77e3efee
Author: Markos Gogoulos <mgogoulos@unweb.me>
Date:   Wed Mar 23 18:25:00 2011 +0200

    remove description fields for VM, Image
    
     * remove description from VirtualMachine model, handlers and tests
     * return images metadata (as on servers). for now return image.description as image.metadata.meta.key.description
    
    Ref #185

diff --git a/api/fixtures/api_redux_test_data.json b/api/fixtures/api_redux_test_data.json
index 6c0806f..975454a 100644
--- a/api/fixtures/api_redux_test_data.json
+++ b/api/fixtures/api_redux_test_data.json
@@ -63,4 +63,4 @@
             "disk": 80 
         }
     }
-]
\ No newline at end of file
+]
diff --git a/api/fixtures/api_test_data.json b/api/fixtures/api_test_data.json
index 482bcba..edd4cb7 100644
--- a/api/fixtures/api_test_data.json
+++ b/api/fixtures/api_test_data.json
@@ -265,7 +265,6 @@
             "charged": "2011-02-06 00:00:00",
             "sourceimage": 1,
             "hostid": "HAL-9000",
-            "description": "database server",
             "ipfour": "192.168.2.1",
             "ipsix": "::1",
             "flavor": 1,
@@ -283,7 +282,6 @@
             "charged": "2011-02-10 00:00:00",
             "sourceimage": 1,
             "hostid": "HAL-9000",
-            "description": "mail server",
             "ipfour": "192.168.2.2",
             "ipsix": "::2",
             "flavor": 1,
@@ -301,7 +299,6 @@
             "charged": "2011-02-10 00:00:00",
             "sourceimage": 1,
             "hostid": "HAL-9000",
-            "description": "my server",
             "ipfour": "192.168.2.3",
             "ipsix": "::3",
             "flavor": 1,
@@ -319,7 +316,6 @@
             "charged": "2011-02-10 00:00:00",
             "sourceimage": 1,
             "hostid": "HAL-9000",
-            "description": "my 2nd server",
             "ipfour": "192.168.2.4",
             "ipsix": "::4",
             "flavor": 1,
diff --git a/api/handlers.py b/api/handlers.py
index 76bd68f..5bbf9b6 100644
--- a/api/handlers.py
+++ b/api/handlers.py
@@ -106,7 +106,6 @@ class ServerHandler(BaseHandler):
             server = {'status': server.rsapi_state, 
                      'flavorRef': server.flavor.id, 
                      'name': server.name, 
-                     'description': server.description, 
                      'id': server.id, 
                      'imageRef': server.sourceimage.id,
                      'created': server.created, 
@@ -149,7 +148,6 @@ class ServerHandler(BaseHandler):
                                          'flavorRef': server.flavor.id, 
                                          'name': server.name, 
                                          'id': server.id, 
-                                         'description': server.description, 
                                          'created': server.created, 
                                          'updated': server.updated,
                                          'imageRef': server.sourceimage.id, 
@@ -254,7 +252,7 @@ class ServerHandler(BaseHandler):
                 "progress" : 0,
                 "status" : 'BUILD',
                 "adminPass" : self.random_password(),
-                "metadata" : {"My Server Name" : vm.description},
+                "metadata" : {"My Server Name" : vm.name},
                 "addresses" : {
                     "public" : [  ],
                     "private" : [  ],
@@ -639,11 +637,12 @@ class ImageHandler(BaseHandler):
                         'id': image.id,
                         'name': image.name,
                         'updated': image.updated.isoformat(),    
-                        'description': image.description, 
                         'status': image.state, 
                         'progress': image.state == 'ACTIVE' and 100 or 0, 
                         'size': image.size, 
-                        'serverId': image.sourcevm and image.sourcevm.id or ""
+                        'serverId': image.sourcevm and image.sourcevm.id or "",
+                        #'metadata':[{'meta': { 'key': {metadata.meta_key: metadata.meta_value}}} for metadata in image.imagemetadata_set.all()]
+                        'metadata':{'meta': { 'key': {'description': image.description}}},
                        } for image in images]
             # Images info is stored in the DB. Ganeti is not aware of this
             if id == "detail":
@@ -660,7 +659,9 @@ class ImageHandler(BaseHandler):
                     'status': image.state, 
                     'progress': image.state == 'ACTIVE' and 100 or 0, 
                     'size': image.size, 
-                    'serverId': image.sourcevm and image.sourcevm.id or ""
+                    'serverId': image.sourcevm and image.sourcevm.id or "",
+                    #'metadata':[{'meta': { 'key': {metadata.meta_key: metadata.meta_value}}} for metadata in image.imagemetadata_set.all()]
+                    'metadata':{'meta': { 'key': {'description': image.description}}},
                    } }
         except Image.DoesNotExist:
                     raise fault.itemNotFound
diff --git a/api/servers.py b/api/servers.py
index 3749008..0ba8d48 100644
--- a/api/servers.py
+++ b/api/servers.py
@@ -66,7 +66,7 @@ def server_to_dict(server, detail=False):
         d['created'] = server.created.isoformat()
         d['flavorRef'] = server.flavor.id
         d['imageRef'] = server.sourceimage.id
-        d['description'] = server.description       # XXX Not in OpenStack docs
+        #d['description'] = server.description       # XXX Not in OpenStack docs
         
         server_meta = server.virtualmachinemetadata_set.all()
         metadata = dict((meta.meta_key, meta.meta_value) for meta in server_meta)
diff --git a/api/tests.py b/api/tests.py
index 9896c06..1e5140b 100644
--- a/api/tests.py
+++ b/api/tests.py
@@ -287,7 +287,7 @@ class APITestCase(TestCase):
         self.assertEqual(image_from_api['serverId'], image_from_db.sourcevm and image_from_db.sourcevm.id or "")
         self.assertEqual(image_from_api['size'], image_from_db.size)
         self.assertEqual(image_from_api['status'], image_from_db.state)
-        self.assertEqual(image_from_api['description'], image_from_db.description)
+        self.assertEqual(image_from_api['metadata']['meta']['key']['description'], image_from_db.description)
         self.assertTrue(response.status_code in [200,203])
 
 
@@ -305,7 +305,7 @@ class APITestCase(TestCase):
             self.assertEqual(image_from_api['serverId'], image_from_db.sourcevm and image_from_db.sourcevm.id or "")
             self.assertEqual(image_from_api['size'], image_from_db.size)
             self.assertEqual(image_from_api['status'], image_from_db.state)
-            self.assertEqual(image_from_api['description'], image_from_db.description)
+            self.assertEqual(image_from_api['metadata']['meta']['key']['description'], image_from_db.description)
 
         for image_from_api in images_from_api:
             image_from_db = Image.objects.get(id=image_from_api['id'])
@@ -314,7 +314,7 @@ class APITestCase(TestCase):
             self.assertEqual(image_from_api['serverId'], image_from_db.sourcevm and image_from_db.sourcevm.id or "")
             self.assertEqual(image_from_api['size'], image_from_db.size)
             self.assertEqual(image_from_api['status'], image_from_db.state)
-            self.assertEqual(image_from_api['description'], image_from_db.description)
+            self.assertEqual(image_from_api['metadata']['meta']['key']['description'], image_from_db.description)
             
         self.assertTrue(response.status_code in [200,203])
 
diff --git a/db/models.py b/db/models.py
index 7e5e257..a4ab798 100644
--- a/db/models.py
+++ b/db/models.py
@@ -314,7 +314,6 @@ class VirtualMachine(models.Model):
     charged = models.DateTimeField(default=datetime.datetime.now())
     sourceimage = models.ForeignKey("Image", null=False) 
     hostid = models.CharField(max_length=100)
-    description = models.TextField()
     ipfour = models.IPAddressField()
     ipsix = models.CharField(max_length=100)
     flavor = models.ForeignKey(Flavor)
diff --git a/ui/static/synnefo.js b/ui/static/synnefo.js
index 108d7c6..edc5878 100644
--- a/ui/static/synnefo.js
+++ b/ui/static/synnefo.js
@@ -182,7 +182,7 @@ function update_images() {
                     var img = $('#image-template').clone().attr("id","img-"+image.id).fadeIn("slow");
                     img.find("label").attr('for',"img-radio-" + image.id);
                     img.find(".image-title").text(image.name);
-                    img.find(".description").text(image.description);
+                    img.find(".description").text(image.metadata.meta.key.description);
                     img.find(".size").text(image.size);
                     img.find("input.radio").attr('id',"img-radio-" + image.id);
                     if (i==0) img.find("input.radio").attr("checked","checked"); 
