c6accb78184080be11a5d6e24564189ec4cd9ce1
[pyi2ncommon] / src / cnfline / build_intraclient.py
1 # The software in this package is distributed under the GNU General
2 # Public License version 2 (with a special exception described below).
3 #
4 # A copy of GNU General Public License (GPL) is included in this distribution,
5 # in the file COPYING.GPL.
6 #
7 # As a special exception, if other files instantiate templates or use macros
8 # or inline functions from this file, or you compile this file and link it
9 # with other works to produce a work based on this file, this file
10 # does not by itself cause the resulting work to be covered
11 # by the GNU General Public License.
12 #
13 # However the source code for this file must still be made available
14 # in accordance with section (3) of the GNU General Public License.
15 #
16 # This exception does not invalidate any other reasons why a work based
17 # on this file might be covered by the GNU General Public License.
18 #
19 # Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
20
21 """
22 Create intraclients.
23 """
24
25 from . import build_cnfvar
26
27 default_intraclient_name = "sample client"
28 default_intraclient_instance = 1
29 default_cnfvars = {
30     "INTRACLIENT_COMMENT": default_intraclient_name + " comment",
31     "INTRACLIENT_DNS_RELAYING_ALLOWED": "1",
32     "INTRACLIENT_EMAIL_RELAYING_ALLOWED": "1",
33     "INTRACLIENT_FIREWALL_RULESET_REF": "5",
34     "INTRACLIENT_IP": None,
35     "INTRACLIENT_MAC": None,
36     "INTRACLIENT_PROXY_PROFILE_REF": "-1",
37 }
38
39
40 class BuildIntraclient(build_cnfvar.BuildCnfVar):
41
42     def __init__(self,
43                  data=default_intraclient_name,
44                  instance=default_intraclient_instance,
45                  line_no=1,
46                  ip="192.168.0.42",
47                  mac=None,
48                  alias=None):
49         build_cnfvar.BuildCnfVar.__init__(self,
50                                           "INTRACLIENT",
51                                           instance,
52                                           data, line_no)
53         self.add_defaults(default_cnfvars)
54
55         self.update_cnf("INTRACLIENT_IP", 0, ip)
56         self.update_cnf("INTRACLIENT_MAC", 0, mac or "")
57
58         if alias is not None:
59             self.update_cnf("INTRACLIENT_ALIAS", 0, alias)