Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions config/vpnc/config/config-hub.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ network_instances:
# List of IPv4 and IPv6 networks natively reachable via this connection.
# IPv4 prefixes are ignored for core and downlink in hub mode.
routes:
ipv6:
ipv6: []
# IP prefixes for provider client subnets initiating administration traffic to tenants.
- to: fd00::/16
# Using BGP is preferred over static routes.
# - to: fd00::/16
# via: fd00:1:2::1 # Optional, ignored for tunnel interfaces
# IPv4 prefixes are ignored for core and downlink in hub mode.
ipv4: []
Expand Down Expand Up @@ -102,9 +103,10 @@ network_instances:
# List of IPv4 and IPv6 networks natively reachable via this connection.
# IPv4 prefixes are ignored for core and downlink in hub mode.
routes:
ipv6:
ipv6: []
# IP prefixes for provider client subnets initiating administration traffic to tenants.
- to: fd00::/16
# Using BGP is preferred over static routes.
# - to: fd00::/16
# via: fd00:1:2::1 # Optional, ignored for tunnel interfaces
# IPv4 prefixes are ignored for core and downlink in hub mode.
ipv4: []
Expand Down Expand Up @@ -144,6 +146,10 @@ bgp:
asn: 4255555555
router_id: 5.5.5.5
bfd: false # bool: defaults to false
# Prefixes to accept from neighbors. Preferred over static routes.
prefix_set:
- prefix: fd00::/16
masklength_range: [16, 128] # exact | [int, int]
neighbors:
- neighbor_asn: 4233333333
neighbor_address: fd00:1:2::1
Expand Down
20 changes: 16 additions & 4 deletions setup/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def _get_version(path: pathlib.Path) -> Version | None:
}

fa.seek(0)
yaml.dump(v12_svc, fa, explicit_start=True, explicit_end=True)
yaml.dump(v12_svc, fc, explicit_start=True, explicit_end=True)
yaml.dump(v12_svc, fa, explicit_start=True, explicit_end=True, sort_keys=False)
yaml.dump(v12_svc, fc, explicit_start=True, explicit_end=True, sort_keys=False)
fa.truncate()
fc.truncate()

Expand Down Expand Up @@ -153,7 +153,19 @@ def _get_version(path: pathlib.Path) -> Version | None:
}

fa.seek(0)
yaml.dump(v12_rem, fa, explicit_start=True, explicit_end=True)
yaml.dump(v12_rem, fc, explicit_start=True, explicit_end=True)
yaml.dump(
v12_rem,
fa,
explicit_start=True,
explicit_end=True,
sort_keys=False,
)
yaml.dump(
v12_rem,
fc,
explicit_start=True,
explicit_end=True,
sort_keys=False,
)
fa.truncate()
fc.truncate()
14 changes: 10 additions & 4 deletions test/01_base_config/hub00/DEFAULT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ network_instances:
# List of IPv4 and IPv6 networks natively reachable via this connection.
# IPv4 prefixes are ignored for core and downlink in hub mode.
routes:
ipv6:
ipv6: []
# IP prefixes for provider client subnets initiating administration traffic to tenants.
- to: fd00::/16
# Using BGP is preferred over static routes.
# - to: fd00::/16
# via: fd00:1:2::1 # Optional, ignored for tunnel interfaces
# IPv4 prefixes are ignored for core and downlink in hub mode.
ipv4: []
Expand Down Expand Up @@ -102,9 +103,10 @@ network_instances:
# List of IPv4 and IPv6 networks natively reachable via this connection.
# IPv4 prefixes are ignored for core and downlink in hub mode.
routes:
ipv6:
ipv6: []
# IP prefixes for provider client subnets initiating administration traffic to tenants.
- to: fd00::/16
# Using BGP is preferred over static routes.
# - to: fd00::/16
# via: fd00:1:2::1 # Optional, ignored for tunnel interfaces
# IPv4 prefixes are ignored for core and downlink in hub mode.
ipv4: []
Expand Down Expand Up @@ -144,6 +146,10 @@ bgp:
asn: 4255555555
router_id: 5.5.5.5
bfd: true
# Prefixes to accept from neighbors. Preferred over static routes.
prefix_set:
- prefix: fd00::/16
masklength_range: [16, 128] # exact | [int, int]
neighbors:
- neighbor_asn: 4233333333
neighbor_address: fd00:1:2::1
Expand Down
14 changes: 10 additions & 4 deletions test/01_base_config/hub01/DEFAULT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ network_instances:
# List of IPv4 and IPv6 networks natively reachable via this connection.
# IPv4 prefixes are ignored for core and downlink in hub mode.
routes:
ipv6:
ipv6: []
# IP prefixes for provider client subnets initiating administration traffic to tenants.
- to: fd00::/16
# Using BGP is preferred over static routes.
# - to: fd00::/16
# via: fd00:1:2::1 # Optional, ignored for tunnel interfaces
# IPv4 prefixes are ignored for core and downlink in hub mode.
ipv4: []
Expand Down Expand Up @@ -102,9 +103,10 @@ network_instances:
# List of IPv4 and IPv6 networks natively reachable via this connection.
# IPv4 prefixes are ignored for core and downlink in hub mode.
routes:
ipv6:
ipv6: []
# IP prefixes for provider client subnets initiating administration traffic to tenants.
- to: fd00::/16
# Using BGP is preferred over static routes.
# - to: fd00::/16
# via: fd00:1:2::1 # Optional, ignored for tunnel interfaces
# IPv4 prefixes are ignored for core and downlink in hub mode.
ipv4: []
Expand Down Expand Up @@ -144,6 +146,10 @@ bgp:
asn: 4266666666
router_id: 6.6.6.6
bfd: false
# Prefixes to accept from neighbors. Preferred over static routes.
prefix_set:
- prefix: fd00::/16
masklength_range: [16, 128] # exact | [int, int]
neighbors:
- neighbor_asn: 4233333333
neighbor_address: fd00:1:2::3
Expand Down
6 changes: 4 additions & 2 deletions vpnc/src/vpnc/ctl/bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def show(
bgp = service.bgp

output = bgp.model_dump(mode="json")
print(yaml.safe_dump(output, explicit_start=True, explicit_end=True))
print(
yaml.safe_dump(output, explicit_start=True, explicit_end=True, sort_keys=False),
)


@app.command()
Expand Down Expand Up @@ -125,7 +127,7 @@ def summary(
# output = yaml.safe_dump(
# service.model_dump(mode="json"),
# explicit_start=True,
# explicit_end=True,
# explicit_end=True, sort_keys=False,
# )
# with path.open("w+", encoding="utf-8") as f:
# f.write(output)
Expand Down
1 change: 1 addition & 0 deletions vpnc/src/vpnc/ctl/tenant_ni_con.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def show(
connection.model_dump(mode="json"),
explicit_start=True,
explicit_end=True,
sort_keys=False,
),
)

Expand Down
36 changes: 30 additions & 6 deletions vpnc/src/vpnc/ctl/tenants.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,24 @@ def show(

output = tenant.model_dump(mode="json")
if full:
print(yaml.safe_dump(output, explicit_start=True, explicit_end=True))
print(
yaml.safe_dump(
output,
explicit_start=True,
explicit_end=True,
sort_keys=False,
),
)
else:
output["network_instance_count"] = len(output.pop("network_instances"))
print(yaml.safe_dump(output, explicit_start=True, explicit_end=True))
print(
yaml.safe_dump(
output,
explicit_start=True,
explicit_end=True,
sort_keys=False,
),
)


@app.command()
Expand Down Expand Up @@ -144,6 +158,7 @@ def edit(ctx: typer.Context) -> None:
tenant.model_dump(mode="json"),
explicit_start=True,
explicit_end=True,
sort_keys=False,
),
)
tf.flush()
Expand Down Expand Up @@ -187,6 +202,7 @@ def edit(ctx: typer.Context) -> None:
edited_config.model_dump(mode="json"),
explicit_start=True,
explicit_end=True,
sort_keys=False,
)
with path.joinpath(f"{tenant_id}.yaml").open(mode="w", encoding="utf-8") as f:
f.write(output)
Expand Down Expand Up @@ -228,6 +244,7 @@ def add(
tenant.model_dump(mode="json"),
explicit_start=True,
explicit_end=True,
sort_keys=False,
)
with path.open("w+", encoding="utf-8") as f:
f.write(output)
Expand Down Expand Up @@ -264,7 +281,7 @@ def add(
# updated_remote.metadata.update(all_metadata)

# output = yaml.safe_dump(
# updated_remote.model_dump(mode="json"), explicit_start=True, explicit_end=True
# updated_remote.model_dump(mode="json"), explicit_start=True, explicit_end=True, sort_keys=False,
# )
# with open(path, "w+", encoding="utf-8") as f:
# f.write(output)
Expand Down Expand Up @@ -311,7 +328,7 @@ def add(
# updated_remote = vpnc.models.tenant.Tenant(**remote_dict)

# output = yaml.safe_dump(
# updated_remote.model_dump(mode="json"), explicit_start=True, explicit_end=True
# updated_remote.model_dump(mode="json"), explicit_start=True, explicit_end=True, sort_keys=False,
# )
# with open(path, "w+", encoding="utf-8") as f:
# f.write(output)
Expand Down Expand Up @@ -347,6 +364,7 @@ def delete(
tenant.model_dump(mode="json"),
explicit_start=True,
explicit_end=True,
sort_keys=False,
)
print(output)
if dry_run:
Expand Down Expand Up @@ -378,7 +396,9 @@ def commit(
path_active_tenant = path_active.joinpath(f"{tenant_id}.yaml")
if not path_candidate_tenant.exists():
tenant_config_candidate = vpnc.models.tenant.Tenant(
id=tenant_id, name="", version="0.1.0"
id=tenant_id,
name="",
version="0.1.0",
)
else:
tenant_config_candidate = helpers.get_tenant_config(
Expand All @@ -389,7 +409,9 @@ def commit(

if not path_active_tenant.exists():
tenant_config_active = vpnc.models.tenant.Tenant(
id=tenant_id, name="", version="0.1.0"
id=tenant_id,
name="",
version="0.1.0",
)
else:
tenant_config_active = helpers.get_tenant_config(ctx, tenant_id, path_active)
Expand Down Expand Up @@ -421,6 +443,7 @@ def commit(
tenant_config_active.model_dump(mode="json"),
explicit_start=True,
explicit_end=True,
sort_keys=False,
),
)
print("Revert succeeded.")
Expand Down Expand Up @@ -449,6 +472,7 @@ def commit(
tenant_config_candidate.model_dump(mode="json"),
explicit_start=True,
explicit_end=True,
sort_keys=False,
),
)
print("Commit succeeded.")
Expand Down
12 changes: 7 additions & 5 deletions vpnc/src/vpnc/ctl/tenants_ni.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def show(
if not network_instance:
return
output = {instance_id: network_instance.model_dump(mode="json")}
print(yaml.safe_dump(output, explicit_start=True, explicit_end=True))
print(
yaml.safe_dump(output, explicit_start=True, explicit_end=True, sort_keys=False),
)


@app.command()
Expand Down Expand Up @@ -206,7 +208,7 @@ class IkeVersion(str, Enum):
# remote.connections[tunnel_id] = tunnel

# output = yaml.safe_dump(
# remote.model_dump(mode="json"), explicit_start=True, explicit_end=True
# remote.model_dump(mode="json"), explicit_start=True, explicit_end=True, sort_keys=False,
# )
# with open(path, "w+", encoding="utf-8") as f:
# f.write(output)
Expand Down Expand Up @@ -284,7 +286,7 @@ class IkeVersion(str, Enum):
# remote.connections[tunnel_id] = updated_tunnel

# output = yaml.safe_dump(
# remote.model_dump(mode="json"), explicit_start=True, explicit_end=True
# remote.model_dump(mode="json"), explicit_start=True, explicit_end=True, sort_keys=False,
# )
# with open(path, "w+", encoding="utf-8") as f:
# f.write(output)
Expand Down Expand Up @@ -367,7 +369,7 @@ class IkeVersion(str, Enum):
# remote.connections[tunnel_id] = updated_tunnel

# output = yaml.safe_dump(
# remote.model_dump(mode="json"), explicit_start=True, explicit_end=True
# remote.model_dump(mode="json"), explicit_start=True, explicit_end=True, sort_keys=False,
# )
# with open(path, "w+", encoding="utf-8") as f:
# f.write(output)
Expand Down Expand Up @@ -403,7 +405,7 @@ class IkeVersion(str, Enum):
# remote.connections.pop(tunnel_id)

# output = yaml.safe_dump(
# remote.model_dump(mode="json"), explicit_start=True, explicit_end=True
# remote.model_dump(mode="json"), explicit_start=True, explicit_end=True, sort_keys=False,
# )
# print(yaml.safe_dump({tunnel_id: tunnel.model_dump(mode="json")}))
# if dry_run:
Expand Down
Loading