| @@ 672-701 (lines=30) @@ | ||
| 669 | _xmlkey = cmd.add_element("key") |
|
| 670 | _xmlkey.add_element("private", private_key) |
|
| 671 | ||
| 672 | if credential_type == CredentialType.SNMP: |
|
| 673 | if not isinstance(auth_algorithm, SnmpAuthAlgorithm): |
|
| 674 | raise InvalidArgumentType( |
|
| 675 | function=self.create_credential.__name__, |
|
| 676 | argument="auth_algorithm", |
|
| 677 | arg_type=SnmpAuthAlgorithm.__name__, |
|
| 678 | ) |
|
| 679 | ||
| 680 | cmd.add_element("auth_algorithm", auth_algorithm.value) |
|
| 681 | ||
| 682 | if community: |
|
| 683 | cmd.add_element("community", community) |
|
| 684 | ||
| 685 | if privacy_algorithm is not None or privacy_password: |
|
| 686 | _xmlprivacy = cmd.add_element("privacy") |
|
| 687 | ||
| 688 | if privacy_algorithm is not None: |
|
| 689 | if not isinstance(privacy_algorithm, SnmpPrivacyAlgorithm): |
|
| 690 | raise InvalidArgumentType( |
|
| 691 | function=self.create_credential.__name__, |
|
| 692 | argument="privacy_algorithm", |
|
| 693 | arg_type=SnmpPrivacyAlgorithm.__name__, |
|
| 694 | ) |
|
| 695 | ||
| 696 | _xmlprivacy.add_element( |
|
| 697 | "algorithm", privacy_algorithm.value |
|
| 698 | ) |
|
| 699 | ||
| 700 | if privacy_password: |
|
| 701 | _xmlprivacy.add_element("password", privacy_password) |
|
| 702 | ||
| 703 | return self._send_xml_command(cmd) |
|
| 704 | ||
| @@ 261-290 (lines=30) @@ | ||
| 258 | _xmlkey = cmd.add_element("key") |
|
| 259 | _xmlkey.add_element("private", private_key) |
|
| 260 | ||
| 261 | if credential_type == CredentialType.SNMP: |
|
| 262 | if not isinstance(auth_algorithm, SnmpAuthAlgorithm): |
|
| 263 | raise InvalidArgumentType( |
|
| 264 | function=self.create_credential.__name__, |
|
| 265 | argument='auth_algorithm', |
|
| 266 | arg_type=SnmpAuthAlgorithm.__name__, |
|
| 267 | ) |
|
| 268 | ||
| 269 | cmd.add_element("auth_algorithm", auth_algorithm.value) |
|
| 270 | ||
| 271 | if community: |
|
| 272 | cmd.add_element("community", community) |
|
| 273 | ||
| 274 | if privacy_algorithm is not None or privacy_password: |
|
| 275 | _xmlprivacy = cmd.add_element("privacy") |
|
| 276 | ||
| 277 | if privacy_algorithm is not None: |
|
| 278 | if not isinstance(privacy_algorithm, SnmpPrivacyAlgorithm): |
|
| 279 | raise InvalidArgumentType( |
|
| 280 | function=self.create_credential.__name__, |
|
| 281 | argument='privacy_algorithm', |
|
| 282 | arg_type=SnmpPrivacyAlgorithm.__name__, |
|
| 283 | ) |
|
| 284 | ||
| 285 | _xmlprivacy.add_element( |
|
| 286 | "algorithm", privacy_algorithm.value |
|
| 287 | ) |
|
| 288 | ||
| 289 | if privacy_password: |
|
| 290 | _xmlprivacy.add_element("password", privacy_password) |
|
| 291 | ||
| 292 | if credential_type == CredentialType.PGP_ENCRYPTION_KEY: |
|
| 293 | if not public_key: |
|