#!/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 = "50"; # 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 = "1-FEB-01"; # PK Creation Date $PUB_DATE = "30-JAN-01"; # PK Publishing Date $SCHED_DATE = "30-JAN-01"; # PK Distribution Date $ACTV_DATE = "30-JAN-01"; # PK Activation Date $HOST = "barbaree.globecom.net"; # GNS Node To Publish; $NODE = "1"; $OFFSET = "100"; # OffSET for start Counting ID's ########################################################################### # MAIN ############################################################################ system ("clear"); open (FILE, "> $SQLFILE"); 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. Schedule (); # Schedule Distribition and Activation. print FILE ("exit;"); # close (FILE); system ("sqlplus $DBUSER/$DBPASS \@$SQLFILE"); Request_Publish (); ############################################################################ 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', '$CREATE_DATE', '$PUB_DATE', '$ACCOUNT_ID', '0', 'QAPK$i', '2', '$SCHED_DATE','$ACTV_DATE', '8');\n"); print FILE (" insert 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 ("Create PK $i\n"); print FILE ("insert 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}1 $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://$SERVER/servlets/globecom.servlets.publishVersion.Main?versionid=$i&username=$PRODUCER&userPassword=$PRODUCER_PASS"; 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,Location_id,is_r_and_d) values ('100','12','200','0');\n"); print FILE ("insert into ACCOUNT_NODES (NODE_ID, ACCOUNT_ID) values ('100','1');\n"); print FILE ("commit;\n"); } ############################################################################# sub Schedule ############################################################################# { for ( $i=$OFFSET; $i <= $PK_NUM+$OFFSET; $i++ ) { print ("scheduling PK $i\n"); print FILE ("insert into scheduler_tab (pk_id,node_id,status) values ('$i','100','0');\n"); } print FILE ("commit;\n"); } ##Schedule ############################################################################# sub run_sql ############################################################################# { system ("sqlplus $DBUSER/$DBPASS \@$SQLFILE"); } ##run_sql