db connect info from config file

agranig/2.004-ramoptimized
Lars Dieckow 12 years ago
parent dda73c0c8b
commit bf7bff193f

@ -9,8 +9,10 @@ my $builder = Module::Build->new(
'DBIx::Class::Schema::Loader' => 0,
'File::Path' => 0,
'Getopt::Long' => 0,
'MooseX::ClassAttribute' => 0,
'MooseX::FileAttribute' => 0,
'MooseX::NonMoose' => 0,
'MooseX::Singleton' => 0,
'namespace::sweep' => 0,
'Quantum::Superpositions' => 0,
'Pod::Usage' => 0,

@ -7,7 +7,9 @@ use Regexp::IPv6 qw($IPv6_re);
our $VERSION = '1.000';
has('config', is => 'rw', lazy => 1, default => sub { NGCP::Schema::Config->new->config });
has('config', is => 'rw', isa => 'NGCP::Schema::Config', lazy => 1, default => sub {
return NGCP::Schema::Config->instance;
});
method validate($data, $mandatory_params, $optional_params?) {
Exception->throw({
@ -40,7 +42,7 @@ method check_domain($data) {
$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->config->{allow_ip_as_domain}
return 1 if $self->config->as_hash->{allow_ip_as_domain}
and ($self->check_ip4({ip4 => $domain}) || $self->check_ip6_brackets({ip6brackets => $domain}));
return;
}

@ -2,12 +2,13 @@ package NGCP::Schema::Config;
use Sipwise::Base;
use Log::Log4perl qw();
use MooseX::FileAttribute qw(has_file);
use MooseX::Singleton qw(has);
use XML::Simple qw();
our $VERSION = '1.000';
has_file('config_file', is => 'rw', required => 1, default => '/etc/ngcp-ossbss/provisioning.conf');
has('config', isa => 'HashRef', is => 'rw', lazy => 1, default => method {
has('as_hash', isa => 'HashRef', is => 'rw', lazy => 1, default => method {
return $self->check_config(XML::Simple->new->XMLin($self->config_file->stringify, ForceArray => 0));
});

@ -13,7 +13,15 @@ __PACKAGE__->load_namespaces;
# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-04-09 12:30:37
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/gINj3OenRQkhpdpfbQq4Q
use MooseX::ClassAttribute qw(class_has);
class_has('config', is => 'rw', isa => 'NGCP::Schema::Config', lazy => 1, default => sub {
return NGCP::Schema::Config->instance;
});
method connection {
my %connect_info = %{ $self->config->as_hash->{accountingdb} };
$self->SUPER::connection(@connect_info{qw(dsn username password)});
}
# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable(inline_constructor => 0);
1;

@ -13,15 +13,24 @@ __PACKAGE__->load_namespaces;
# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-04-09 12:33:44
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pFNyB1lQTWbvEckC6oqjJw
use MooseX::ClassAttribute qw(class_has);
use NGCP::Schema qw();
use NGCP::Schema::provisioning qw();
use aliased 'NGCP::Schema::Exception';
class_has('config', is => 'rw', isa => 'NGCP::Schema::Config', lazy => 1, default => sub {
return NGCP::Schema::Config->instance;
});
has('validator', is => 'rw', isa => 'NGCP::Schema', lazy => 1, default => sub { return NGCP::Schema->new; });
has('provisioning', is => 'rw', isa => 'NGCP::Schema::provisioning', lazy => 1, default => sub {
return NGCP::Schema::provisioning->connect;
});
method connection {
my %connect_info = %{ $self->config->as_hash->{billingdb} };
$self->SUPER::connection(@connect_info{qw(dsn username password)});
}
method get_domain($reseller_id, $domain) {
my %return;
$return{domain} = $domain;

@ -13,7 +13,15 @@ __PACKAGE__->load_namespaces;
# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-04-09 12:33:48
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2tiLLQMoqYYiicae6bptbA
use MooseX::ClassAttribute qw(class_has);
class_has('config', is => 'rw', isa => 'NGCP::Schema::Config', lazy => 1, default => sub {
return NGCP::Schema::Config->instance;
});
method connection {
my %connect_info = %{ $self->config->as_hash->{carrierdb} };
$self->SUPER::connection(@connect_info{qw(dsn username password)});
}
# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable(inline_constructor => 0);
1;

@ -13,7 +13,15 @@ __PACKAGE__->load_namespaces;
# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-04-09 12:33:56
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:F+YCA+y1IL8DMrefBOhpIg
use MooseX::ClassAttribute qw(class_has);
class_has('config', is => 'rw', isa => 'NGCP::Schema::Config', lazy => 1, default => sub {
return NGCP::Schema::Config->instance;
});
method connection {
my %connect_info = %{ $self->config->as_hash->{kamailiodb} };
$self->SUPER::connection(@connect_info{qw(dsn username password)});
}
# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable(inline_constructor => 0);
1;

@ -13,7 +13,15 @@ __PACKAGE__->load_namespaces;
# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-04-09 12:33:59
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:P/HNiALDBrupRVTapqCHkg
use MooseX::ClassAttribute qw(class_has);
class_has('config', is => 'rw', isa => 'NGCP::Schema::Config', lazy => 1, default => sub {
return NGCP::Schema::Config->instance;
});
method connection {
my %connect_info = %{ $self->config->as_hash->{ngcpdb} };
$self->SUPER::connection(@connect_info{qw(dsn username password)});
}
# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable(inline_constructor => 0);
1;

@ -13,11 +13,20 @@ __PACKAGE__->load_namespaces;
# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-04-09 12:34:07
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9CSthIxIDhU92F42rZZoQQ
use MooseX::ClassAttribute qw(class_has);
use NGCP::Schema qw();
use aliased 'NGCP::Schema::Exception';
class_has('config', is => 'rw', isa => 'NGCP::Schema::Config', lazy => 1, default => sub {
return NGCP::Schema::Config->instance;
});
has('validator', is => 'rw', isa => 'NGCP::Schema', lazy => 1, default => sub { return NGCP::Schema->new; });
method connection {
my %connect_info = %{ $self->config->as_hash->{provisioningdb} };
$self->SUPER::connection(@connect_info{qw(dsn username password)});
}
method _get_domain_id($domain) {
my $domainid;
try {

@ -13,7 +13,15 @@ __PACKAGE__->load_namespaces;
# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-04-09 12:34:11
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Uqcm6asjrNcv63rMCeWfiQ
use MooseX::ClassAttribute qw(class_has);
class_has('config', is => 'rw', isa => 'NGCP::Schema::Config', lazy => 1, default => sub {
return NGCP::Schema::Config->instance;
});
method connection {
my %connect_info = %{ $self->config->as_hash->{sipstatsdb} };
$self->SUPER::connection(@connect_info{qw(dsn username password)});
}
# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable(inline_constructor => 0);
1;

Loading…
Cancel
Save