Clean up CLI argument style
This commit is contained in:
parent
ab96965767
commit
88ee0ddaa6
1 changed files with 207 additions and 69 deletions
|
|
@ -17,77 +17,215 @@ def get_config():
|
||||||
prog='netbox_agent',
|
prog='netbox_agent',
|
||||||
description="Netbox agent to run on your infrastructure's servers",
|
description="Netbox agent to run on your infrastructure's servers",
|
||||||
env_prefix='NETBOX_AGENT_',
|
env_prefix='NETBOX_AGENT_',
|
||||||
default_env=True
|
default_env=True,
|
||||||
)
|
)
|
||||||
p.add_argument('-c', '--config', action=jsonargparse.ActionConfigFile)
|
|
||||||
|
|
||||||
p.add_argument('-r', '--register', action='store_true', help='Register server to Netbox')
|
p.add_argument(
|
||||||
p.add_argument('-u', '--update-all', action='store_true', help='Update all infos in Netbox')
|
'-c',
|
||||||
p.add_argument('-d', '--debug', action='store_true', help='Print debug infos')
|
'--config',
|
||||||
p.add_argument('--update-network', action='store_true', help='Update network')
|
action=jsonargparse.ActionConfigFile,
|
||||||
p.add_argument('--update-inventory', action='store_true', help='Update inventory')
|
)
|
||||||
p.add_argument('--update-location', action='store_true', help='Update location')
|
p.add_argument(
|
||||||
p.add_argument('--update-psu', action='store_true', help='Update PSU')
|
'-r',
|
||||||
p.add_argument('--purge-old-devices', action='store_true',
|
'--register',
|
||||||
help='Purge existing (old ?) devices having same name but different serial')
|
action='store_true',
|
||||||
p.add_argument('--expansion-as-device', action='store_true',
|
help='Register server to Netbox',
|
||||||
help='Manage blade expansions as external devices')
|
)
|
||||||
|
p.add_argument(
|
||||||
p.add_argument('--log_level', default='debug')
|
'-u',
|
||||||
p.add_argument('--netbox.ssl_ca_certs_file', help='SSL CA certificates file')
|
'--update-all',
|
||||||
p.add_argument('--netbox.url', help='Netbox URL')
|
action='store_true',
|
||||||
p.add_argument('--netbox.token', help='Netbox API Token')
|
help='Update all infos in Netbox',
|
||||||
p.add_argument('--netbox.ssl_verify', default=True, action='store_true',
|
)
|
||||||
help='Disable SSL verification')
|
p.add_argument(
|
||||||
p.add_argument('--virtual.enabled', action='store_true', help='Is a virtual machine or not')
|
'-d',
|
||||||
p.add_argument('--virtual.cluster_name', help='Cluster name of VM')
|
'--debug',
|
||||||
p.add_argument('--hostname_cmd', default=None,
|
action='store_true',
|
||||||
help="Command to output hostname, used as Device's name in netbox")
|
help='Print debug infos',
|
||||||
p.add_argument('--device.platform', default=None,
|
)
|
||||||
help='Override device platform. Here we use OS distribution.')
|
p.add_argument(
|
||||||
p.add_argument('--device.tags', default=r'',
|
'--update-network',
|
||||||
help='tags to use for a host')
|
action='store_true',
|
||||||
p.add_argument('--preserve-tags', action='store_true', help='Append new unique tags, preserve those already present')
|
help='Update network',
|
||||||
p.add_argument('--device.custom_fields', default=r'',
|
)
|
||||||
help='custom_fields to use for a host, eg: field1=v1,field2=v2')
|
p.add_argument(
|
||||||
p.add_argument('--device.blade_role', default=r'Blade',
|
'--update-inventory',
|
||||||
help='role to use for a blade server')
|
action='store_true',
|
||||||
p.add_argument('--device.chassis_role', default=r'Server Chassis',
|
help='Update inventory',
|
||||||
help='role to use for a chassis')
|
)
|
||||||
p.add_argument('--device.server_role', default=r'Server',
|
p.add_argument(
|
||||||
help='role to use for a server')
|
'--update-location',
|
||||||
p.add_argument('--tenant.driver',
|
action='store_true',
|
||||||
help='tenant driver, ie cmd, file')
|
help='Update location',
|
||||||
p.add_argument('--tenant.driver_file',
|
)
|
||||||
help='tenant driver custom driver file path')
|
p.add_argument(
|
||||||
p.add_argument('--tenant.regex',
|
'--update-psu',
|
||||||
help='tenant regex to extract Netbox tenant slug')
|
action='store_true',
|
||||||
p.add_argument('--datacenter_location.driver',
|
help='Update PSU',
|
||||||
help='Datacenter location driver, ie: cmd, file')
|
)
|
||||||
p.add_argument('--datacenter_location.driver_file',
|
p.add_argument(
|
||||||
help='Datacenter location custom driver file path')
|
'--purge-old-devices',
|
||||||
p.add_argument('--datacenter_location.regex',
|
action='store_true',
|
||||||
help='Datacenter location regex to extract Netbox DC slug')
|
help='Purge existing (old ?) devices having same name but different serial',
|
||||||
p.add_argument('--rack_location.driver', help='Rack location driver, ie: cmd, file')
|
)
|
||||||
p.add_argument('--rack_location.driver_file', help='Rack location custom driver file path')
|
p.add_argument(
|
||||||
p.add_argument('--rack_location.regex', help='Rack location regex to extract Rack name')
|
'--expansion-as-device',
|
||||||
p.add_argument('--slot_location.driver', help='Slot location driver, ie: cmd, file')
|
action='store_true',
|
||||||
p.add_argument('--slot_location.driver_file', help='Slot location custom driver file path')
|
help='Manage blade expansions as external devices',
|
||||||
p.add_argument('--slot_location.regex', help='Slot location regex to extract slot name')
|
)
|
||||||
p.add_argument('--network.ignore_interfaces', default=r'(dummy.*|docker.*)',
|
p.add_argument(
|
||||||
help='Regex to ignore interfaces')
|
'--log_level',
|
||||||
p.add_argument('--network.ignore_ips', default=r'^(127\.0\.0\..*|fe80.*|::1.*)',
|
default='debug',
|
||||||
help='Regex to ignore IPs')
|
)
|
||||||
p.add_argument('--network.lldp', help='Enable auto-cabling feature through LLDP infos')
|
p.add_argument(
|
||||||
p.add_argument('--inventory', action='store_true',
|
'--netbox.ssl_ca_certs_file',
|
||||||
help='Enable HW inventory (CPU, Memory, RAID Cards, Disks) feature')
|
help='SSL CA certificates file',
|
||||||
p.add_argument('--process-virtual-drives', action='store_true',
|
)
|
||||||
help='Process virtual drives information from RAID '
|
p.add_argument(
|
||||||
'controllers to fill disk custom_fields')
|
'--netbox.url',
|
||||||
p.add_argument('--force-disk-refresh', action='store_true',
|
help='Netbox URL',
|
||||||
help='Forces disks detection reprocessing')
|
)
|
||||||
p.add_argument('--dump-disks-map',
|
p.add_argument(
|
||||||
help='File path to dump physical/virtual disks map')
|
'--netbox.token',
|
||||||
|
help='Netbox API Token',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--netbox.ssl_verify',
|
||||||
|
default=True,
|
||||||
|
action='store_true',
|
||||||
|
help='Disable SSL verification',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--virtual.enabled',
|
||||||
|
action='store_true',
|
||||||
|
help='Is a virtual machine or not',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--virtual.cluster_name',
|
||||||
|
help='Cluster name of VM',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--hostname_cmd',
|
||||||
|
default=None,
|
||||||
|
help="Command to output hostname, used as Device's name in netbox",
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--device.platform',
|
||||||
|
default=None,
|
||||||
|
help='Override device platform. Here we use OS distribution.',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--device.tags',
|
||||||
|
default=r'',
|
||||||
|
help='tags to use for a host',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--preserve-tags',
|
||||||
|
action='store_true',
|
||||||
|
help='Append new unique tags, preserve those already present',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--device.custom_fields',
|
||||||
|
default=r'',
|
||||||
|
help='custom_fields to use for a host, eg: field1=v1,field2=v2',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--device.blade_role',
|
||||||
|
default=r'Blade',
|
||||||
|
help='role to use for a blade server',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--device.chassis_role',
|
||||||
|
default=r'Server Chassis',
|
||||||
|
help='role to use for a chassis',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--device.server_role',
|
||||||
|
default=r'Server',
|
||||||
|
help='role to use for a server',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--tenant.driver',
|
||||||
|
help='tenant driver, ie cmd, file',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--tenant.driver_file',
|
||||||
|
help='tenant driver custom driver file path',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--tenant.regex',
|
||||||
|
help='tenant regex to extract Netbox tenant slug',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--datacenter_location.driver',
|
||||||
|
help='Datacenter location driver, ie: cmd, file',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--datacenter_location.driver_file',
|
||||||
|
help='Datacenter location custom driver file path',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--datacenter_location.regex',
|
||||||
|
help='Datacenter location regex to extract Netbox DC slug',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--rack_location.driver',
|
||||||
|
help='Rack location driver, ie: cmd, file',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--rack_location.driver_file',
|
||||||
|
help='Rack location custom driver file path',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--rack_location.regex',
|
||||||
|
help='Rack location regex to extract Rack name',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--slot_location.driver',
|
||||||
|
help='Slot location driver, ie: cmd, file',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--slot_location.driver_file',
|
||||||
|
help='Slot location custom driver file path',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--slot_location.regex',
|
||||||
|
help='Slot location regex to extract slot name',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--network.ignore_interfaces',
|
||||||
|
default=r'(dummy.*|docker.*)',
|
||||||
|
help='Regex to ignore interfaces',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--network.ignore_ips',
|
||||||
|
default=r'^(127\.0\.0\..*|fe80.*|::1.*)',
|
||||||
|
help='Regex to ignore IPs',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--network.lldp',
|
||||||
|
help='Enable auto-cabling feature through LLDP infos',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--inventory',
|
||||||
|
action='store_true',
|
||||||
|
help='Enable HW inventory (CPU, Memory, RAID Cards, Disks) feature',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--process-virtual-drives',
|
||||||
|
action='store_true',
|
||||||
|
help='Process virtual drives information from RAID controllers to fill '
|
||||||
|
'disk custom_fields',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--force-disk-refresh',
|
||||||
|
action='store_true',
|
||||||
|
help='Forces disks detection reprocessing',
|
||||||
|
)
|
||||||
|
p.add_argument(
|
||||||
|
'--dump-disks-map',
|
||||||
|
help='File path to dump physical/virtual disks map',
|
||||||
|
)
|
||||||
|
|
||||||
options = p.parse_args()
|
options = p.parse_args()
|
||||||
return options
|
return options
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue