You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by pq...@apache.org on 2010/05/20 02:03:07 UTC
svn commit: r946486 - in /incubator/libcloud/trunk/libcloud/drivers:
gogrid.py linode.py rackspace.py rimuhosting.py vpsnet.py
Author: pquerna
Date: Thu May 20 00:03:07 2010
New Revision: 946486
URL: http://svn.apache.org/viewvc?rev=946486&view=rev
Log:
Add updated Pricing information for several drivers.
Submitted by: Brad Morgan <morgabra cloudkick.com>
Modified:
incubator/libcloud/trunk/libcloud/drivers/gogrid.py
incubator/libcloud/trunk/libcloud/drivers/linode.py
incubator/libcloud/trunk/libcloud/drivers/rackspace.py
incubator/libcloud/trunk/libcloud/drivers/rimuhosting.py
incubator/libcloud/trunk/libcloud/drivers/vpsnet.py
Modified: incubator/libcloud/trunk/libcloud/drivers/gogrid.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/gogrid.py?rev=946486&r1=946485&r2=946486&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/gogrid.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/gogrid.py Thu May 20 00:03:07 2010
@@ -141,7 +141,7 @@ class GoGridNodeDriver(NodeDriver):
return NodeState.UNKNOWN
def _get_ip(self, element):
- return element['ip']['ip']
+ return element.get('ip').get('ip')
def _get_id(self, element):
return element.get('id')
@@ -157,6 +157,7 @@ class GoGridNodeDriver(NodeDriver):
state=state,
public_ip=[ip],
private_ip=[],
+ extra={'ram':element.get('ram').get('name')},
driver=self.connection.driver)
return n
Modified: incubator/libcloud/trunk/libcloud/drivers/linode.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/linode.py?rev=946486&r1=946485&r2=946486&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/linode.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/linode.py Thu May 20 00:03:07 2010
@@ -52,6 +52,19 @@ LINODE_API = "api.linode.com"
# For beta accounts, change this to "/api/".
LINODE_ROOT = "/"
+# Map of TOTALRAM to PLANID, allows us to figure out what plan
+# a particular node is on
+LINODE_PLAN_IDS = {360:'1',
+ 540:'2',
+ 720:'3',
+ 1080:'4',
+ 1440:'5',
+ 2880:'6',
+ 5760:'7',
+ 8640:'8',
+ 11520:'9',
+ 14400:'10'}
+
class LinodeResponse(Response):
# Wraps a Linode API HTTP response.
@@ -144,6 +157,7 @@ class LinodeNodeDriver(NodeDriver):
type = Provider.LINODE
name = "Linode"
connectionCls = LinodeConnection
+ _linode_plan_ids = LINODE_PLAN_IDS
def __init__(self, key):
self.datacenter = None
@@ -455,6 +469,7 @@ class LinodeNodeDriver(NodeDriver):
state=self.LINODE_STATES[obj["STATUS"]], public_ip=public_ip,
private_ip=private_ip, driver=self.connection.driver)
n.extra = copy(obj)
+ n.extra = {"PLANID":self._linode_plan_ids.get(obj.get("TOTALRAM"))}
return n
features = {"create_node": ["ssh_key", "password"]}
Modified: incubator/libcloud/trunk/libcloud/drivers/rackspace.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/rackspace.py?rev=946486&r1=946485&r2=946486&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/rackspace.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/rackspace.py Thu May 20 00:03:07 2010
@@ -28,6 +28,21 @@ from xml.parsers.expat import ExpatError
NAMESPACE = 'http://docs.rackspacecloud.com/servers/api/v1.0'
+#
+# Prices need to be hardcoded as Rackspace doesn't expose them through
+# the API. Prices are associated with flavors, of which there are 7.
+# See - http://www.rackspacecloud.com/cloud_hosting_products/servers/pricing
+#
+RACKSPACE_PRICES = {
+ '1':'.015',
+ '2':'.030',
+ '3':'.060',
+ '4':'.120',
+ '5':'.240',
+ '6':'.480',
+ '7':'.960',
+}
+
class RackspaceResponse(Response):
def success(self):
@@ -147,6 +162,8 @@ class RackspaceNodeDriver(NodeDriver):
type = Provider.RACKSPACE
name = 'Rackspace'
+ _rackspace_prices = RACKSPACE_PRICES
+
features = {"create_node": ["generates_password"]}
NODE_STATE_MAP = { 'BUILD': NodeState.PENDING,
@@ -307,7 +324,7 @@ class RackspaceNodeDriver(NodeDriver):
ram=int(el.get('ram')),
disk=int(el.get('disk')),
bandwidth=None, # XXX: needs hardcode
- price=None, # XXX: needs hardcode,
+ price=self._rackspace_prices.get(el.get('id')), # Hardcoded,
driver=self.connection.driver)
return s
Modified: incubator/libcloud/trunk/libcloud/drivers/rimuhosting.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/rimuhosting.py?rev=946486&r1=946485&r2=946486&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/rimuhosting.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/rimuhosting.py Thu May 20 00:03:07 2010
@@ -141,7 +141,8 @@ class RimuHostingNodeDriver(NodeDriver):
),
private_ip=[],
driver=self.connection.driver,
- extra={'order_oid': order['order_oid']})
+ extra={'order_oid': order['order_oid'],
+ 'monthly_recurring_fee': order['billing_info']['monthly_recurring_fee']})
return n
def _to_size(self,plan):
Modified: incubator/libcloud/trunk/libcloud/drivers/vpsnet.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/vpsnet.py?rev=946486&r1=946485&r2=946486&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/vpsnet.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/vpsnet.py Thu May 20 00:03:07 2010
@@ -101,6 +101,7 @@ class VPSNetNodeDriver(NodeDriver):
state=state,
public_ip=[vm.get('primary_ip_address', None)],
private_ip=[],
+ extra={'slices_count':vm['slices_count']}, # Number of nodes consumed by VM
driver=self.connection.driver)
return n
@@ -166,8 +167,8 @@ class VPSNetNodeDriver(NodeDriver):
def list_sizes(self, location=None):
res = self.connection.request('/nodes.%s' % (API_VERSION,))
available_nodes = len([size for size in res.object
- if not size['slice']["virtual_machine_id"]])
- sizes = [self._to_size(i) for i in range(1,available_nodes + 1)]
+ if size['slice']['virtual_machine_id']])
+ sizes = [self._to_size(i) for i in range(1, available_nodes + 1)]
return sizes
def destroy_node(self, node):