Code Duplication    Length = 24-24 lines in 2 locations

gvm/protocols/gmpv8.py 1 location

@@ 225-248 (lines=24) @@
222
            _xmlkey = cmd.add_element('key')
223
            _xmlkey.add_element('private', private_key)
224
225
        if credential_type == 'snmp':
226
            if auth_algorithm not in ('md5', 'sha1'):
227
                raise InvalidArgument(
228
                    'create_credential requires auth_algorithm to be either '
229
                    'md5 or sha1')
230
231
            cmd.add_element('auth_algorithm', auth_algorithm)
232
233
            if community:
234
                cmd.add_element('community', community)
235
236
            if privacy_algorithm is not None or privacy_password:
237
                _xmlprivacy = cmd.add_element('privacy')
238
239
                if privacy_algorithm is not None:
240
                    if privacy_algorithm not in ('aes', 'des'):
241
                        raise InvalidArgument(
242
                            'create_credential requires algorithm to be either '
243
                            'aes or des')
244
245
                    _xmlprivacy.add_element('algorithm', privacy_algorithm)
246
247
                if privacy_password:
248
                    _xmlprivacy.add_element('password', privacy_password)
249
250
        if credential_type == 'pgp':
251
            if not public_key:

gvm/protocols/gmpv7.py 1 location

@@ 663-686 (lines=24) @@
660
            _xmlkey = cmd.add_element('key')
661
            _xmlkey.add_element('private', private_key)
662
663
        if credential_type == 'snmp':
664
            if auth_algorithm not in ('md5', 'sha1'):
665
                raise InvalidArgument(
666
                    'create_credential requires auth_algorithm to be either '
667
                    'md5 or sha1')
668
669
            cmd.add_element('auth_algorithm', auth_algorithm)
670
671
            if community:
672
                cmd.add_element('community', community)
673
674
            if privacy_algorithm is not None or privacy_password:
675
                _xmlprivacy = cmd.add_element('privacy')
676
677
                if privacy_algorithm is not None:
678
                    if privacy_algorithm not in ('aes', 'des'):
679
                        raise InvalidArgument(
680
                            'create_credential requires algorithm to be either '
681
                            'aes or des')
682
683
                    _xmlprivacy.add_element('algorithm', privacy_algorithm)
684
685
                if privacy_password:
686
                    _xmlprivacy.add_element('password', privacy_password)
687
688
        return self._send_xml_command(cmd)
689