libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1209932 - in /libcloud/branches/py3k: libcloud/compute/drivers/ libcloud/storage/drivers/ test/compute/
Date Sat, 03 Dec 2011 15:18:54 GMT
Author: tomaz
Date: Sat Dec  3 15:18:54 2011
New Revision: 1209932

URL: http://svn.apache.org/viewvc?rev=1209932&view=rev
Log:
Use 'in' instead of has_key().

Modified:
    libcloud/branches/py3k/libcloud/compute/drivers/brightbox.py
    libcloud/branches/py3k/libcloud/compute/drivers/cloudsigma.py
    libcloud/branches/py3k/libcloud/compute/drivers/openstack.py
    libcloud/branches/py3k/libcloud/compute/drivers/rimuhosting.py
    libcloud/branches/py3k/libcloud/storage/drivers/s3.py
    libcloud/branches/py3k/test/compute/test_dreamhost.py
    libcloud/branches/py3k/test/compute/test_slicehost.py

Modified: libcloud/branches/py3k/libcloud/compute/drivers/brightbox.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/brightbox.py?rev=1209932&r1=1209931&r2=1209932&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/brightbox.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/brightbox.py Sat Dec  3 15:18:54 2011
@@ -169,7 +169,7 @@ class BrightboxNodeDriver(NodeDriver):
             'user_data': ''
         }
 
-        if kwargs.has_key('location'):
+        if 'location' in kwargs:
             data['zone'] = kwargs['location'].id
         else:
             data['zone'] = ''

Modified: libcloud/branches/py3k/libcloud/compute/drivers/cloudsigma.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/cloudsigma.py?rev=1209932&r1=1209931&r2=1209932&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/cloudsigma.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/cloudsigma.py Sat Dec  3 15:18:54 2011
@@ -336,10 +336,10 @@ class CloudSigmaBaseNodeDriver(NodeDrive
 
         response = self.connection.request(action = '/drives/%s/info' % (drive_uuid)).object
         imaging_start = time.time()
-        while response[0].has_key('imaging'):
+        while 'imaging' in response[0]:
             response = self.connection.request(action = '/drives/%s/info' % (drive_uuid)).object
             elapsed_time = time.time() - imaging_start
-            if response[0].has_key('imaging') and elapsed_time >= IMAGING_TIMEOUT:
+            if 'imaging' in response[0] and elapsed_time >= IMAGING_TIMEOUT:
                 raise CloudSigmaException('Drive imaging timed out')
             time.sleep(1)
 
@@ -512,7 +512,7 @@ class CloudSigmaBaseNodeDriver(NodeDrive
                 return None
 
             public_ips = []
-            if data.has_key('nic:0:dhcp'):
+            if 'nic:0:dhcp' in data:
                 if isinstance(data['nic:0:dhcp'], list):
                     public_ips = data['nic:0:dhcp']
                 else:
@@ -521,7 +521,7 @@ class CloudSigmaBaseNodeDriver(NodeDrive
             extra = {}
             extra_keys = [ ('cpu', 'int'), ('smp', 'auto'), ('mem', 'int'), ('status', 'str')
]
             for key, value_type in extra_keys:
-                if data.has_key(key):
+                if key in data:
                     value = data[key]
 
                     if value_type == 'int':
@@ -534,7 +534,7 @@ class CloudSigmaBaseNodeDriver(NodeDrive
 
                     extra.update({key: value})
 
-            if data.has_key('vnc:ip') and data.has_key('vnc:password'):
+            if 'vnc:ip' in data and 'vnc:password' in data:
                 extra.update({'vnc_ip': data['vnc:ip'], 'vnc_password': data['vnc:password']})
 
             node = Node(id = data['server'], name = data['name'], state =  state,

Modified: libcloud/branches/py3k/libcloud/compute/drivers/openstack.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/openstack.py?rev=1209932&r1=1209931&r2=1209932&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/openstack.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/openstack.py Sat Dec  3 15:18:54 2011
@@ -25,8 +25,7 @@ import os
 
 import warnings
 from libcloud.py3 import httplib
-ffrom libcloud.py3 import b
-rom libcloud.py3 import b
+from libcloud.py3 import b
 
 import base64
 

Modified: libcloud/branches/py3k/libcloud/compute/drivers/rimuhosting.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/rimuhosting.py?rev=1209932&r1=1209931&r2=1209932&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/rimuhosting.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/rimuhosting.py Sat Dec  3 15:18:54 2011
@@ -247,46 +247,46 @@ class RimuHostingNodeDriver(NodeDriver):
             'pricing_plan_code': size.id,
         }
 
-        if kwargs.has_key('ex_control_panel'):
+        if 'ex_control_panel' in kwargs:
             data['instantiation_options']['control_panel'] = kwargs['ex_control_panel']
 
-        if kwargs.has_key('auth'):
+        if 'auth' in kwargs:
             auth = kwargs['auth']
             if not isinstance(auth, NodeAuthPassword):
                 raise ValueError('auth must be of NodeAuthPassword type')
             data['instantiation_options']['password'] = auth.password
 
-        if kwargs.has_key('ex_billing_oid'):
+        if 'ex_billing_oid' in kwargs:
             #TODO check for valid oid.
             data['billing_oid'] = kwargs['ex_billing_oid']
 
-        if kwargs.has_key('ex_host_server_oid'):
+        if 'ex_host_server_oid' in kwargs:
             data['host_server_oid'] = kwargs['ex_host_server_oid']
 
-        if kwargs.has_key('ex_vps_order_oid_to_clone'):
+        if 'ex_vps_order_oid_to_clone' in kwargs:
             data['vps_order_oid_to_clone'] = kwargs['ex_vps_order_oid_to_clone']
 
-        if kwargs.has_key('ex_num_ips') and int(kwargs['ex_num_ips']) > 1:
-            if not kwargs.has_key('ex_extra_ip_reason'):
+        if 'ex_num_ips' in kwargs and int(kwargs['ex_num_ips']) > 1:
+            if not 'ex_extra_ip_reason' in kwargs:
                 raise RimuHostingException('Need an reason for having an extra IP')
             else:
-                if not data.has_key('ip_request'):
+                if not 'ip_request' in data:
                     data['ip_request'] = {}
                 data['ip_request']['num_ips'] = int(kwargs['ex_num_ips'])
                 data['ip_request']['extra_ip_reason'] = kwargs['ex_extra_ip_reason']
 
-        if kwargs.has_key('ex_memory_mb'):
-            if not data.has_key('vps_parameters'):
+        if 'ex_memory_mb' in kwargs:
+            if not 'vps_parameters' in data:
                 data['vps_parameters'] = {}
             data['vps_parameters']['memory_mb'] = kwargs['ex_memory_mb']
 
-        if kwargs.has_key('ex_disk_space_mb'):
-            if not data.has_key('ex_vps_parameters'):
+        if 'ex_disk_space_mb' in kwargs:
+            if not 'ex_vps_parameters' in data:
                 data['vps_parameters'] = {}
             data['vps_parameters']['disk_space_mb'] = kwargs['ex_disk_space_mb']
 
-        if kwargs.has_key('ex_disk_space_2_mb'):
-            if not data.has_key('vps_parameters'):
+        if 'ex_disk_space_2_mb' in kwargs:
+            if not 'vps_parameters' in data:
                 data['vps_parameters'] = {}
             data['vps_parameters']['disk_space_2_mb'] = kwargs['ex_disk_space_2_mb']
 

Modified: libcloud/branches/py3k/libcloud/storage/drivers/s3.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/storage/drivers/s3.py?rev=1209932&r1=1209931&r2=1209932&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/storage/drivers/s3.py (original)
+++ libcloud/branches/py3k/libcloud/storage/drivers/s3.py Sat Dec  3 15:18:54 2011
@@ -120,10 +120,10 @@ class S3Connection(ConnectionUserAndKey)
             elif key.lower().startswith('x-amz-'):
                 amz_header_values[key.lower()] = value.strip()
 
-        if not special_header_values.has_key('content-md5'):
+        if not 'content-md5' in special_header_values:
             special_header_values['content-md5'] = ''
 
-        if not special_header_values.has_key('content-type'):
+        if not 'content-type' in special_header_values:
             special_header_values['content-type'] = ''
 
         if expires:

Modified: libcloud/branches/py3k/test/compute/test_dreamhost.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_dreamhost.py?rev=1209932&r1=1209931&r2=1209932&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_dreamhost.py (original)
+++ libcloud/branches/py3k/test/compute/test_dreamhost.py Sat Dec  3 15:18:54 2011
@@ -79,15 +79,15 @@ class DreamhostTest(unittest.TestCase, T
         self.assertEqual(web_node.state, NodeState.UNKNOWN)
         self.assertTrue('75.119.203.51' in web_node.public_ips)
         self.assertTrue(
-            web_node.extra.has_key('current_size') and
+            'current_size' in web_node.extra and
             web_node.extra['current_size'] == 500
         )
         self.assertTrue(
-            web_node.extra.has_key('account_id') and
+            'account_id' in web_node.extra and
             web_node.extra['account_id'] == 000000
         )
         self.assertTrue(
-            web_node.extra.has_key('type') and
+            'type' in web_node.extra and
             web_node.extra['type'] == 'web'
         )
         # MySql node tests
@@ -95,15 +95,15 @@ class DreamhostTest(unittest.TestCase, T
         self.assertEqual(mysql_node.state, NodeState.UNKNOWN)
         self.assertTrue('75.119.203.52' in mysql_node.public_ips)
         self.assertTrue(
-            mysql_node.extra.has_key('current_size') and
+            'current_size' in mysql_node.extra and
             mysql_node.extra['current_size'] == 1500
         )
         self.assertTrue(
-            mysql_node.extra.has_key('account_id') and
+            'account_id' in mysql_node.extra and
             mysql_node.extra['account_id'] == 000000
         )
         self.assertTrue(
-            mysql_node.extra.has_key('type') and
+            'type' in mysql_node.extra and
             mysql_node.extra['type'] == 'mysql'
         )
 
@@ -124,7 +124,7 @@ class DreamhostTest(unittest.TestCase, T
         self.assertEqual(new_node.id, 'ps12345')
         self.assertEqual(new_node.state, NodeState.PENDING)
         self.assertTrue(
-            new_node.extra.has_key('type') and
+            'type' in new_node.extra and
             new_node.extra['type'] == 'web'
         )
 

Modified: libcloud/branches/py3k/test/compute/test_slicehost.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_slicehost.py?rev=1209932&r1=1209931&r2=1209932&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_slicehost.py (original)
+++ libcloud/branches/py3k/test/compute/test_slicehost.py Sat Dec  3 15:18:54 2011
@@ -114,7 +114,7 @@ class SlicehostMockHttp(MockHttp):
             # the correct validation logic
             if not (name and image_id and flavor_id) \
                 or tree.tag != 'slice' \
-                or not headers.has_key('Content-Type')  \
+                or not 'Content-Type' in headers  \
                 or headers['Content-Type'] != 'application/xml':
 
                 err_body = self.fixtures.load('slices_error.xml')



Mime
View raw message