| @@ 502-525 (lines=24) @@ | ||
| 499 | _xmlkey = cmd.add_element('key') |
|
| 500 | _xmlkey.add_element('private', private_key) |
|
| 501 | ||
| 502 | if credential_type == 'snmp': |
|
| 503 | if auth_algorithm not in ('md5', 'sha1'): |
|
| 504 | raise InvalidArgument( |
|
| 505 | 'create_credential requires auth_algorithm to be either ' |
|
| 506 | 'md5 or sha1') |
|
| 507 | ||
| 508 | cmd.add_element('auth_algorithm', auth_algorithm) |
|
| 509 | ||
| 510 | if community: |
|
| 511 | cmd.add_element('community', community) |
|
| 512 | ||
| 513 | if privacy_algorithm is not None or privacy_password: |
|
| 514 | _xmlprivacy = cmd.add_element('privacy') |
|
| 515 | ||
| 516 | if privacy_algorithm is not None: |
|
| 517 | if privacy_algorithm not in ('aes', 'des'): |
|
| 518 | raise InvalidArgument( |
|
| 519 | 'create_credential requires algorithm to be either ' |
|
| 520 | 'aes or des') |
|
| 521 | ||
| 522 | _xmlprivacy.add_element('algorithm', privacy_algorithm) |
|
| 523 | ||
| 524 | if privacy_password: |
|
| 525 | _xmlprivacy.add_element('password', privacy_password) |
|
| 526 | ||
| 527 | return self._send_xml_command(cmd) |
|
| 528 | ||
| @@ 145-168 (lines=24) @@ | ||
| 142 | _xmlkey = cmd.add_element('key') |
|
| 143 | _xmlkey.add_element('private', private_key) |
|
| 144 | ||
| 145 | if credential_type == 'snmp': |
|
| 146 | if auth_algorithm not in ('md5', 'sha1'): |
|
| 147 | raise InvalidArgument( |
|
| 148 | 'create_credential requires auth_algorithm to be either ' |
|
| 149 | 'md5 or sha1') |
|
| 150 | ||
| 151 | cmd.add_element('auth_algorithm', auth_algorithm) |
|
| 152 | ||
| 153 | if community: |
|
| 154 | cmd.add_element('community', community) |
|
| 155 | ||
| 156 | if privacy_algorithm is not None or privacy_password: |
|
| 157 | _xmlprivacy = cmd.add_element('privacy') |
|
| 158 | ||
| 159 | if privacy_algorithm is not None: |
|
| 160 | if privacy_algorithm not in ('aes', 'des'): |
|
| 161 | raise InvalidArgument( |
|
| 162 | 'create_credential requires algorithm to be either ' |
|
| 163 | 'aes or des') |
|
| 164 | ||
| 165 | _xmlprivacy.add_element('algorithm', privacy_algorithm) |
|
| 166 | ||
| 167 | if privacy_password: |
|
| 168 | _xmlprivacy.add_element('password', privacy_password) |
|
| 169 | ||
| 170 | if credential_type == 'pgp': |
|
| 171 | if not public_key: |
|