REPOID=`./repoid.pl .git`
SERVICES = pmgdaemon pmgproxy
-CLITOOLS = proxdb
+CLITOOLS = pmgdb
CLI_CLASSES = $(addprefix, 'PMG/API2/', $(addsuffix '.pm', ${CLITOOLS}))
CLI_BINARIES = $(addprefix, 'bin/', ${CLITOOLS})
PMG/Ticket.pm \
PMG/AccessControl.pm \
PMG/DBTools.pm \
- PMG/CLI/proxdb.pm \
+ PMG/CLI/pmgdb.pm \
${CLI_CLASSES} \
PMG/API2/Network.pm \
PMG/API2/Services.pm \
--- /dev/null
+package PMG::CLI::pmgdb;
+
+use strict;
+use warnings;
+use Data::Dumper;
+
+use PVE::SafeSyslog;
+use PVE::Tools qw(extract_param);
+use PVE::INotify;
+
+use PMG::DBTools;
+
+use base qw(PVE::CLIHandler);
+
+my $nodename = PVE::INotify::nodename();
+
+__PACKAGE__->register_method ({
+ name => 'dump',
+ path => 'dump',
+ method => 'GET',
+ description => "Print the PMG rule database.",
+ parameters => {
+ additionalProperties => 0,
+ },
+ returns => { type => 'null'},
+ code => sub {
+ my ($param) = @_;
+
+ print "DUMP\n";
+
+ return undef;
+ }});
+
+
+__PACKAGE__->register_method ({
+ name => 'delete',
+ path => 'delete',
+ method => 'DELETE',
+ description => "Delete PMG rule database.",
+ parameters => {
+ additionalProperties => 0,
+ },
+ returns => { type => 'null'},
+ code => sub {
+ my ($param) = @_;
+
+ my $list = PMG::DBTools::database_list();
+
+ my $dbname = "Proxmox_ruledb";
+
+ die "Database '$dbname' does not exist\n" if !$list->{$dbname};
+
+ syslog('info', "delete rule database");
+
+ PMG::DBTools::delete_ruledb($dbname);
+
+ return undef;
+ }});
+
+
+__PACKAGE__->register_method ({
+ name => 'update',
+ path => 'update',
+ method => 'POST',
+ description => "Update or initialize PMG rule database.",
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ force => {
+ type => 'boolean',
+ description => "Delete existing database.",
+ optional => 1,
+ default => 0,
+ },
+ statistics => {
+ type => 'boolean',
+ description => "Update/initialize statistic database (this is done by default).",
+ optional => 1,
+ default => 1,
+ },
+ }
+ },
+ returns => { type => 'null'},
+ code => sub {
+ my ($param) = @_;
+
+ my $list = PMG::DBTools::database_list();
+
+ my $dbname = "Proxmox_ruledb";
+
+ if (!$list->{$dbname} || $param->{force}) {
+
+ if ($list->{$dbname}) {
+ print "Destroy existing rule database\n";
+ PMG::DBTools::delete_ruledb($dbname);
+ }
+
+ print "Initialize rule database\n";
+
+ my $dbh = PMG::DBTools::create_ruledb ($dbname);
+ #$ruledb = Proxmox::RuleDB->new ($dbh);
+ #Proxmox::Utils::init_ruledb ($ruledb);
+
+ $dbh->disconnect();
+
+ } else {
+
+ my $dbh = PMG::DBTools::open_ruledb("Proxmox_ruledb");
+ #$ruledb = Proxmox::RuleDB->new ($dbh);
+
+ #print "Analyzing/Upgrading existing Databases...";
+ #Proxmox::Utils::upgradedb ($ruledb);
+ #print "done\n";
+
+ # reset and update statistic databases
+ if ($param->{statistics}) {
+ print "Generating Proxmox Statistic Databases... ";
+ #Proxmox::Statistic::clear_stats($dbh);
+ #Proxmox::Statistic::update_stats($dbh, $cinfo);
+ print "done\n";
+ }
+
+ $dbh->disconnect();
+ }
+
+ return undef;
+ }});
+
+
+our $cmddef = {
+ 'dump' => [ __PACKAGE__, 'dump', []],
+ delete => [ __PACKAGE__, 'delete', []],
+ update => [ __PACKAGE__, 'update', []],
+};
+
+1;
+++ /dev/null
-package PMG::CLI::proxdb;
-
-use strict;
-use warnings;
-use Data::Dumper;
-
-use PVE::SafeSyslog;
-use PVE::Tools qw(extract_param);
-use PVE::INotify;
-
-use PMG::DBTools;
-
-use base qw(PVE::CLIHandler);
-
-my $nodename = PVE::INotify::nodename();
-
-__PACKAGE__->register_method ({
- name => 'dump',
- path => 'dump',
- method => 'GET',
- description => "Print the PMG rule database.",
- parameters => {
- additionalProperties => 0,
- },
- returns => { type => 'null'},
- code => sub {
- my ($param) = @_;
-
- print "DUMP\n";
-
- return undef;
- }});
-
-
-__PACKAGE__->register_method ({
- name => 'delete',
- path => 'delete',
- method => 'DELETE',
- description => "Delete PMG rule database.",
- parameters => {
- additionalProperties => 0,
- },
- returns => { type => 'null'},
- code => sub {
- my ($param) = @_;
-
- my $list = PMG::DBTools::database_list();
-
- my $dbname = "Proxmox_ruledb";
-
- die "Database '$dbname' does not exist\n" if !$list->{$dbname};
-
- syslog('info', "delete rule database");
-
- PMG::DBTools::delete_ruledb($dbname);
-
- return undef;
- }});
-
-
-__PACKAGE__->register_method ({
- name => 'update',
- path => 'update',
- method => 'POST',
- description => "Update or initialize PMG rule database.",
- parameters => {
- additionalProperties => 0,
- properties => {
- force => {
- type => 'boolean',
- description => "Delete existing database.",
- optional => 1,
- default => 0,
- },
- statistics => {
- type => 'boolean',
- description => "Update/initialize statistic database (this is done by default).",
- optional => 1,
- default => 1,
- },
- }
- },
- returns => { type => 'null'},
- code => sub {
- my ($param) = @_;
-
- my $list = PMG::DBTools::database_list();
-
- my $dbname = "Proxmox_ruledb";
-
- if (!$list->{$dbname} || $param->{force}) {
-
- if ($list->{$dbname}) {
- print "Destroy existing rule database\n";
- PMG::DBTools::delete_ruledb($dbname);
- }
-
- print "Initialize rule database\n";
-
- my $dbh = PMG::DBTools::create_ruledb ($dbname);
- #$ruledb = Proxmox::RuleDB->new ($dbh);
- #Proxmox::Utils::init_ruledb ($ruledb);
-
- $dbh->disconnect();
-
- } else {
-
- my $dbh = PMG::DBTools::open_ruledb("Proxmox_ruledb");
- #$ruledb = Proxmox::RuleDB->new ($dbh);
-
- #print "Analyzing/Upgrading existing Databases...";
- #Proxmox::Utils::upgradedb ($ruledb);
- #print "done\n";
-
- # reset and update statistic databases
- if ($param->{statistics}) {
- print "Generating Proxmox Statistic Databases... ";
- #Proxmox::Statistic::clear_stats($dbh);
- #Proxmox::Statistic::update_stats($dbh, $cinfo);
- print "done\n";
- }
-
- $dbh->disconnect();
- }
-
- return undef;
- }});
-
-
-our $cmddef = {
- 'dump' => [ __PACKAGE__, 'dump', []],
- delete => [ __PACKAGE__, 'delete', []],
- update => [ __PACKAGE__, 'update', []],
-};
-
-1;
--- /dev/null
+#!/usr/bin/perl -T
+
+use strict;
+use warnings;
+
+use PMG::CLI::pmgdb;
+
+PMG::CLI::pmgdb->run_cli_handler();
+++ /dev/null
-#!/usr/bin/perl -T
-
-use strict;
-use warnings;
-
-use PMG::CLI::proxdb;
-
-PMG::CLI::proxdb->run_cli_handler();