libcloud/compute/drivers/dimensiondata.py [552:740]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                        additional_nics.append(add_nic)
                else:
                    if ips is not None:
                        raise TypeError("ex_additional_nics_ipv4 must " "be None or a tuple/list")

            if "ex_additional_nics_vlan" in kwargs or "ex_additional_nics_ipv4" in kwargs:
                ex_additional_nics = additional_nics

            # Handle MCP2 latest. CaaS API 2.3 onwards
            if ex_network_domain is None:
                raise ValueError("ex_network_domain must be specified")

            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

            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_primary_nic_private_ipv4 is None and ex_primary_nic_vlan is None:
                raise ValueError(
                    "Missing argument. Either "
                    "ex_primary_nic_private_ipv4 or "
                    "ex_primary_nic_vlan "
                    "must be specified."
                )

            if ex_primary_nic_private_ipv4 is not None and ex_primary_nic_vlan is not None:
                raise ValueError(
                    "Either ex_primary_nic_private_ipv4 or "
                    "ex_primary_nic_vlan "
                    "be specified. Not both."
                )

            network_elm = ET.SubElement(server_elm, "networkInfo")

            net_domain_id = self._network_domain_to_network_domain_id(ex_network_domain)

            network_elm.set("networkDomainId", net_domain_id)

            pri_nic = ET.SubElement(network_elm, "primaryNic")

            if ex_primary_nic_private_ipv4 is not None:
                ET.SubElement(pri_nic, "privateIpv4").text = ex_primary_nic_private_ipv4

            if ex_primary_nic_vlan is not None:
                vlan_id = self._vlan_to_vlan_id(ex_primary_nic_vlan)
                ET.SubElement(pri_nic, "vlanId").text = vlan_id

            if ex_primary_nic_network_adapter is not None:
                ET.SubElement(pri_nic, "networkAdapter").text = ex_primary_nic_network_adapter

            if isinstance(ex_additional_nics, (list, tuple)):
                for nic in ex_additional_nics:
                    additional_nic = ET.SubElement(network_elm, "additionalNic")

                    if nic.private_ip_v4 is None and nic.vlan is None:
                        raise ValueError(
                            "Either a vlan or private_ip_v4 "
                            "must be specified for each "
                            "additional nic."
                        )

                    if nic.private_ip_v4 is not None and nic.vlan is not None:
                        raise ValueError(
                            "Either a vlan or private_ip_v4 "
                            "must be specified for each "
                            "additional nic. Not both."
                        )

                    if nic.private_ip_v4 is not None:
                        ET.SubElement(additional_nic, "privateIpv4").text = nic.private_ip_v4

                    if nic.vlan is not None:
                        vlan_id = self._vlan_to_vlan_id(nic.vlan)
                        ET.SubElement(additional_nic, "vlanId").text = vlan_id

                    if nic.network_adapter_name is not None:
                        ET.SubElement(additional_nic, "networkAdapter").text = (
                            nic.network_adapter_name
                        )
            elif ex_additional_nics is not None:
                raise TypeError("ex_additional_NICs must be None or tuple/list")

            if ex_primary_dns:
                dns_elm = ET.SubElement(server_elm, "primaryDns")
                dns_elm.text = ex_primary_dns

            if ex_secondary_dns:
                dns_elm = ET.SubElement(server_elm, "secondaryDns")
                dns_elm.text = ex_secondary_dns

            if ex_ipv4_gateway:
                ET.SubElement(server_elm, "ipv4Gateway").text = ex_ipv4_gateway

            if isinstance(ex_disks, (list, tuple)):
                for disk in ex_disks:
                    disk_elm = ET.SubElement(server_elm, "disk")
                    disk_elm.set("scsiId", disk.scsi_id)
                    disk_elm.set("speed", disk.speed)
            elif ex_disks is not None:
                raise TypeError("ex_disks must be None or tuple/list")

            if ex_microsoft_time_zone:
                ET.SubElement(server_elm, "microsoftTimeZone").text = ex_microsoft_time_zone

            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")

            new_node = self.ex_get_node_by_id(node_id)

            if image_needs_auth:
                if getattr(auth_obj, "generated", False):
                    new_node.extra["password"] = auth_obj.password

        return new_node

    def destroy_node(self, node):
        """
        Deletes a node, node must be stopped before deletion


        :keyword node: The node to delete
        :type    node: :class:`Node`

        :rtype: ``bool``
        """
        request_elm = ET.Element("deleteServer", {"xmlns": TYPES_URN, "id": node.id})
        body = self.connection.request_with_orgId_api_2(
            "server/deleteServer", method="POST", data=ET.tostring(request_elm)
        ).object
        response_code = findtext(body, "responseCode", TYPES_URN)
        return response_code in ["IN_PROGRESS", "OK"]

    def reboot_node(self, node):
        """
        Reboots a node by requesting the OS restart via the hypervisor


        :keyword node: The node to reboot
        :type    node: :class:`Node`

        :rtype: ``bool``
        """
        request_elm = ET.Element("rebootServer", {"xmlns": TYPES_URN, "id": node.id})
        body = self.connection.request_with_orgId_api_2(
            "server/rebootServer", method="POST", data=ET.tostring(request_elm)
        ).object
        response_code = findtext(body, "responseCode", TYPES_URN)
        return response_code in ["IN_PROGRESS", "OK"]

    def list_nodes(
        self,
        ex_location=None,
        ex_name=None,
        ex_ipv6=None,
        ex_ipv4=None,
        ex_vlan=None,
        ex_image=None,
        ex_deployed=None,
        ex_started=None,
        ex_state=None,
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



libcloud/compute/drivers/nttcis.py [567:763]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                        additional_nics.append(add_nic)
                else:
                    if ips is not None:
                        raise TypeError("ex_additional_nics_ipv4 must " "be None or a tuple/list")

            if "ex_additional_nics_vlan" in kwargs or "ex_additional_nics_ipv4" in kwargs:
                ex_additional_nics = additional_nics

            # Handle MCP2 latest. CaaS API 2.3 onwards

            if ex_network_domain is None:
                raise ValueError("ex_network_domain must be specified")

            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

            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_primary_nic_private_ipv4 is None and ex_primary_nic_vlan is None:
                raise ValueError(
                    "Missing argument. Either "
                    "ex_primary_nic_private_ipv4 or "
                    "ex_primary_nic_vlan "
                    "must be specified."
                )

            if ex_primary_nic_private_ipv4 is not None and ex_primary_nic_vlan is not None:
                raise ValueError(
                    "Either ex_primary_nic_private_ipv4 or "
                    "ex_primary_nic_vlan "
                    "be specified. Not both."
                )

            network_elm = ET.SubElement(server_elm, "networkInfo")

            net_domain_id = self._network_domain_to_network_domain_id(ex_network_domain)

            network_elm.set("networkDomainId", net_domain_id)

            pri_nic = ET.SubElement(network_elm, "primaryNic")

            if ex_primary_nic_private_ipv4 is not None:
                ET.SubElement(pri_nic, "privateIpv4").text = ex_primary_nic_private_ipv4

            if ex_primary_nic_vlan is not None:
                vlan_id = self._vlan_to_vlan_id(ex_primary_nic_vlan)
                ET.SubElement(pri_nic, "vlanId").text = vlan_id

            if ex_primary_nic_network_adapter is not None:
                ET.SubElement(pri_nic, "networkAdapter").text = ex_primary_nic_network_adapter

            if isinstance(ex_additional_nics, (list, tuple)):
                for nic in ex_additional_nics:
                    additional_nic = ET.SubElement(network_elm, "additionalNic")

                    if nic.private_ip_v4 is None and nic.vlan is None:
                        raise ValueError(
                            "Either a vlan or private_ip_v4 "
                            "must be specified for each "
                            "additional nic."
                        )

                    if nic.private_ip_v4 is not None and nic.vlan is not None:
                        raise ValueError(
                            "Either a vlan or private_ip_v4 "
                            "must be specified for each "
                            "additional nic. Not both."
                        )

                    if nic.private_ip_v4 is not None:
                        ET.SubElement(additional_nic, "privateIpv4").text = nic.private_ip_v4

                    if nic.vlan is not None:
                        vlan_id = self._vlan_to_vlan_id(nic.vlan)
                        ET.SubElement(additional_nic, "vlanId").text = vlan_id

                    if nic.network_adapter_name is not None:
                        ET.SubElement(additional_nic, "networkAdapter").text = (
                            nic.network_adapter_name
                        )
            elif ex_additional_nics is not None:
                raise TypeError("ex_additional_NICs must be None or tuple/list")

            if ex_primary_dns:
                dns_elm = ET.SubElement(server_elm, "primaryDns")
                dns_elm.text = ex_primary_dns

            if ex_secondary_dns:
                dns_elm = ET.SubElement(server_elm, "secondaryDns")
                dns_elm.text = ex_secondary_dns

            if ex_ipv4_gateway:
                ET.SubElement(server_elm, "ipv4Gateway").text = ex_ipv4_gateway

            if isinstance(ex_disks, (list, tuple)):
                for disk in ex_disks:
                    disk_elm = ET.SubElement(server_elm, "disk")
                    disk_elm.set("scsiId", disk.scsi_id)
                    disk_elm.set("speed", disk.speed)
            elif ex_disks is not None:
                raise TypeError("ex_disks must be None or tuple/list")

            if ex_microsoft_time_zone:
                ET.SubElement(server_elm, "microsoftTimeZone").text = ex_microsoft_time_zone

            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")

            new_node = self.ex_get_node_by_id(node_id)

            if image_needs_auth:
                if getattr(auth_obj, "generated", False):
                    new_node.extra["password"] = auth_obj.password

        return new_node

    def destroy_node(self, node):
        """
        Deletes a node, node must be stopped before deletion


        :keyword node: The node to delete
        :type    node: :class:`Node`

        :rtype: ``bool``
        """

        request_elm = ET.Element("deleteServer", {"xmlns": TYPES_URN, "id": node.id})
        body = self.connection.request_with_orgId_api_2(
            "server/deleteServer", method="POST", data=ET.tostring(request_elm)
        ).object
        response_code = findtext(body, "responseCode", TYPES_URN)

        return response_code in ["IN_PROGRESS", "OK"]

    def reboot_node(self, node):
        """
        Reboots a node by requesting the OS restart via the hypervisor


        :keyword node: The node to reboot
        :type    node: :class:`Node`

        :rtype: ``bool``
        """

        request_elm = ET.Element("rebootServer", {"xmlns": TYPES_URN, "id": node.id})
        body = self.connection.request_with_orgId_api_2(
            "server/rebootServer", method="POST", data=ET.tostring(request_elm)
        ).object
        response_code = findtext(body, "responseCode", TYPES_URN)

        return response_code in ["IN_PROGRESS", "OK"]

    def list_nodes(
        self,
        ex_location=None,
        ex_name=None,
        ex_ipv6=None,
        ex_ipv4=None,
        ex_vlan=None,
        ex_image=None,
        ex_deployed=None,
        ex_started=None,
        ex_state=None,
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



