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

@@ 610-633 (lines=24) @@
607
            _xmlkey = cmd.add_element('key')
608
            _xmlkey.add_element('private', private_key)
609
610
        if credential_type == 'snmp':
611
            if auth_algorithm not in ('md5', 'sha1'):
612
                raise InvalidArgument(
613
                    'create_credential requires auth_algorithm to be either '
614
                    'md5 or sha1')
615
616
            cmd.add_element('auth_algorithm', auth_algorithm)
617
618
            if community:
619
                cmd.add_element('community', community)
620
621
            if privacy_algorithm is not None or privacy_password:
622
                _xmlprivacy = cmd.add_element('privacy')
623
624
                if privacy_algorithm is not None:
625
                    if privacy_algorithm not in ('aes', 'des'):
626
                        raise InvalidArgument(
627
                            'create_credential requires algorithm to be either '
628
                            'aes or des')
629
630
                    _xmlprivacy.add_element('algorithm', privacy_algorithm)
631
632
                if privacy_password:
633
                    _xmlprivacy.add_element('password', privacy_password)
634
635
        return self._send_xml_command(cmd)
636