Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix test example
  • Loading branch information
chadell committed Jun 9, 2022
commit ef13113896fc756c8de0908d5b751de9afb073f5
8 changes: 5 additions & 3 deletions examples/06-ip-prefixes/adapter_ipam_a.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""IPAM A adapter."""
import os
import ipaddress
from pathlib import Path
import yaml
from models import Prefix # pylint: disable=no-name-in-module
from diffsync import DiffSync

dirname = os.path.dirname(os.path.realpath(__file__))


class IpamAPrefix(Prefix):
"""Implementation of Prefix create/update/delete methods for IPAM A."""
Expand Down Expand Up @@ -71,13 +73,13 @@ class IpamA(DiffSync):
@staticmethod
def load_yaml_data():
"""Read data from a YAML file."""
with open(Path.joinpath(Path().resolve(), "data", "ipam_a.yml"), encoding="utf-8") as data_file:
with open(os.path.join(dirname, "data", "ipam_a.yml"), encoding="utf-8") as data_file:
return yaml.safe_load(data_file)

@staticmethod
def write_yaml_data(data):
"""Write data to a YAML file."""
with open(Path.joinpath(Path().resolve(), "data", "ipam_a.yml"), encoding="utf-8", mode="w") as data_file:
with open(os.path.join(dirname, "data", "ipam_a.yml"), encoding="utf-8", mode="w") as data_file:
return yaml.safe_dump(data, data_file)

def load(self):
Expand Down
8 changes: 5 additions & 3 deletions examples/06-ip-prefixes/adapter_ipam_b.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""IPAM B adapter."""
from pathlib import Path
import os
import yaml
from models import Prefix # pylint: disable=no-name-in-module
from diffsync import DiffSync

dirname = os.path.dirname(os.path.realpath(__file__))


class IpamBPrefix(Prefix):
"""Implementation of Prefix create/update/delete methods for IPAM B."""
Expand Down Expand Up @@ -76,13 +78,13 @@ class IpamB(DiffSync):
@staticmethod
def load_yaml_data():
"""Read data from a YAML file."""
with open(Path.joinpath(Path().resolve(), "data", "ipam_b.yml"), encoding="utf-8") as data_file:
with open(os.path.join(dirname, "data", "ipam_b.yml"), encoding="utf-8") as data_file:
return yaml.safe_load(data_file)

@staticmethod
def write_yaml_data(data):
"""Write data to a YAML file."""
with open(Path.joinpath(Path().resolve(), "data", "ipam_b.yml"), encoding="utf-8", mode="w") as data_file:
with open(os.path.join(dirname, "data", "ipam_b.yml"), encoding="utf-8", mode="w") as data_file:
return yaml.safe_dump(data, data_file)

def load(self):
Expand Down
1 change: 1 addition & 0 deletions examples/06-ip-prefixes/main.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
"""Main example."""
from adapter_ipam_a import IpamA
from adapter_ipam_b import IpamB
Expand Down