-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dedcfc5
commit 3513553
Showing
4 changed files
with
41 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from .device import Device | ||
from ..helpers import StrEnum | ||
|
||
# noinspection PyUnresolvedReferences | ||
class _HostDevice(Device): | ||
""" | ||
Denotes a Host device that is connected to the network. This device is not | ||
managemed by the NetCAD system. The Host device is used to represent | ||
connectivity related design aspects. | ||
Attributes | ||
--------- | ||
is_host: bool, always True | ||
is_not_managed: bool, always True | ||
""" | ||
|
||
is_host = True | ||
is_pseudo = True | ||
is_not_managed = True | ||
|
||
|
||
class HostDevice(_HostDevice): | ||
def __init__(self, name: str, **kwargs): | ||
super().__init__(name, **kwargs) | ||
self.port_connectivity = {} | ||
if not kwargs.get('no_auto_cable'): | ||
for iface in self.interfaces.values(): | ||
iface.cable_id = self.cable_id(iface.name) | ||
|
||
def cable_id(self, port_id): | ||
return f"{self.name}_{port_id}" | ||
|
||
|
||
def attach_host_port(dev: Device, if_name: str, host_name: str | StrEnum, host_port: str): | ||
host_dev = dev.design.devices[host_name] | ||
with dev.interfaces[if_name] as iface: | ||
iface.profile = host_dev.port_connectivity[host_port] | ||
iface.cable_id = host_dev.cable_id(host_port) |
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