-
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.
feat: prevent device/address change when linked to CMDB
- Loading branch information
1 parent
17732ae
commit 2d72a08
Showing
8 changed files
with
114 additions
and
1 deletion.
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
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,34 @@ | ||
MODELS_LINKED_TO_DEVICE = {} | ||
MODELS_LINKED_TO_IP_ADDRESS = {} | ||
|
||
|
||
def from_device_name_change(*fields): | ||
def decorator(cls): | ||
if cls not in MODELS_LINKED_TO_DEVICE: | ||
MODELS_LINKED_TO_DEVICE[cls] = set() | ||
|
||
if not fields: | ||
return cls | ||
|
||
for field in fields: | ||
MODELS_LINKED_TO_DEVICE[cls].add(field) | ||
|
||
return cls | ||
|
||
return decorator | ||
|
||
|
||
def from_ip_address_change(*fields): | ||
def decorator(cls): | ||
if cls not in MODELS_LINKED_TO_IP_ADDRESS: | ||
MODELS_LINKED_TO_IP_ADDRESS[cls] = set() | ||
|
||
if not fields: | ||
return cls | ||
|
||
for field in fields: | ||
MODELS_LINKED_TO_IP_ADDRESS[cls].add(field) | ||
|
||
return cls | ||
|
||
return decorator |
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