You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/09/10 16:31:42 UTC

svn commit: r1167525 - in /libcloud/trunk: demos/ test/ test/compute/

Author: tomaz
Date: Sat Sep 10 14:31:41 2011
New Revision: 1167525

URL: http://svn.apache.org/viewvc?rev=1167525&view=rev
Log:
Update compute demo and change credentials syntax in secret.py. This patch has
been contributed by Mike Nerone <mike at nerone dot org> and is part of
LIBCLOUD-111.

Added:
    libcloud/trunk/demos/compute_demo.py
    libcloud/trunk/demos/secrets.py-dist
Modified:
    libcloud/trunk/demos/ec2_demo.py
    libcloud/trunk/demos/secrets.py.dist
    libcloud/trunk/test/compute/test_bluebox.py
    libcloud/trunk/test/compute/test_brightbox.py
    libcloud/trunk/test/compute/test_deployment.py
    libcloud/trunk/test/compute/test_dreamhost.py
    libcloud/trunk/test/compute/test_ec2.py
    libcloud/trunk/test/compute/test_ecp.py
    libcloud/trunk/test/compute/test_gandi.py
    libcloud/trunk/test/compute/test_ibm_sbc.py
    libcloud/trunk/test/compute/test_opennebula.py
    libcloud/trunk/test/compute/test_openstack.py
    libcloud/trunk/test/compute/test_opsource.py
    libcloud/trunk/test/compute/test_rackspace.py
    libcloud/trunk/test/compute/test_slicehost.py
    libcloud/trunk/test/compute/test_softlayer.py
    libcloud/trunk/test/compute/test_vcloud.py
    libcloud/trunk/test/compute/test_voxel.py
    libcloud/trunk/test/compute/test_vpsnet.py
    libcloud/trunk/test/secrets.py-dist

Added: libcloud/trunk/demos/compute_demo.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/demos/compute_demo.py?rev=1167525&view=auto
==============================================================================
--- libcloud/trunk/demos/compute_demo.py (added)
+++ libcloud/trunk/demos/compute_demo.py Sat Sep 10 14:31:41 2011
@@ -0,0 +1,114 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# This example provides both a running script (invoke from command line)
+# and an importable module one can play with in Interactive Mode.
+#
+# See docstrings for usage examples.
+#
+
+try:
+    import secrets
+except ImportError:
+    secrets = None
+
+import os.path
+import sys
+
+# Add parent dir of this file's dir to sys.path (OS-agnostically)
+sys.path.append(os.path.normpath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
+
+from libcloud.common.types import InvalidCredsError
+from libcloud.compute.types import Provider
+from libcloud.providers import get_driver
+
+from pprint import pprint
+
+def get_demo_driver(provider_name='RACKSPACE', *args, **kwargs):
+    """An easy way to play with a driver interactively.
+
+    # Load credentials from secrets.py:
+    >>> from compute_demo import get_demo_driver
+    >>> driver = get_demo_driver('RACKSPACE')
+
+    # Or, provide credentials:
+    >>> from compute_demo import get_demo_driver
+    >>> driver = get_demo_driver('RACKSPACE', 'username', 'api_key')
+    # Note that these parameters vary by driver ^^^
+
+    # Do things like the demo:
+    >>> driver.load_nodes()
+    >>> images = driver.load_images()
+    >>> sizes = driver.load_sizes()
+    
+    # And maybe do more than that:
+    >>> node = driver.create_node(
+            name='my_first_node',
+            image=images[0],
+            size=sizes[0],
+        )
+    >>> node.destroy()
+    """
+    provider_name = provider_name.upper()
+
+    DriverClass = get_driver(getattr(Provider, provider_name))
+
+    if not args:
+        args = getattr(secrets, provider_name + '_PARAMS', ())
+    if not kwargs:
+        kwargs = getattr(secrets, provider_name + '_KEYWORD_PARAMS', {})
+
+    try:
+        return DriverClass(*args, **kwargs)
+    except InvalidCredsError:
+        raise InvalidCredsError(
+            'valid values should be put in secrets.py'
+        )
+
+def main(argv):
+    """Main Compute Demo
+
+    When invoked from the command line, it will connect using secrets.py
+    (see secrets.py-dist for instructions and examples), and perform the
+    following tasks:
+
+    - List current nodes
+    - List available images (up to 10)
+    - List available sizes (up to 10)
+    """
+    try:
+        driver = get_demo_driver()
+    except InvalidCredsError as ex:
+        print("Invalid Credentials: %s" % (ex.value,))
+        return 1
+
+    try:
+        print(">> Loading nodes...")
+        pprint(driver.list_nodes())
+
+        print(">> Loading images... (showing up to 10)")
+        pprint(driver.list_images()[:10])
+
+        print(">> Loading sizes... (showing up to 10)")
+        pprint(driver.list_sizes()[:10])
+    except Exception as ex:
+        print("A fatal error occurred: %s" % (ex,))
+        return 1
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv))

Added: libcloud/trunk/demos/secrets.py-dist
URL: http://svn.apache.org/viewvc/libcloud/trunk/demos/secrets.py-dist?rev=1167525&view=auto
==============================================================================
--- libcloud/trunk/demos/secrets.py-dist (added)
+++ libcloud/trunk/demos/secrets.py-dist Sat Sep 10 14:31:41 2011
@@ -0,0 +1,36 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Make a copy of this file named 'secrets.py' and add your credentials there.
+# Note you can run unit tests without setting your credentials.
+
+BLUEBOX_PARAMS = ('customer_id', 'api_key')
+BRIGHTBOX_PARAMS = ('client_id', 'client_secret')
+DREAMHOST_PARAMS = ('key',)
+EC2_PARAMS = ('access_id', 'secret')
+ECP_PARAMS = ('user_name', 'password')
+GANDI_PARAMS = ('user',)
+HOSTINGCOM_PARAMS = ('user', 'secret')
+IBM_PARAMS = ('user', 'secret')
+# OPENSTACK_PARAMS = ('user_name', 'api_key', secure_bool, 'host', port_int)
+OPENSTACK_PARAMS = ('user_name', 'api_key', False, 'host', 8774)
+OPENNEBULA_PARAMS = ('user', 'key')
+OPSOURCE_PARAMS = ('user', 'password')
+RACKSPACE_PARAMS = ('user', 'key')
+SLICEHOST_PARAMS = ('key',)
+SOFTLAYER_PARAMS = ('user', 'api_key')
+VCLOUD_PARAMS = ('user', 'secret')
+VOXEL_PARAMS = ('key', 'secret')
+VPSNET_PARAMS = ('user', 'key')

Modified: libcloud/trunk/test/compute/test_bluebox.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_bluebox.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_bluebox.py (original)
+++ libcloud/trunk/test/compute/test_bluebox.py Sat Sep 10 14:31:41 2011
@@ -23,13 +23,13 @@ from libcloud.compute.types import NodeS
 
 from test import MockHttp
 from test.file_fixtures import ComputeFileFixtures
-from test.secrets import BLUEBOX_CUSTOMER_ID, BLUEBOX_API_KEY
+from test.secrets import BLUEBOX_PARAMS
 
 class BlueboxTest(unittest.TestCase):
 
     def setUp(self):
         Bluebox.connectionCls.conn_classes = (None, BlueboxMockHttp)
-        self.driver = Bluebox(BLUEBOX_CUSTOMER_ID, BLUEBOX_API_KEY)
+        self.driver = Bluebox(*BLUEBOX_PARAMS)
 
     def test_create_node(self):
         node = self.driver.create_node(

Modified: libcloud/trunk/test/compute/test_brightbox.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_brightbox.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_brightbox.py (original)
+++ libcloud/trunk/test/compute/test_brightbox.py Sat Sep 10 14:31:41 2011
@@ -28,14 +28,14 @@ from libcloud.compute.types import NodeS
 from test import MockHttp
 from test.compute import TestCaseMixin
 from test.file_fixtures import ComputeFileFixtures
-from test.secrets import BRIGHTBOX_CLIENT_ID, BRIGHTBOX_CLIENT_SECRET
+from test.secrets import BRIGHTBOX_PARAMS
 
 
 class BrightboxTest(unittest.TestCase, TestCaseMixin):
     def setUp(self):
         BrightboxNodeDriver.connectionCls.conn_classes = (None, BrightboxMockHttp)
         BrightboxMockHttp.type = None
-        self.driver = BrightboxNodeDriver(BRIGHTBOX_CLIENT_ID, BRIGHTBOX_CLIENT_SECRET)
+        self.driver = BrightboxNodeDriver(*BRIGHTBOX_PARAMS)
 
     def test_authentication(self):
         BrightboxMockHttp.type = 'INVALID_CLIENT'

Modified: libcloud/trunk/test/compute/test_deployment.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_deployment.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_deployment.py (original)
+++ libcloud/trunk/test/compute/test_deployment.py Sat Sep 10 14:31:41 2011
@@ -30,7 +30,7 @@ from test import MockHttp, XML_HEADERS
 from test.file_fixtures import ComputeFileFixtures
 from mock import Mock, patch
 
-from test.secrets import RACKSPACE_USER, RACKSPACE_KEY
+from test.secrets import RACKSPACE_PARAMS
 
 class MockDeployment(Deployment):
     def run(self, node, client):
@@ -56,7 +56,7 @@ class DeploymentTests(unittest.TestCase)
     def setUp(self):
         Rackspace.connectionCls.conn_classes = (None, RackspaceMockHttp)
         RackspaceMockHttp.type = None
-        self.driver = Rackspace(RACKSPACE_USER, RACKSPACE_KEY)
+        self.driver = Rackspace(*RACKSPACE_PARAMS)
         self.driver.features = {'create_node': ['generates_password']}
         self.node = Node(id=12345, name='test', state=NodeState.RUNNING,
                    public_ip=['1.2.3.4'], private_ip='1.2.3.5',

Modified: libcloud/trunk/test/compute/test_dreamhost.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_dreamhost.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_dreamhost.py (original)
+++ libcloud/trunk/test/compute/test_dreamhost.py Sat Sep 10 14:31:41 2011
@@ -17,9 +17,9 @@ import unittest
 import httplib
 
 try:
-  import json
-except: 
-  import simplejson as json
+    import json
+except:
+    import simplejson as json
 
 from libcloud.common.types import InvalidCredsError
 from libcloud.compute.drivers.dreamhost import DreamhostNodeDriver
@@ -27,7 +27,7 @@ from libcloud.compute.types import NodeS
 
 from test import MockHttp
 from test.compute import TestCaseMixin
-from test.secrets import DREAMHOST_KEY
+from test.secrets import DREAMHOST_PARAMS
 
 class DreamhostTest(unittest.TestCase, TestCaseMixin):
 
@@ -38,7 +38,7 @@ class DreamhostTest(unittest.TestCase, T
         )
         DreamhostMockHttp.type = None
         DreamhostMockHttp.use_param = 'cmd'
-        self.driver = DreamhostNodeDriver(DREAMHOST_KEY)
+        self.driver = DreamhostNodeDriver(*DREAMHOST_PARAMS)
 
     def test_invalid_creds(self):
         """
@@ -117,9 +117,9 @@ class DreamhostTest(unittest.TestCase, T
         Once the PS is ready it will appear in the list generated by list_ps.
         """
         new_node = self.driver.create_node(
-            image = self.driver.list_images()[0],
-            size = self.driver.list_sizes()[0],
-            movedata = 'no',
+            image=self.driver.list_images()[0],
+            size=self.driver.list_sizes()[0],
+            movedata='no',
         )
         self.assertEqual(new_node.id, 'ps12345')
         self.assertEqual(new_node.state, NodeState.PENDING)

Modified: libcloud/trunk/test/compute/test_ec2.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_ec2.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_ec2.py (original)
+++ libcloud/trunk/test/compute/test_ec2.py Sat Sep 10 14:31:41 2011
@@ -26,7 +26,7 @@ from test import MockHttp, LibcloudTestC
 from test.compute import TestCaseMixin
 from test.file_fixtures import ComputeFileFixtures
 
-from test.secrets import EC2_ACCESS_ID, EC2_SECRET
+from test.secrets import EC2_PARAMS
 
 
 class EC2Tests(LibcloudTestCase, TestCaseMixin):
@@ -37,7 +37,7 @@ class EC2Tests(LibcloudTestCase, TestCas
         EC2NodeDriver.connectionCls.conn_classes = (None, EC2MockHttp)
         EC2MockHttp.use_param = 'Action'
         EC2MockHttp.type = None
-        self.driver = EC2NodeDriver(EC2_ACCESS_ID, EC2_SECRET)
+        self.driver = EC2NodeDriver(*EC2_PARAMS)
 
     def test_create_node(self):
         image = NodeImage(id='ami-be3adfd7',
@@ -110,7 +110,6 @@ class EC2Tests(LibcloudTestCase, TestCas
     def test_list_nodes_with_name_tag(self):
         EC2MockHttp.type = 'WITH_TAGS'
         node = self.driver.list_nodes()[0]
-        public_ips = sorted(node.public_ip)
         self.assertEqual(node.id, 'i-8474834a')
         self.assertEqual(node.name, 'foobar1')
 
@@ -353,7 +352,7 @@ class EC2APSETests(EC2Tests):
         EC2APSENodeDriver.connectionCls.conn_classes = (None, EC2MockHttp)
         EC2MockHttp.use_param = 'Action'
         EC2MockHttp.type = None
-        self.driver = EC2APSENodeDriver(EC2_ACCESS_ID, EC2_SECRET)
+        self.driver = EC2APSENodeDriver(*EC2_PARAMS)
 
 
 class EC2APNETests(EC2Tests):
@@ -361,7 +360,7 @@ class EC2APNETests(EC2Tests):
         EC2APNENodeDriver.connectionCls.conn_classes = (None, EC2MockHttp)
         EC2MockHttp.use_param = 'Action'
         EC2MockHttp.type = None
-        self.driver = EC2APNENodeDriver(EC2_ACCESS_ID, EC2_SECRET)
+        self.driver = EC2APNENodeDriver(*EC2_PARAMS)
 
 
 class NimbusTests(EC2Tests):
@@ -369,8 +368,8 @@ class NimbusTests(EC2Tests):
         NimbusNodeDriver.connectionCls.conn_classes = (None, EC2MockHttp)
         EC2MockHttp.use_param = 'Action'
         EC2MockHttp.type = None
-        self.driver = NimbusNodeDriver(EC2_ACCESS_ID, EC2_SECRET,
-                host="some.nimbuscloud.com")
+        self.driver = NimbusNodeDriver(key=EC2_PARAMS[0], secret=EC2_PARAMS[1],
+                                       host='some.nimbuscloud.com')
 
     def test_ex_describe_addresses_for_node(self):
         # overridden from EC2Tests -- Nimbus doesn't support elastic IPs.
@@ -425,8 +424,8 @@ class EucTests(LibcloudTestCase, TestCas
         EucNodeDriver.connectionCls.conn_classes = (None, EucMockHttp)
         EC2MockHttp.use_param = 'Action'
         EC2MockHttp.type = None
-        self.driver = EucNodeDriver(EC2_ACCESS_ID, EC2_SECRET,
-                host="some.eucalyptus.com")
+        self.driver = EucNodeDriver(key=EC2_PARAMS[0], secret=EC2_PARAMS[1],
+                                    host='some.eucalyptus.com')
 
     def test_list_locations_response(self):
         try:

Modified: libcloud/trunk/test/compute/test_ecp.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_ecp.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_ecp.py (original)
+++ libcloud/trunk/test/compute/test_ecp.py Sat Sep 10 14:31:41 2011
@@ -23,19 +23,19 @@ from test import MockHttp
 from test.compute import TestCaseMixin
 from test.file_fixtures import ComputeFileFixtures
 
-from test.secrets import ECP_USER_NAME, ECP_PASSWORD
+from test.secrets import ECP_PARAMS
 
 class ECPTests(unittest.TestCase, TestCaseMixin):
 
     def setUp(self):
         ECPNodeDriver.connectionCls.conn_classes = (None,
                                                             ECPMockHttp)
-        self.driver = ECPNodeDriver(ECP_USER_NAME, ECP_PASSWORD)
+        self.driver = ECPNodeDriver(*ECP_PARAMS)
 
 
     def test_list_nodes(self):
         nodes = self.driver.list_nodes()
-        self.assertEqual(len(nodes),2)
+        self.assertEqual(len(nodes), 2)
         node = nodes[0]
         self.assertEqual(node.id, '1')
         self.assertEqual(node.name, 'dummy-1')
@@ -45,20 +45,20 @@ class ECPTests(unittest.TestCase, TestCa
 
     def test_list_sizes(self):
         sizes = self.driver.list_sizes()
-        self.assertEqual(len(sizes),3)
+        self.assertEqual(len(sizes), 3)
         size = sizes[0]
-        self.assertEqual(size.id,'1')
-        self.assertEqual(size.ram,512)
-        self.assertEqual(size.disk,0)
-        self.assertEqual(size.bandwidth,0)
-        self.assertEqual(size.price,0)
+        self.assertEqual(size.id, '1')
+        self.assertEqual(size.ram, 512)
+        self.assertEqual(size.disk, 0)
+        self.assertEqual(size.bandwidth, 0)
+        self.assertEqual(size.price, 0)
 
     def test_list_images(self):
         images = self.driver.list_images()
-        self.assertEqual(len(images),2)
-        self.assertEqual(images[0].name,"centos54: AUTO import from /opt/enomalism2/repo/5d407a68-c76c-11de-86e5-000475cb7577.xvm2")
+        self.assertEqual(len(images), 2)
+        self.assertEqual(images[0].name, "centos54: AUTO import from /opt/enomalism2/repo/5d407a68-c76c-11de-86e5-000475cb7577.xvm2")
         self.assertEqual(images[0].id, "1")
-        self.assertEqual(images[1].name,"centos54 two: AUTO import from /opt/enomalism2/repo/5d407a68-c76c-11de-86e5-000475cb7577.xvm2")
+        self.assertEqual(images[1].name, "centos54 two: AUTO import from /opt/enomalism2/repo/5d407a68-c76c-11de-86e5-000475cb7577.xvm2")
         self.assertEqual(images[1].id, "2")
 
     def test_reboot_node(self):
@@ -93,11 +93,11 @@ class ECPMockHttp(MockHttp):
         if method == 'GET':
             body = self.fixtures.load('vm_1_get.json')
         if method == 'POST':
-            if body.find('delete',0):
+            if body.find('delete', 0):
                 body = self.fixtures.load('vm_1_action_delete.json')
-            if body.find('stop',0):
+            if body.find('stop', 0):
                 body = self.fixtures.load('vm_1_action_stop.json')
-            if body.find('start',0):
+            if body.find('start', 0):
                 body = self.fixtures.load('vm_1_action_start.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 

Modified: libcloud/trunk/test/compute/test_gandi.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_gandi.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_gandi.py (original)
+++ libcloud/trunk/test/compute/test_gandi.py Sat Sep 10 14:31:41 2011
@@ -26,7 +26,7 @@ from libcloud.compute.types import NodeS
 from xml.etree import ElementTree as ET
 from test import MockHttp
 from test.file_fixtures import ComputeFileFixtures
-from test.secrets import GANDI_USER
+from test.secrets import GANDI_PARAMS
 
 class MockGandiTransport(xmlrpclib.Transport):
 
@@ -48,11 +48,11 @@ class GandiTests(unittest.TestCase):
     node_name = 'test2'
     def setUp(self):
         Gandi.connectionCls.proxyCls.transportCls = [MockGandiTransport, MockGandiTransport]
-        self.driver = Gandi(GANDI_USER)
+        self.driver = Gandi(*GANDI_PARAMS)
 
     def test_list_nodes(self):
         nodes = self.driver.list_nodes()
-        self.assertTrue(len(nodes)>0)
+        self.assertTrue(len(nodes) > 0)
 
     def test_list_locations(self):
         loc = filter(lambda x: 'france' in x.country.lower(), self.driver.list_locations())[0]
@@ -61,11 +61,11 @@ class GandiTests(unittest.TestCase):
     def test_list_images(self):
         loc = filter(lambda x: 'france' in x.country.lower(), self.driver.list_locations())[0]
         images = self.driver.list_images(loc)
-        self.assertTrue(len(images)>2)
+        self.assertTrue(len(images) > 2)
 
     def test_list_sizes(self):
         sizes = self.driver.list_sizes()
-        self.assertTrue(len(sizes)>=1)
+        self.assertTrue(len(sizes) >= 1)
 
     def test_destroy_node_running(self):
         nodes = self.driver.list_nodes()
@@ -93,7 +93,7 @@ class GandiTests(unittest.TestCase):
         img = filter(lambda x: '5' in x.name, images)[0]
         # Get a configuration size
         size = self.driver.list_sizes()[0]
-        node = self.driver.create_node(name=self.node_name,login=login,password=passwd,image=img,location=loc,size=size)
+        node = self.driver.create_node(name=self.node_name, login=login, password=passwd, image=img, location=loc, size=size)
         self.assertEqual(node.name, self.node_name)
 
 class GandiMockHttp(MockHttp):

Modified: libcloud/trunk/test/compute/test_ibm_sbc.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_ibm_sbc.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_ibm_sbc.py (original)
+++ libcloud/trunk/test/compute/test_ibm_sbc.py Sat Sep 10 14:31:41 2011
@@ -22,7 +22,7 @@ from libcloud.compute.base import Node, 
 from test import MockHttp
 from test.compute import TestCaseMixin
 from test.file_fixtures import ComputeFileFixtures
-from test.secrets import IBM_USER, IBM_SECRET
+from test.secrets import IBM_PARAMS
 
 class IBMTests(unittest.TestCase, TestCaseMixin):
     """
@@ -32,7 +32,7 @@ class IBMTests(unittest.TestCase, TestCa
     def setUp(self):
         IBM.connectionCls.conn_classes = (None, IBMMockHttp)
         IBMMockHttp.type = None
-        self.driver = IBM(IBM_USER, IBM_SECRET)
+        self.driver = IBM(*IBM_PARAMS)
 
     def test_auth(self):
         IBMMockHttp.type = 'UNAUTHORIZED'
@@ -89,7 +89,7 @@ class IBMTests(unittest.TestCase, TestCa
                                       size=size,
                                       location=location,
                                       publicKey='MyPublicKey',
-                                      configurationData = {
+                                      configurationData={
                                            'insight_admin_password': 'myPassword1',
                                            'db2_admin_password': 'myPassword2',
                                            'report_user_password': 'myPassword3'})
@@ -105,7 +105,7 @@ class IBMTests(unittest.TestCase, TestCa
                                           size=size,
                                           location=location,
                                           publicKey='MyPublicKey',
-                                          configurationData = {
+                                          configurationData={
                                                'insight_admin_password': 'myPassword1',
                                                'db2_admin_password': 'myPassword2',
                                                'report_user_password': 'myPassword3'})

Modified: libcloud/trunk/test/compute/test_opennebula.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_opennebula.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_opennebula.py (original)
+++ libcloud/trunk/test/compute/test_opennebula.py Sat Sep 10 14:31:41 2011
@@ -26,13 +26,13 @@ from test import MockHttp
 from test.compute import TestCaseMixin
 from test.file_fixtures import ComputeFileFixtures
 
-from test.secrets import OPENNEBULA_USER, OPENNEBULA_KEY
+from test.secrets import OPENNEBULA_PARAMS
 
 class OpenNebulaTests(unittest.TestCase, TestCaseMixin):
 
     def setUp(self):
         OpenNebulaNodeDriver.connectionCls.conn_classes = (None, OpenNebulaMockHttp)
-        self.driver = OpenNebulaNodeDriver(OPENNEBULA_USER, OPENNEBULA_KEY)
+        self.driver = OpenNebulaNodeDriver(*OPENNEBULA_PARAMS)
 
     def test_create_node(self):
         image = NodeImage(id=1, name='UbuntuServer9.04-Contextualized', driver=self.driver)

Modified: libcloud/trunk/test/compute/test_openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_openstack.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_openstack.py (original)
+++ libcloud/trunk/test/compute/test_openstack.py Sat Sep 10 14:31:41 2011
@@ -25,8 +25,7 @@ from test import MockResponse, MockHttpT
 from test.file_fixtures import ComputeFileFixtures
 from test.compute import TestCaseMixin
 
-from test.secrets import NOVA_USERNAME, NOVA_API_KEY, NOVA_HOST, NOVA_PORT
-from test.secrets import NOVA_SECURE
+from test.secrets import OPENSTACK_PARAMS
 
 
 class OpenStackResponseTestCase(unittest.TestCase):
@@ -59,13 +58,7 @@ class OpenStackTests(unittest.TestCase, 
     should_list_locations = False
 
     driver_type = OpenStackNodeDriver
-    driver_args = (
-        NOVA_USERNAME,
-        NOVA_API_KEY,
-        NOVA_SECURE,
-        NOVA_HOST,
-        NOVA_PORT,
-    )
+    driver_args = OPENSTACK_PARAMS
 
     @classmethod
     def create_driver(self):

Modified: libcloud/trunk/test/compute/test_opsource.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_opsource.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_opsource.py (original)
+++ libcloud/trunk/test/compute/test_opsource.py Sat Sep 10 14:31:41 2011
@@ -18,21 +18,21 @@ import httplib
 
 from libcloud.common.types import InvalidCredsError
 from libcloud.compute.drivers.opsource import OpsourceNodeDriver as Opsource
-from libcloud.compute.drivers.opsource import OpsourceAPIException, OpsourceNetwork
-from libcloud.compute.base import Node, NodeImage, NodeSize, NodeAuthPassword, NodeLocation
+from libcloud.compute.drivers.opsource import OpsourceAPIException
+from libcloud.compute.base import Node, NodeAuthPassword, NodeLocation
 
 from test import MockHttp
 from test.compute import TestCaseMixin
 from test.file_fixtures import ComputeFileFixtures
 
-from test.secrets import OPSOURCE_USER, OPSOURCE_PASS
+from test.secrets import OPSOURCE_PARAMS
 
 class OpsourceTests(unittest.TestCase, TestCaseMixin):
 
     def setUp(self):
         Opsource.connectionCls.conn_classes = (None, OpsourceMockHttp)
         OpsourceMockHttp.type = None
-        self.driver = Opsource(OPSOURCE_USER, OPSOURCE_PASS)
+        self.driver = Opsource(*OPSOURCE_PARAMS)
 
     def test_invalid_creds(self):
         OpsourceMockHttp.type = 'UNAUTHORIZED'
@@ -60,7 +60,7 @@ class OpsourceTests(unittest.TestCase, T
         node = Node(id='11', name=None, state=None,
                     public_ip=None, private_ip=None, driver=self.driver)
         try:
-            ret = node.reboot()
+            node.reboot()
             self.assertTrue(False) # above command should have thrown OpsourceAPIException
         except OpsourceAPIException:
             self.assertTrue(True)
@@ -76,7 +76,7 @@ class OpsourceTests(unittest.TestCase, T
         node = Node(id='11', name=None, state=None,
                     public_ip=None, private_ip=None, driver=self.driver)
         try:
-            ret = node.destroy()
+            node.destroy()
             self.assertTrue(False) # above command should have thrown OpsourceAPIException
         except OpsourceAPIException:
             self.assertTrue(True)
@@ -84,7 +84,6 @@ class OpsourceTests(unittest.TestCase, T
     def test_create_node_response(self):
         rootPw = NodeAuthPassword('pass123')
         image = self.driver.list_images()[0]
-        location = self.driver.list_locations()[0]
         network = self.driver.ex_list_networks()[0]
         node = self.driver.create_node(name='test2', image=image, auth=rootPw,
                                 ex_description='test2 node', ex_network=network,
@@ -103,7 +102,7 @@ class OpsourceTests(unittest.TestCase, T
         node = Node(id='11', name=None, state=None,
                     public_ip=None, private_ip=None, driver=self.driver)
         try:
-            ret = self.driver.ex_shutdown_graceful(node)
+            self.driver.ex_shutdown_graceful(node)
             self.assertTrue(False) # above command should have thrown OpsourceAPIException
         except OpsourceAPIException:
             self.assertTrue(True)
@@ -119,7 +118,7 @@ class OpsourceTests(unittest.TestCase, T
         node = Node(id='11', name=None, state=None,
                     public_ip=None, private_ip=None, driver=self.driver)
         try:
-            ret = self.driver.ex_start_node(node)
+            self.driver.ex_start_node(node)
             self.assertTrue(False) # above command should have thrown OpsourceAPIException
         except OpsourceAPIException:
             self.assertTrue(True)
@@ -135,7 +134,7 @@ class OpsourceTests(unittest.TestCase, T
         node = Node(id='11', name=None, state=None,
                     public_ip=None, private_ip=None, driver=self.driver)
         try:
-            ret = self.driver.ex_power_off(node)
+            self.driver.ex_power_off(node)
             self.assertTrue(False) # above command should have thrown OpsourceAPIException
         except OpsourceAPIException:
             self.assertTrue(True)

Modified: libcloud/trunk/test/compute/test_rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_rackspace.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_rackspace.py (original)
+++ libcloud/trunk/test/compute/test_rackspace.py Sat Sep 10 14:31:41 2011
@@ -18,7 +18,7 @@ import unittest
 from libcloud.compute.drivers.rackspace import RackspaceNodeDriver
 from test.compute.test_openstack import OpenStackTests
 
-from test.secrets import RACKSPACE_USER, RACKSPACE_KEY
+from test.secrets import RACKSPACE_PARAMS
 
 
 class RackspaceTests(OpenStackTests):
@@ -26,10 +26,7 @@ class RackspaceTests(OpenStackTests):
     should_have_pricing = True
 
     driver_type = RackspaceNodeDriver
-    driver_args = (
-        RACKSPACE_USER,
-        RACKSPACE_KEY,
-    )
+    driver_args = RACKSPACE_PARAMS
 
 
 if __name__ == '__main__':

Modified: libcloud/trunk/test/compute/test_slicehost.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_slicehost.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_slicehost.py (original)
+++ libcloud/trunk/test/compute/test_slicehost.py Sat Sep 10 14:31:41 2011
@@ -25,7 +25,7 @@ from libcloud.compute.base import Node, 
 from test import MockHttp
 from test.compute import TestCaseMixin
 from test.file_fixtures import ComputeFileFixtures
-from test.secrets import SLICEHOST_KEY
+from test.secrets import SLICEHOST_PARAMS
 
 class SlicehostTest(unittest.TestCase, TestCaseMixin):
 
@@ -33,7 +33,7 @@ class SlicehostTest(unittest.TestCase, T
 
         Slicehost.connectionCls.conn_classes = (None, SlicehostMockHttp)
         SlicehostMockHttp.type = None
-        self.driver = Slicehost(SLICEHOST_KEY)
+        self.driver = Slicehost(*SLICEHOST_PARAMS)
 
     def test_list_nodes(self):
         ret = self.driver.list_nodes()

Modified: libcloud/trunk/test/compute/test_softlayer.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_softlayer.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_softlayer.py (original)
+++ libcloud/trunk/test/compute/test_softlayer.py Sat Sep 10 14:31:41 2011
@@ -25,8 +25,7 @@ from libcloud.compute.types import NodeS
 
 from test import MockHttp               # pylint: disable-msg=E0611
 from test.file_fixtures import ComputeFileFixtures # pylint: disable-msg=E0611
-from test.secrets import ( # pylint: disable-msg=E0611
-    SOFTLAYER_USER, SOFTLAYER_APIKEY)
+from test.secrets import SOFTLAYER_PARAMS
 
 class MockSoftLayerTransport(xmlrpclib.Transport):
 
@@ -48,7 +47,7 @@ class SoftLayerTests(unittest.TestCase):
     def setUp(self):
         SoftLayer.connectionCls.proxyCls.transportCls = [
             MockSoftLayerTransport, MockSoftLayerTransport]
-        self.driver = SoftLayer(SOFTLAYER_USER, SOFTLAYER_APIKEY)
+        self.driver = SoftLayer(*SOFTLAYER_PARAMS)
 
     def test_list_nodes(self):
         node = self.driver.list_nodes()[0]

Modified: libcloud/trunk/test/compute/test_vcloud.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_vcloud.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_vcloud.py (original)
+++ libcloud/trunk/test/compute/test_vcloud.py Sat Sep 10 14:31:41 2011
@@ -25,7 +25,7 @@ from test import MockHttp
 from test.compute import TestCaseMixin
 from test.file_fixtures import ComputeFileFixtures
 
-from test.secrets import TERREMARK_USER, TERREMARK_SECRET
+from test.secrets import VCLOUD_PARAMS
 
 class TerremarkTests(unittest.TestCase, TestCaseMixin):
 
@@ -33,11 +33,11 @@ class TerremarkTests(unittest.TestCase, 
         VCloudNodeDriver.connectionCls.host = "test"
         VCloudNodeDriver.connectionCls.conn_classes = (None, TerremarkMockHttp)
         TerremarkMockHttp.type = None
-        self.driver = TerremarkDriver(TERREMARK_USER, TERREMARK_SECRET)
+        self.driver = TerremarkDriver(*VCLOUD_PARAMS)
 
     def test_list_images(self):
         ret = self.driver.list_images()
-        self.assertEqual(ret[0].id,'https://services.vcloudexpress.terremark.com/api/v0.8/vAppTemplate/5')
+        self.assertEqual(ret[0].id, 'https://services.vcloudexpress.terremark.com/api/v0.8/vAppTemplate/5')
 
     def test_list_sizes(self):
         ret = self.driver.list_sizes()

Modified: libcloud/trunk/test/compute/test_voxel.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_voxel.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_voxel.py (original)
+++ libcloud/trunk/test/compute/test_voxel.py Sat Sep 10 14:31:41 2011
@@ -23,7 +23,7 @@ from libcloud.compute.types import Inval
 from test import MockHttp
 from test.file_fixtures import ComputeFileFixtures
 
-from test.secrets import VOXEL_KEY, VOXEL_SECRET
+from test.secrets import VOXEL_PARAMS
 
 class VoxelTest(unittest.TestCase):
 
@@ -31,7 +31,7 @@ class VoxelTest(unittest.TestCase):
 
         Voxel.connectionCls.conn_classes = (None, VoxelMockHttp)
         VoxelMockHttp.type = None
-        self.driver = Voxel(VOXEL_KEY, VOXEL_SECRET)
+        self.driver = Voxel(*VOXEL_PARAMS)
 
     def test_auth_failed(self):
         VoxelMockHttp.type = 'UNAUTHORIZED'

Modified: libcloud/trunk/test/compute/test_vpsnet.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_vpsnet.py?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_vpsnet.py (original)
+++ libcloud/trunk/test/compute/test_vpsnet.py Sat Sep 10 14:31:41 2011
@@ -24,13 +24,13 @@ from libcloud.compute.types import NodeS
 from test import MockHttp
 from test.compute import TestCaseMixin
 
-from test.secrets import VPSNET_USER, VPSNET_KEY
+from test.secrets import VPSNET_PARAMS
 
 class VPSNetTests(unittest.TestCase, TestCaseMixin):
 
     def setUp(self):
         VPSNetNodeDriver.connectionCls.conn_classes = (None, VPSNetMockHttp)
-        self.driver = VPSNetNodeDriver(VPSNET_USER, VPSNET_KEY)
+        self.driver = VPSNetNodeDriver(*VPSNET_PARAMS)
 
     def test_create_node(self):
         VPSNetMockHttp.type = 'create'

Modified: libcloud/trunk/test/secrets.py-dist
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/secrets.py-dist?rev=1167525&r1=1167524&r2=1167525&view=diff
==============================================================================
--- libcloud/trunk/test/secrets.py-dist (original)
+++ libcloud/trunk/test/secrets.py-dist Sat Sep 10 14:31:41 2011
@@ -16,59 +16,21 @@
 # Make a copy of this file named 'secrets.py' and add your credentials there.
 # Note you can run unit tests without setting your credentials.
 
-# for test_ec2.py
-EC2_ACCESS_ID='YoUR K3Y'
-EC2_SECRET='secr3t'
-
-BRIGHTBOX_CLIENT_ID = ''
-BRIGHTBOX_CLIENT_SECRET = ''
-
-BLUEBOX_CUSTOMER_ID = ''
-BLUEBOX_API_KEY = ''
-
-RACKSPACE_USER = ''
-RACKSPACE_KEY = ''
-
-SLICEHOST_KEY = ''
-
-VPSNET_USER = ''
-VPSNET_KEY = ''
-
-GOGRID_API_KEY = ''
-GOGRID_SECRET = ''
-
-LINODE_KEY = ''
-
-HOSTINGCOM_USER = ''
-HOSTINGCOM_SECRET = ''
-
-TERREMARK_USER = ''
-TERREMARK_SECRET = ''
-
-SOFTLAYER_USER = ''
-SOFTLAYER_APIKEY = ''
-
-VOXEL_KEY = ''
-VOXEL_SECRET = ''
-
-ECP_USER_NAME = ''
-ECP_PASSWORD = ''
-
-IBM_USER = ''
-IBM_SECRET = ''
-
-DREAMHOST_KEY=''
-
-GANDI_USER = ''
-
-OPENNEBULA_USER = ''
-OPENNEBULA_KEY = ''
-
-OPSOURCE_USER=''
-OPSOURCE_PASS=''
-
-NOVA_USERNAME = ''
-NOVA_API_KEY = ''
-NOVA_HOST = ''
-NOVA_PORT = 8774
-NOVA_SECURE = False
+BLUEBOX_PARAMS = ('customer_id', 'api_key')
+BRIGHTBOX_PARAMS = ('client_id', 'client_secret')
+DREAMHOST_PARAMS = ('key',)
+EC2_PARAMS = ('access_id', 'secret')
+ECP_PARAMS = ('user_name', 'password')
+GANDI_PARAMS = ('user',)
+HOSTINGCOM_PARAMS = ('user', 'secret')
+IBM_PARAMS = ('user', 'secret')
+# OPENSTACK_PARAMS = ('user_name', 'api_key', secure_bool, 'host', port_int)
+OPENSTACK_PARAMS = ('user_name', 'api_key', False, 'host', 8774)
+OPENNEBULA_PARAMS = ('user', 'key')
+OPSOURCE_PARAMS = ('user', 'password')
+RACKSPACE_PARAMS = ('user', 'key')
+SLICEHOST_PARAMS = ('key',)
+SOFTLAYER_PARAMS = ('user', 'api_key')
+VCLOUD_PARAMS = ('user', 'secret')
+VOXEL_PARAMS = ('key', 'secret')
+VPSNET_PARAMS = ('user', 'key')