@@ 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: |
@@ 530-553 (lines=24) @@ | ||
527 | _xmlkey = cmd.add_element('key') |
|
528 | _xmlkey.add_element('private', private_key) |
|
529 | ||
530 | if credential_type == 'snmp': |
|
531 | if auth_algorithm not in ('md5', 'sha1'): |
|
532 | raise InvalidArgument( |
|
533 | 'create_credential requires auth_algorithm to be either ' |
|
534 | 'md5 or sha1') |
|
535 | ||
536 | cmd.add_element('auth_algorithm', auth_algorithm) |
|
537 | ||
538 | if community: |
|
539 | cmd.add_element('community', community) |
|
540 | ||
541 | if privacy_algorithm is not None or privacy_password: |
|
542 | _xmlprivacy = cmd.add_element('privacy') |
|
543 | ||
544 | if privacy_algorithm is not None: |
|
545 | if privacy_algorithm not in ('aes', 'des'): |
|
546 | raise InvalidArgument( |
|
547 | 'create_credential requires algorithm to be either ' |
|
548 | 'aes or des') |
|
549 | ||
550 | _xmlprivacy.add_element('algorithm', privacy_algorithm) |
|
551 | ||
552 | if privacy_password: |
|
553 | _xmlprivacy.add_element('password', privacy_password) |
|
554 | ||
555 | return self._send_xml_command(cmd) |
|
556 |