← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~bac/launchpad/update-image into lp:launchpad

 

Brad Crittenden has proposed merging lp:~bac/launchpad/update-image into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~bac/launchpad/update-image/+merge/74430

= Summary =

Images in AWS do not have a creation date.  It is therefore not
possible to know when an image was created to determine if a new one
is needed.

== Proposed fix ==

When creating a new AMI set the description to the creation date.
Change 'ec2 images' to display this description.
-- 
https://code.launchpad.net/~bac/launchpad/update-image/+merge/74430
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~bac/launchpad/update-image into lp:launchpad.
=== modified file 'lib/devscripts/ec2test/builtins.py'
--- lib/devscripts/ec2test/builtins.py	2011-03-31 16:06:16 +0000
+++ lib/devscripts/ec2test/builtins.py	2011-09-07 13:46:24 +0000
@@ -672,13 +672,15 @@
         credentials = EC2Credentials.load_from_file()
         session_name = EC2SessionName.make(EC2TestRunner.name)
         account = credentials.connect(session_name)
-        format = "%5s  %-12s  %-12s  %s\n"
-        self.outf.write(format % ("Rev", "AMI", "Owner ID", "Owner"))
+        format = "%5s  %-12s  %-12s  %-12s %s\n"
+        self.outf.write(
+            format % ("Rev", "AMI", "Owner ID", "Owner", "Description"))
         for revision, images in account.find_images():
             for image in images:
                 self.outf.write(format % (
-                        revision, image.id, image.ownerId,
-                        VALID_AMI_OWNERS.get(image.ownerId, "unknown")))
+                    revision, image.id, image.ownerId,
+                    VALID_AMI_OWNERS.get(image.ownerId, "unknown"),
+                    image.description or ''))
 
 
 class cmd_list(EC2Command):
@@ -743,7 +745,7 @@
         uptime = self.get_uptime(instance)
         if data is None:
             description = instance.id
-            current_status =     'unknown '
+            current_status = 'unknown '
         else:
             description = data['description']
             if data['failed-yet']:

=== modified file 'lib/devscripts/ec2test/instance.py'
--- lib/devscripts/ec2test/instance.py	2011-04-05 23:37:12 +0000
+++ lib/devscripts/ec2test/instance.py	2011-09-07 13:46:24 +0000
@@ -18,7 +18,7 @@
 import sys
 import time
 import traceback
-
+from datetime import datetime
 from bzrlib.errors import BzrCommandError
 from devscripts.ec2test.session import EC2SessionName
 import paramiko
@@ -575,11 +575,14 @@
         env = os.environ.copy()
         if 'JAVA_HOME' not in os.environ:
             env['JAVA_HOME'] = '/usr/lib/jvm/default-java'
+        now = datetime.strftime(datetime.utcnow(), "%Y-%m-%d %H:%M:%S UTC")
+        description = "Created %s" % now
         cmd = [
             'ec2-register',
             '--private-key=%s' % self.local_pk,
             '--cert=%s' % self.local_cert,
             '--name=%s' % (name,),
+            '--description=%s' % description,
             manifest_path,
             ]
         self.log("Executing command: %s" % ' '.join(cmd))