[pkg-eucalyptus-commits] [SCM] managing cloud instances for Eucalyptus branch, master, updated. 3.0.0-alpha3-257-g1da8e3a

Matt Spaulding mspaulding06 at gmail.com
Sun Jun 16 02:31:27 UTC 2013


The following commit has been merged in the master branch:
commit ddf4086627aca1f7f77c428c3a0ba68210109683
Author: Matt Spaulding <mspaulding06 at gmail.com>
Date:   Wed May 15 16:54:33 2013 -0700

    Deal with ConnectionError exceptions and metadata
    
    Added support to metadata helper methods to deal with ConnectionError
    exceptions. When a ConnectionError is raised, the warning messages do
    not get displayed since we're only catching ServerError exceptions. I've
    added code to raise ConnectionError exceptions as ClientError exceptions
    and now when retrieving metadata we catch both ServerError and
    ClientError exceptions.

diff --git a/euca2ools/commands/bundle/bundlevol.py b/euca2ools/commands/bundle/bundlevol.py
index f60abde..20e0dbe 100644
--- a/euca2ools/commands/bundle/bundlevol.py
+++ b/euca2ools/commands/bundle/bundlevol.py
@@ -41,7 +41,7 @@ from euca2ools.commands.bundle.helpers import (check_metadata, get_metadata,
 from euca2ools.commands.bundle.imagecreator import ImageCreator
 from requestbuilder import Arg, MutuallyExclusiveArgList
 from requestbuilder.command import BaseCommand
-from requestbuilder.exceptions import ServerError
+from requestbuilder.exceptions import ClientError, ServerError
 
 
 IMAGE_MAX_SIZE_IN_MB = Bundle.EC2_IMAGE_SIZE_LIMIT / 1024 // 1024
@@ -131,7 +131,7 @@ class BundleVol(BundleCreator):
                 self.args['productcodes'].extend(productcodes)
                 self.log.debug("inheriting product codes: {0}"
                                .format(productcodes))
-            except ServerError:
+            except (ClientError, ServerError):
                 msg = 'unable to read product codes from metadata.'
                 print sys.stderr, msg
                 self.log.warn(msg)
@@ -142,11 +142,11 @@ class BundleVol(BundleCreator):
                 self.args['ancestor_image_ids'].extend(ancestor_ids)
                 self.log.debug("inheriting ancestor ids: {0}"
                                .format(ancestor_ids))
-            except ServerError:
+            except (ClientError, ServerError):
                 msg = 'unable to read ancestor ids from metadata.'
                 print sys.stderr, msg
                 self.log.warn(msg)
-        except ServerError:
+        except (ClientError, ServerError):
             msg = ('Unable to read instance metadata.  Use --no-inherit if '
                    'you want to proceed without the metadata service.')
             print >> sys.stderr, msg
diff --git a/euca2ools/commands/bundle/helpers.py b/euca2ools/commands/bundle/helpers.py
index 781b260..415de3c 100644
--- a/euca2ools/commands/bundle/helpers.py
+++ b/euca2ools/commands/bundle/helpers.py
@@ -33,7 +33,7 @@ from euca2ools.commands.walrus.listbucket import ListBucket
 import os
 from requestbuilder.exceptions import ClientError, ServerError
 import requests
-from requests.exceptions import Timeout
+from requests.exceptions import Timeout, ConnectionError
 from urlparse import urljoin
 from xml.dom import minidom
 
@@ -97,9 +97,13 @@ def download_files(bucket, keys, directory, **kwargs):
 
 def check_metadata():
     """Check if instance metadata is available."""
-    response = requests.get(METADATA_URL)
-    if not response.ok:
-        raise ServerError(response)
+    try:
+        response = requests.get(METADATA_URL)
+        if not response.ok:
+            raise ServerError(response)
+    except ConnectionError as err:
+        raise ClientError("unable to contact metadata service: {0}"
+                          .format(err.args[0]))
 
 
 def get_metadata(*paths):
@@ -117,6 +121,9 @@ def get_metadata(*paths):
     except Timeout:
         raise ClientError("timeout occurred when getting metadata from {0}"
                           .format(url))
+    except ConnectionError as err:
+        raise ClientError("error occurred when getting metadata from {0}: {1}"
+                          .format(url, err.args[0]))
 
     if response.ok:
         return response.content

-- 
managing cloud instances for Eucalyptus



More information about the pkg-eucalyptus-commits mailing list