| @@ 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: |
|
| @@ 507-530 (lines=24) @@ | ||
| 504 | _xmlkey = cmd.add_element('key') |
|
| 505 | _xmlkey.add_element('private', private_key) |
|
| 506 | ||
| 507 | if credential_type == 'snmp': |
|
| 508 | if auth_algorithm not in ('md5', 'sha1'): |
|
| 509 | raise InvalidArgument( |
|
| 510 | 'create_credential requires auth_algorithm to be either ' |
|
| 511 | 'md5 or sha1') |
|
| 512 | ||
| 513 | cmd.add_element('auth_algorithm', auth_algorithm) |
|
| 514 | ||
| 515 | if community: |
|
| 516 | cmd.add_element('community', community) |
|
| 517 | ||
| 518 | if privacy_algorithm is not None or privacy_password: |
|
| 519 | _xmlprivacy = cmd.add_element('privacy') |
|
| 520 | ||
| 521 | if privacy_algorithm is not None: |
|
| 522 | if privacy_algorithm not in ('aes', 'des'): |
|
| 523 | raise InvalidArgument( |
|
| 524 | 'create_credential requires algorithm to be either ' |
|
| 525 | 'aes or des') |
|
| 526 | ||
| 527 | _xmlprivacy.add_element('algorithm', privacy_algorithm) |
|
| 528 | ||
| 529 | if privacy_password: |
|
| 530 | _xmlprivacy.add_element('password', privacy_password) |
|
| 531 | ||
| 532 | return self._send_xml_command(cmd) |
|
| 533 | ||