#!/usr/local/bin/perl
use LWP::Simple;
############################################################################
# Title: PK Creator
# Author: Erez Ben Simon
# Last Update: 12/12/2000
############################################################################
$ROOT_PATH = "/install/ftp/publisher"; # Publisher FTP PATH
$PK_NUM = "0"; # Numbers Of PK to Create
$SERVER = "avazi.globecom.net"; # Publisher server Host name
$SQLFILE = "qa.sql" ; # SQL script
$DBUSER = "globalsale" ; # DataBase User Name
$PRODUCER = "globecom" ; # Globecom Producer User
$PRODUCER_PASS = "inter5678"; # Globecom Producer Password
$DBPASS = "informix" ; # DataBase Password
$ACCOUNT_ID = "1"; # Acount ID
$CREATE_DATE = "12-FEB-01 10:00:00"; # PK Creation Date
$PUB_DATE = "12-FEB-01 10:00:00"; # PK Publishing Date
$SCHED_DATE = "12-FEB-01 10:00:00"; # PK Distribution Date
$ACTV_DATE = "12-FEB-01 10:00:00"; # PK Activation Date
$HOST = "barbaree.globecom.net"; # GNS Node To Publish;
$NODE = "100"; # Node I'D
$OFFSET = "510"; # OffSET for start Counting ID's
$Date_format = "dd-mon-yy hh:mi:ss";
$zevel = "n";
############################################################################
# MAIN
############################################################################
while ( $zevel ne "exit" )
{
system ("clear");
print ("The numbers Of PK to Create is $PK_NUM \n" );
print ("Do you want to change the numbers Of PK to Create ? (y or n)\n");
$zevel = <STDIN>;
chop $zevel;
if ( $zevel eq "y" )
{
print ("Enter the numbers Of PK to Create\n");
$PK_NUM = <STDIN>;
chop $PK_NUM;
print ("$PK_NUM\n");
}
print ("The PK Creation Date is $CREATE_DATE\n" );
print ("Do you want to change the PK Creation Date ? (y or n)\n");
$zevel = <STDIN>;
chop $zevel;
if ( $zevel eq "y" )
{
print ("Enter the PK Creation Date, for example 12-FEB-01\n");
$CREATE_DATE = <STDIN>;
chop $CREATE_DATE;
}
print ("The PK Publishing Date is $PUB_DATE\n" );
print ("Do you want to change the PK Publishing Date ? (y or n)\n");
$zevel = <STDIN>;
chop $zevel;
if ( $zevel eq "y" )
{
print ("Enter the PK Publishing Date\n");
$PUB_DATE = <STDIN>;
chop $PUB_DATE;
}
print ("The PK Distribution Date is $SCHED_DATE\n" );
print ("Do you want to change the PK Distribution Date ? (y or n)\n");
$zevel = <STDIN>;
chop $zevel;
if ( $zevel eq "y" )
{
print ("Enter the PK Distribution Date\n");
$SCHED_DATE = <STDIN>;
chop $SCHED_DATE;
}
print ("The PK Activation Date is $ACTV_DATE\n" );
print ("Do you want to change the PK Activation Date ? (y or n)\n");
$zevel = <STDIN>;
chop $zevel;
if ( $zevel eq "y" )
{
print ("Enter the PK Activation Date\n");
$ACTV_DATE = <STDIN>;
chop $ACTV_DATE;
}
print ("The GNS Node To Publish is $HOST\n" );
print ("Do you want to change the GNS Node To Publish ? (y or n)\n");
$zevel = <STDIN>;
chop $zevel;
if ( $zevel eq "y" )
{
print ("Enter the GNS Node To Publish, for example barbaree.globecom.net\n");
$HOST = <STDIN>;
chop $HOST;
}
print ("The OffSET for start Counting ID's is $OFFSET\n" );
print ("Do you want to change the OffSET for start Counting ID's? (y or n)\n");
$zevel = <STDIN>;
chop $zevel;
if ( $zevel eq "y" )
{
print ("Enter the OffSET for start Counting ID's\n");
$OFFSET = <STDIN>;
chop $OFFSET;
}
open (FILE, "> qa.sql");
Duplicate_PK_Dir (); # Copy the first Pk direcotry with the assets
CreateNode (); # Define the GNS Node in the DataBase
Duplicate_PK_In_DB (); # Insert $PK_NUM PKS to the PK Table.
print FILE ("exit;"); #
close (FILE);
system ("sqlplus $DBUSER/$DBPASS \@qa.sql");
Request_Publish ();
open (FILE, "> schedule.sql");
Schedule ();
close (FILE);
system ("sqlplus $DBUSER/$DBPASS \@schedule.sql");
print ("\npress enter to continue or exit to stop\n");
$zevel = <STDIN>;
chop $zevel;
}
############################################################################
sub Duplicate_PK_In_DB
############################################################################
{
for ( $i=$OFFSET; $i <= $PK_NUM+$OFFSET ; $i++ )
{
print FILE ("insert into PK (PK_ID, ROOT_PK, CREATION_DATE ,PUBLISHING_DATE, ACCOUNT_ID, CONTENT_BASE_ID,NAME, PRODUCER_ID, DISTRIBUTION_DATE, ACTIVATION_DATE, STATUS) values ('$i','$i',to_date('$CREATE_DATE','$Date_format'),to_date('$PUB_DATE','$Date_format'), '$ACCOUNT_ID', '0', 'QAPK$i', '2', to_date('$SCHED_DATE','$Date_format'),to_date('$ACTV_DATE','$Date_format'), '2');\n");
print ("\ninsert into PK (PK_ID, ROOT_PK, CREATION_DATE ,PUBLISHING_DATE, ACCOUNT_ID, CONTENT_BASE_ID,NAME, PRODUCER_ID, DISTRIBUTION_DATE, ACTIVATION_DATE, STATUS) values ('$i','$i',to_date('$CREATE_DATE','$Date_format'),to_date('$PUB_DATE','$Date_format'), '$ACCOUNT_ID', '0', 'QAPK$i', '2', to_date('$SCHED_DATE','$Date_format'),to_date('$ACTV_DATE','$Date_format'), '2');\n");
print FILE (" insert into profile_pk (PROFILE_ID, PK_ID, ROOT_PK, LAST_PK_ID) values ('0','$i','$i','0');\n");
print ("\ninsert into profile_pk (PROFILE_ID, PK_ID, ROOT_PK, LAST_PK_ID) values ('0','$i','$i','0');\n");
print FILE ("insert into PK_SP (PK_ID, SP_ID) values ('$i','1');\n");
print ("\ninsert into PK_SP (PK_ID, SP_ID) values ('$i','1');\n");
print ("Create PK $i\n");
print FILE ("insert into USER_PKS (USER_ID, PK_ID) values ('2','$i');\n");
print ("\ninsert into USER_PKS (USER_ID, PK_ID) values ('2','$i');\n");
}
print FILE ("commit;\n");
} ##Duplicate_PK_In_DB
############################################################################
sub Duplicate_PK_Dir
############################################################################
{
print ("$ROOT_PK_DIR...");
for ( $i=$OFFSET; $i <= $PK_NUM+$OFFSET; $i++ )
{
system ("cp -r $ROOT_PATH\/${PRODUCER} $ROOT_PATH\/$PRODUCER$i");
print("copy $ROOT_PATH\/${PRODUCER}1 to $ROOT_PATH\/$PRODUCER$i \n");
}
} ##Duplicate_PK_Dir
##############################################################################
sub Request_Publish
##############################################################################
{
for ( $i=$OFFSET; $i <= $PK_NUM+$OFFSET; $i++ )
{
$text = get "http://avazi/servlets/globecom.servlets.publishVersion.Main?versionId=$i&userName=globecom&userPassword=inter5678";
print $text;
print ("http://$SERVER/servlets/globecom.servlets.publishVersion.Main?versionid=$i&username=$PRODUCER&userPassword=$PRODUCER_PASS \n");
}
} ##Publish_Version
#############################################################################
sub CreateNode
#############################################################################
{
print ("Create Node $HOST\n");
print FILE ("insert into nodes (node_id,name,node_type,group_type,comp_name) values ('100','$HOST','GIN','NOD','$HOST');\n");
print FILE ("insert into location (location_id,contact,country_id) values ('200','globecom-interactive','1');\n");
print FILE ("insert into node_details (node_id,time_zone,name,location_id,is_r_and_d) values ('100','12','$HOST','200','0');\n");
print FILE ("insert into ACCOUNT_NODES (NODE_ID, ACCOUNT_ID) values ('100','$ACCOUNT_ID');\n");
print FILE ("commit;\n");
}
#############################################################################
sub Schedule
#############################################################################
{
for ( $i=$OFFSET; $i <= $PK_NUM+$OFFSET; $i++ )
{
print FILE ("update PK set STATUS ='8' where pk_id = $i;\n");
print ("scheduling PK $i\n");
print FILE ("insert into scheduler_tab (pk_id,node_id,status) values ('$i','100','0');\n");
print FILE ("exit;");
}
print FILE ("commit;\n");
}
##Schedule
#############################################################################
sub run_sql
#############################################################################
{
system ("sqlplus $DBUSER/$DBPASS \@$SQLFILE");
} ##run_sql