Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
 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,
     )
Ejemplo n.º 7
0
    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),
        ]
Ejemplo n.º 8
0
 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
Ejemplo n.º 9
0
 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
Ejemplo n.º 10
0
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()
Ejemplo n.º 11
0
Archivo: ecp.py Proyecto: eskp/dewpoint
    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
Ejemplo n.º 12
0
 def list_sizes(self, location=None):
     return [
         NodeSize(driver=self.connection.driver, **i)
         for i in self._instance_types.values()
     ]
Ejemplo n.º 13
0
 def list_sizes(self, **kwargs):
     return [ NodeSize(driver=self.connection.driver, **i)
         for i in self._sizes.values() ]
Ejemplo n.º 14
0
 def list_sizes(self, location=None):
     return [
         NodeSize(driver=self.connection.driver, **i)
         for i in VOXEL_INSTANCE_TYPES.values()
     ]
Ejemplo n.º 15
0
    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')