Skip to content

Commit 9e0b5cd

Browse files
committed
fixes indentations and adds updated default settings
1 parent 8b93942 commit 9e0b5cd

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11

22
# NetBox-Sync
33

4-
> [!CAUTION]
5-
> **Maintainer wanted - sunsetting this repository by 31.10.2025 [#474](https://github.com/bb-Ricardo/netbox-sync/issues/474)**
6-
74
This is a tool to sync data from different sources to a NetBox instance.
85

96
Available source types:

module/netbox/object_classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ def update(self, data=None, read_from_netbox=False, source=None):
750750
new_value_str = new_value_str.replace("\n", " ")
751751
log.info(f"{self.name.capitalize()} '{display_name}' attribute '{key}' changed from "
752752
f"'{current_value_str}' to '{new_value_str}'")
753-
753+
754754
self.data[key] = new_value
755755
self.updated_items.append(key)
756756
data_updated = True

module/sources/vmware/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(self):
8989
If a filter is unset it will be ignored. Filters are all treated as regex expressions!
9090
If more then one expression should match, a '|' needs to be used
9191
""",
92-
config_example="""Example: (exclude all VMs with "replica" in their name
92+
config_example="""Example: (exclude all VMs with "replica" in their name
9393
and all VMs starting with "backup"): vm_exclude_filter = .*replica.*|^backup.*""",
9494
options=[
9595
ConfigOption("cluster_exclude_filter",
@@ -143,7 +143,7 @@ def __init__(self):
143143
description="""Same as cluster site but on host level.
144144
If unset it will fall back to cluster_site_relation""",
145145
config_example="nyc02.* = New York, ffm01.* = Frankfurt"),
146-
ConfigOption("cluster_scope_type_relation",
146+
ConfigOption("cluster_scope_type_relation",
147147
str,
148148
description="""This option defines the scope type for a cluster.
149149
The scope type can be 'dcim.site', 'dcim.sitegroup', 'dcim.location' or 'dcim.region'.

module/sources/vmware/connection.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def get_site_name(self, object_type, object_name, cluster_name=""):
501501
log.debug2(f"Returning site name '{site_name}' for {object_type.name} '{object_name}'.")
502502

503503
return site_name
504-
504+
505505
def get_scope_type(self, object_type, object_name):
506506
"""
507507
Retrieve the scope_type for a NBCluster instance by object name or from the config option
@@ -524,12 +524,12 @@ def get_scope_type(self, object_type, object_name):
524524
# Validate object type
525525
if object_type != NBCluster:
526526
raise ValueError(f"Object type must be '{NBCluster.name}'.")
527-
527+
528528
# get scope type from relation config
529529
relation_name = "cluster_scope_type_relation"
530530
scope_type = self.get_object_relation(object_name, relation_name)
531531
log.debug(f"Retrieved scope type '{scope_type}' for {object_type.name} '{object_name}' from relation '{relation_name}'.")
532-
532+
533533
# if the scope_type is a list, use the first element
534534
if scope_type is not None and type(scope_type) is list:
535535
scope_type_list = scope_type
@@ -545,7 +545,7 @@ def get_scope_type(self, object_type, object_name):
545545
if scope_type == "<NONE>":
546546
log.debug(f"Scope type for {object_type.name} '{object_name}' is set to None")
547547
return None
548-
548+
549549
log.debug2(f"Returning scope type '{scope_type}' for {object_type.name} '{object_name}'.")
550550
return scope_type
551551

@@ -577,16 +577,16 @@ def get_scope_id(self, object_type, object_name):
577577

578578
# return None if scope_id is None or not a string
579579
if scope_id is None:
580-
log.debug(f"No scope id found for {object_name}.")
580+
log.debug(f"No scope id found for {object_name}.")
581581
return None
582582
if type(scope_id) is not str:
583583
log.debug(f"scope_id is type: {type(scope_id)}, not str")
584584
return None
585-
585+
586586
log.debug2(f"Retrieved scope id '{scope_id}' for {object_type.name} '{object_name}' from relation '{relation_name}'. End of method.")
587587

588588
return scope_id
589-
589+
590590
def get_object_based_on_macs(self, object_type, mac_list=None):
591591
"""
592592
Try to find a NetBox object based on list of MAC addresses.
@@ -1480,10 +1480,10 @@ def add_cluster(self, obj):
14801480
scope_type = self.get_scope_type(NBCluster, full_cluster_name)
14811481
if scope_type is None:
14821482
scope_type = self.get_scope_type(NBCluster, name)
1483-
1483+
14841484
site_name = self.get_site_name(NBCluster, full_cluster_name)
14851485

1486-
scope_id = self.get_scope_id(NBCluster, full_cluster_name)
1486+
scope_id = self.get_scope_id(NBCluster, full_cluster_name)
14871487
if scope_id is None:
14881488
scope_id = self.get_scope_id(NBCluster, name)
14891489
log.debug(f"Cluster '{full_cluster_name}' has scope id '{scope_id}' of type {type(scope_id)}.")

settings-example.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,19 @@ password = super-secret
199199
; cluster_site_relation
200200
;host_site_relation = nyc02.* = New York, ffm01.* = Frankfurt
201201

202+
; This option defines the scope type for a cluster. The scope type can be 'dcim.site',
203+
; 'dcim.sitegroup', 'dcim.location' or 'dcim.region'. This is done with a comma separated
204+
; key = value list. Can be set to "<NONE>" to not assign a scope type. Note: this does not
205+
; remove scope types from existing clusters in NetBox. key: defines a cluster name as
206+
; regex value: defines the NetBox scope type name (use quotes if name contains commas)
207+
;cluster_scope_type_relation = Cluster_NYC = dcim.site, Cluster_FFM = dcim.sitegroup, Cluster_BER = dcim.location
208+
209+
; This option defines the scope id for a cluster. The scope id is the NetBox ID of the
210+
; scope type. This is done with a comma separated key = value list. To be used in
211+
; combination with the 'cluster_scope_type_relation'. key: defines a cluster name as regex
212+
; value: defines the NetBox scope id (use quotes if name contains commas)
213+
;cluster_scope_id_relation = Cluster_NYC = 1, Cluster_FFM.* = 2, Cluster_BER = 7
214+
202215
; This option defines which cluster/host/VM belongs to which tenant.
203216
; This is done with a comma separated key = value list.
204217
; key: defines a hosts/VM name as regex

0 commit comments

Comments
 (0)