Commit | Line | Data |
---|---|---|
11cbb815 PD |
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 | ||
f49f6323 PD |
21 | """ |
22 | Create provider profiles. | |
b7e04a3e CH |
23 | |
24 | .. note:: DEPRECATED! Please do not extend this or add new uses of this module, | |
25 | use :py:mod:`pyi2ncommon.arnied_api` or :py:mod:`pyi2ncommon.cnfvar` | |
26 | instead! | |
f49f6323 PD |
27 | """ |
28 | ||
29 | from . import build_cnfvar | |
30 | ||
31 | # Defaults are extracted from data/shared_arnied/provider.cnf. | |
bcd9beb1 | 32 | default_provider_name = "sample_provider" |
f49f6323 PD |
33 | default_provider_instance = 1 |
34 | default_cnfvars = { | |
35 | "PROVIDER_PROXY_SERVER": "", | |
36 | "PROVIDER_PROXY_PORT": "", | |
37 | "PROVIDER_PROXY_PASSWORD": "", | |
38 | "PROVIDER_PROXY_LOGIN": "", | |
39 | "PROVIDER_NIC_REF": "1", | |
40 | "PROVIDER_NETMASK": "255.255.0.0", | |
41 | "PROVIDER_MTU_SIZE": "1500", | |
42 | "PROVIDER_MODE": "ROUTER", | |
43 | "PROVIDER_MAILTRANSFER_MODE": "IMMEDIATE", | |
44 | "PROVIDER_LOCALIP": "", | |
45 | "PROVIDER_IP": "", | |
46 | "PROVIDER_FIREWALL_RULESET_REF": "7", | |
47 | "PROVIDER_FALLBACK_TIMEOUT": "60", | |
48 | "PROVIDER_FALLBACK_PROVIDER_REF": "-1", | |
49 | "PROVIDER_EMAIL_RELAY_REF": "-1", | |
50 | "PROVIDER_DYNDNS_WEBCHECKIP": "0", | |
51 | "PROVIDER_DYNDNS_ENABLE": "1", | |
52 | "PROVIDER_DNS_MODE": "IP", | |
53 | "PROVIDER_DNS": "", | |
54 | "PROVIDER_BWIDTH_MANAGEMENT_UPSTREAM_SPEED": "", | |
55 | "PROVIDER_BWIDTH_MANAGEMENT_ENABLE": "0", | |
56 | "PROVIDER_BWIDTH_MANAGEMENT_DOWNSTREAM_SPEED": "", | |
57 | "PROVIDER_PINGCHECK_SERVERLIST_REF": "-2", | |
58 | } | |
59 | ||
60 | ||
61 | class BuildProvider(build_cnfvar.BuildCnfVar): | |
62 | ||
63 | def __init__(self, | |
64 | data=default_provider_name, | |
65 | instance=default_provider_instance, | |
66 | line_no=1, | |
67 | mode="ROUTER", | |
68 | dns=None, | |
69 | ip=None, | |
70 | localip=None): | |
71 | build_cnfvar.BuildCnfVar.__init__(self, | |
72 | "PROVIDER", | |
73 | instance, | |
74 | data, | |
75 | line_no) | |
76 | self.add_defaults(default_cnfvars) | |
77 | self.update_cnf("PROVIDER_MODE", 0, mode) | |
78 | ||
79 | if dns is not None: | |
80 | self.update_cnf("PROVIDER_DNS", 0, dns) | |
81 | if ip is not None: | |
82 | self.update_cnf("PROVIDER_IP", 0, ip) | |
83 | if localip is not None: | |
84 | self.update_cnf("PROVIDER_LOCALIP", 0, localip) |