def _to_size(self, plan): return NodeSize(id=plan['pricing_plan_code'], name=plan['pricing_plan_description'], ram=plan['minimum_memory_mb'], disk=plan['minimum_disk_gb'], bandwidth=plan['minimum_data_transfer_allowance_gb'], price=plan['monthly_recurring_fee_usd'], driver=self.connection.driver)
def _to_size(self, num): size = NodeSize(id=num, name="%d Node" % (num,), ram=RAM_PER_NODE * num, disk=DISK_PER_NODE, bandwidth=BANDWIDTH_PER_NODE * num, price=self._get_price_per_node(num) * num, driver=self.connection.driver) return size
def _to_size(self, element): s = NodeSize(id=int(element.findtext('id')), name=str(element.findtext('name')), ram=int(element.findtext('ram')), disk=None, # XXX: needs hardcode bandwidth=None, # XXX: needs hardcode price=float(element.findtext('price'))/(100*24*30), driver=self.connection.driver) return s
def _to_size(self, ram): ns = NodeSize(id=None, name="%s Ram" % ram, ram=ram, disk=None, bandwidth=None, price=None, driver=self.connection.driver) return ns
def _to_size(self, el): s = NodeSize( id=el.get('id'), name=el.get('name'), ram=int(el.get('ram')), disk=int(el.get('disk')), bandwidth=None, # XXX: needs hardcode price=None, # XXX: needs hardcode, driver=self.connection.driver) return s
def _to_size(self, id, size): return NodeSize( id=id, name=size['name'], ram=size['ram'], disk=size['disk'], bandwidth=size['bandwidth'], price=None, driver=self.connection.driver, )
def list_sizes(self, location=None): """ Returns a list of node sizes as a cloud provider might have >>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> sorted([size.ram for size in driver.list_sizes()]) [128, 512, 4096, 8192] """ return [ NodeSize(id=1, name="Small", ram=128, disk=4, bandwidth=500, price=4, driver=self), NodeSize(id=2, name="Medium", ram=512, disk=16, bandwidth=1500, price=8, driver=self), NodeSize(id=3, name="Big", ram=4096, disk=32, bandwidth=2500, price=32, driver=self), NodeSize(id=4, name="XXL Big", ram=4096 * 2, disk=32 * 4, bandwidth=2500 * 3, price=32 * 2, driver=self), ]
def list_sizes(self): # List Sizes # Retrieve all available Linode plans. # FIXME: Prices get mangled due to 'float'. params = { "api_action": "avail.linodeplans" } data = self.connection.request(LINODE_ROOT, params=params).object sizes = [] for obj in data: n = NodeSize(id=obj["PLANID"], name=obj["LABEL"], ram=obj["RAM"], disk=(obj["DISK"] * 1024), bandwidth=obj["XFER"], price=obj["PRICE"], driver=self.connection.driver) sizes.append(n) return sizes
def start(self): "Fire up a fresh EC2 instance." EC2 = get_driver(Provider.EC2) self.driver = EC2NodeDriver(settings.id, settings.key) image = NodeImage(self.ec2_ami, self.ec2_ami, EC2) size = NodeSize(self.ec2_mtype, self.ec2_mtype, None, None, None, None, EC2) self.node = self.driver.create_node(image=image, name=self.ec2_ami, size=size, keyname=self.ec2_sshkey, securitygroup=self.ec2_groups) print "Created node %s" % self.node.id
def tryEC2(): image=NodeImage('ami-bf07ead6', 'ubuntu 10.4', EC2) size=NodeSize('m1.large', 'large', None, None, None, None, EC2) node = None try: node = EC2Driver.create_node(image=image, name="ubuntu-test", size=size, keyname="kp1", securitygroup=['default', 'dist-slave', 'buildbot-slave']) print node print node.id while node.state == NodeState.PENDING: time.sleep(3) finally: if node: node.destroy()
def list_sizes(self, location=None): """ Returns a list of all hardware templates """ #Make the call response = self.connection.request( '/rest/hosting/htemplate/list').parse_body() #Turn the response into an array of NodeSize objects sizes = [] for htemplate in response['templates']: sizes.append( NodeSize( id=htemplate['uuid'], name=htemplate['name'], ram=htemplate['memory'], disk=0, #Disk is independent of hardware template bandwidth=0, #There is no way to keep track of bandwidth price=0, #The billing system is external driver=self, )) return sizes
def list_sizes(self, location=None): return [ NodeSize(driver=self.connection.driver, **i) for i in self._instance_types.values() ]
def list_sizes(self, **kwargs): return [ NodeSize(driver=self.connection.driver, **i) for i in self._sizes.values() ]
def list_sizes(self, location=None): return [ NodeSize(driver=self.connection.driver, **i) for i in VOXEL_INSTANCE_TYPES.values() ]
def __init__(self): image=NodeImage('ami-bf07ead6', 'ubuntu 10.4', EC2) size=NodeSize('m1.large', 'large', None, None, None, None, EC2) self.node = EC2Driver.create_node(image=image, name="ubuntu-test", size=size, securitygroup=['default', 'dist-slave', 'buildbot-slave'], keyname='kp1')