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

Garrett Holmstrom gholms at fedoraproject.org
Sun Jun 16 02:31:29 UTC 2013


The following commit has been merged in the master branch:
commit 1c69a8896feea9e731b27a3e5b2d568c0471f27d
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date:   Wed May 22 16:33:04 2013 -0700

    Assorted cleanup, bugfixes to appease pylint

diff --git a/bin/euca-bundle-vol b/bin/euca-bundle-vol
index 4e9e3c2..e3bdcd2 100755
--- a/bin/euca-bundle-vol
+++ b/bin/euca-bundle-vol
@@ -1,38 +1,4 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
-# All rights reserved.
-#
-# Redistribution and use of this software in source and binary forms, with or
-# without modification, are permitted provided that the following conditions
-# are met:
-#
-#   Redistributions of source code must retain the above
-#   copyright notice, this list of conditions and the
-#   following disclaimer.
-#
-#   Redistributions in binary form must reproduce the above
-#   copyright notice, this list of conditions and the
-#   following disclaimer in the documentation and/or other
-#   materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Neil Soman neil at eucalyptus.com
-#         Mitch Garnaat mgarnaat at eucalyptus.com
+#!/usr/bin/python -tt
 
 import euca2ools.commands.bundle.bundlevol
 
diff --git a/bin/euca-version b/bin/euca-version
index 33bbc34..16256c3 100755
--- a/bin/euca-version
+++ b/bin/euca-version
@@ -1,35 +1,5 @@
 #!/usr/bin/python -tt
 
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009-2013, Eucalyptus Systems, Inc.
-# All rights reserved.
-#
-# Redistribution and use of this software in source and binary forms, with or
-# without modification, are permitted provided that the following conditions
-# are met:
-#
-#   Redistributions of source code must retain the above
-#   copyright notice, this list of conditions and the
-#   following disclaimer.
-#
-#   Redistributions in binary form must reproduce the above
-#   copyright notice, this list of conditions and the
-#   following disclaimer in the documentation and/or other
-#   materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
 import euca2ools.commands
 import sys
 
diff --git a/euca2ools/commands/argtypes.py b/euca2ools/commands/argtypes.py
index 333c7fc..95c9365 100644
--- a/euca2ools/commands/argtypes.py
+++ b/euca2ools/commands/argtypes.py
@@ -199,12 +199,12 @@ def vpc_interface(iface_as_str):
         iface['SecurityGroupId'] = groups
     if bits[6]:
         # DeleteOnTermination
-            if bits[6] in ('true', 'false'):
-                iface['DeleteOnTermination'] = bits[6]
-            else:
-                raise argparse.ArgumentTypeError(
-                    'seventh element of network interface definition "{0}" '
-                    'must be "true" or "false"'.format(iface_as_str))
+        if bits[6] in ('true', 'false'):
+            iface['DeleteOnTermination'] = bits[6]
+        else:
+            raise argparse.ArgumentTypeError(
+                'seventh element of network interface definition "{0}" '
+                'must be "true" or "false"'.format(iface_as_str))
     if bits[7]:
         # SecondaryPrivateIpAddressCount
         if bits[8]:
@@ -219,10 +219,10 @@ def vpc_interface(iface_as_str):
                 'an integer'.format(iface_as_str))
     if bits[8]:
         # PrivateIpAddresses.n.PrivateIpAddress
-            sec_ips = [{'PrivateIpAddress': addr} for addr in
-                       bits[8].split(',') if addr]
-            iface.setdefault('PrivateIpAddresses', [])
-            iface['PrivateIpAddresses'].extend(sec_ips)
+        sec_ips = [{'PrivateIpAddress': addr} for addr in
+                   bits[8].split(',') if addr]
+        iface.setdefault('PrivateIpAddresses', [])
+        iface['PrivateIpAddresses'].extend(sec_ips)
     return iface
 
 
diff --git a/euca2ools/commands/autoscaling/createlaunchconfiguration.py b/euca2ools/commands/autoscaling/createlaunchconfiguration.py
index 792b5fa..b43af1e 100644
--- a/euca2ools/commands/autoscaling/createlaunchconfiguration.py
+++ b/euca2ools/commands/autoscaling/createlaunchconfiguration.py
@@ -32,7 +32,9 @@ import base64
 from euca2ools.commands.argtypes import (delimited_list,
     ec2_block_device_mapping)
 from euca2ools.commands.autoscaling import AutoScalingRequest
+import os.path
 from requestbuilder import Arg, MutuallyExclusiveArgList
+from requestbuilder.exceptions import ArgumentError
 
 
 class CreateLaunchConfiguration(AutoScalingRequest):
diff --git a/euca2ools/commands/autoscaling/putscalingpolicy.py b/euca2ools/commands/autoscaling/putscalingpolicy.py
index fd3cac7..a4e086d 100644
--- a/euca2ools/commands/autoscaling/putscalingpolicy.py
+++ b/euca2ools/commands/autoscaling/putscalingpolicy.py
@@ -28,7 +28,6 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-from euca2ools.commands.argtypes import delimited_list
 from euca2ools.commands.autoscaling import AutoScalingRequest
 from requestbuilder import Arg
 
diff --git a/euca2ools/commands/bundle/bundle.py b/euca2ools/commands/bundle/bundle.py
index 30404ba..336978f 100644
--- a/euca2ools/commands/bundle/bundle.py
+++ b/euca2ools/commands/bundle/bundle.py
@@ -71,9 +71,9 @@ class Bundle(object):
     def create_from_image(cls, image_filename, part_prefix, part_size=None,
                           progressbar=None):
         new_bundle = cls()
-        new_bundle.__create_from_image(image_filename, part_prefix,
-                                       part_size=part_size,
-                                       progressbar=progressbar)
+        new_bundle._create_from_image(image_filename, part_prefix,
+                                      part_size=part_size,
+                                      progressbar=progressbar)
         return new_bundle
 
     @classmethod
@@ -107,8 +107,8 @@ class Bundle(object):
             new_bundle.parts.append(part_dict)
         return new_bundle
 
-    def __create_from_image(self, image_filename, part_prefix, part_size=None,
-                            progressbar=None):
+    def _create_from_image(self, image_filename, part_prefix, part_size=None,
+                           progressbar=None):
         if part_size is None:
             part_size = self.DEFAULT_PART_SIZE
         with self._lock:
@@ -363,7 +363,7 @@ def _try_to_decrypt_keys(hex_encrypted_keys, privkey_filename):
             return decrypted_key
         except ValueError:
             pass
-    raise ValueError("Failed to decrypt the manifest's encryption info.  "
+    raise ValueError("Failed to decrypt the bundle's encryption key.  "
                      "Ensure the key supplied matches the one used for "
                      "bundling.")
 
diff --git a/euca2ools/commands/bundle/bundleimage.py b/euca2ools/commands/bundle/bundleimage.py
index 55de5a4..226ee51 100644
--- a/euca2ools/commands/bundle/bundleimage.py
+++ b/euca2ools/commands/bundle/bundleimage.py
@@ -89,11 +89,11 @@ class BundleImage(BundleCreator):
         self.log.debug('bundle path prefix: %s', path_prefix)
 
         label = self.args.get('progressbar_label', 'Bundling image')
-        bar = self.get_progressbar(label=label,
-                                   maxval=os.path.getsize(self.args['image']))
+        pbar = self.get_progressbar(label=label,
+                                    maxval=os.path.getsize(self.args['image']))
         bundle = Bundle.create_from_image(
             self.args['image'], path_prefix,
-            part_size=self.args.get('part_size'), progressbar=bar)
+            part_size=self.args.get('part_size'), progressbar=pbar)
         manifest = self.generate_manifest_xml(bundle)
         manifest_filename = path_prefix + '.manifest.xml'
         with open(manifest_filename, 'w') as manifest_file:
diff --git a/euca2ools/commands/bundle/bundlevol.py b/euca2ools/commands/bundle/bundlevol.py
index 20e0dbe..f1784d1 100644
--- a/euca2ools/commands/bundle/bundlevol.py
+++ b/euca2ools/commands/bundle/bundlevol.py
@@ -40,7 +40,6 @@ from euca2ools.commands.bundle.helpers import (check_metadata, get_metadata,
                                                get_metadata_list)
 from euca2ools.commands.bundle.imagecreator import ImageCreator
 from requestbuilder import Arg, MutuallyExclusiveArgList
-from requestbuilder.command import BaseCommand
 from requestbuilder.exceptions import ClientError, ServerError
 
 
@@ -55,8 +54,8 @@ BUNDLE_IMAGE_ARG_FILTER = ('generate_fstab', 'fstab', 'bundle_all_dirs',
 
 
 class BundleVol(BundleCreator):
-    DESCRIPTION = '''Bundle an image for use with Eucalyptus or Amazon EC2
-                  (requires superuser privileges).'''
+    DESCRIPTION = ("Create a bundled iamge based on the running machine's "
+                   'filesystem\n\nThis command must be run as the superuser.')
     ARGS = [Arg('-s', '--size', metavar='MB',
                 type=filesize, default=IMAGE_MAX_SIZE_IN_MB,
                 help='''Size of the image in MB (default: {0}; recommended
@@ -92,14 +91,13 @@ class BundleVol(BundleCreator):
                     help='Generate fstab to bundle in image.'))]
 
     def __init__(self, **kwargs):
-        #
-        # We want to do this before arguments to the command are processed.
-        # Users should be informed if they don't have sufficient privileges
-        # before being told about missing required arguments.
-        #
-        if os.geteuid() != 0:
-            raise Exception("must be root user to run euca-bundle-vol.")
-        BaseCommand.__init__(self, **kwargs)
+        if (os.geteuid() != 0 and '--help' not in sys.argv and
+            '-h' not in sys.argv):
+            # Inform people with insufficient privileges before parsing args
+            # so they don't have to wade through required arg messages and
+            # whatnot first.
+            raise Exception("must be superuser")
+        BundleCreator.__init__(self, **kwargs)
 
     def _inherit_metadata(self):
         """Read instance metadata which we will propagate to the BundleImage
diff --git a/euca2ools/commands/bundle/deletebundle.py b/euca2ools/commands/bundle/deletebundle.py
index ff11ab7..a96aab6 100644
--- a/euca2ools/commands/bundle/deletebundle.py
+++ b/euca2ools/commands/bundle/deletebundle.py
@@ -41,7 +41,6 @@ from requestbuilder.exceptions import ArgumentError
 import argparse
 import os
 import shutil
-import sys
 import tempfile
 
 
diff --git a/euca2ools/commands/bundle/downloadbundle.py b/euca2ools/commands/bundle/downloadbundle.py
index 5babb5a..3116a7d 100644
--- a/euca2ools/commands/bundle/downloadbundle.py
+++ b/euca2ools/commands/bundle/downloadbundle.py
@@ -39,7 +39,6 @@ import os
 from requestbuilder import Arg, MutuallyExclusiveArgList
 from requestbuilder.exceptions import ArgumentError
 import shutil
-import sys
 
 
 class DownloadBundle(WalrusRequest):
diff --git a/euca2ools/commands/bundle/imagecreator.py b/euca2ools/commands/bundle/imagecreator.py
index f86aa7a..cde505e 100644
--- a/euca2ools/commands/bundle/imagecreator.py
+++ b/euca2ools/commands/bundle/imagecreator.py
@@ -134,8 +134,8 @@ class VolumeSync(object):
         # the user keeps their fstab from the original volume.
         #
         if self.fstab:
-            with open(self.fstab, 'r') as fp:
-                self._install_fstab(fp.read())
+            with open(self.fstab, 'r') as fstab_file:
+                self._install_fstab(fstab_file.read())
         elif self.generate_fstab_file:
             self._install_generated_fstab()
 
@@ -201,7 +201,7 @@ class VolumeSync(object):
         """
         with open(MOUNTS_FILE, 'r') as mounts:
             for line in mounts.readlines():
-                (mount, type) = line.split()[1:3]
+                (mount, fstype) = line.split()[1:3]
                 #
                 # If we find that a mount in our volume's mtab file is
                 # and shares a parent directory with the volume we will
@@ -209,8 +209,9 @@ class VolumeSync(object):
                 # (e.g., NFS) and we will exclude it. This will not happen
                 # if you have chosen the 'all' option.
                 #
-                if mount.find(self.volume) == 0 and type \
-                    not in ALLOWED_FS_TYPES:
+                if (mount.find(self.volume) == 0 and
+                    fstype not in ALLOWED_FS_TYPES):
+
                     self.excludes.append(mount)
 
     def _populate_tmpfs_mounts(self):
@@ -219,8 +220,8 @@ class VolumeSync(object):
         """
         with open(MOUNTS_FILE, 'r') as mounts:
             for line in mounts.readlines():
-                (mount, type) = line.split()[1:3]
-                if type == 'tmpfs':
+                (mount, fstype) = line.split()[1:3]
+                if fstype == 'tmpfs':
                     fullpath = os.path.join(self.mpoint, mount[1:])
                     if not os.path.exists(fullpath):
                         os.makedirs(fullpath)
@@ -244,12 +245,12 @@ class VolumeSync(object):
         self._install_fstab(_generate_fstab_content())
 
     def _install_fstab(self, content):
-        curr_fstab = os.path.join(self.mpoint, 'etc', 'fstab')
-        if os.path.exists(curr_fstab):
-            shutil.copyfile(curr_fstab, curr_fstab + '.old')
-            os.remove(curr_fstab)
-        with open(os.path.join(self.mpoint, 'etc', 'fstab'), 'wb') as fp:
-            fp.write(content)
+        fstab_path = os.path.join(self.mpoint, 'etc', 'fstab')
+        if os.path.exists(fstab_path):
+            shutil.copyfile(fstab_path, fstab_path + '.old')
+            os.remove(fstab_path)
+        with open(fstab_path, 'wb') as fstab:
+            fstab.write(content)
 
     def _sync_files(self):
         cmd = ['rsync', '-aXS']
@@ -298,7 +299,7 @@ class VolumeSync(object):
         self.mount()
         return self
 
-    def __exit__(self, type, value, traceback):
+    def __exit__(self, exc_type, exc_value, traceback):
         self.unmount()
 
 
@@ -308,7 +309,7 @@ class ImageCreator(object):
         # Assign settings for image creation
         #
         self.log = log
-        self.fs = {}
+        self.filesystem = {}
         self.volume = kwargs.get('volume')
         self.fstab = kwargs.get('fstab')
         self.generate_fstab = kwargs.get('generate_fstab', False)
@@ -346,7 +347,7 @@ class ImageCreator(object):
         print >> sys.stderr, "Creating image...",
         self._create_raw_diskimage()
         self._populate_filesystem_info()
-        self._make_filesystem(**self.fs)
+        self._make_filesystem(**self.filesystem)
         print >> sys.stderr, " done"
         #
         # Inside the VolumeSync context we will mount our image
@@ -393,7 +394,7 @@ class ImageCreator(object):
                                             '-ovalue', devnode],
                                            stdout=subprocess.PIPE
                                            ).communicate()[0]
-                    self.fs[tag.lower()] = out.rstrip()
+                    self.filesystem[tag.lower()] = out.rstrip()
                 except subprocess.CalledProcessError:
                     pass
         finally:
diff --git a/euca2ools/commands/bundle/uploadbundle.py b/euca2ools/commands/bundle/uploadbundle.py
index 9c1fc2c..9b28bb5 100644
--- a/euca2ools/commands/bundle/uploadbundle.py
+++ b/euca2ools/commands/bundle/uploadbundle.py
@@ -28,7 +28,6 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-from euca2ools.commands import Euca2ools
 from euca2ools.commands.walrus import WalrusRequest
 from euca2ools.commands.walrus.checkbucket import CheckBucket
 from euca2ools.commands.walrus.createbucket import CreateBucket
@@ -37,12 +36,8 @@ from euca2ools.exceptions import AWSError
 import lxml.etree
 import lxml.objectify
 import os.path
-from requestbuilder import Arg, MutuallyExclusiveArgList
-from requestbuilder.auth import S3RestAuth
-from requestbuilder.command import BaseCommand
-from requestbuilder.exceptions import ServerError
+from requestbuilder import Arg
 from requestbuilder.mixins import FileTransferProgressBarMixin
-from requestbuilder.util import set_userregion
 
 
 class UploadBundle(WalrusRequest, FileTransferProgressBarMixin):
diff --git a/euca2ools/commands/elasticloadbalancing/argtypes.py b/euca2ools/commands/elasticloadbalancing/argtypes.py
index da82bd6..b0ab200 100644
--- a/euca2ools/commands/elasticloadbalancing/argtypes.py
+++ b/euca2ools/commands/elasticloadbalancing/argtypes.py
@@ -32,7 +32,6 @@ import argparse
 
 
 def listener(listener_str):
-    bits = listener_str.split(',')
     pairs = {}
     for pair_str in listener_str.strip().split(','):
         if pair_str:
diff --git a/euca2ools/commands/elasticloadbalancing/deregisterinstancesfromloadbalancer.py b/euca2ools/commands/elasticloadbalancing/deregisterinstancesfromloadbalancer.py
index a6bff98..ae86a53 100644
--- a/euca2ools/commands/elasticloadbalancing/deregisterinstancesfromloadbalancer.py
+++ b/euca2ools/commands/elasticloadbalancing/deregisterinstancesfromloadbalancer.py
@@ -34,7 +34,7 @@ from requestbuilder import Arg
 from requestbuilder.mixins import TabifyingMixin
 
 
-def instance(inst_as_str):
+def instance_id(inst_as_str):
     return {'InstanceId': inst_as_str}
 
 
@@ -44,7 +44,7 @@ class DeregisterInstancesFromLoadBalancer(ELBRequest, TabifyingMixin):
                 help='name of the load balancer to modify (required)'),
             Arg('--instances', dest='Instances.member', required=True,
                 metavar='INSTANCE1,INSTANCE2,...',
-                type=delimited_list(',', item_type=instance),
+                type=delimited_list(',', item_type=instance_id),
                 help='''IDs of the instances to remove from the load balancer
                 (required)''')]
     LIST_TAGS = ['Instances']
diff --git a/euca2ools/commands/elasticloadbalancing/describeinstancehealth.py b/euca2ools/commands/elasticloadbalancing/describeinstancehealth.py
index 9861a4e..8964d52 100644
--- a/euca2ools/commands/elasticloadbalancing/describeinstancehealth.py
+++ b/euca2ools/commands/elasticloadbalancing/describeinstancehealth.py
@@ -34,7 +34,7 @@ from requestbuilder import Arg
 from requestbuilder.mixins import TabifyingMixin
 
 
-def instance(inst_as_str):
+def instance_id(inst_as_str):
     return {'InstanceId': inst_as_str}
 
 
@@ -44,7 +44,7 @@ class DescribeInstanceHealth(ELBRequest, TabifyingMixin):
                 balancer to describe instances for (required)'''),
             Arg('--instances', dest='Instances.member',
                 metavar='INSTANCE1,INSTANCE2,...',
-                type=delimited_list(',', item_type=instance),
+                type=delimited_list(',', item_type=instance_id),
                 help='limit results to specific instances'),
             Arg('--show-long', action='store_true', route_to=None,
                 help="show all of the instances' info")]
diff --git a/euca2ools/commands/elasticloadbalancing/registerinstanceswithloadbalancer.py b/euca2ools/commands/elasticloadbalancing/registerinstanceswithloadbalancer.py
index f61f27b..afda9c5 100644
--- a/euca2ools/commands/elasticloadbalancing/registerinstanceswithloadbalancer.py
+++ b/euca2ools/commands/elasticloadbalancing/registerinstanceswithloadbalancer.py
@@ -34,7 +34,7 @@ from requestbuilder import Arg
 from requestbuilder.mixins import TabifyingMixin
 
 
-def instance(inst_as_str):
+def instance_id(inst_as_str):
     return {'InstanceId': inst_as_str}
 
 
@@ -44,7 +44,7 @@ class RegisterInstancesWithLoadBalancer(ELBRequest, TabifyingMixin):
                 help='name of the load balancer to modify (required)'),
             Arg('--instances', dest='Instances.member', required=True,
                 metavar='INSTANCE1,INSTANCE2,...',
-                type=delimited_list(',', item_type=instance),
+                type=delimited_list(',', item_type=instance_id),
                 help='''IDs of the instances to register with the load
                 balancer (required)''')]
     LIST_TAGS = ['Instances']
diff --git a/euca2ools/commands/euare/createsigningcertificate.py b/euca2ools/commands/euare/createsigningcertificate.py
index 660b642..3a6fea1 100644
--- a/euca2ools/commands/euare/createsigningcertificate.py
+++ b/euca2ools/commands/euare/createsigningcertificate.py
@@ -29,6 +29,7 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 from euca2ools.commands.euare import EuareRequest, AS_ACCOUNT
+import os
 from requestbuilder import Arg
 
 
diff --git a/euca2ools/commands/euare/deleteaccount.py b/euca2ools/commands/euare/deleteaccount.py
index 1b18323..21dfa6b 100644
--- a/euca2ools/commands/euare/deleteaccount.py
+++ b/euca2ools/commands/euare/deleteaccount.py
@@ -28,7 +28,7 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-from euca2ools.commands.euare import EuareRequest, AS_ACCOUNT
+from euca2ools.commands.euare import EuareRequest
 from requestbuilder import Arg
 
 
diff --git a/euca2ools/commands/euare/deleteaccountpolicy.py b/euca2ools/commands/euare/deleteaccountpolicy.py
index b8258a4..5620719 100644
--- a/euca2ools/commands/euare/deleteaccountpolicy.py
+++ b/euca2ools/commands/euare/deleteaccountpolicy.py
@@ -28,7 +28,7 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-from euca2ools.commands.euare import EuareRequest, AS_ACCOUNT
+from euca2ools.commands.euare import EuareRequest
 from requestbuilder import Arg
 
 
diff --git a/euca2ools/commands/euare/deleteuser.py b/euca2ools/commands/euare/deleteuser.py
index 2ae4cb5..d9a3564 100644
--- a/euca2ools/commands/euare/deleteuser.py
+++ b/euca2ools/commands/euare/deleteuser.py
@@ -32,17 +32,18 @@ import argparse
 from euca2ools.commands.euare import EuareRequest, AS_ACCOUNT
 from euca2ools.commands.euare.deleteaccesskey import DeleteAccessKey
 from euca2ools.commands.euare.deleteloginprofile import DeleteLoginProfile
-from euca2ools.commands.euare.deletesigningcertificate import DeleteSigningCertificate
+from euca2ools.commands.euare.deletesigningcertificate import \
+    DeleteSigningCertificate
 from euca2ools.commands.euare.deleteuserpolicy import DeleteUserPolicy
 from euca2ools.commands.euare.getloginprofile import GetLoginProfile
 from euca2ools.commands.euare.listaccesskeys import ListAccessKeys
 from euca2ools.commands.euare.listgroupsforuser import ListGroupsForUser
-from euca2ools.commands.euare.listsigningcertificates import ListSigningCertificates
+from euca2ools.commands.euare.listsigningcertificates import \
+    ListSigningCertificates
 from euca2ools.commands.euare.listuserpolicies import ListUserPolicies
 from euca2ools.commands.euare.removeuserfromgroup import RemoveUserFromGroup
 from euca2ools.exceptions import AWSError
 from requestbuilder import Arg
-import sys
 
 
 class DeleteUser(EuareRequest):
diff --git a/euca2ools/commands/euare/getaccountpolicy.py b/euca2ools/commands/euare/getaccountpolicy.py
index 1104f70..856f810 100644
--- a/euca2ools/commands/euare/getaccountpolicy.py
+++ b/euca2ools/commands/euare/getaccountpolicy.py
@@ -28,7 +28,7 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-from euca2ools.commands.euare import EuareRequest, AS_ACCOUNT
+from euca2ools.commands.euare import EuareRequest
 import json
 from requestbuilder import Arg
 import urllib
diff --git a/euca2ools/commands/euare/getaccountsummary.py b/euca2ools/commands/euare/getaccountsummary.py
index 1bbe59c..c6dcf1b 100644
--- a/euca2ools/commands/euare/getaccountsummary.py
+++ b/euca2ools/commands/euare/getaccountsummary.py
@@ -29,7 +29,6 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 from euca2ools.commands.euare import EuareRequest, AS_ACCOUNT
-from requestbuilder import Arg
 
 
 class GetAccountSummary(EuareRequest):
diff --git a/euca2ools/commands/euare/getldapsyncstatus.py b/euca2ools/commands/euare/getldapsyncstatus.py
index 86fdaac..e6c5cec 100644
--- a/euca2ools/commands/euare/getldapsyncstatus.py
+++ b/euca2ools/commands/euare/getldapsyncstatus.py
@@ -28,7 +28,7 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-from euca2ools.commands.euare import EuareRequest, AS_ACCOUNT
+from euca2ools.commands.euare import EuareRequest
 from requestbuilder.mixins import TabifyingMixin
 
 
diff --git a/euca2ools/commands/euare/listaccountaliases.py b/euca2ools/commands/euare/listaccountaliases.py
index 13195e3..488db62 100644
--- a/euca2ools/commands/euare/listaccountaliases.py
+++ b/euca2ools/commands/euare/listaccountaliases.py
@@ -29,7 +29,6 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 from euca2ools.commands.euare import EuareRequest, AS_ACCOUNT
-from requestbuilder import Arg
 
 
 class ListAccountAliases(EuareRequest):
diff --git a/euca2ools/commands/euare/listaccountpolicies.py b/euca2ools/commands/euare/listaccountpolicies.py
index 0602240..9e39e73 100644
--- a/euca2ools/commands/euare/listaccountpolicies.py
+++ b/euca2ools/commands/euare/listaccountpolicies.py
@@ -28,7 +28,7 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-from euca2ools.commands.euare import EuareRequest, AS_ACCOUNT
+from euca2ools.commands.euare import EuareRequest
 from euca2ools.commands.euare.getaccountpolicy import GetAccountPolicy
 from requestbuilder import Arg
 from requestbuilder.response import PaginatedResponse
diff --git a/euca2ools/commands/euare/listaccounts.py b/euca2ools/commands/euare/listaccounts.py
index 8e038eb..b6a2083 100644
--- a/euca2ools/commands/euare/listaccounts.py
+++ b/euca2ools/commands/euare/listaccounts.py
@@ -29,7 +29,6 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 from euca2ools.commands.euare import EuareRequest
-from requestbuilder import Arg
 from requestbuilder.mixins import TabifyingMixin
 
 
diff --git a/euca2ools/commands/euare/putaccountpolicy.py b/euca2ools/commands/euare/putaccountpolicy.py
index e0083be..2fee993 100644
--- a/euca2ools/commands/euare/putaccountpolicy.py
+++ b/euca2ools/commands/euare/putaccountpolicy.py
@@ -28,7 +28,7 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-from euca2ools.commands.euare import EuareRequest, AS_ACCOUNT
+from euca2ools.commands.euare import EuareRequest
 from requestbuilder import Arg, MutuallyExclusiveArgList
 
 
diff --git a/euca2ools/commands/euca/__init__.py b/euca2ools/commands/euca/__init__.py
index 8d712bb..875f17b 100644
--- a/euca2ools/commands/euca/__init__.py
+++ b/euca2ools/commands/euca/__init__.py
@@ -208,8 +208,8 @@ class EucalyptusRequest(AWSQueryRequest, TabifyingMixin):
     def __init__(self, **kwargs):
         AWSQueryRequest.__init__(self, **kwargs)
 
-    def parse_http_response(self, response_body):
-        response = AWSQueryRequest.parse_http_response(self, response_body)
+    def parse_response(self, response_body):
+        response = AWSQueryRequest.parse_response(self, response_body)
         # Compute cloud controller responses enclose their useful data inside
         # FooResponse elements.  If that's all we have after stripping out
         # RequestId then just return its contents.
@@ -238,8 +238,6 @@ class EucalyptusRequest(AWSQueryRequest, TabifyingMixin):
             self.print_instance(instance)
 
     def print_instance(self, instance):
-        # FIXME: Amazon's documentation doesn't say what order the fields in
-        #        ec2-describe-instances output appear.
         instance_line = ['INSTANCE']
         for key in ['instanceId', 'imageId', 'dnsName', 'privateDnsName']:
             instance_line.append(instance.get(key))
@@ -251,7 +249,8 @@ class EucalyptusRequest(AWSQueryRequest, TabifyingMixin):
                              instance.get('productCodes', [])]))
         instance_line.append(instance.get('instanceType'))
         instance_line.append(instance.get('launchTime'))
-        instance_line.append(instance.get('placement', {}).get('availabilityZone'))
+        instance_line.append(instance.get('placement', {}).get(
+            'availabilityZone'))
         instance_line.append(instance.get('kernelId'))
         instance_line.append(instance.get('ramdiskId'))
         instance_line.append(instance.get('platform'))
@@ -378,7 +377,7 @@ class _ResourceTypeMap(object):
             'i':      'instance',
             'igw':    'internet-gateway',
             'acl':    'network-acl',
-            'XXX':    'reserved-instances',  # reserved instance IDs are UUIDs
+            'xxx':    'reserved-instances',  # reserved instance IDs are UUIDs
             'rtb':    'route-table',
             'sg':     'security-group',
             'snap':   'snapshot',
diff --git a/euca2ools/commands/euca/associateaddress.py b/euca2ools/commands/euca/associateaddress.py
index 02d91d9..1afde07 100644
--- a/euca2ools/commands/euca/associateaddress.py
+++ b/euca2ools/commands/euca/associateaddress.py
@@ -73,7 +73,7 @@ class AssociateAddress(EucalyptusRequest):
             # VPC
             print self.tabify(('ADDRESS', self.args.get('InstanceId'),
                                self.args.get('AllocationId'),
-                               response.get('associationId'),
+                               result.get('associationId'),
                                self.args.get('PrivateIpAddress')))
         else:
             # EC2
diff --git a/euca2ools/commands/euca/describesnapshots.py b/euca2ools/commands/euca/describesnapshots.py
index 0eb978c..d686ec9 100644
--- a/euca2ools/commands/euca/describesnapshots.py
+++ b/euca2ools/commands/euca/describesnapshots.py
@@ -28,7 +28,6 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-from argparse import SUPPRESS
 from euca2ools.commands.euca import EucalyptusRequest
 from requestbuilder import Arg, Filter, GenericTagFilter
 from requestbuilder.exceptions import ArgumentError
diff --git a/euca2ools/commands/euca/modifyimageattribute.py b/euca2ools/commands/euca/modifyimageattribute.py
index 6dcb8ce..9be1a9b 100644
--- a/euca2ools/commands/euca/modifyimageattribute.py
+++ b/euca2ools/commands/euca/modifyimageattribute.py
@@ -54,23 +54,23 @@ class ModifyImageAttribute(EucalyptusRequest):
 
     def preprocess(self):
         if self.args.get('launch_permission'):
-            lp = {}
+            lperm = {}
             for entity in self.args.get('add', []):
-                lp.setdefault('Add', [])
+                lperm.setdefault('Add', [])
                 if entity == 'all':
-                    lp['Add'].append({'Group':  entity})
+                    lperm['Add'].append({'Group':  entity})
                 else:
-                    lp['Add'].append({'UserId': entity})
+                    lperm['Add'].append({'UserId': entity})
             for entity in self.args.get('remove', []):
-                lp.setdefault('Remove', [])
+                lperm.setdefault('Remove', [])
                 if entity == 'all':
-                    lp['Remove'].append({'Group':  entity})
+                    lperm['Remove'].append({'Group':  entity})
                 else:
-                    lp['Remove'].append({'UserId': entity})
-            if not lp:
+                    lperm['Remove'].append({'UserId': entity})
+            if not lperm:
                 raise ArgumentError('at least one entity must be specified '
                                     'with -a/--add or -r/--remove')
-            self.params['LaunchPermission'] = lp
+            self.params['LaunchPermission'] = lperm
         else:
             if self.args.get('add'):
                 raise ArgumentError('argument -a/--add may only be used '
diff --git a/euca2ools/commands/euca/modifyinstancetypeattribute.py b/euca2ools/commands/euca/modifyinstancetypeattribute.py
index c95eb40..7f7b060 100644
--- a/euca2ools/commands/euca/modifyinstancetypeattribute.py
+++ b/euca2ools/commands/euca/modifyinstancetypeattribute.py
@@ -53,8 +53,8 @@ class ModifyInstanceTypeAttribute(EucalyptusRequest, TabifyingMixin):
             any(self.args.get(attr) is not None for attr in ('Cpu', 'Disk',
                                                             'Memory'))):
             # Basically, reset is mutually exclusive with everything else.
-                raise ArgumentError('argument --reset may not be used with '
-                                    'instance type attributes')
+            raise ArgumentError('argument --reset may not be used with '
+                                'instance type attributes')
 
     def print_result(self, result):
         newtype = result.get('instanceType', {})
diff --git a/euca2ools/commands/euca/runinstances.py b/euca2ools/commands/euca/runinstances.py
index 7031f8d..6aca30c 100644
--- a/euca2ools/commands/euca/runinstances.py
+++ b/euca2ools/commands/euca/runinstances.py
@@ -28,7 +28,6 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-import argparse
 import base64
 from euca2ools.commands.argtypes import (ec2_block_device_mapping,
     vpc_interface)
@@ -36,7 +35,6 @@ from euca2ools.commands.euca import EucalyptusRequest
 import os.path
 from requestbuilder import Arg, MutuallyExclusiveArgList
 from requestbuilder.exceptions import ArgumentError
-import sys
 
 
 class RunInstances(EucalyptusRequest):
@@ -123,7 +121,7 @@ class RunInstances(EucalyptusRequest):
                 help='''[VPC only] add a network interface to the new
                 instance.  If the interface already exists, supply its ID and
                 a numeric index for it, separated by ":", in the form
-                "eni-XXXXXXXX:INDEX".  To create a new interface, supply a
+                "eni-NNNNNNNN:INDEX".  To create a new interface, supply a
                 numeric index and subnet ID for it, along with (in order) an
                 optional description, a primary private IP address, a list of
                 security group IDs to associate with the interface, whether to
diff --git a/euca2ools/commands/eustore/installimage.py b/euca2ools/commands/eustore/installimage.py
index dff56eb..494830e 100644
--- a/euca2ools/commands/eustore/installimage.py
+++ b/euca2ools/commands/eustore/installimage.py
@@ -223,6 +223,7 @@ class InstallImage(EuStoreRequest, FileTransferProgressBarMixin):
             else:
                 raise KeyError("no such image: '{0}'"
                                .format(self.args['image_name']))
+            # pylint: disable=W0631
             self.log.debug('image data: %s', str(image))
             if self.args.get('architecture') is None:
                 self.args['architecture'] = image.get('architecture')
@@ -258,18 +259,20 @@ class InstallImage(EuStoreRequest, FileTransferProgressBarMixin):
                                    '(checksum: {0}, expected: {1})'
                                    .format(real_crc, expected_crc))
             return tarball_path
+            # pylint: enable=W0631
 
     def calc_file_checksum(self, filename):
         filesize = os.path.getsize(filename)
-        bar = self.get_progressbar(label='Verifying image   ', maxval=filesize)
+        pbar = self.get_progressbar(label='Verifying image   ',
+                                    maxval=filesize)
         digest = hashlib.md5()
         with open(filename) as file_:
-            bar.start()
+            pbar.start()
             while file_.tell() < filesize:
                 chunk = file_.read(4096)
                 digest.update(chunk)
-                bar.update(file_.tell())
-        bar.finish()
+                pbar.update(file_.tell())
+        pbar.finish()
         crc = zlib.crc32(digest.hexdigest()) & 0xffffffff
         return '{0:0>10d}'.format(crc)
 
@@ -366,7 +369,7 @@ class InstallImage(EuStoreRequest, FileTransferProgressBarMixin):
         self.log.info('extracting %s from tarball to %s', member.name,
                       dest_filename)
         src = tarball.extractfile(member)
-        bar = self.get_progressbar(label=bar_label, maxval=member.size)
+        pbar = self.get_progressbar(label=bar_label, maxval=member.size)
         try:
             with open(dest_filename, 'w') as dest:
                 while dest.tell() < member.size:
@@ -374,10 +377,10 @@ class InstallImage(EuStoreRequest, FileTransferProgressBarMixin):
                     # doesn't support seeking.
                     chunk = src.read(16384)
                     dest.write(chunk)
-                    if bar.start_time is None:
-                        bar.start()
-                    bar.update(dest.tell())
-                bar.finish()
+                    if pbar.start_time is None:
+                        pbar.start()
+                    pbar.update(dest.tell())
+                pbar.finish()
         finally:
             src.close()
         return dest_filename
diff --git a/euca2ools/commands/monitoring/__init__.py b/euca2ools/commands/monitoring/__init__.py
index 28103ce..cb3c559 100644
--- a/euca2ools/commands/monitoring/__init__.py
+++ b/euca2ools/commands/monitoring/__init__.py
@@ -32,8 +32,9 @@ from euca2ools.commands import Euca2ools
 from euca2ools.exceptions import AWSError
 from requestbuilder import Arg, MutuallyExclusiveArgList, SERVICE
 import requestbuilder.auth
+from requestbuilder.mixins import TabifyingMixin
 import requestbuilder.service
-import requestbuilder.request
+from requestbuilder.request import AWSQueryRequest
 
 
 class CloudWatch(requestbuilder.service.BaseService):
@@ -55,14 +56,13 @@ class CloudWatch(requestbuilder.service.BaseService):
         raise AWSError(response)
 
 
-class CloudWatchRequest(requestbuilder.request.AWSQueryRequest):
+class CloudWatchRequest(AWSQueryRequest, TabifyingMixin):
     SUITE = Euca2ools
     SERVICE_CLASS = CloudWatch
     METHOD = 'POST'
 
     def parse_response(self, response):
-        response_dict = requestbuilder.request.AWSQueryRequest.parse_response(
-            self, response)
+        response_dict = AWSQueryRequest.parse_response(self, response)
         useful_keys = list(filter(lambda x: x != 'ResponseMetadata',
                                   response_dict.keys()))
         if len(useful_keys) == 1:
diff --git a/euca2ools/commands/monitoring/describealarms.py b/euca2ools/commands/monitoring/describealarms.py
index 00f9340..40c2fba 100644
--- a/euca2ools/commands/monitoring/describealarms.py
+++ b/euca2ools/commands/monitoring/describealarms.py
@@ -28,7 +28,6 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-import argparse
 from euca2ools.commands.monitoring import CloudWatchRequest
 from requestbuilder import Arg
 from requestbuilder.mixins import TabifyingMixin
diff --git a/euca2ools/commands/monitoring/putmetricdata.py b/euca2ools/commands/monitoring/putmetricdata.py
index 7eec337..7d31aa2 100644
--- a/euca2ools/commands/monitoring/putmetricdata.py
+++ b/euca2ools/commands/monitoring/putmetricdata.py
@@ -46,7 +46,8 @@ def statistic_set(set_as_str):
         try:
             pairs[key] = float(val)
         except ValueError:
-            raise argparse.ArgumentTypeError('value "{0}" must be numeric'.format(val))
+            raise argparse.ArgumentTypeError('value "{0}" must be numeric'
+                                             .format(val))
     for field in ('Maximum', 'Minimum', 'SampleCount', 'Sum'):
         if field not in pairs:
             raise argparse.ArgumentTypeError(
diff --git a/euca2ools/commands/walrus/__init__.py b/euca2ools/commands/walrus/__init__.py
index db6f039..236b415 100644
--- a/euca2ools/commands/walrus/__init__.py
+++ b/euca2ools/commands/walrus/__init__.py
@@ -85,7 +85,9 @@ class WalrusRequest(requestbuilder.request.BaseRequest):
                 self.service.endpoint = new_url
                 if isinstance(self.body, file):
                     self.log.debug('re-seeking body to beginning of file')
+                    # pylint: disable=E1101
                     self.body.seek(0)
+                    # pylint: enable=E1101
                 return self.send()
             else:
                 self.log.warn('too many redirects; giving up')
@@ -123,13 +125,13 @@ def validate_dns_bucket_name(bucket):
                 raise ValueError('invalid character \'{0}\''.format(char))
         if label[0] not in string.ascii_lowercase + string.digits:
             raise ValueError(('character \'{0}\' may not begin part of a '
-                              'bucket name').format(char))
+                              'bucket name').format(label[0]))
         if label[-1] not in string.ascii_lowercase + string.digits:
             raise ValueError(('character \'{0}\' may not end part of a '
-                              'bucket name').format(char))
+                              'bucket name').format(label[-1]))
     if len(labels) == 4:
         try:
-            bucket_as_digits = map(int, bucket.split('.'))
+            map(int, bucket.split('.'))
         except ValueError:
             # This is actually the case we want
             pass
diff --git a/euca2ools/commands/walrus/putobject.py b/euca2ools/commands/walrus/putobject.py
index 0def6bc..4f5ce4c 100644
--- a/euca2ools/commands/walrus/putobject.py
+++ b/euca2ools/commands/walrus/putobject.py
@@ -28,7 +28,6 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-import datetime
 from euca2ools.commands.walrus import WalrusRequest
 from euca2ools.util import build_progressbar_label_template
 import mimetypes
@@ -37,7 +36,6 @@ from requestbuilder import Arg
 from requestbuilder.exceptions import ArgumentError, ClientError
 from requestbuilder.mixins import FileTransferProgressBarMixin
 import socket
-import sys
 import threading
 import time
 
@@ -125,7 +123,9 @@ class PutObject(WalrusRequest, FileTransferProgressBarMixin):
                 upload_thread.join()
             with self._lock:
                 if self.last_upload_error is not None:
+                    # pylint: disable=E0702
                     raise self.last_upload_error
+                    # pylint: enable=E0702
 
     def try_send(self, source, retries_left=0):
         self.body = source
diff --git a/euca2ools/util.py b/euca2ools/util.py
index 94b5377..dac9466 100644
--- a/euca2ools/util.py
+++ b/euca2ools/util.py
@@ -45,6 +45,7 @@ def build_progressbar_label_template(fnames):
                                    total=len(fnames))
 
 
+# pylint: disable=W0622
 def mkdtemp_for_large_files(suffix='', prefix='tmp', dir=None):
     '''
     Like tempfile.mkdtemp, but using /var/tmp as a last resort instead of /tmp.
@@ -57,6 +58,7 @@ def mkdtemp_for_large_files(suffix='', prefix='tmp', dir=None):
         dir = (os.getenv('TMPDIR') or os.getenv('TEMP') or os.getenv('TMP') or
                '/var/tmp')
     return tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=dir)
+# pylint: enable=W0622
 
 
 def sanitize_path(path):

-- 
managing cloud instances for Eucalyptus



More information about the pkg-eucalyptus-commits mailing list