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

@@ 652-675 (lines=24) @@
649
            _xmlkey = cmd.add_element('key')
650
            _xmlkey.add_element('private', private_key)
651
652
        if credential_type == 'snmp':
653
            if auth_algorithm not in ('md5', 'sha1'):
654
                raise InvalidArgument(
655
                    'create_credential requires auth_algorithm to be either '
656
                    'md5 or sha1')
657
658
            cmd.add_element('auth_algorithm', auth_algorithm)
659
660
            if community:
661
                cmd.add_element('community', community)
662
663
            if privacy_algorithm is not None or privacy_password:
664
                _xmlprivacy = cmd.add_element('privacy')
665
666
                if privacy_algorithm is not None:
667
                    if privacy_algorithm not in ('aes', 'des'):
668
                        raise InvalidArgument(
669
                            'create_credential requires algorithm to be either '
670
                            'aes or des')
671
672
                    _xmlprivacy.add_element('algorithm', privacy_algorithm)
673
674
                if privacy_password:
675
                    _xmlprivacy.add_element('password', privacy_password)
676
677
        return self._send_xml_command(cmd)
678