Title: [opsview] [11352] Updated opspack creation so directory names are right now.
- Revision
- 11352
- Author
- tvoon
- Date
- 2013-02-05 15:14:44 +0000 (Tue, 05 Feb 2013)
Log Message
Updated opspack creation so directory names are right now. Fixed some opspack names
and added test to pick this up in future
Modified Paths
Added Paths
Modified: trunk/opsview-core/bin/create_opspack
===================================================================
--- trunk/opsview-core/bin/create_opspack 2013-02-05 14:18:55 UTC (rev 11351)
+++ trunk/opsview-core/bin/create_opspack 2013-02-05 15:14:44 UTC (rev 11352)
@@ -79,7 +79,10 @@
my %common_servicecheck_dependences =
map { ( $_ => 1 ) } @common_servicecheck_dependencies;
-my $norm_hosttemplate_name = lc $hosttemplate_name;
+$_ = lc $hosttemplate_name;
+my $norm_hosttemplate_dir = $_;
+my $norm_hosttemplate_name = $_;
+$norm_hosttemplate_dir =~ s/\W+/-/g;
$norm_hosttemplate_name =~ s/\W+/_/g;
my $result;
@@ -388,11 +391,11 @@
);
my %common_plugins = map { ( $_ => 1 ) } @common_plugins_list;
-mkdir($norm_hosttemplate_name);
+mkdir($norm_hosttemplate_dir);
-if ( !-e "$norm_hosttemplate_name/plugins" ) {
- mkdir "$norm_hosttemplate_name/plugins"
- or my_die( "Cannot create $norm_hosttemplate_name/plugins/ directory" );
+if ( !-e "$norm_hosttemplate_dir/plugins" ) {
+ mkdir "$norm_hosttemplate_dir/plugins"
+ or my_die( "Cannot create $norm_hosttemplate_dir/plugins/ directory" );
}
my %needed_plugins;
@@ -402,7 +405,7 @@
if ( !-e $plugin_file ) {
my_die( "$plugin_file does not exist" );
}
- my $dest = "$norm_hosttemplate_name/plugins/$p";
+ my $dest = "$norm_hosttemplate_dir/plugins/$p";
cp( $plugin_file, $dest ) or my_die( "Cannot copy $p to $dest" );
chmod( 0755, $dest );
print "Copied $p\n";
@@ -410,7 +413,7 @@
}
# Delete unused plugins
-foreach my $plugin_path (<"$norm_hosttemplate_name/plugins/check_*">) {
+foreach my $plugin_path (<"$norm_hosttemplate_dir/plugins/check_*">) {
( my $p = $plugin_path ) =~ s%plugins/%%;
next if $needed_plugins{$p};
print "Deleting $p\n";
@@ -457,15 +460,15 @@
"attribute" => \@attributes,
};
-open F, ">", "$norm_hosttemplate_name/config.json"
- or my_die( "Cannot open $norm_hosttemplate_name/config.json for writing" );
+open F, ">", "$norm_hosttemplate_dir/config.json"
+ or my_die( "Cannot open $norm_hosttemplate_dir/config.json for writing" );
print F $j->pretty->canonical->encode($export);
close F;
print "Created config.json\n";
if ( !-e "info" ) {
- open F, ">", "$norm_hosttemplate_name/info"
- or my_die( "Cannot open $norm_hosttemplate_name/info for writing" );
+ open F, ">", "$norm_hosttemplate_dir/info"
+ or my_die( "Cannot open $norm_hosttemplate_dir/info for writing" );
print F <<"EOF";
NAME=com.example.monitorpack.$norm_hosttemplate_name
VERSION=1.0
@@ -477,8 +480,8 @@
print "Created info\n";
}
-open F, ">", "$norm_hosttemplate_name/Makefile"
- or my_die( "Cannot open $norm_hosttemplate_name/Makefile for writing" );
+open F, ">", "$norm_hosttemplate_dir/Makefile"
+ or my_die( "Cannot open $norm_hosttemplate_dir/Makefile for writing" );
print F << 'EOF';
NAME := $(shell perl -ne 'if (/ALIAS=(.*)/){ $$_ = lc($$1); s/ /-/g; s/\-+/-/g; print $$_ }' info)
Modified: trunk/opsview-core/import/opspacks_source/application-http/info
===================================================================
--- trunk/opsview-core/import/opspacks_source/application-http/info 2013-02-05 14:18:55 UTC (rev 11351)
+++ trunk/opsview-core/import/opspacks_source/application-http/info 2013-02-05 15:14:44 UTC (rev 11352)
@@ -1,4 +1,4 @@
-NAME=com.example.monitorpack.application_http
+NAME=com.opsview.opspack.application_http
VERSION=1.0
ALIAS=Application - HTTP
DEPENDENCIES=
Modified: trunk/opsview-core/import/opspacks_source/os-opsview-agent/info
===================================================================
--- trunk/opsview-core/import/opspacks_source/os-opsview-agent/info 2013-02-05 14:18:55 UTC (rev 11351)
+++ trunk/opsview-core/import/opspacks_source/os-opsview-agent/info 2013-02-05 15:14:44 UTC (rev 11352)
@@ -1,4 +1,4 @@
-NAME=com.example.monitorpack.os_opsview_agent
+NAME=com.opsview.opspack.os_opsview_agent
VERSION=1.0
ALIAS=OS - Opsview Agent
DEPENDENCIES=
Added: trunk/opsview-core/t/008opspacks.t
===================================================================
--- trunk/opsview-core/t/008opspacks.t (rev 0)
+++ trunk/opsview-core/t/008opspacks.t 2013-02-05 15:14:44 UTC (rev 11352)
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+use Test::More qw(no_plan);
+
+use FindBin qw($Bin);
+use File::Next;
+
+my $file_filter = sub { $_ && $_ =~ m/info$/ };
+my $opspack_files = File::Next::files(
+ { file_filter => $file_filter, },
+ "$Bin/../import/opspacks_source/"
+);
+while ( defined( my $info = $opspack_files->() ) ) {
+ open INFO, $info or die "Cannot read $info: $!";
+ my @lines = <INFO>;
+ my $goodname = grep {/NAME=com\.opsview\.opspack/} @lines;
+ close INFO;
+ if ($goodname) {
+ pass( "Got good name for opspack" );
+ }
+ else {
+ fail( "Got bad name for opspack $lines[0]" );
+ }
+}
Property changes on: trunk/opsview-core/t/008opspacks.t
___________________________________________________________________
Added: svn:executable
+ *
_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins