TT#23774 remove Moose completely

and clean up the dependencies by throwing out libraries we
don't use

Change-Id: Ia88a9d9f9d6744178ee382fb4a2311c1608cef32
changes/53/16353/3
Gerhard Jungwirth 8 years ago
parent 37939b5ca1
commit 824bb3102b

@ -16,11 +16,6 @@ my $builder = Module::Build->new(
'DBIx::Class::Schema::Loader' => 0,
'File::Path' => 0,
'Getopt::Long' => 0,
'MooseX::ClassAttribute' => 0,
'MooseX::NonMoose' => 0,
'MooseX::Singleton' => 0,
'MooseX::Types::Path::Class' => 0,
'namespace::sweep' => 0,
'Quantum::Superpositions' => 0,
'Pod::Usage' => 0,
'Regexp::Common' => 0,

18
debian/control vendored

@ -18,13 +18,7 @@ Build-Depends:
libgetopt-long-descriptive-perl,
libgtk2-gladexml-simple-perl,
libhash-storediterator-perl,
liblog-log4perl-perl,
libmodule-build-perl,
libmoosex-classattribute-perl,
libmoosex-nonmoose-perl,
libmoosex-singleton-perl,
libmoosex-types-path-class-perl,
libnamespace-sweep-perl,
libquantum-superpositions-perl,
libregexp-common-email-address-perl,
libregexp-common-net-cidr-perl,
@ -35,11 +29,8 @@ Build-Depends:
libtemplate-plugin-xml-perl,
libtest-fatal-perl,
libtest-xml-simple-perl,
libthrowable-perl,
libxml-libxml-simple-perl,
libxml-simple-perl,
libxml-simpleobject-libxml-perl,
libxml-simpleobject-perl,
perl-doc,
Standards-Version: 3.9.8
Homepage: https://www.sipwise.com/
@ -61,12 +52,6 @@ Depends:
libgetopt-long-descriptive-perl,
libgtk2-gladexml-simple-perl,
libhash-storediterator-perl,
liblog-log4perl-perl,
libmoosex-classattribute-perl,
libmoosex-nonmoose-perl,
libmoosex-singleton-perl,
libmoosex-types-path-class-perl,
libnamespace-sweep-perl,
libparse-debianchangelog-perl,
libquantum-superpositions-perl,
libregexp-common-email-address-perl,
@ -78,11 +63,8 @@ Depends:
libtemplate-plugin-xml-perl,
libtest-fatal-perl,
libtest-xml-simple-perl,
libthrowable-perl,
libxml-libxml-simple-perl,
libxml-simple-perl,
libxml-simpleobject-libxml-perl,
libxml-simpleobject-perl,
perl-doc,
${misc:Depends},
${perl:Depends},

@ -1,13 +1,16 @@
package NGCP::InterceptSchema;
use Moose;
extends 'NGCP::Schema';
use warnings;
use strict;
use base 'NGCP::Schema';
our $VERSION = '2.007';
sub connection {
my ($self) = @_;
$self->SUPER::connection($self->config->as_hash->{ngcp_intercept_connect_info});
my $full_config = NGCP::Schema::Config::get_config_hash();
$self->SUPER::connection($full_config->{ngcp_intercept_connect_info});
}
no Moose;
1;

@ -1,12 +1,10 @@
package NGCP::Schema;
use Sipwise::Base;
use aliased 'NGCP::Schema::Exception';
use NGCP::Schema::Config qw();
use Regexp::Common qw(net);
use Regexp::IPv6 qw($IPv6_re);
use Moose;
use MooseX::ClassAttribute qw(class_has);
extends 'DBIx::Class::Schema';
use base 'DBIx::Class::Schema';
our $VERSION = '2.007';
@ -17,45 +15,36 @@ __PACKAGE__->load_namespaces(
use DBIx::Class::Storage::DBI;
DBIx::Class::Storage::DBI->datetime_parser_type('NGCP::Schema::Storage::DateTime::Format::MySQL');
class_has('config', is => 'rw', isa => 'NGCP::Schema::Config', lazy => 1, default => sub {
return NGCP::Schema::Config->instance;
});
sub connection {
my ($self, $cfg) = @_;
my $config_file_name;
if ($cfg->{config_file}) {
$self->config->config_file($cfg->{config_file});
$config_file_name = $cfg->{config_file};
} else {
$config_file_name = NGCP::Schema::Config::get_config_filename();
}
unless(defined $cfg->{dsn}) {
$cfg = $self->config->as_hash->{ngcp_connect_info};
my $full_config = NGCP::Schema::Config::get_config_hash($config_file_name);
$cfg = $full_config->{ngcp_connect_info};
}
$self->SUPER::connection($cfg);
}
sub validate {
my ($self, $data, $mandatory_params, $optional_params) = @_;
Exception->throw({
description => 'Client.Syntax.MissingParam',
message => q(missing parameter 'data'),
}) unless defined $data;
Exception->throw({
description => 'Client.Syntax.MalformedParam',
message => q(parameter 'data' should be an object/hash, but is '%s')->sprintf(ref $data)
}) unless defined eval { %$data };
die q(missing parameter 'data')
unless defined $data;
die q(parameter 'data' should be an object/hash, but is '%s')->sprintf(ref $data)
unless defined eval { %$data };
my %check_data = %$data;
for my $param (@$mandatory_params) {
Exception->throw({
description => 'Client.Syntax.MissingParam',
message => "missing parameter '$param' in request"
}) unless exists $check_data{$param};
die "missing parameter '$param' in request"
unless exists $check_data{$param};
delete $check_data{$param};
}
foreach my $key (keys %check_data) {
next if grep { $key eq $_ } @$optional_params;
Exception->throw({
description => 'Client.Syntax.UnknownParam',
message => "unknown parameter '$key'",
});
die "unknown parameter '$key'";
}
return;
}
@ -65,7 +54,7 @@ sub check_domain {
$self->validate($data, ['domain']);
my $domain = $data->{domain};
return 1 if $domain =~ /^(?:[a-z0-9]+(?:-[a-z0-9]+)*\.)+[a-z]+$/i;
return 1 if $self->config->as_hash->{allow_ip_as_domain}
return 1 if NGCP::Schema::Config::get_config_hash->{allow_ip_as_domain}
and ($self->check_ip4({ip4 => $domain}) || $self->check_ip6_brackets({ip6brackets => $domain}));
return;
}
@ -99,8 +88,6 @@ sub _check_ip_generic {
return;
}
__PACKAGE__->meta->make_immutable;
no Moose;
1;
__END__
@ -111,10 +98,6 @@ __END__
NGCP::Schema - DBIC-derived ORM schema classes
=head1 VERSION
This document describes NGCP::Schema version 2.007
=head1 SYNOPSIS
use NGCP::Schema::accounting;
@ -153,15 +136,11 @@ Version 2 moves the result classes of all tables into one namespace. This means
This is solved by prefixing the result class name I<on the right-hand side only> with the database name and an
underscore, e.g. table C<provisioning.voip_subscribers> becomes the result class <provisioning_voip_subscribers>.
=head1 BUGS AND LIMITATIONS
L<https://bugtracker.sipwise.com>
=head1 AUTHOR
Lars Dieckow C<< <ldieckow@sipwise.com> >>
Sipwise Development Team C<< <support@sipwise.com> >>
=head1 LICENCE
=head1 LICENSE
This software is Copyright © 2013 by Sipwise GmbH, Austria.

@ -1,35 +1,26 @@
package NGCP::Schema::Config;
use Sipwise::Base;
use Log::Log4perl qw();
use MooseX::Types::Path::Class qw(File);
use MooseX::Singleton qw(has);
use XML::Simple qw();
our $VERSION = '2.007';
has 'config_file' => (
is => 'rw',
isa => File,
required => 1,
coerce => 1,
default => '/etc/ngcp-panel/provisioning.conf'
);
has('as_hash', isa => 'HashRef', is => 'rw', lazy => 1, default => sub {
my ($self) = @_;
return $self->check_config(XML::Simple->new->XMLin($self->config_file->stringify, ForceArray => 0));
});
sub BUILD {
my ($self) = @_;
die q(can't find config file %s)->sprintf($self->config_file)
unless -e $self->config_file;
Log::Log4perl->init_once($self->config->{logconf});
Log::Log4perl->get_logger($self)->info('using config file "%s"'->sprintf($self->config_file));
my $_config;
sub get_config_filename {
return '/etc/ngcp-panel/provisioning.conf';
}
sub get_config_hash {
my ($config_file) = @_;
$config_file //= get_config_filename;
unless ($_config) {
my $tmp_config = XML::Simple->new->XMLin($config_file, ForceArray => 0);
$_config = check_config($tmp_config);
}
return $_config;
}
sub check_config {
my ($self, $config) = @_;
my ($config) = @_;
$config->{vsc}{actions} = [$config->{vsc}{actions}]
if defined $config->{vsc}
and defined $config->{vsc}{actions}
@ -51,7 +42,7 @@ sub check_config {
return $config;
}
__PACKAGE__->meta->make_immutable;
1;
__END__
@ -61,76 +52,22 @@ __END__
NGCP::Schema::Config - configuration class
=head1 VERSION
This document describes NGCP::Schema::Config version 2.007
=head1 SYNOPSIS
use NGCP::Schema::Config qw();
my $c_hashref = NGCP::Schema::Config->new;
my $c_hashref = NGCP::Schema::Config::get_config_hash();
=head1 DESCRIPTION
Reads a configuration file, initialises the logger, provides configuration as structured data.
=head1 INTERFACE
=head2 Attributes
=head3 C<config_file>
Type C<MooseX::Types::Path::Class>, B<required> attribute, location of the configuration file. Default is
C</etc/ngcp-panel/provisioning.conf>.
=head3 C<config>
Type C<HashRef>, supplies configuration from the L</config_file>.
=head2 Methods
=head3 C<check_config>
Takes hashref as just parsed by the configuration file reader and makes sure it is formatted correctly. At the moment,
it only ensures that arrays are arrays even if there is only one member.
=head1 DIAGNOSTICS
=over
=item C<can't find config file %s>
The configuration file does not exist.
=back
=head1 CONFIGURATION AND ENVIRONMENT
See L</config_file>.
The meaning of the configuration items are detailed in the manual.
=head1 DEPENDENCIES
See meta file in the source distribution.
=head1 INCOMPATIBILITIES
None reported.
=head1 BUGS AND LIMITATIONS
L<https://bugtracker.sipwise.com>
No known limitations.
Reads a configuration file, provides configuration as structured data.
=head1 AUTHOR
Lars Dieckow C<< <ldieckow@sipwise.com> >>
Sipwise Development Team C<< <support@sipwise.com> >>
=head1 LICENCE
=head1 LICENSE
This software is Copyright © 2013 by Sipwise GmbH, Austria.
This software is Copyright © 2017 by Sipwise GmbH, Austria.
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public

@ -1,118 +0,0 @@
package NGCP::Schema::Exception;
use Sipwise::Base;
use Moose;
our $VERSION = '2.007';
extends 'Throwable::Error';
has('description', is => 'ro', isa => 'Str', required => 1);
has('context', is => 'ro', isa => 'HashRef', documentation => 'extra data to pass along');
no Moose;
__PACKAGE__->meta->make_immutable(inline_constructor => 0);
__END__
=encoding UTF-8
=head1 NAME
NGCP::Schema::Exception - exceptions that work like ossbss mydie
=head1 VERSION
This document describes NGCP::Schema::Exception version 2.007
=head1 SYNOPSIS
use aliased 'NGCP::Schema::Exception';
Exception->throw({
description => 'Client.Auth.Failed',
message => 'authentication failed',
});
=head1 DESCRIPTION
This is a stop-gap measure to port ossbss code.
=head1 INTERFACE
=head2 Composition
NGCP::Schema::Exception
ISA Throwable::Error
All methods and attributes not mentioned here are inherited from L<Throwable::Error>.
=head2 Attributes
=head3 C<description>
Type C<Str>, B<required> attribute, designates the ossbss error type.
=head3 C<context>
Type C<HashRef>, extra data to pass along to the error handler.
=head2 Exports
None.
=head1 DIAGNOSTICS
None.
=head1 CONFIGURATION AND ENVIRONMENT
NGCP::Schema::Exception requires no configuration files or environment variables.
=head1 DEPENDENCIES
See meta file in the source distribution.
=head1 INCOMPATIBILITIES
None reported.
=head1 BUGS AND LIMITATIONS
L<https://bugtracker.sipwise.com>
No known limitations.
=head1 TO DO
This becomes obsolete with a hierarchy of exception classes.
=head1 SEE ALSO
L<Sipwise::Provisioning/mydie>
=head1 AUTHOR
Lars Dieckow C<< <ldieckow@sipwise.com> >>
=head1 LICENCE
This software is Copyright © 2013 by Sipwise GmbH, Austria.
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public
License along with this package; if not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301 USA
On Debian systems, the full text of the GNU General Public
License version 3 can be found in the file
F</usr/share/common-licenses/GPL-3>.

@ -1,6 +1,7 @@
package NGCP::Schema::Storage::DateTime::Format::MySQL;
use strict;
use warnings;
use vars qw ($VERSION);

Loading…
Cancel
Save