Skip to content
Merged
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
36 changes: 36 additions & 0 deletions examples/peeringdb_to_infrahub/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: from-peeringdb
source:
name: genericrestapi
settings:
url: "https://www.peeringdb.com"
api_endpoint: "api"
auth_method: "none" # PeeringDB allows public access (beware rate limits)
response_key_pattern: "data" # PeeringDB wraps lists under "data"


destination:
name: infrahub
settings:
url: "http://localhost:8000"

# Optional: Skip objects in the source that don't exist in the destination (prevents creation)
dyffsync_flags: ["SKIP_UNMATCHED_SRC"]

order: ["InfraAutonomousSystem"]

schema_mapping:
- name: InfraAutonomousSystem
mapping: net # PeeringDB resource
identifiers: ["asn"] # needed to match/merge objects
fields:
- name: asn # minimal id field
mapping: asn
- name: name
mapping: name
- name: irr_as_set
mapping: irr_as_set
- name: ipv4_max_prefixes
mapping: info_prefixes4
- name: ipv6_max_prefixes
mapping: info_prefixes6
Empty file.
28 changes: 28 additions & 0 deletions examples/peeringdb_to_infrahub/genenericrestapi/sync_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from infrahub_sync.adapters.genenericrestapi import GenenericrestapiAdapter

from .sync_models import (
InfraAutonomousSystem,
InfraBGPCommunity,
InfraBGPPeerGroup,
InfraBGPRoutingPolicy,
InfraIXP,
InfraIXPConnection,
IpamIPAddress,
OrganizationProvider,
)


# -------------------------------------------------------
# AUTO-GENERATED FILE, DO NOT MODIFY
# This file has been generated with the command `infrahub-sync generate`
# All modifications will be lost the next time you reexecute this command
# -------------------------------------------------------
class GenenericrestapiSync(GenenericrestapiAdapter):
InfraAutonomousSystem = InfraAutonomousSystem
InfraBGPPeerGroup = InfraBGPPeerGroup
IpamIPAddress = IpamIPAddress
OrganizationProvider = OrganizationProvider
InfraBGPCommunity = InfraBGPCommunity
InfraBGPRoutingPolicy = InfraBGPRoutingPolicy
InfraIXP = InfraIXP
InfraIXPConnection = InfraIXPConnection
141 changes: 141 additions & 0 deletions examples/peeringdb_to_infrahub/genenericrestapi/sync_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
from __future__ import annotations

from typing import Any

from infrahub_sync.adapters.genenericrestapi import GenenericrestapiModel


# -------------------------------------------------------
# AUTO-GENERATED FILE, DO NOT MODIFY
# This file has been generated with the command `infrahub-sync generate`
# All modifications will be lost the next time you reexecute this command
# -------------------------------------------------------
class InfraAutonomousSystem(GenenericrestapiModel):
_modelname = "InfraAutonomousSystem"
_identifiers = ("asn",)
_attributes = (
"organization",
"affiliated",
"irr_as_set",
"name",
"ipv4_max_prefixes",
"description",
"ipv6_max_prefixes",
)
asn: int
affiliated: bool | None = None
irr_as_set: str | None = None
name: str
ipv4_max_prefixes: int | None = None
description: str | None = None
ipv6_max_prefixes: int | None = None
organization: str | None = None

local_id: str | None = None
local_data: Any | None = None


class InfraBGPPeerGroup(GenenericrestapiModel):
_modelname = "InfraBGPPeerGroup"
_identifiers = ("name",)
_attributes = ("bgp_communities", "import_policies", "export_policies", "description", "status")
name: str
description: str | None = None
status: str | None = None
bgp_communities: list[str] | None = []
import_policies: list[str] | None = []
export_policies: list[str] | None = []

local_id: str | None = None
local_data: Any | None = None


class IpamIPAddress(GenenericrestapiModel):
_modelname = "IpamIPAddress"
_identifiers = ("address",)
_attributes = ("description",)
description: str | None = None
address: str

local_id: str | None = None
local_data: Any | None = None


class OrganizationProvider(GenenericrestapiModel):
_modelname = "OrganizationProvider"
_identifiers = ("name",)
_attributes = ()
name: str

local_id: str | None = None
local_data: Any | None = None


class InfraBGPCommunity(GenenericrestapiModel):
_modelname = "InfraBGPCommunity"
_identifiers = ("name",)
_attributes = ("description", "label", "community_type", "value")
name: str
description: str | None = None
label: str | None = None
community_type: str | None = None
value: str

local_id: str | None = None
local_data: Any | None = None


class InfraBGPRoutingPolicy(GenenericrestapiModel):
_modelname = "InfraBGPRoutingPolicy"
_identifiers = ("name",)
_attributes = ("bgp_communities", "address_family", "policy_type", "label", "weight", "description")
address_family: int
policy_type: str
label: str | None = None
weight: int | None = 1000
name: str
description: str | None = None
bgp_communities: list[str] | None = []

local_id: str | None = None
local_data: Any | None = None


class InfraIXP(GenenericrestapiModel):
_modelname = "InfraIXP"
_identifiers = ("name",)
_attributes = ("export_policies", "bgp_communities", "import_policies", "status", "description")
status: str | None = "enabled"
name: str
description: str | None = None
export_policies: list[str] | None = []
bgp_communities: list[str] | None = []
import_policies: list[str] | None = []

local_id: str | None = None
local_data: Any | None = None


class InfraIXPConnection(GenenericrestapiModel):
_modelname = "InfraIXPConnection"
_identifiers = ("name",)
_attributes = (
"internet_exchange_point",
"ipv4_address",
"ipv6_address",
"status",
"peeringdb_netixlan",
"vlan",
"description",
)
name: str
status: str | None = "enabled"
peeringdb_netixlan: int | None = None
vlan: int | None = None
description: str | None = None
internet_exchange_point: str
ipv4_address: str | None = None
ipv6_address: str | None = None

local_id: str | None = None
local_data: Any | None = None
Empty file.
28 changes: 28 additions & 0 deletions examples/peeringdb_to_infrahub/generic_rest_api/sync_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from infrahub_sync.adapters.generic_rest_api import Generic_Rest_ApiAdapter

from .sync_models import (
InfraAutonomousSystem,
InfraBGPCommunity,
InfraBGPPeerGroup,
InfraBGPRoutingPolicy,
InfraIXP,
InfraIXPConnection,
IpamIPAddress,
OrganizationProvider,
)


# -------------------------------------------------------
# AUTO-GENERATED FILE, DO NOT MODIFY
# This file has been generated with the command `infrahub-sync generate`
# All modifications will be lost the next time you reexecute this command
# -------------------------------------------------------
class Generic_Rest_ApiSync(Generic_Rest_ApiAdapter):
InfraAutonomousSystem = InfraAutonomousSystem
InfraBGPPeerGroup = InfraBGPPeerGroup
IpamIPAddress = IpamIPAddress
OrganizationProvider = OrganizationProvider
InfraBGPRoutingPolicy = InfraBGPRoutingPolicy
InfraBGPCommunity = InfraBGPCommunity
InfraIXP = InfraIXP
InfraIXPConnection = InfraIXPConnection
141 changes: 141 additions & 0 deletions examples/peeringdb_to_infrahub/generic_rest_api/sync_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
from __future__ import annotations

from typing import Any

from infrahub_sync.adapters.generic_rest_api import Generic_Rest_ApiModel


# -------------------------------------------------------
# AUTO-GENERATED FILE, DO NOT MODIFY
# This file has been generated with the command `infrahub-sync generate`
# All modifications will be lost the next time you reexecute this command
# -------------------------------------------------------
class InfraAutonomousSystem(Generic_Rest_ApiModel):
_modelname = "InfraAutonomousSystem"
_identifiers = ("asn",)
_attributes = (
"organization",
"affiliated",
"irr_as_set",
"name",
"ipv4_max_prefixes",
"description",
"ipv6_max_prefixes",
)
asn: int
affiliated: bool | None = None
irr_as_set: str | None = None
name: str
ipv4_max_prefixes: int | None = None
description: str | None = None
ipv6_max_prefixes: int | None = None
organization: str | None = None

local_id: str | None = None
local_data: Any | None = None


class InfraBGPPeerGroup(Generic_Rest_ApiModel):
_modelname = "InfraBGPPeerGroup"
_identifiers = ("name",)
_attributes = ("import_policies", "export_policies", "bgp_communities", "description", "status")
name: str
description: str | None = None
status: str | None = None
import_policies: list[str] | None = []
export_policies: list[str] | None = []
bgp_communities: list[str] | None = []

local_id: str | None = None
local_data: Any | None = None


class IpamIPAddress(Generic_Rest_ApiModel):
_modelname = "IpamIPAddress"
_identifiers = ("address",)
_attributes = ("description",)
description: str | None = None
address: str

local_id: str | None = None
local_data: Any | None = None


class OrganizationProvider(Generic_Rest_ApiModel):
_modelname = "OrganizationProvider"
_identifiers = ("name",)
_attributes = ()
name: str

local_id: str | None = None
local_data: Any | None = None


class InfraBGPRoutingPolicy(Generic_Rest_ApiModel):
_modelname = "InfraBGPRoutingPolicy"
_identifiers = ("name",)
_attributes = ("bgp_communities", "label", "description", "policy_type", "weight", "address_family")
name: str
label: str | None = None
description: str | None = None
policy_type: str
weight: int | None = 1000
address_family: int
bgp_communities: list[str] | None = []

local_id: str | None = None
local_data: Any | None = None


class InfraBGPCommunity(Generic_Rest_ApiModel):
_modelname = "InfraBGPCommunity"
_identifiers = ("name",)
_attributes = ("description", "label", "community_type", "value")
name: str
description: str | None = None
label: str | None = None
community_type: str | None = None
value: str

local_id: str | None = None
local_data: Any | None = None


class InfraIXP(Generic_Rest_ApiModel):
_modelname = "InfraIXP"
_identifiers = ("name",)
_attributes = ("export_policies", "bgp_communities", "import_policies", "description", "status")
name: str
description: str | None = None
status: str | None = "enabled"
export_policies: list[str] | None = []
bgp_communities: list[str] | None = []
import_policies: list[str] | None = []

local_id: str | None = None
local_data: Any | None = None


class InfraIXPConnection(Generic_Rest_ApiModel):
_modelname = "InfraIXPConnection"
_identifiers = ("name",)
_attributes = (
"internet_exchange_point",
"ipv4_address",
"ipv6_address",
"status",
"peeringdb_netixlan",
"vlan",
"description",
)
name: str
status: str | None = "enabled"
peeringdb_netixlan: int | None = None
vlan: int | None = None
description: str | None = None
internet_exchange_point: str
ipv4_address: str | None = None
ipv6_address: str | None = None

local_id: str | None = None
local_data: Any | None = None
Empty file.
14 changes: 14 additions & 0 deletions examples/peeringdb_to_infrahub/genericrestapi/sync_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from infrahub_sync.adapters.genericrestapi import GenericrestapiAdapter

from .sync_models import (
InfraAutonomousSystem,
)


# -------------------------------------------------------
# AUTO-GENERATED FILE, DO NOT MODIFY
# This file has been generated with the command `infrahub-sync generate`
# All modifications will be lost the next time you reexecute this command
# -------------------------------------------------------
class GenericrestapiSync(GenericrestapiAdapter):
InfraAutonomousSystem = InfraAutonomousSystem
Loading