Browse Source

begin pdns business

develop
Robin Thoni 8 years ago
parent
commit
8345537c40
2 changed files with 79 additions and 0 deletions
  1. 42
    0
      src/Business/PdnsSlave.cpp
  2. 37
    0
      src/Business/PdnsSlave.h

+ 42
- 0
src/Business/PdnsSlave.cpp View File

@@ -0,0 +1,42 @@
1
+//
2
+// Created by robin on 8/8/15.
3
+//
4
+
5
+#include <fstream>
6
+#include "DataAccess/PdnsSlaveConfig.h"
7
+#include "PdnsSlave.h"
8
+
9
+PdnsSlave::PdnsSlave(const std::string &filePath)
10
+    : _filePath(filePath)
11
+{
12
+}
13
+
14
+bool PdnsSlave::readConfig()
15
+{
16
+    PdnsSlaveConfig conf(_filePath);
17
+    if (!conf.readConfig())
18
+        return false;
19
+
20
+    _dhcpdFilePath = conf.getDhcpdFilePath();
21
+    _dhcpdTemplatePath = conf.getDhcpdTemplatePath();
22
+    _hostsPath = conf.getHostsPath();
23
+    _masterConfig = conf.getMasterConfig();
24
+    _slaveConfig = conf.getSlaveConfig();
25
+
26
+    return true;
27
+}
28
+
29
+bool PdnsSlave::readDhcpdTemplate()
30
+{
31
+    std::ifstream dhcpTemplate(_dhcpdTemplatePath);
32
+    if (!dhcpTemplate)
33
+        return false;
34
+    while (!dhcpTemplate.eof())
35
+    {
36
+        std::string line;
37
+        getline(dhcpTemplate, line);
38
+        _dhcpdTemplateContent += line + "\n";
39
+    }
40
+    dhcpTemplate.close();
41
+    return true;
42
+}

+ 37
- 0
src/Business/PdnsSlave.h View File

@@ -0,0 +1,37 @@
1
+//
2
+// Created by robin on 8/8/15.
3
+//
4
+
5
+#ifndef PDNS_SLAVE_PDNSSLAVE_H
6
+#define PDNS_SLAVE_PDNSSLAVE_H
7
+
8
+# include <string>
9
+# include "DBO/SqlConfiguration.h"
10
+
11
+class PdnsSlave
12
+{
13
+public:
14
+    PdnsSlave(const std::string& filePath);
15
+
16
+    bool readConfig();
17
+
18
+    bool readDhcpdTemplate();
19
+
20
+private:
21
+    std::string _filePath;
22
+
23
+    std::string _dhcpdFilePath;
24
+
25
+    std::string _dhcpdTemplatePath;
26
+
27
+    std::string _hostsPath;
28
+
29
+    SqlConfiguration _masterConfig;
30
+
31
+    SqlConfiguration _slaveConfig;
32
+
33
+    std::string _dhcpdTemplateContent;
34
+};
35
+
36
+
37
+#endif //PDNS_SLAVE_PDNSSLAVE_H

Loading…
Cancel
Save