mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #1375: Renamed NETBOX_USERNAME and NETBOX_PASSWORD configuration parameters to NAPALM_USERNAME and NAPALM_PASSWORD
This commit is contained in:
@ -135,11 +135,21 @@ An API consumer can request an arbitrary number of objects by appending the "lim
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## NETBOX_USERNAME
|
## NAPALM_USERNAME
|
||||||
|
|
||||||
## NETBOX_PASSWORD
|
## NAPALM_PASSWORD
|
||||||
|
|
||||||
If provided, NetBox will use these credentials to authenticate against devices when collecting data.
|
NetBox will use these credentials when authenticating to remote devices via the NAPALM library. Both parameters are optional.
|
||||||
|
|
||||||
|
Note: If SSH public key authentication has been set up for the system account under which NetBox runs, these parameters are not needed.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## NETBOX_USERNAME (Deprecated)
|
||||||
|
|
||||||
|
## NETBOX_PASSWORD (Deprecated)
|
||||||
|
|
||||||
|
These settings have been deprecated and will be removed in NetBox v2.2. Please use `NAPALM_USERNAME` and `NAPALM_PASSWORD` instead.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -272,8 +272,8 @@ class DeviceViewSet(WritableSerializerMixin, CustomFieldModelViewSet):
|
|||||||
ip_address = str(device.primary_ip.address.ip)
|
ip_address = str(device.primary_ip.address.ip)
|
||||||
d = driver(
|
d = driver(
|
||||||
hostname=ip_address,
|
hostname=ip_address,
|
||||||
username=settings.NETBOX_USERNAME,
|
username=settings.NAPALM_USERNAME,
|
||||||
password=settings.NETBOX_PASSWORD
|
password=settings.NAPALM_PASSWORD
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
d.open()
|
d.open()
|
||||||
|
@ -13,8 +13,8 @@ from dcim.models import Device, InventoryItem, Site, STATUS_ACTIVE
|
|||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = "Update inventory information for specified devices"
|
help = "Update inventory information for specified devices"
|
||||||
username = settings.NETBOX_USERNAME
|
username = settings.NAPALM_USERNAME
|
||||||
password = settings.NETBOX_PASSWORD
|
password = settings.NAPALM_PASSWORD
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
parser.add_argument('-u', '--username', dest='username', help="Specify the username to use")
|
parser.add_argument('-u', '--username', dest='username', help="Specify the username to use")
|
||||||
|
@ -60,8 +60,8 @@ BASE_PATH = os.environ.get('BASE_PATH', '')
|
|||||||
MAINTENANCE_MODE = os.environ.get('MAINTENANCE_MODE', False)
|
MAINTENANCE_MODE = os.environ.get('MAINTENANCE_MODE', False)
|
||||||
|
|
||||||
# Credentials that NetBox will use to access live devices.
|
# Credentials that NetBox will use to access live devices.
|
||||||
NETBOX_USERNAME = os.environ.get('NETBOX_USERNAME', '')
|
NAPALM_USERNAME = os.environ.get('NAPALM_USERNAME', '')
|
||||||
NETBOX_PASSWORD = os.environ.get('NETBOX_PASSWORD', '')
|
NAPALM_PASSWORD = os.environ.get('NAPALM_PASSWORD', '')
|
||||||
|
|
||||||
# Determine how many objects to display per page within a list. (Default: 50)
|
# Determine how many objects to display per page within a list. (Default: 50)
|
||||||
PAGINATE_COUNT = os.environ.get('PAGINATE_COUNT', 50)
|
PAGINATE_COUNT = os.environ.get('PAGINATE_COUNT', 50)
|
||||||
|
@ -93,9 +93,9 @@ MAINTENANCE_MODE = False
|
|||||||
# all objects by specifying "?limit=0".
|
# all objects by specifying "?limit=0".
|
||||||
MAX_PAGE_SIZE = 1000
|
MAX_PAGE_SIZE = 1000
|
||||||
|
|
||||||
# Credentials that NetBox will use to access live devices (future use).
|
# Credentials that NetBox will uses to authenticate to devices when connecting via NAPALM.
|
||||||
NETBOX_USERNAME = ''
|
NAPALM_USERNAME = ''
|
||||||
NETBOX_PASSWORD = ''
|
NAPALM_PASSWORD = ''
|
||||||
|
|
||||||
# Determine how many objects to display per page within a list. (Default: 50)
|
# Determine how many objects to display per page within a list. (Default: 50)
|
||||||
PAGINATE_COUNT = 50
|
PAGINATE_COUNT = 50
|
||||||
|
@ -46,8 +46,10 @@ MAINTENANCE_MODE = getattr(configuration, 'MAINTENANCE_MODE', False)
|
|||||||
MAX_PAGE_SIZE = getattr(configuration, 'MAX_PAGE_SIZE', 1000)
|
MAX_PAGE_SIZE = getattr(configuration, 'MAX_PAGE_SIZE', 1000)
|
||||||
PAGINATE_COUNT = getattr(configuration, 'PAGINATE_COUNT', 50)
|
PAGINATE_COUNT = getattr(configuration, 'PAGINATE_COUNT', 50)
|
||||||
PREFER_IPV4 = getattr(configuration, 'PREFER_IPV4', False)
|
PREFER_IPV4 = getattr(configuration, 'PREFER_IPV4', False)
|
||||||
NETBOX_USERNAME = getattr(configuration, 'NETBOX_USERNAME', '')
|
NAPALM_USERNAME = getattr(configuration, 'NAPALM_USERNAME', '')
|
||||||
NETBOX_PASSWORD = getattr(configuration, 'NETBOX_PASSWORD', '')
|
NAPALM_PASSWORD = getattr(configuration, 'NAPALM_PASSWORD', '')
|
||||||
|
NETBOX_USERNAME = getattr(configuration, 'NETBOX_USERNAME', '') # Deprecated
|
||||||
|
NETBOX_PASSWORD = getattr(configuration, 'NETBOX_PASSWORD', '') # Deprecated
|
||||||
SHORT_DATE_FORMAT = getattr(configuration, 'SHORT_DATE_FORMAT', 'Y-m-d')
|
SHORT_DATE_FORMAT = getattr(configuration, 'SHORT_DATE_FORMAT', 'Y-m-d')
|
||||||
SHORT_DATETIME_FORMAT = getattr(configuration, 'SHORT_DATETIME_FORMAT', 'Y-m-d H:i')
|
SHORT_DATETIME_FORMAT = getattr(configuration, 'SHORT_DATETIME_FORMAT', 'Y-m-d H:i')
|
||||||
SHORT_TIME_FORMAT = getattr(configuration, 'SHORT_TIME_FORMAT', 'H:i:s')
|
SHORT_TIME_FORMAT = getattr(configuration, 'SHORT_TIME_FORMAT', 'H:i:s')
|
||||||
@ -56,6 +58,19 @@ TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
|
|||||||
|
|
||||||
CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS
|
CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS
|
||||||
|
|
||||||
|
# Check for deprecated configuration parameters
|
||||||
|
config_logger = logging.getLogger('configuration')
|
||||||
|
config_logger.addHandler(logging.StreamHandler())
|
||||||
|
config_logger.setLevel(logging.WARNING)
|
||||||
|
if NETBOX_USERNAME:
|
||||||
|
config_logger.warning('NETBOX_USERNAME is deprecated and will be removed in v2.2. Please use NAPALM_USERNAME instead.')
|
||||||
|
if not NAPALM_USERNAME:
|
||||||
|
NAPALM_USERNAME = NETBOX_USERNAME
|
||||||
|
if NETBOX_PASSWORD:
|
||||||
|
config_logger.warning('NETBOX_PASSWORD is deprecated and will be removed in v2.2. Please use NAPALM_PASSWORD instead.')
|
||||||
|
if not NAPALM_PASSWORD:
|
||||||
|
NAPALM_PASSWORD = NETBOX_PASSWORD
|
||||||
|
|
||||||
# Attempt to import LDAP configuration if it has been defined
|
# Attempt to import LDAP configuration if it has been defined
|
||||||
LDAP_IGNORE_CERT_ERRORS = False
|
LDAP_IGNORE_CERT_ERRORS = False
|
||||||
try:
|
try:
|
||||||
@ -78,9 +93,9 @@ if LDAP_CONFIGURED:
|
|||||||
if LDAP_IGNORE_CERT_ERRORS:
|
if LDAP_IGNORE_CERT_ERRORS:
|
||||||
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
|
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
|
||||||
# Enable logging for django_auth_ldap
|
# Enable logging for django_auth_ldap
|
||||||
logger = logging.getLogger('django_auth_ldap')
|
ldap_logger = logging.getLogger('django_auth_ldap')
|
||||||
logger.addHandler(logging.StreamHandler())
|
ldap_logger.addHandler(logging.StreamHandler())
|
||||||
logger.setLevel(logging.DEBUG)
|
ldap_logger.setLevel(logging.DEBUG)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"LDAP authentication has been configured, but django-auth-ldap is not installed. You can remove "
|
"LDAP authentication has been configured, but django-auth-ldap is not installed. You can remove "
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if settings.NETBOX_USERNAME or settings.NETBOX_PASSWORD %}
|
||||||
|
<div class="alert alert-warning alert-dismissable" role="alert">
|
||||||
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
<strong>Warning:</strong> The <code>NETBOX_USERNAME</code> and <code>NETBOX_PASSWORD</code> configuration parameters have been deprecated. Please replace them in configuration.py with <code>NAPALM_USERNAME</code> and <code>NAPALM_PASSWORD</code>.
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% include 'search_form.html' %}
|
{% include 'search_form.html' %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6 col-md-4">
|
<div class="col-sm-6 col-md-4">
|
||||||
|
Reference in New Issue
Block a user