| @@ 235-258 (lines=24) @@ | ||
| 232 | _xmlkey = cmd.add_element("key") |
|
| 233 | _xmlkey.add_element("private", private_key) |
|
| 234 | ||
| 235 | if credential_type == "snmp": |
|
| 236 | if auth_algorithm not in ("md5", "sha1"): |
|
| 237 | raise InvalidArgument( |
|
| 238 | "create_credential requires auth_algorithm to be either " |
|
| 239 | "md5 or sha1" |
|
| 240 | ) |
|
| 241 | ||
| 242 | cmd.add_element("auth_algorithm", auth_algorithm) |
|
| 243 | ||
| 244 | if community: |
|
| 245 | cmd.add_element("community", community) |
|
| 246 | ||
| 247 | if privacy_algorithm is not None or privacy_password: |
|
| 248 | _xmlprivacy = cmd.add_element("privacy") |
|
| 249 | ||
| 250 | if privacy_algorithm is not None: |
|
| 251 | if privacy_algorithm not in ("aes", "des"): |
|
| 252 | raise InvalidArgument( |
|
| 253 | "create_credential requires algorithm to be either " |
|
| 254 | "aes or des" |
|
| 255 | ) |
|
| 256 | ||
| 257 | _xmlprivacy.add_element("algorithm", privacy_algorithm) |
|
| 258 | ||
| 259 | if privacy_password: |
|
| 260 | _xmlprivacy.add_element("password", privacy_password) |
|
| 261 | ||
| @@ 691-714 (lines=24) @@ | ||
| 688 | _xmlkey = cmd.add_element("key") |
|
| 689 | _xmlkey.add_element("private", private_key) |
|
| 690 | ||
| 691 | if credential_type == "snmp": |
|
| 692 | if auth_algorithm not in ("md5", "sha1"): |
|
| 693 | raise InvalidArgument( |
|
| 694 | "create_credential requires auth_algorithm to be either " |
|
| 695 | "md5 or sha1" |
|
| 696 | ) |
|
| 697 | ||
| 698 | cmd.add_element("auth_algorithm", auth_algorithm) |
|
| 699 | ||
| 700 | if community: |
|
| 701 | cmd.add_element("community", community) |
|
| 702 | ||
| 703 | if privacy_algorithm is not None or privacy_password: |
|
| 704 | _xmlprivacy = cmd.add_element("privacy") |
|
| 705 | ||
| 706 | if privacy_algorithm is not None: |
|
| 707 | if privacy_algorithm not in ("aes", "des"): |
|
| 708 | raise InvalidArgument( |
|
| 709 | "create_credential requires algorithm to be either " |
|
| 710 | "aes or des" |
|
| 711 | ) |
|
| 712 | ||
| 713 | _xmlprivacy.add_element("algorithm", privacy_algorithm) |
|
| 714 | ||
| 715 | if privacy_password: |
|
| 716 | _xmlprivacy.add_element("password", privacy_password) |
|
| 717 | ||