-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 0.1.6
- Loading branch information
Showing
19 changed files
with
114 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
from Kathara.exceptions import LinkNotFoundError | ||
from Kathara.model import Link | ||
from Kathara.model.Lab import Lab | ||
from Kathara.model.Machine import Machine | ||
|
||
from .AbstractCheck import AbstractCheck | ||
from .CheckResult import CheckResult | ||
|
||
|
||
class CollisionDomainCheck(AbstractCheck): | ||
def check(self, cd_t: Link, lab: Lab) -> CheckResult: | ||
self.description = f"Checking collision domain `{cd_t.name}`" | ||
def check(self, machine_t: Machine, lab: Lab) -> list[CheckResult]: | ||
|
||
results = [] | ||
try: | ||
cd = lab.get_link(cd_t.name) | ||
if cd.machines.keys() != cd_t.machines.keys(): | ||
reason = ( | ||
f"Devices connected to collision domain {cd.name} {list(cd.machines.keys())} " | ||
f"are different from the one in the template {list(cd_t.machines.keys())}." | ||
) | ||
return CheckResult(self.description, False, reason) | ||
machine = lab.get_machine(machine_t.name) | ||
for iface_num, interface in machine.interfaces.items(): | ||
self.description = f"Checking the collision domain attached to interface `eth{iface_num}` of `{machine_t.name}`" | ||
interface_t = machine_t.interfaces[iface_num] | ||
if interface_t.link.name != interface.link.name: | ||
reason = ( | ||
f"Interface `{iface_num}` of device {machine_t.name} is connected to collision domain " | ||
f"`{interface.link.name}` instead of `{interface_t.link.name}`" | ||
) | ||
results.append(CheckResult(self.description, False, reason)) | ||
else: | ||
results.append(CheckResult(self.description, True, "OK")) | ||
|
||
|
||
return CheckResult(self.description, True, "OK") | ||
except LinkNotFoundError as e: | ||
return CheckResult(self.description, False, str(e)) | ||
results.append(CheckResult(self.description, False, str(e))) | ||
return results | ||
|
||
def run(self, template_cds: list[Link], lab: Lab) -> list[CheckResult]: | ||
def run(self, template_machines: list[Machine], lab: Lab) -> list[CheckResult]: | ||
results = [] | ||
for cd_t in template_cds: | ||
check_result = self.check(cd_t, lab) | ||
results.append(check_result) | ||
for machine_t in template_machines: | ||
check_result = self.check(machine_t, lab) | ||
results.extend(check_result) | ||
return results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/kathara_lab_checker/checks/applications/dns/DNSRecordCheck.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from kathara_lab_checker.__main__ import main | ||
|
||
if __name__ == '__main__': | ||
main() |