#!/usr/bin/env perl

# program to Create a new distribution data store product and add it to the database
# Note: The list of names of the product specific columns is set here.
# The contents are set in dist_make_fileset.pl. 

use warnings;
use strict;

use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
use Pod::Usage qw( pod2usage );


my $prod_name;
my $dbhost;

GetOptions(
           'prod_name=s'     => \$prod_name,
           'dbhost=s'        => \$dbhost,
) or pod2usage( 2 );

pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
pod2usage( -msg => "Required options: --prod_name --dbhost",
           -exitval => 3)
    unless defined $prod_name
    and defined $dbhost;  

my $cmd = "dsprodtool --add $prod_name --type ipp-dist --description $prod_name";
$cmd .= " --ps0 target_id --ps1 stage --ps2 stage_id --ps3 fs_tag --ps4 data_group --ps5 filter";

print "$cmd\n";

my $rc = system $cmd;
die "dsprodtool failed: $rc" if $rc;

$cmd = "disttool -dbname gpc1 -definedestination -ds_dbname ippRequestServer -ds_dbhost $dbhost -name $prod_name";

$rc = system $cmd;
die "disttool failed: $rc" if $rc;

