

def create_node(self, **kwargs):
    '\n        Create a new OpenNebula node.\n\n        @inherits: :class:`NodeDriver.create_node`\n\n        :keyword networks: List of virtual networks to which this node should\n                           connect. (optional)\n        :type    networks: :class:`OpenNebulaNetwork` or ``list``\n                           of :class:`OpenNebulaNetwork`\n\n        :keyword context: Custom (key, value) pairs to be injected into\n                          compute node XML description. (optional)\n        :type    context: ``dict``\n\n        :return: Instance of a newly created node.\n        :rtype:  :class:`Node`\n        '
    compute = ET.Element('COMPUTE')
    name = ET.SubElement(compute, 'NAME')
    name.text = kwargs['name']
    instance_type = ET.SubElement(compute, 'INSTANCE_TYPE')
    instance_type.text = kwargs['size'].name
    disk = ET.SubElement(compute, 'DISK')
    ET.SubElement(disk, 'STORAGE', {
        'href': ('/storage/%s' % str(kwargs['image'].id)),
    })
    if ('networks' in kwargs):
        if (not isinstance(kwargs['networks'], list)):
            kwargs['networks'] = [kwargs['networks']]
        for network in kwargs['networks']:
            nic = ET.SubElement(compute, 'NIC')
            ET.SubElement(nic, 'NETWORK', {
                'href': ('/network/%s' % str(network.id)),
            })
            if network.address:
                ip_line = ET.SubElement(node, 'IP')
                ip_line.text = network.address
    if ('context' in kwargs):
        if isinstance(kwargs['context'], dict):
            contextGroup = ET.SubElement(compute, 'CONTEXT')
            for (key, value) in list(kwargs['context'].items()):
                context = ET.SubElement(contextGroup, key.upper())
                context.text = value
    xml = ET.tostring(compute)
    node = self.connection.request('/compute', method='POST', data=xml).object
    return self._to_node(node)

dataset/ETHPy150Open apache/libcloud/libcloud/compute/drivers/opennebula.py OpenNebula_2_0_NodeDriver.create_node/VarMisuse@206/473 `nic`->`node`