@@ 261-292 (lines=32) @@ | ||
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, self.types.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( |
|
279 | privacy_algorithm, self.types.SnmpPrivacyAlgorithm |
|
280 | ): |
|
281 | raise InvalidArgumentType( |
|
282 | function=self.create_credential.__name__, |
|
283 | argument='privacy_algorithm', |
|
284 | arg_type=SnmpPrivacyAlgorithm.__name__, |
|
285 | ) |
|
286 | ||
287 | _xmlprivacy.add_element( |
|
288 | "algorithm", privacy_algorithm.value |
|
289 | ) |
|
290 | ||
291 | if privacy_password: |
|
292 | _xmlprivacy.add_element("password", privacy_password) |
|
293 | ||
294 | if credential_type == CredentialType.PGP_ENCRYPTION_KEY: |
|
295 | if not public_key: |
@@ 682-711 (lines=30) @@ | ||
679 | _xmlkey = cmd.add_element("key") |
|
680 | _xmlkey.add_element("private", private_key) |
|
681 | ||
682 | if credential_type == CredentialType.SNMP: |
|
683 | if not isinstance(auth_algorithm, SnmpAuthAlgorithm): |
|
684 | raise InvalidArgumentType( |
|
685 | function=self.create_credential.__name__, |
|
686 | argument="auth_algorithm", |
|
687 | arg_type=SnmpAuthAlgorithm.__name__, |
|
688 | ) |
|
689 | ||
690 | cmd.add_element("auth_algorithm", auth_algorithm.value) |
|
691 | ||
692 | if community: |
|
693 | cmd.add_element("community", community) |
|
694 | ||
695 | if privacy_algorithm is not None or privacy_password: |
|
696 | _xmlprivacy = cmd.add_element("privacy") |
|
697 | ||
698 | if privacy_algorithm is not None: |
|
699 | if not isinstance(privacy_algorithm, SnmpPrivacyAlgorithm): |
|
700 | raise InvalidArgumentType( |
|
701 | function=self.create_credential.__name__, |
|
702 | argument="privacy_algorithm", |
|
703 | arg_type=SnmpPrivacyAlgorithm.__name__, |
|
704 | ) |
|
705 | ||
706 | _xmlprivacy.add_element( |
|
707 | "algorithm", privacy_algorithm.value |
|
708 | ) |
|
709 | ||
710 | if privacy_password: |
|
711 | _xmlprivacy.add_element("password", privacy_password) |
|
712 | ||
713 | return self._send_xml_command(cmd) |
|
714 |