diff --git a/module/sources/check_redfish/config.py b/module/sources/check_redfish/config.py index 24d6953..c9550fe 100644 --- a/module/sources/check_redfish/config.py +++ b/module/sources/check_redfish/config.py @@ -30,11 +30,7 @@ class CheckRedfishConfig(ConfigBase): self.options = [ ConfigOption(**config_option_enabled_definition), - ConfigOption("type", - str, - description="type of source. This defines which source handler to use", - config_example="check_redfish", - mandatory=True), + ConfigOption(**{**config_option_type_definition, "config_example": "check_redfish"}), ConfigOption("inventory_file_path", str, @@ -74,19 +70,7 @@ class CheckRedfishConfig(ConfigBase): via check_redfish if False only data which is not preset in NetBox will be added""", default_value=True), - ConfigOption("ip_tenant_inheritance_order", - str, - description="""\ - define in which order the IP address tenant will be assigned if tenant is undefined. - possible values: - * device : host or VM tenant will be assigned to the IP address - * prefix : if the IP address belongs to an existing prefix and this prefix has a tenant assigned, then this one is used - * disabled : no tenant assignment to the IP address will be performed - the order of the definition is important, the default is "device, prefix" which means: - If the device has a tenant then this one will be used. If not, the prefix tenant will be used if defined - """, - default_value="device, prefix" - ), + ConfigOption(**config_option_ip_tenant_inheritance_order_definition), ] super().__init__() diff --git a/module/sources/common/conifg.py b/module/sources/common/conifg.py index 99273d8..d42a7c9 100644 --- a/module/sources/common/conifg.py +++ b/module/sources/common/conifg.py @@ -7,6 +7,14 @@ # For a copy, see file LICENSE.txt included in this # repository or visit: . +config_option_type_definition = { + "key": "type", + "value_type": str, + "description": "type of source. This defines which source handler to use", + "config_example": "UNDEFINED", + "mandatory": True +} + config_option_enabled_definition = { "key": "enabled", "value_type": bool, @@ -23,3 +31,18 @@ config_option_permitted_subnets_definition = { """, "config_example": "172.16.0.0/12, 10.0.0.0/8, 192.168.0.0/16, fd00::/8, !10.23.42.0/24" } + +config_option_ip_tenant_inheritance_order_definition = { + "key": "ip_tenant_inheritance_order", + "value_type": str, + "description": """\ + define in which order the IP address tenant will be assigned if tenant is undefined. + possible values: + * device : host or VM tenant will be assigned to the IP address + * prefix : if the IP address belongs to an existing prefix and this prefix has a tenant assigned, then this one is used + * disabled : no tenant assignment to the IP address will be performed + the order of the definition is important, the default is "device, prefix" which means: + If the device has a tenant then this one will be used. If not, the prefix tenant will be used if defined + """, + "default_value": "device, prefix" +} \ No newline at end of file diff --git a/module/sources/vmware/config.py b/module/sources/vmware/config.py index 264d004..699c633 100644 --- a/module/sources/vmware/config.py +++ b/module/sources/vmware/config.py @@ -32,11 +32,7 @@ class VMWareConfig(ConfigBase): self.options = [ ConfigOption(**config_option_enabled_definition), - ConfigOption("type", - str, - description="type of source. This defines which source handler to use", - config_example="vmware", - mandatory=True), + ConfigOption(**{**config_option_type_definition, "config_example": "vmware"}), ConfigOption("host_fqdn", str, @@ -317,19 +313,7 @@ class VMWareConfig(ConfigBase): description="""set a matching value for ESXi host management interface description (case insensitive, comma separated). Used to figure out the ESXi primary IP address""", default_value="management, mgmt"), - ConfigOption("ip_tenant_inheritance_order", - str, - description="""\ - define in which order the IP address tenant will be assigned if tenant is undefined. - possible values: - * device : host or VM tenant will be assigned to the IP address - * prefix : if the IP address belongs to an existing prefix and this prefix has a tenant assigned, then this one is used - * disabled : no tenant assignment to the IP address will be performed - the order of the definition is important, the default is "device, prefix" which means: - If the device has a tenant then this one will be used. If not, the prefix tenant will be used if defined - """, - default_value="device, prefix" - ), + ConfigOption(**config_option_ip_tenant_inheritance_order_definition), ConfigOption("sync_vm_interface_mtu", bool, description="""Usually netbox-sync grabs the MTU size for the VM interface from the