|
@@ -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
|
+}
|