fix rte_crypto_ipsec_mb dependency
[samplevnf.git] / VNFs / DPPD-PROX / helper-scripts / dpi / systemconfig.py
1 #!/bin/env python
2
3 ##
4 ## Copyright (c) 2010-2017 Intel Corporation
5 ##
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
9 ##
10 ##     http://www.apache.org/licenses/LICENSE-2.0
11 ##
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
17 ##
18
19 class SystemConfig:
20     _user = None
21     _ip = None
22     _proxDir = None
23     _cfgFile = None
24     def __init__(self, user, ip, proxDir, configDir):
25         self._user = user;
26         self._ip = ip;
27         self._proxDir = proxDir;
28         self._cfgFile = configDir;
29     def __init__(self, text):
30         self._user = text.split("@")[0];
31         text = text.split("@")[1];
32         self._ip = text.split(":")[0];
33         self._proxDir = text.split(":")[1];
34         self._cfgFile = text.split(":")[2];
35
36     def getUser(self):
37         return self._user;
38
39     def getIP(self):
40         return self._ip;
41
42     def getProxDir(self):
43         return self._proxDir;
44
45     def getCfgFile(self):
46         return self._cfgFile;
47
48     @staticmethod
49     def checkSyntax(text):
50         split = text.split("@");
51         if (len(split) != 2):
52             return SystemConfig.getSyntaxError(text);
53         after = split[1].split(":");
54         if (len(after) != 3):
55             return SystemConfig.getSyntaxError(text);
56         return ""
57     def toString(self):
58         ret = "";
59         ret += "  " + self._user + "@" + self._ip + "\n"
60         ret += "    " + "prox dir: " + self._proxDir + "\n"
61         ret += "    " + "cfg dir: " + self._cfgFile + "\n"
62         return ret;
63
64     @staticmethod
65     def getSyntaxError(text):
66         ret = "Invaild system syntax"
67         ret += ", got: " + str(text)
68         ret += ", expected: " + str(SystemConfig.expectedSyntax())
69         return ret;
70
71     @staticmethod
72     def expectedSyntax():
73         return "user@ip:proxDir:cfgFile"