App-Netdisco

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


  * allow ACL property match to contain ":"
  * fix skip long SNMP timeout for initial discover

2.063002 - 2023-07-14

  [ENHANCEMENTS]

  * #1059 NETDISCO_SNMP_BULKWALK_OFF environment to disable bulkwalk
  * #1060 portctl_topology setting to enable manual topology for port control users
  * #1066 faster device credentials discovery and snmp_try_slow_connect setting
  * #1067 netdisco-do --force to enqueue more than 512 jobs
  * deleting a device is now always a job, never done in the web engine
  * update netdisco-do documentation

  [BUG FIXES]

  * #1058 error when the log string is empty

2.063001 - 2023-06-28

Changes  view on Meta::CPAN

  * #539 fix an issue with VLAN reindixing for VRFs (earendilfr)
  * fix device port change check

2.041000 - 2019-03-12

  [NEW FEATURES]

  * netdisco-sshcollector no longer required - the functionality (arpnip via
    ssh) will be run within netdisco's core schedule (rc9000 and ollyg)

  * get_credentials replaces get_community and accepts any device_auth stanza
    in JSON format (ollyg)

2.040007 - 2019-03-06

  [BUG FIXES]

  * #521-redux Search Node Date Range not working (ollyg)

2.040006 - 2019-03-04

Changes  view on Meta::CPAN


  [ENHANCEMENTS]

  * Device Port filter by vlan includes both tagging and untagged (closes #37)
  * Change colour and name of Port Control toggle option in Device Port View
  * Incorporate latest DB schema changes from upstream
  * Add some doc clarifcations

  [BUG FIXES]

  * No longer prompt for demo/demo credentials (closes #38) (J. Binks)
  * Display IP in Vlan search if device has no DNS (closes #36) (J. Binks)

2.004000 - 2013-01-14

  [BUG FIXES]

  * Very naughty typo in netmap code, which I forgot to merge a fix for.
  * Typo in installation docs (S. Gupta)

2.002000 - 2013-01-06

lib/App/Netdisco/Util/DeviceAuth.pm  view on Meta::CPAN


use Dancer qw/:syntax :script/;
use App::Netdisco::Util::DNS 'hostname_from_ip';

use Storable 'dclone';
use Try::Tiny;

use base 'Exporter';
our @EXPORT = ();
our @EXPORT_OK = qw/
  fixup_device_auth get_external_credentials
/;
our %EXPORT_TAGS = (all => \@EXPORT_OK);

=head1 NAME

App::Netdisco::Util::DeviceAuth

=head1 DESCRIPTION

Helper functions for device authentication.

lib/App/Netdisco/Util/DeviceAuth.pm  view on Meta::CPAN


  foreach my $stanza (@new_stanzas) {
    $stanza->{driver} ||= 'snmp'
      if exists $stanza->{community}
         or exists $stanza->{user};
  }

  return @new_stanzas;
}

=head2 get_external_credentials( $device, $mode )

Runs a command to gather SNMP credentials or a C<device_auth> stanza.

Mode can be C<read> or C<write> and defaults to 'read'.

=cut

sub get_external_credentials {
  my ($device, $mode) = @_;
  my $cmd = (setting('get_credentials') || setting('get_community'));
  my $ip = $device->ip;
  my $host = ($device->dns || hostname_from_ip($ip) || $ip);
  $mode ||= 'read';

  if (defined $cmd and length $cmd) {
      # replace variables
      $cmd =~ s/\%MODE\%/$mode/egi;
      $cmd =~ s/\%HOST\%/$host/egi;
      $cmd =~ s/\%IP\%/$ip/egi;

      my $result = `$cmd`; # BACKTICKS
      return () unless defined $result and length $result;

      my @lines = split (m/\n/, $result);
      foreach my $line (@lines) {
          if ($line =~ m/^community\s*=\s*(.*)\s*$/i) {
              if (length $1 and $mode eq 'read') {
                  debug sprintf '[%s] external read credentials added',
                    $device->ip;

                  return map {{
                    read => 1,
                    only => [$device->ip],
                    community => $_,
                  }} split(m/\s*,\s*/,$1);
              }
          }
          elsif ($line =~ m/^setCommunity\s*=\s*(.*)\s*$/i) {
              if (length $1 and $mode eq 'write') {
                  debug sprintf '[%s] external write credentials added',
                    $device->ip;

                  return map {{
                    write => 1,
                    only => [$device->ip],
                    community => $_,
                  }} split(m/\s*,\s*/,$1);
              }
          }
          else {
            my $stanza = undef;
            try {
              $stanza = from_json( $line );
              debug sprintf '[%s] external credentials stanza added',
                $device->ip;
            }
            catch {
              info sprintf '[%s] error! failed to parse external credentials stanza',
                $device->ip;
            };
            return $stanza if ref $stanza;
          }
      }
  }

  return ();
}

lib/App/Netdisco/Util/SNMP.pm  view on Meta::CPAN

package App::Netdisco::Util::SNMP;

use Dancer qw/:syntax :script/;
use App::Netdisco::Util::DeviceAuth 'get_external_credentials';

use Path::Class 'dir';
use File::Spec::Functions qw/splitdir catdir catfile/;
use MIME::Base64 'decode_base64';
use SNMP::Info;
use JSON::PP ();

use base 'Exporter';
our @EXPORT = ();
our @EXPORT_OK = qw/

lib/App/Netdisco/Util/SNMP.pm  view on Meta::CPAN


sub get_communities {
  my ($device, $mode) = @_;
  $mode ||= 'read';

  my $seen_tags = {}; # for cleaning community table
  my $config = (setting('device_auth') || []);
  my @communities = ();

  # first of all, use external command if configured
  push @communities, get_external_credentials($device, $mode);

  # last known-good by tag
  my $tag_name = 'snmp_auth_tag_'. $mode;
  my $stored_tag = eval { $device->community->$tag_name };

  if ($device->in_storage and $stored_tag) {
    foreach my $stanza (@$config) {
      if ($stanza->{tag} and $stored_tag eq $stanza->{tag}) {
        push @communities, {%$stanza, only => [$device->ip]};
        last;

share/config.yml  view on Meta::CPAN

use_legacy_sshcollector: false
custom_fields:
  device: []
  device_port: []
tags:
  device: {}
  device_port: {}
hide_tags:
  device: []
  device_port: []
get_credentials: ""
bulkwalk_off: false
bulkwalk_no: []
bulkwalk_repeaters: 20
nonincreasing: false
snmpver: 3
snmptimeout: 3000000
snmpretries: 2
net_snmp_options: {}
snmp_try_slow_connect: true
snmp_remoteport: {}

share/environments/deployment.yml  view on Meta::CPAN

  name: 'netdisco'
  user: 'changeme'
  pass: 'changeme'
  #host: 'localhost'

# --------------------
# RECOMMENDED SETTINGS
# --------------------

# Device authentication settings
# define snmp communities and ssh credentials here
# ````````````````````````````````````````````````
device_auth:
  - tag: 'default_v2_readonly'
    community: 'public'
    read: true
    write: false
#  - tag: 'default_v2_for_write'
#    community: 'private'
#    read: false
#    write: true

share/public/swagger-ui/swagger-ui-bundle.js  view on Meta::CPAN

 * @param {string} eventNameSuffix Event name, e.g. "click".
 * @param {?boolean} capture Check if the capture phase is supported.
 * @return {boolean} True if the event is supported.
 * @internal
 * @license Modernizr 3.0.0pre (Custom Build) | MIT
 */,e.exports=function(e,t){if(!o.canUseDOM||t&&!("addEventListener"in document))return!1;var n="on"+e,i=n in document;if(!i){var a=document.createElement("div");a.setAttribute(n,"return;"),i="function"==typeof a[n]}return!i&&r&&"wheel"===e&&(i=docum...
/*!
 * https://github.com/Starcounter-Jack/JSON-Patch
 * (c) 2017 Joachim Wester
 * MIT license
 */function o(e,t){return r.call(e,t)}function i(e){if(Array.isArray(e)){for(var t=new Array(e.length),n=0;n<t.length;n++)t[n]=""+n;return t}if(Object.keys)return Object.keys(e);t=[];for(var r in e)o(e,r)&&t.push(r);return t}function a(e){return-1===...
/*!
 * cookie
 * Copyright(c) 2012-2014 Roman Shtylman
 * Copyright(c) 2015 Douglas Christopher Wilson
 * MIT Licensed
 */t.parse=function(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");for(var n={},o=t||{},a=e.split(i),s=o.decode||r,l=0;l<a.length;l++){var c=a[l],f=c.indexOf("=");if(!(f<0)){var p=c.substr(0,f).trim(),d=c.substr(++f,c...
/*!
 * repeat-string <https://github.com/jonschlinkert/repeat-string>
 *
 * Copyright (c) 2014-2015, Jon Schlinkert.
 * Licensed under the MIT License.
 */var r,o="";e.exports=function(e,t){if("string"!=typeof e)throw new TypeError("expected a string");if(1===t)return e;if(2===t)return e+e;var n=e.length*t;if(r!==e||void 0===r)r=e,o="";else if(o.length>=n)return o.substr(0,n);for(;n>o.length&&t>1;)1...
/*!
 * Autolinker.js
 * 0.15.3
 *

share/public/swagger-ui/swagger-ui-bundle.js.map  view on Meta::CPAN

{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 396b8c743e9ffbc09e47","webpack:///./node_modules/react/react.js","webpack:///./node_modules/prop-types/index.js","webpack:///./node_modules/babel-run...

share/public/swagger-ui/swagger-ui.js  view on Meta::CPAN

(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==="object"&&typeof module==="object")module.exports=factory(require("deep-extend"),require("immutable"),require("css.escape"),require("memoizee"),require("stream"),require("ba...
/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
 * @license  MIT
 */
var base64=__webpack_require__(383);var ieee754=__webpack_require__(384);var isArray=__webpack_require__(385);exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==und...
//# sourceMappingURL=swagger-ui.js.map

share/public/swagger-ui/swagger-ui.js.map  view on Meta::CPAN

{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap fb516ccd71e38bfe6f58","webpack:///external \"react\"","webpack:///external \"prop-types\"","webpack:///./node_modules/babel-runtime/helpers/classCall...

share/python/netdisco/netdisco/util/ssh.py  view on Meta::CPAN

"""
netdisco.util.ssh
~~~~~~~~~~~~~~~~~

This module provides a netmiko connection handler using
the credentials in device_auth.
"""

import os
from netmiko import ConnectHandler

from netdisco.util.config import setting
from netdisco.util.job import job

if 'ND2_FSM_TEMPLATES' in os.environ:
    os.environ['NET_TEXTFSM'] = os.environ['ND2_FSM_TEMPLATES']



( run in 0.313 second using v1.01-cache-2.11-cpan-a5abf4f5562 )