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
46 changes: 46 additions & 0 deletions examples/phpipam_to_infrahub/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: from-phpipam

source:
name: phpipam
settings:
url: "http://localhost:8080"
app_id: "infrahub"
username: "infrahub"
password: "infrahub"
verify_ssl: false

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

order: [
# "InfraVLAN",
"IpamIPPrefix",
"IpamIPAddress",
]

schema_mapping:
- name: IpamIPPrefix
mapping: subnets
identifiers: ["prefix"]
fields:
- name: prefix
mapping: subnet
- name: is_pool
mapping: isPool
# - name: vlan
# mapping: vlanId
# reference: InfraVLAN

- name: IpamIPAddress
mapping: addresses
identifiers: ["address"]
fields:
- name: address
mapping: ip
- name: description
mapping: description
# - name: XXXX
# mapping: hostname
Empty file.
16 changes: 16 additions & 0 deletions examples/phpipam_to_infrahub/infrahub/sync_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from infrahub_sync.adapters.infrahub import InfrahubAdapter

from .sync_models import (
IpamIPAddress,
IpamIPPrefix,
)


# -------------------------------------------------------
# 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 InfrahubSync(InfrahubAdapter):
IpamIPPrefix = IpamIPPrefix
IpamIPAddress = IpamIPAddress
30 changes: 30 additions & 0 deletions examples/phpipam_to_infrahub/infrahub/sync_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from __future__ import annotations

from typing import Any, List

from infrahub_sync.adapters.infrahub import InfrahubModel

# -------------------------------------------------------
# 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 IpamIPPrefix(InfrahubModel):
_modelname = "IpamIPPrefix"
_identifiers = ("prefix",)
_attributes = ("is_pool",)
is_pool: bool | None = False
prefix: str

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

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

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

from .sync_models import (
IpamIPAddress,
IpamIPPrefix,
)


# -------------------------------------------------------
# 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 PhpipamSync(PhpipamAdapter):
IpamIPPrefix = IpamIPPrefix
IpamIPAddress = IpamIPAddress
30 changes: 30 additions & 0 deletions examples/phpipam_to_infrahub/phpipam/sync_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from __future__ import annotations

from typing import Any, List

from infrahub_sync.adapters.phpipam import PhpipamModel

# -------------------------------------------------------
# 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 IpamIPPrefix(PhpipamModel):
_modelname = "IpamIPPrefix"
_identifiers = ("prefix",)
_attributes = ("is_pool",)
is_pool: bool | None = False
prefix: str

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

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

local_id: str | None = None
local_data: Any | None = None
11 changes: 11 additions & 0 deletions infrahub_sync/adapters/peeringmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ def obj_to_diffsync(
mapping: SchemaMappingModel,
model: PeeringmanagerModel,
) -> dict:
"""
Transform PeeringManager data to DiffSync format.

Parameters:
obj: The PeeringManager object data
model: The DiffSync model class
element: The schema mapping element

Returns:
dict: The transformed data
"""
obj_id = derive_identifier_key(obj=obj)
data: dict[str, Any] = {"local_id": str(obj_id)}

Expand Down
Loading
Loading