windows 10, intellij idea ultimate and wsl
the goal of this document is NOT to make netdisco work under windows
it is however a starting point for those wanting to develop under windows.
while our ide and most of our tools will be running on windows, we will be making use of wsl however so we have a build environment that very closely mimics a linux system.
-
git and github support
-
perl syntax checking
-
perl can be written in many ways, the lexer is very good but not yet complete (but which is?)
-
-
template toolkit syntax checking
-
sql (postgresql specific) syntax checking
-
building
-
Build.PL
-
Build
-
Build install (installs in wsl/plenv environment)
-
Build distclean
-
Build distcheck
-
Build makemeta
-
Build manifest
-
Build test (mostly)
-
-
perl pod
-
pod syntax
-
code coverage
-
-
code analysis
-
html linting
-
javascript linting
-
perl critic support
-
Build test (for some modules)
-
some mro based modules
-
the perl module does not yet support all perl syntax variations, in particular fancy function calls or redefining the module will lead confuse code keywords sometimes, but most of the syntax it has issues with confuses me too 😄. it might also think some dancer exported functions are not defined.
-
example of code that could be misinterpreted (most seem to use
ref
):return () unless ref {} eq ref $comm and scalar keys %$comm; $opts = {} if (ref {} ne ref $opts); next unless ref {} eq ref $map;
-
Netdisco is not supported on windows. several features will not work due to no underlying support from several perl modules (Net::OpenSSH being one of them).
That being said, we can set up a working dev environment based on wsl & the intellij idea ultimate edition ide.
for now the rancid plugin is a simple project to experiment with (also has working tests) https://github.com/netdisco/nd2-web-plugin-rancid/
-
windows 10 x64 version 1903
-
a wsl distribution, opensuse leap 15 or debian are recommended
-
intellij idea ultimate edition 2019.2
this is as basic as opening the windows store app, searching for either debian or opensuse leap 15 and clicking install. when the app is installed just start it up and input a username and password.
for opensuse you will need to install several extra modules, this can be done with the following commands:
zypper in --no-recommends make gcc lsof postgresql expect libopenssl-devel postgresql10-devel postgresql-server rsync zsh expat libexpat-devel zypper in --no-recommends perl-SNMP perl-local-lib perl-Module-Build git zypper in --no-recommends graphviz graphviz-devel graphviz-gd graphviz-plugins-core zypper rm command-not-found
intellij idea ultimate has several options to select perl versions. namely
-
system native perl
-
perlbrew
-
plenv
docker support or windows native support are also options but not in scope here.
i found plenv the easiest and most versatile option. it has a small codebase, is active and has no problems with mixing compiled code & perl. the biggest downside is that local::lib support is subpar.
to install (see https://github.com/tokuhirom/plenv#basic-github-checkout):
git clone https://github.com/tokuhirom/plenv.git ~/.plenv git clone https://github.com/tokuhirom/Perl-Build.git ~/.plenv/plugins/perl-build/
this has now installed the plenv package manager and a build system to install perl versions.
next you need to set up your environment. the plenv webpage explains this too, and configurations depends on your shell choice (mine is zsh). for this example we’ll use the standard bash setup.
echo 'export PATH="$HOME/.plenv/bin:$PATH"' >> ~/.bash_profile echo 'eval "$(plenv init -)"' >> ~/.bash_profile
now close the wsl app and restart it, this will initialize the variables you need.
now let’s install a perl version and set it as the default for our user:
plenv install 5.28.2 plenv global 5.28.2 plenv install-cpanm
cpanm is also set up now so you can install modules without issue. these should cover most dev needs.
cpanm -n Module::Build Expect Dancer::Plugin::Swagger Test::More cpanm -n Term::ANSIColor App::local::lib::helper AnyEvent::DNS::EtcHosts cpanm -n Net::OpenSSH Net::LDAP Pod::Usage ExtUtils::InstallPaths ExtUtils::Helpers ExtUtils::Config cpanm -n Test::Class::Most Test::Distribution Test::Exception Test::MockObject::Extends cpanm -n Class::Inspector File::Slurper Module::Find Path::Class cpanm -n Class::ISA File::Slurp Module::Info Module::Load PPI Math::BigInt NetAddr::IP cpanm -n Env::Path Test::Compile Graph GraphViz Test::Perl::Critic cpanm -n Bundle::Camelcade
net-snmp’s perl modules are one of the hardest things to get working, but at this point we need the perl modules to continue.
while not elegant, it can be done with plenv:
-
installed in my homedir
-
linked to the perl version i set with plenv
-
make the actual modules also work
we’re disabling most of the net-snmp functions, the goal is to get working snmp-cmd tools and perl modules, don’t use this as your system snmpd.
first make sure your plenv is good to go. running perl -V should show a lot of include dirs in your home directory. download net-snmp-5.8 and extract it. then use the following configure arguments. do make sure --prefix is set to somewhere useful.
./configure --disable-snmptrapd-subagent --disable-debugging --disable-agent --disable-mibs --with-sys-contact=root@localhost --with-sys-contact=root@localhost --with-ldflags="-Wl,-z,relro -Wl,-z,now" --with-perl-modules=verbose --enable-shared --disable-static --disable-embedded-perl --prefix=/home/user2448/local
just press enter on all the questions, then run "make" followed by "make install"
this will install the perl snmp modules & shared libraries under your .plenv environment, however the rest of the net-snmp binaries will be placed under what you used for --prefix. what all this means is that you can use plenv to get net-snmp to work with different perl verions, but the net-snmp version must remain the same.
do remember that for this to work you need to add whatever local path you installed in to your $PATH for the binaries to work. even more important is that the library path to your local snmp install is known, this can be done with ldconfig or $LD_LIBRARY_PATH.
make sure to download the ultimate edition since it’s the only one with wsl support. this is not a free product however. there are 3 options here:
-
buy a license
-
apply for an opensource license. both netdisco & snmp::info have been approved by jetbrains, but certain terms apply.
-
use the early access version, this will send basic usage metrics to jetbrains and needs to be updated monthly.
perl5 support is provided through the Camelcade Perl5-IDEA project. you will need to install the following plugins through the plugin manager:
-
Perl (Version 2019.2.1 or higher)
-
Perl WSL Support (Version 2019.2.1 or higher)
-
Template Toolkit Support (Version 2019.2.1 or higher)
-
MIB support (not required, only for working with mibs)
in the intellij settings menu, go to:
-
languages & frameworks
-
perl5
-
add a new perl5 interpreter as wsl. select the plenv option. next you will need to choose your wsl distro (multiple are supported at the same time), finally you will get a choice of perl versions you installed with plenv.
this should show somewhat like this: "Wsl[opensuse15], Plenv[5.28.2]: Perl 5.28.2"
the system will then index all the perl modules you have installled in that plenv environment, nothing more is required.
netdisco will run under wsl, but not easily or with any support!
it can however be used to poll a few devices to actually test your code.
to get started i would advise to install netdisco in the wsl environment (with plenv working!)
cpanm -n App::Netdisco
since this is a bad idea i’ll list the steps but will leave it up to the reader to actually figure them out.
-
get your postgresql server running, either on your wsl instance (remember no systemd support in wsl) or somewhere remote
-
create a directory for netdisco, ~/nd2 is a decent option
-
set your NETDISCO_HOME env to that directory
-
! plenv & local::lib don’t play nice, working on getting netdisco accept plenv
-
git clone https://github.com/miyagawa/plenv-contrib.git ~/.plenv/plugins/plenv-contrib/
-
add the required dirs & files (deployment, bin dir, link to perl install)
-
use "plenv lib" to set up a local::lib instance, then use "plenv use" to switch to it
-
now your normal netdisco commands will run just like you’re used to
-
- Home
- Installation ⇗
- Configuration ⚙
- API
- Hooks
- Cookbook
- Troubleshooting
- Install Tips
- Vendor Tips
- Database Tips
- Custom Reports
- Release Notes
- Docker Images ⇗
- Commercial Support