Code Duplication    Length = 18-18 lines in 2 locations

glances/exports/glances_couchdb.py 1 location

@@ 26-43 (lines=18) @@
23
24
    """This class manages the CouchDB export module."""
25
26
    def __init__(self, config=None, args=None):
27
        """Init the CouchDB export IF."""
28
        super(Export, self).__init__(config=config, args=args)
29
30
        # Mandatory configuration keys (additional to host and port)
31
        self.db = None
32
33
        # Optional configuration keys
34
        self.user = None
35
        self.password = None
36
37
        # Load the Cassandra configuration file section
38
        self.export_enable = self.load_conf('couchdb', mandatories=['host', 'port', 'db'], options=['user', 'password'])
39
        if not self.export_enable:
40
            sys.exit(2)
41
42
        # Init the CouchDB client
43
        self.client = self.init()
44
45
    def init(self):
46
        """Init the connection to the CouchDB server."""

glances/exports/glances_mongodb.py 1 location

@@ 25-42 (lines=18) @@
22
23
    """This class manages the MongoDB export module."""
24
25
    def __init__(self, config=None, args=None):
26
        """Init the MongoDB export IF."""
27
        super(Export, self).__init__(config=config, args=args)
28
29
        # Mandatory configuration keys (additional to host and port)
30
        self.db = None
31
32
        # Optional configuration keys
33
        self.user = None
34
        self.password = None
35
36
        # Load the Cassandra configuration file section
37
        self.export_enable = self.load_conf('mongodb', mandatories=['host', 'port', 'db'], options=['user', 'password'])
38
        if not self.export_enable:
39
            sys.exit(2)
40
41
        # Init the CouchDB client
42
        self.client = self.init()
43
44
    def init(self):
45
        """Init the connection to the CouchDB server."""