Skip to content

Commit

Permalink
Merge pull request #1318 from GlobalNOC/2.0.12-dev
Browse files Browse the repository at this point in the history
2.0.12
  • Loading branch information
jonstout authored Aug 4, 2021
2 parents d844d59 + 6479cdb commit ade1291
Show file tree
Hide file tree
Showing 102 changed files with 7,910 additions and 1,336 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MYSQL_PASSWORD=
OESS_PASSWORD=
OESS_NETWORK_TYPE=vpn-mpls
NSO_HOST=
NSO_PASSWORD=
NSO_USERNAME=
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ perl-lib/OESS/lib/OESS/pod2htmd.tmp
perl-lib/OESS/lib/OESS/pod2htmi.tmp
perl-lib/OESS/lib/OESS/t/conf/database.xml
frontend/.htpasswd
*.DS_Store
.env
26 changes: 26 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM centos:7

COPY globalnoc-public-el7.repo /etc/yum.repos.d/globalnoc-public-el7.repo
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | bash
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | bash

RUN yum makecache
RUN yum -y install epel-release
RUN yum -y install perl httpd mariadb-server rabbitmq-server
RUN yum -y install perl-Carp-Always perl-Test-Deep perl-Test-Exception perl-Test-Pod perl-Test-Pod-Coverage perl-Devel-Cover perl-Net-AMQP-RabbitMQ perl-LWP-Protocol-https perl-AnyEvent-HTTP
RUN yum -y install perl-OESS oess-core oess-frontend yui2

COPY app/mpls/mpls_discovery.pl /usr/bin/mpls_discovery.pl
COPY app/mpls/mpls_fwdctl.pl /usr/bin/mpls_fwdctl.pl

COPY frontend/conf/oe-ss.conf.example /etc/httpd/conf.d/oe-ss.conf
COPY app/etc/firmware.xml /etc/oess/firmware.xml
COPY perl-lib/OESS/t/conf/database.xml /etc/oess/database.xml
COPY perl-lib/OESS/t/conf/logging.conf /etc/oess/logging.conf
COPY perl-lib/OESS/t/conf/passwd.xml /etc/oess/.passwd.xml

COPY perl-lib/OESS/entrypoint.dev.sh /entrypoint.sh
RUN chmod 777 /entrypoint.sh

RUN touch /var/log/oess.log
RUN chmod 666 /var/log/oess.log
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
OESS_VERSION=2.0.11
OESS_NETWORK=oess

container:
docker build -f Dockerfile.dev --tag oess:${OESS_VERSION} .
dev:
docker run -it \
--env-file .env \
--publish 8000:80 \
--publish 5672:5672 \
--network ${OESS_NETWORK} \
--mount type=bind,src=${PWD}/perl-lib/OESS/lib/OESS,dst=/usr/share/perl5/vendor_perl/OESS \
--mount type=bind,src=${PWD}/frontend,dst=/usr/share/oess-frontend \
--mount type=bind,src=${PWD}/perl-lib/OESS/share,dst=/usr/share/doc/perl-OESS-${OESS_VERSION}/share \
oess:${OESS_VERSION} /bin/bash
2 changes: 1 addition & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME= oess-core
VERSION = 2.0.11
VERSION = 2.0.12

rpm: dist
rpmbuild -ta dist/$(NAME)-$(VERSION).tar.gz
Expand Down
2 changes: 2 additions & 0 deletions app/etc/firmware.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
<version make="junos" model="mx960" number="15.1F6-S6.4" />
<version make="junos" model="mx960" number="15.1F6-S7.2" />
<version make="junos" model="mx960" number="15.1I20171208_1648_amahale" />
<version make="junos" model="mx960" number="17.3R3.10" />
<version make="junos" model="mx960" number="17.3R3-S7.2" />
</firmware>
49 changes: 45 additions & 4 deletions app/mpls/mpls_discovery.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,57 @@
use Proc::Daemon;
use Data::Dumper;

use OESS::Database;
use GRNOC::WebService::Client;

use OESS::Config;
use OESS::MPLS::Discovery;
use OESS::NSO::Client;
use OESS::NSO::Discovery;

my $pid_file = "/var/run/oess/mpls_discovery.pid";
my $cnf_file = "/etc/oess/database.xml";

sub core{
#basic init stuffs
Log::Log4perl::init_and_watch('/etc/oess/logging.conf',10);
Log::Log4perl::init_and_watch('/etc/oess/logging.conf', 10);

my $config = new OESS::Config(config_filename => $cnf_file);
my $mpls_discovery;
my $nso_discovery;
my $nso_client = new OESS::NSO::Client(config_obj => $config);
my $tsds_client = new GRNOC::WebService::Client(
url => $config->tsds_url . "/push.cgi",
uid => $config->tsds_username,
passwd => $config->tsds_password,
realm => $config->tsds_realm,
usePost => 1
);

if ($config->network_type eq 'nso') {
my $nso_discovery = OESS::NSO::Discovery->new(
config_obj => $config,
nso => $nso_client,
tsds => $tsds_client
);
$nso_discovery->start;
}
elsif ($config->network_type eq 'vpn-mpls' || $config->network_type eq 'evpn-vxlan') {
$mpls_discovery = OESS::MPLS::Discovery->new(config_obj => $config);
}
elsif ($config->network_type eq 'nso+vpn-mpls') {
$nso_discovery = OESS::NSO::Discovery->new(
config_obj => $config,
nso => $nso_client,
tsds => $tsds_client
);
$nso_discovery->start;

$mpls_discovery = OESS::MPLS::Discovery->new(config_obj => $config);
}
else {
die "Unexpected network type configured.";
}

my $discovery = OESS::MPLS::Discovery->new();
Log::Log4perl->get_logger('OESS.MPLS.Discovery.APP')->info("Starting OESS.MPLS.Discovery event loop.");
AnyEvent->condvar->recv;
}

Expand Down
42 changes: 35 additions & 7 deletions app/mpls/mpls_fwdctl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
use strict;
use warnings;

use OESS::Config;
use OESS::MPLS::FWDCTL;
use OESS::NSO::FWDCTLService;

use English;
use Data::Dumper;
Expand All @@ -12,6 +14,7 @@
use XML::Simple;

my $pid_file = "/var/run/oess/mpls_fwdctl.pid";
my $cnf_file = "/etc/oess/database.xml";

sub get_diff_interval{
eval {
Expand All @@ -27,11 +30,36 @@ sub get_diff_interval{
sub core{
Log::Log4perl::init_and_watch('/etc/oess/logging.conf', 10);

my $FWDCTL = OESS::MPLS::FWDCTL->new();
my $reaper = AnyEvent->timer( after => 3600, interval => 3600, cb => sub { $FWDCTL->reap_old_events() } );
my $status = AnyEvent->timer( after => 10, interval => 60, cb => sub { $FWDCTL->save_mpls_nodes_status() } );
my $differ = AnyEvent->timer( after => 5, interval => get_diff_interval(), cb => sub { $FWDCTL->diff() } );

my $config = new OESS::Config(config_filename => $cnf_file);
my $mpls_fwdctl;
my $mpls_reaper;
my $mpls_status;
my $mpls_differ;
my $nso_fwdctl;

if ($config->network_type eq 'nso') {
$nso_fwdctl = OESS::NSO::FWDCTLService->new(config_obj => $config);
$nso_fwdctl->start;
}
elsif ($config->network_type eq 'vpn-mpls' || $config->network_type eq 'evpn-vxlan') {
$mpls_fwdctl = OESS::MPLS::FWDCTL->new(config_obj => $config);
$mpls_reaper = AnyEvent->timer( after => 3600, interval => 3600, cb => sub { $mpls_fwdctl->reap_old_events() } );
$mpls_status = AnyEvent->timer( after => 10, interval => 60, cb => sub { $mpls_fwdctl->save_mpls_nodes_status() } );
$mpls_differ = AnyEvent->timer( after => 15, interval => get_diff_interval(), cb => sub { $mpls_fwdctl->diff() } );
}
elsif ($config->network_type eq 'nso+vpn-mpls') {
$nso_fwdctl = OESS::NSO::FWDCTLService->new(config_obj => $config);
$nso_fwdctl->start;

$mpls_fwdctl = OESS::MPLS::FWDCTL->new(config_obj => $config);
$mpls_reaper = AnyEvent->timer( after => 3600, interval => 3600, cb => sub { $mpls_fwdctl->reap_old_events() } );
$mpls_status = AnyEvent->timer( after => 10, interval => 60, cb => sub { $mpls_fwdctl->save_mpls_nodes_status() } );
$mpls_differ = AnyEvent->timer( after => 15, interval => get_diff_interval(), cb => sub { $mpls_fwdctl->diff() } );
}
else {
die "Unexpected network type configured.";
}

Log::Log4perl->get_logger('OESS.MPLS.FWDCTL.APP')->info("Starting OESS.MPLS.FWDCTL event loop.");
AnyEvent->condvar->recv;
}
Expand All @@ -42,8 +70,8 @@ sub main{
my $username;
#remove the ready file

# This directory is auto-removed on reboot. Create the directory
# if not already created.
# This directory is auto-removed on reboot. Create the directory if not
# already created. This is used to store connection cache files.
if (!-d "/var/run/oess/") {
`/usr/bin/mkdir /var/run/oess`;
`/usr/bin/chown _oess:_oess /var/run/oess`;
Expand Down
104 changes: 104 additions & 0 deletions app/nso/nso_discovery.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/perl

use strict;
use warnings;

use AnyEvent;
use English;
use Getopt::Long;
use Proc::Daemon;

use OESS::Config;
use OESS::NSO::Discovery;

my $pid_file = "/var/run/oess/nso_discovery.pid";
my $cnf_file = "/etc/oess/database.xml";

sub core{
Log::Log4perl::init_and_watch('/etc/oess/logging.conf', 10);

my $config = new OESS::Config(config_filename => $cnf_file);
if ($config->network_type eq 'nso') {
my $discovery = new OESS::NSO::Discovery(config_obj => $config);
$discovery->start;
AnyEvent->condvar->recv;
} else {
die "Unexpected network type configured.";
}

Log::Log4perl->get_logger('OESS.NSO.Discovery.APP')->info("Starting OESS.NSO.Discovery event loop.");
}

sub main{
my $is_daemon = 0;
my $verbose;
my $username;
#remove the ready file

#--- see if the pid file exists. if not then just continue running.
if(-e $pid_file){
#--- read the file to get the PID
my $pid = `head -n 1 $pid_file`;
chomp $pid;

my $run_test = `ps -p $pid | grep $pid`;

#--- if run test is empty then the pid didn't exist. If it isn't empty then the process is already running.
if($run_test){
print "Found $0 process: $pid already running. Aborting.\n";
exit(0);
}
else{
print "Pid File: $pid_file already exists but it looks like process $pid is dead. Continuing startup.\n";
}
}

my $result = GetOptions (
"user|u=s" => \$username,
"verbose" => \$verbose,
"daemon|d" => \$is_daemon,
);

#now change username/
if (defined $username) {
my $new_uid=getpwnam($username);
my $new_gid=getgrnam($username);
$EGID=$new_gid;
$EUID=$new_uid;
}

if ($is_daemon != 0) {
my $daemon;
if ($verbose) {
$daemon = Proc::Daemon->new(
pid_file => $pid_file,
child_STDOUT => '/var/log/oess/nso_discovery.out',
child_STDERR => '/var/log/oess/nso_discovery.log',
);
} else {
$daemon = Proc::Daemon->new(pid_file => $pid_file);
}

# Init returns the PID (scalar) of the daemon to the parent, or
# the PIDs (array) of the daemons created if exec_command has
# more then one program to execute.
#
# Init returns 0 to the child (daemon).
my $kid_pid = $daemon->Init;
if ($kid_pid) {
`chmod 0644 $pid_file`; # How to wait until the child process is ready.
return;
} else {
core();
}
}
#not a daemon, just run the core;
else {
$SIG{HUP} = sub{ exit(0); };
core();
}
}

main();

1;
Loading

0 comments on commit ade1291

Please sign in to comment.