

def create_node(self, name, image, auth, ex_description, ex_network=None, ex_network_domain=None, ex_vlan=None, ex_primary_ipv4=None, ex_memory_gb=None, ex_cpu_specification=None, ex_is_started=True, ex_additional_nics_vlan=None, ex_additional_nics_ipv4=None, **kwargs):
    '\n        Create a new DimensionData node\n\n        :keyword    name:   String with a name for this new node (required)\n        :type       name:   ``str``\n\n        :keyword    image:  OS Image to boot on node. (required)\n        :type       image:  :class:`NodeImage` or ``str``\n\n        :keyword    auth:   Initial authentication information for the\n                            node. (If this is a customer LINUX\n                            image auth will be ignored)\n        :type       auth:   :class:`NodeAuthPassword` or ``str`` or ``None``\n\n        :keyword    ex_description:  description for this node (required)\n        :type       ex_description:  ``str``\n\n        :keyword    ex_network:  Network to create the node within\n                                 (required unless using ex_network_domain\n                                 or ex_primary_ipv4)\n\n        :type       ex_network: :class:`DimensionDataNetwork` or ``str``\n\n        :keyword    ex_network_domain:  Network Domain to create the node\n                                        (required unless using network\n                                        or ex_primary_ipv4)\n        :type       ex_network_domain: :class:`DimensionDataNetworkDomain`\n                                        or ``str``\n\n        :keyword    ex_primary_ipv4: Primary nics IPv4 Address\n                                     MCP1: (required unless ex_network)\n                                     MCP2: (required unless ex_vlan)\n        :type       ex_primary_ipv4: ``str``\n\n        :keyword    ex_vlan:  VLAN to create the node within\n                              (required unless using network)\n        :type       ex_vlan: :class:`DimensionDataVlan` or ``str``\n\n        :keyword    ex_memory_gb:  The amount of memory in GB for the server\n        :type       ex_memory_gb: ``int``\n\n        :keyword    ex_cpu_specification: The spec of CPU to deploy (optional)\n        :type       ex_cpu_specification:\n            :class:`DimensionDataServerCpuSpecification`\n\n        :keyword    ex_is_started:  Start server after creation? default\n                                   true (required)\n        :type       ex_is_started:  ``bool``\n\n        :keyword    ex_additional_nics_vlan: (MCP2 Only) List of additional\n                                              nics to add by vlan\n        :type       ex_additional_nics_vlan: ``list`` of\n            :class:`DimensionDataVlan` or ``list`` of ``str``\n\n        :keyword    ex_additional_nics_ipv4: (MCP2 Only) List of additional\n                                              nics to add by ipv4 address\n        :type       ex_additional_nics_ipv4: ``list`` of ``str``\n\n        :return: The newly created :class:`Node`.\n        :rtype: :class:`Node`\n        '
    password = None
    image_needs_auth = self._image_needs_auth(image)
    if image_needs_auth:
        if isinstance(auth, basestring):
            auth_obj = NodeAuthPassword(password=auth)
            password = auth
        else:
            auth_obj = self._get_and_check_auth(auth)
            password = auth_obj.password
    if ((ex_network_domain is None) and (ex_network is None) and (ex_primary_ipv4 is None)):
        raise ValueError('One of ex_network_domain, ex_network, or ex_ipv6_primary must be specified')
    server_elm = ET.Element('deployServer', {
        'xmlns': TYPES_URN,
    })
    ET.SubElement(server_elm, 'name').text = name
    ET.SubElement(server_elm, 'description').text = ex_description
    image_id = self._image_to_image_id(image)
    ET.SubElement(server_elm, 'imageId').text = image_id
    ET.SubElement(server_elm, 'start').text = str(ex_is_started).lower()
    if (password is not None):
        ET.SubElement(server_elm, 'administratorPassword').text = password
    if (ex_cpu_specification is not None):
        cpu = ET.SubElement(server_elm, 'cpu')
        cpu.set('speed', ex_cpu_specification.performance)
        cpu.set('count', str(ex_cpu_specification.cpu_count))
        cpu.set('coresPerSocket', str(ex_cpu_specification.cores_per_socket))
    if (ex_memory_gb is not None):
        ET.SubElement(server_elm, 'memoryGb').text = str(ex_memory_gb)
    if (ex_network is not None):
        network_elm = ET.SubElement(server_elm, 'network')
        network_id = self._network_to_network_id(ex_network)
        ET.SubElement(network_elm, 'networkId').text = network_id
    elif ((ex_network_domain is None) and (ex_primary_ipv4 is not None)):
        network_elm = ET.SubElement(server_elm, 'network')
        ET.SubElement(network_elm, 'privateIpv4').text = ex_primary_ipv4
    elif (ex_network_domain is not None):
        net_domain_id = self._network_domain_to_network_domain_id(ex_network_domain)
        network_inf_elm = ET.SubElement(server_elm, 'networkInfo', {
            'networkDomainId': net_domain_id,
        })
        if (ex_vlan is not None):
            vlan_id = self._vlan_to_vlan_id(ex_vlan)
            pri_nic = ET.SubElement(network_inf_elm, 'primaryNic')
            ET.SubElement(pri_nic, 'vlanId').text = vlan_id
        elif (ex_primary_ipv4 is not None):
            pri_nic = ET.SubElement(network_inf_elm, 'primaryNic')
            ET.SubElement(pri_nic, 'privateIpv4').text = ex_primary_ipv4
        else:
            raise ValueError('One of ex_vlan or ex_primary_ipv4 must be specified')
        if isinstance(ex_additional_nics_ipv4, (list, tuple)):
            for ipv4_nic in ex_additional_nics_ipv4:
                add_nic = ET.SubElement(network_inf_elm, 'additionalNic')
                ET.SubElement(add_nic, 'privateIpv4').text = ipv4_nic
        elif (ex_additional_nics_ipv4 is not None):
            raise TypeError('ex_additional_nics_ipv4 must be None or a tuple/list')
        if isinstance(ex_additional_nics_vlan, (list, tuple)):
            for vlan_nic in ex_additional_nics_vlan:
                add_nic = ET.SubElement(network_inf_elm, 'additionalNic')
                ET.SubElement(add_nic, 'vlanId').text = vlan_nic
        elif (ex_additional_nics_vlan is not None):
            raise TypeError('ex_additional_nics_vlanmust be None or tuple/list')
    response = self.connection.request_with_orgId_api_2('server/deployServer', method='POST', data=ET.tostring(server_elm)).object
    node_id = None
    for info in findall(response, 'info', TYPES_URN):
        if (info.get('name') == 'serverId'):
            node_id = info.get('value')
    node = self.ex_get_node_by_id(node_id)
    if image_needs_auth:
        if getattr(auth_obj, 'generated', False):
            node.extra['password'] = auth_obj.password
    return node

dataset/ETHPy150Open apache/libcloud/libcloud/compute/drivers/dimensiondata.py DimensionDataNodeDriver.create_node/original