'Creates the node, and sets the ssh key, console key
NephoScale will respond with a 200-200 response after sending a valid
request. If nowait=True is specified in the args, we then ask a few
times until the server is created and assigned a public IP address,
so that deploy_node can be run
>>> from libcloud.compute.providers import get_driver
>>> driver = get_driver(\'nephoscale\')
>>> conn = driver(\'nepho_user\',\'nepho_password\')
>>> conn.list_nodes()
>>> name = \'staging-server\'
>>> size = conn.list_sizes()[0]
<NodeSize: id=27, ...name=CS025 - 0.25GB, 10GB, ...>
>>> image = conn.list_images()[9]
<NodeImage: id=49, name=Linux Ubuntu Server 10.04 LTS 64-bit, ...>
>>> server_keys = conn.ex_list_keypairs(key_group=1)[0]
<NodeKey: id=71211, name=markos>
>>> server_key = conn.ex_list_keypairs(key_group=1)[0].id
70867
>>> console_keys = conn.ex_list_keypairs(key_group=4)[0]
<NodeKey: id=71213, name=mistio28434>
>>> console_key = conn.ex_list_keypairs(key_group=4)[0].id
70907
>>> node = conn.create_node(name=name, size=size, image=image,                 console_key=console_key, server_key=server_key)
We can also create an ssh key, plus a console key and
deploy node with them
>>> server_key = conn.ex_create_keypair(name, public_key=\'123\')
71211
>>> console_key = conn.ex_create_keypair(name, key_group=4)
71213
We can increase the number of connect attempts to wait until
the node is created, so that deploy_node has ip address to
deploy the script
We can also specify the location
>>> location = conn.list_locations()[0]
>>> node = conn.create_node(name=name,
>>> ...                     size=size,
>>> ...                     image=image,
>>> ...                     console_key=console_key,
>>> ...                     server_key=server_key,
>>> ...                     connect_attempts=10,
>>> ...                     nowait=True,
>>> ...                     zone=location.id)'

def create_node(self, name, size, image, server_key=None, console_key=None, zone=None, **kwargs):

    hostname = kwargs.get('hostname', name)
    service_type = size.id
    image = image.id
    connect_attempts = int(kwargs.get('connect_attempts', CONNECT_ATTEMPTS))
    data = {'name': name, 'hostname': hostname, 'service_type': service_type, 'image': image, 'server_key': server_key, 'console_key': console_key, 'zone': zone}
    params = urlencode(data)
    try:
        node = self.connection.request('/server/cloud/', data=params, method='POST')
    except Exception:
        e = sys.exc_info()[1]
        raise Exception(('Failed    to    create    node    %s' % e))
    node = Node(id='', name=name, state=NodeState.UNKNOWN, public_ips=[], private_ips=[], driver=self)
    nowait = kwargs.get('ex_wait', False)
    if (not nowait):
        return node
    else:
        created_node = False
        while (connect_attempts > 0):
            nodes = self.list_nodes()
            created_node = [c_node for c_node in nodes if (c_node.name == name)]
            if created_node:
                return created_node[0]
            else:
                time.sleep(60)
                connect_attempts = (connect_attempts - 1)
        return node
