| @@ 6778-6879 (lines=102) @@ | ||
| 6775 | ||
| 6776 | return self._send_xml_command(cmd) |
|
| 6777 | ||
| 6778 | def modify_target( |
|
| 6779 | self, |
|
| 6780 | target_id: str, |
|
| 6781 | *, |
|
| 6782 | name: Optional[str] = None, |
|
| 6783 | comment: Optional[str] = None, |
|
| 6784 | hosts: Optional[List[str]] = None, |
|
| 6785 | exclude_hosts: Optional[List[str]] = None, |
|
| 6786 | ssh_credential_id: Optional[str] = None, |
|
| 6787 | ssh_credential_port: Optional[bool] = None, |
|
| 6788 | smb_credential_id: Optional[str] = None, |
|
| 6789 | esxi_credential_id: Optional[str] = None, |
|
| 6790 | snmp_credential_id: Optional[str] = None, |
|
| 6791 | alive_test: Optional[AliveTest] = None, |
|
| 6792 | reverse_lookup_only: Optional[bool] = None, |
|
| 6793 | reverse_lookup_unify: Optional[bool] = None, |
|
| 6794 | port_list_id: Optional[str] = None, |
|
| 6795 | ) -> Any: |
|
| 6796 | """Modifies an existing target. |
|
| 6797 | ||
| 6798 | Arguments: |
|
| 6799 | target_id: ID of target to modify. |
|
| 6800 | comment: Comment on target. |
|
| 6801 | name: Name of target. |
|
| 6802 | hosts: List of target hosts. |
|
| 6803 | exclude_hosts: A list of hosts to exclude. |
|
| 6804 | ssh_credential_id: UUID of SSH credential to use on target. |
|
| 6805 | ssh_credential_port: The port to use for ssh credential |
|
| 6806 | smb_credential_id: UUID of SMB credential to use on target. |
|
| 6807 | esxi_credential_id: UUID of ESXi credential to use on target. |
|
| 6808 | snmp_credential_id: UUID of SNMP credential to use on target. |
|
| 6809 | port_list_id: UUID of port list describing ports to scan. |
|
| 6810 | alive_test: Which alive tests to use. |
|
| 6811 | reverse_lookup_only: Whether to scan only hosts that have names. |
|
| 6812 | reverse_lookup_unify: Whether to scan only one IP when multiple IPs |
|
| 6813 | have the same name. |
|
| 6814 | ||
| 6815 | Returns: |
|
| 6816 | The response. See :py:meth:`send_command` for details. |
|
| 6817 | """ |
|
| 6818 | if not target_id: |
|
| 6819 | raise RequiredArgument( |
|
| 6820 | function=self.modify_target.__name__, argument='target_id' |
|
| 6821 | ) |
|
| 6822 | ||
| 6823 | cmd = XmlCommand("modify_target") |
|
| 6824 | cmd.set_attribute("target_id", target_id) |
|
| 6825 | ||
| 6826 | if comment: |
|
| 6827 | cmd.add_element("comment", comment) |
|
| 6828 | ||
| 6829 | if name: |
|
| 6830 | cmd.add_element("name", name) |
|
| 6831 | ||
| 6832 | if hosts: |
|
| 6833 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
| 6834 | if exclude_hosts is None: |
|
| 6835 | exclude_hosts = [''] |
|
| 6836 | ||
| 6837 | if exclude_hosts: |
|
| 6838 | cmd.add_element("exclude_hosts", _to_comma_list(exclude_hosts)) |
|
| 6839 | ||
| 6840 | if alive_test: |
|
| 6841 | if not isinstance(alive_test, AliveTest): |
|
| 6842 | raise InvalidArgumentType( |
|
| 6843 | function=self.modify_target.__name__, |
|
| 6844 | argument='alive_test', |
|
| 6845 | arg_type=AliveTest.__name__, |
|
| 6846 | ) |
|
| 6847 | cmd.add_element("alive_tests", alive_test.value) |
|
| 6848 | ||
| 6849 | if ssh_credential_id: |
|
| 6850 | _xmlssh = cmd.add_element( |
|
| 6851 | "ssh_credential", attrs={"id": ssh_credential_id} |
|
| 6852 | ) |
|
| 6853 | ||
| 6854 | if ssh_credential_port: |
|
| 6855 | _xmlssh.add_element("port", str(ssh_credential_port)) |
|
| 6856 | ||
| 6857 | if smb_credential_id: |
|
| 6858 | cmd.add_element("smb_credential", attrs={"id": smb_credential_id}) |
|
| 6859 | ||
| 6860 | if esxi_credential_id: |
|
| 6861 | cmd.add_element("esxi_credential", attrs={"id": esxi_credential_id}) |
|
| 6862 | ||
| 6863 | if snmp_credential_id: |
|
| 6864 | cmd.add_element("snmp_credential", attrs={"id": snmp_credential_id}) |
|
| 6865 | ||
| 6866 | if reverse_lookup_only is not None: |
|
| 6867 | cmd.add_element( |
|
| 6868 | "reverse_lookup_only", _to_bool(reverse_lookup_only) |
|
| 6869 | ) |
|
| 6870 | ||
| 6871 | if reverse_lookup_unify is not None: |
|
| 6872 | cmd.add_element( |
|
| 6873 | "reverse_lookup_unify", _to_bool(reverse_lookup_unify) |
|
| 6874 | ) |
|
| 6875 | ||
| 6876 | if port_list_id: |
|
| 6877 | cmd.add_element("port_list", attrs={"id": port_list_id}) |
|
| 6878 | ||
| 6879 | return self._send_xml_command(cmd) |
|
| 6880 | ||
| 6881 | def modify_task( |
|
| 6882 | self, |
|
| @@ 5849-5950 (lines=102) @@ | ||
| 5846 | ||
| 5847 | return self._send_xml_command(cmd) |
|
| 5848 | ||
| 5849 | def modify_target( |
|
| 5850 | self, |
|
| 5851 | target_id: str, |
|
| 5852 | *, |
|
| 5853 | name: Optional[str] = None, |
|
| 5854 | comment: Optional[str] = None, |
|
| 5855 | hosts: Optional[List[str]] = None, |
|
| 5856 | exclude_hosts: Optional[List[str]] = None, |
|
| 5857 | ssh_credential_id: Optional[str] = None, |
|
| 5858 | ssh_credential_port: Optional[bool] = None, |
|
| 5859 | smb_credential_id: Optional[str] = None, |
|
| 5860 | esxi_credential_id: Optional[str] = None, |
|
| 5861 | snmp_credential_id: Optional[str] = None, |
|
| 5862 | alive_test: Optional[AliveTest] = None, |
|
| 5863 | reverse_lookup_only: Optional[bool] = None, |
|
| 5864 | reverse_lookup_unify: Optional[bool] = None, |
|
| 5865 | port_list_id: Optional[str] = None, |
|
| 5866 | ) -> Any: |
|
| 5867 | """Modifies an existing target. |
|
| 5868 | ||
| 5869 | Arguments: |
|
| 5870 | target_id: ID of target to modify. |
|
| 5871 | comment: Comment on target. |
|
| 5872 | name: Name of target. |
|
| 5873 | hosts: List of target hosts. |
|
| 5874 | exclude_hosts: A list of hosts to exclude. |
|
| 5875 | ssh_credential_id: UUID of SSH credential to use on target. |
|
| 5876 | ssh_credential_port: The port to use for ssh credential |
|
| 5877 | smb_credential_id: UUID of SMB credential to use on target. |
|
| 5878 | esxi_credential_id: UUID of ESXi credential to use on target. |
|
| 5879 | snmp_credential_id: UUID of SNMP credential to use on target. |
|
| 5880 | port_list_id: UUID of port list describing ports to scan. |
|
| 5881 | alive_test: Which alive tests to use. |
|
| 5882 | reverse_lookup_only: Whether to scan only hosts that have names. |
|
| 5883 | reverse_lookup_unify: Whether to scan only one IP when multiple IPs |
|
| 5884 | have the same name. |
|
| 5885 | ||
| 5886 | Returns: |
|
| 5887 | The response. See :py:meth:`send_command` for details. |
|
| 5888 | """ |
|
| 5889 | if not target_id: |
|
| 5890 | raise RequiredArgument( |
|
| 5891 | function=self.modify_target.__name__, argument='target_id' |
|
| 5892 | ) |
|
| 5893 | ||
| 5894 | cmd = XmlCommand("modify_target") |
|
| 5895 | cmd.set_attribute("target_id", target_id) |
|
| 5896 | ||
| 5897 | if comment: |
|
| 5898 | cmd.add_element("comment", comment) |
|
| 5899 | ||
| 5900 | if name: |
|
| 5901 | cmd.add_element("name", name) |
|
| 5902 | ||
| 5903 | if hosts: |
|
| 5904 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
| 5905 | if exclude_hosts is None: |
|
| 5906 | exclude_hosts = [''] |
|
| 5907 | ||
| 5908 | if exclude_hosts: |
|
| 5909 | cmd.add_element("exclude_hosts", _to_comma_list(exclude_hosts)) |
|
| 5910 | ||
| 5911 | if alive_test: |
|
| 5912 | if not isinstance(alive_test, AliveTest): |
|
| 5913 | raise InvalidArgumentType( |
|
| 5914 | function=self.modify_target.__name__, |
|
| 5915 | argument='alive_test', |
|
| 5916 | arg_type=AliveTest.__name__, |
|
| 5917 | ) |
|
| 5918 | cmd.add_element("alive_tests", alive_test.value) |
|
| 5919 | ||
| 5920 | if ssh_credential_id: |
|
| 5921 | _xmlssh = cmd.add_element( |
|
| 5922 | "ssh_credential", attrs={"id": ssh_credential_id} |
|
| 5923 | ) |
|
| 5924 | ||
| 5925 | if ssh_credential_port: |
|
| 5926 | _xmlssh.add_element("port", str(ssh_credential_port)) |
|
| 5927 | ||
| 5928 | if smb_credential_id: |
|
| 5929 | cmd.add_element("smb_credential", attrs={"id": smb_credential_id}) |
|
| 5930 | ||
| 5931 | if esxi_credential_id: |
|
| 5932 | cmd.add_element("esxi_credential", attrs={"id": esxi_credential_id}) |
|
| 5933 | ||
| 5934 | if snmp_credential_id: |
|
| 5935 | cmd.add_element("snmp_credential", attrs={"id": snmp_credential_id}) |
|
| 5936 | ||
| 5937 | if reverse_lookup_only is not None: |
|
| 5938 | cmd.add_element( |
|
| 5939 | "reverse_lookup_only", _to_bool(reverse_lookup_only) |
|
| 5940 | ) |
|
| 5941 | ||
| 5942 | if reverse_lookup_unify is not None: |
|
| 5943 | cmd.add_element( |
|
| 5944 | "reverse_lookup_unify", _to_bool(reverse_lookup_unify) |
|
| 5945 | ) |
|
| 5946 | ||
| 5947 | if port_list_id: |
|
| 5948 | cmd.add_element("port_list", attrs={"id": port_list_id}) |
|
| 5949 | ||
| 5950 | return self._send_xml_command(cmd) |
|
| 5951 | ||
| 5952 | def modify_task( |
|
| 5953 | self, |
|