Author: oremj
Date: Sat Mar 20 00:06:58 2010
New Revision: 925493
URL: http://svn.apache.org/viewvc?rev=925493&view=rev
Log:
Softlayer:
* list_locations test
* hard-code country data
Added:
incubator/libcloud/trunk/test/fixtures/softlayer/v3_SoftLayer_Location_Datacenter_getDatacenters.xml
Modified:
incubator/libcloud/trunk/libcloud/drivers/softlayer.py
incubator/libcloud/trunk/test/test_softlayer.py
Modified: incubator/libcloud/trunk/libcloud/drivers/softlayer.py
URL:
http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/softlayer.py?rev=925493&r1=925492&r2=925493&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/softlayer.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/softlayer.py Sat Mar 20 00:06:58
2010
@@ -24,7 +24,11 @@ from libcloud.base import NodeDriver, No
API_PREFIX = "http://api.service.softlayer.com/xmlrpc/v3"
-DATACENTERS = ['sea01', 'wdc01', 'dal01']
+DATACENTERS = {
+ 'sea01': {'country': 'US'},
+ 'wdc01': {'country': 'US'},
+ 'dal01': {'country': 'US'}
+}
class SoftLayerException(Exception):
pass
@@ -159,7 +163,7 @@ class SoftLayerNodeDriver(NodeDriver):
return NodeLocation(
id=loc['id'],
name=loc['name'],
- country="", # country data not available
+ country=DATACENTERS[loc['name']]['country'],
driver=self
)
Added:
incubator/libcloud/trunk/test/fixtures/softlayer/v3_SoftLayer_Location_Datacenter_getDatacenters.xml
URL:
http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/softlayer/v3_SoftLayer_Location_Datacenter_getDatacenters.xml?rev=925493&view=auto
==============================================================================
---
incubator/libcloud/trunk/test/fixtures/softlayer/v3_SoftLayer_Location_Datacenter_getDatacenters.xml
(added)
+++
incubator/libcloud/trunk/test/fixtures/softlayer/v3_SoftLayer_Location_Datacenter_getDatacenters.xml
Sat Mar 20 00:06:58 2010
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8"?>
+<params>
+<param>
+ <value>
+ <array>
+ <data>
+ <value>
+ <struct>
+ <member>
+ <name>id</name>
+ <value>
+ <int>2</int>
+ </value>
+ </member>
+ <member>
+ <name>name</name>
+ <value>
+ <string>dal00</string>
+ </value>
+ </member>
+ <member>
+ <name>longName</name>
+ <value>
+ <string>Corporate HQ</string>
+ </value>
+ </member>
+ </struct>
+ </value>
+ <value>
+ <struct>
+ <member>
+ <name>id</name>
+ <value>
+ <int>3</int>
+ </value>
+ </member>
+ <member>
+ <name>name</name>
+ <value>
+ <string>dal01</string>
+ </value>
+ </member>
+ <member>
+ <name>longName</name>
+ <value>
+ <string>Dallas</string>
+ </value>
+ </member>
+ </struct>
+ </value>
+ <value>
+ <struct>
+ <member>
+ <name>id</name>
+ <value>
+ <int>18171</int>
+ </value>
+ </member>
+ <member>
+ <name>name</name>
+ <value>
+ <string>sea01</string>
+ </value>
+ </member>
+ <member>
+ <name>longName</name>
+ <value>
+ <string>Seattle</string>
+ </value>
+ </member>
+ </struct>
+ </value>
+ <value>
+ <struct>
+ <member>
+ <name>id</name>
+ <value>
+ <int>37473</int>
+ </value>
+ </member>
+ <member>
+ <name>name</name>
+ <value>
+ <string>wdc01</string>
+ </value>
+ </member>
+ <member>
+ <name>longName</name>
+ <value>
+ <string>Washington, DC</string>
+ </value>
+ </member>
+ </struct>
+ </value>
+ </data>
+ </array>
+ </value>
+</param>
+</params>
Modified: incubator/libcloud/trunk/test/test_softlayer.py
URL:
http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_softlayer.py?rev=925493&r1=925492&r2=925493&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_softlayer.py (original)
+++ incubator/libcloud/trunk/test/test_softlayer.py Sat Mar 20 00:06:58 2010
@@ -48,6 +48,12 @@ class SoftLayerTests(unittest.TestCase):
node = self.driver.list_nodes()[0]
self.assertEqual(node.name, 'test')
+ def test_list_locations(self):
+ locations = self.driver.list_locations()
+ seattle = (l for l in locations if l.name == 'sea01').next()
+ self.assertEqual(seattle.country, 'US')
+ self.assertEqual(seattle.id, 18171)
+
class SoftLayerMockHttp(MockHttp):
fixtures = FileFixtures('softlayer')
@@ -55,5 +61,9 @@ class SoftLayerMockHttp(MockHttp):
body = self.fixtures.load('v3_SoftLayer_Account_getVirtualGuests.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+ def _xmlrpc_v3_SoftLayer_Location_Datacenter_getDatacenters(self, method,
url, body, headers):
+ body =
self.fixtures.load('v3_SoftLayer_Location_Datacenter_getDatacenters.xml')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
if __name__ == '__main__':
sys.exit(unittest.main())