Skip to content

Commit fe20fed

Browse files
authored
Merge pull request #10 from NetNeutralNetworks/feat-tenants-adds-default-vpn-config
Add template generation when using tenant add command
2 parents 7b7aab2 + 05b89e3 commit fe20fed

3 files changed

Lines changed: 80 additions & 25 deletions

File tree

setup/profile-nc-vpn.sh

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,53 +25,61 @@ vpnctl --install-completion > /dev/null
2525

2626
printf "\n"
2727
print_service_state "ncubed-vpnc"
28-
2928
DEFAULT="\e[0m"
3029
BOLD="\e[1m"
31-
printf "\e[1m
30+
31+
printf "$BOLD
3232
_ _
3333
| | | |
3434
____ ____ _ _| |__ _____ __| |
3535
| _ \ / ___) | | | _ \| ___ |/ _ |
3636
| | | ( (___| |_| | |_) ) ____( (_| |
3737
|_| |_|\____)____/|____/|_____)\____|
38-
\e[0m
38+
$DEFAULT
3939
4040
VPNC configuration is stored in /opt/ncubed/config/vpnc
4141
This directory contains the active and candidate configuration directories.
4242
4343
Manage the configuration by using the 'vpnctl' command. This binary has autocompletion.
4444
4545
$BOLD> vpnctl tenants$DEFAULT
46-
List the configured tenants
46+
shows a list of all configured tenants VPNs
4747
48-
$BOLD> vpnctl tenants C0001 [network-instances C0001-00 [connections 0]] show [--active] [--full]$DEFAULT
49-
Show a tenant configuration
50-
Full shows the connection configurations when run against the tenant and not a specific network instance.
48+
$BOLD> vpnctl tenants <TENANTID> show (--active) (--full)$DEFAULT
49+
shows the <TENANTID> (active) tenant VPN configuration without the VPN tunnel configuration
50+
full shows the tunnel configurations as well
5151
52-
$BOLD> vpnctl tenants C0001 [network-instances C0001-00 [connections 0]] summary$DEFAULT
53-
Show connection status summary
52+
$BOLD> vpnctl tenants <TENANTID> add --name <Customer name>
53+
add a new tenant
5454
55-
$BOLD> vpnctl tenants C0001 nat$DEFAULT
56-
Show used NAT translations
55+
$BOLD> vpnctl tenants <TENANTID> delete/set/unset$DEFAULT
56+
delete a tenant
57+
set a tenant property
58+
remove a tenant property
5759
58-
$BOLD> vpnctl tenants C0001 (add|delete)$DEFAULT
59-
Add or delete a tenant
60+
$BOLD> vpnctl tenants <TENANTID> edit$DEFAULT
61+
opens the default editor for editing the tenants configuration. These edits are validated. Invalid
62+
configurations cannot be applied and will be rolled back.
6063
61-
$BOLD> vpnctl tenants C0001 edit$DEFAULT
62-
Open the default editor to edit the tenant configuration.
63-
The edited configuration is validated.
64-
Invalid configurations cannot be applied and will be rolled back.
64+
$BOLD> vpnctl tenants <TENANTID> connection$DEFAULT
65+
shows a list of all configured tunnels for a tenants
6566
66-
$BOLD> vpnctl tenants C0001 commit [--dry-run] [--diff] [--revert]$DEFAULT
67-
Copy the candidate configuration to the active configuration
68-
Reverting the candidate configuration, dry-runs and diffs are possible
67+
$BOLD> vpnctl tenants <TENANTID> connection 0 show$DEFAULT
68+
shows the <TENANTID> tenant tunnel 0 VPN configuration
6969
70-
$BOLD> vpnctl bgp show$DEFAULT
71-
Show the BGP configuration
70+
$BOLD> vpnctl tenants <TENANTID> connection 0 add/delete/set/unset$DEFAULT
71+
add a new connection
72+
delete a connection
73+
set a connection property
74+
remove a connection property
7275
73-
$BOLD> vpnctl bgp summary$DEFAULT
74-
Show the BGP status summary
76+
$BOLD> vpnctl tenants <TENANTID> commit$DEFAULT
77+
copy the candidate configuration to the active configuration
78+
reverting the candidate configuration, dry-runs and diffs are possible
7579
80+
$BOLD> vpnctl bgp show$DEFAULT
81+
shows the bgp configuration
7682
83+
$BOLD> vpnctl bgp summary$DEFAULT
84+
shows the active bgp state summary
7785
"

vpnc/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies = [
3232
"pyroute2~=0.7",
3333
"PyYAML~=6.0",
3434
"tabulate~=0.9",
35-
"typer~=0.12.4",
35+
"typer~=0.24.1",
3636
"vici~=5.9",
3737
"watchdog~=4.0",
3838
"packaging",

vpnc/src/vpnc/ctl/tenants.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,53 @@ def add(
215215
if tenant_id == config.DEFAULT_TENANT:
216216
print(f"Tenant '{tenant_id}' already exists.")
217217
return
218+
219+
all_args["network_instances"] = {
220+
f"{tenant_id}-00": {
221+
"connections": {
222+
"0": {
223+
"config": {
224+
"ike_lifetime": 86400,
225+
"ike_proposal": "aes256-sha384-ecp384",
226+
"ike_version": "2",
227+
"initiation": "start",
228+
"ipsec_lifetime": 3600,
229+
"ipsec_proposal": "aes256gcm-prfsha384-ecp384",
230+
"local_id": None,
231+
"psk": "PSK-STRING",
232+
"remote_addrs": [
233+
"127.0.0.1",
234+
],
235+
"remote_id": None,
236+
"traffic_selectors": {
237+
"local": [],
238+
"remote": [],
239+
},
240+
"type": "ipsec",
241+
},
242+
"id": 0,
243+
"interface": {
244+
"ipv4": [],
245+
"ipv6": [],
246+
},
247+
"metadata": {},
248+
"routes": {
249+
"ipv4": [
250+
{
251+
"to": "0.0.0.0/0",
252+
"via": None,
253+
},
254+
],
255+
"ipv6": [],
256+
},
257+
},
258+
},
259+
"id": f"{tenant_id}-00",
260+
"metadata": {},
261+
"type": "downlink",
262+
},
263+
}
264+
218265
path = helpers.get_config_path(ctx, active=False)
219266
tenant_path = path.joinpath(f"{tenant_id}.yaml")
220267
if tenant_path.exists():

0 commit comments

Comments
 (0)