This example assumes that two configurations share almost the same users and resources.
In this case, it would be necessary to export the two configurations to CSV file format. Then, import the new configuration again with its roles and the roles-related text file.
The following example is a Perl template script to be used for copying roles:
#!/cygdrive/c/Perl/bin/perl $cfg1=$ARGV[0]; $cfg2=$ARGV[1]; $cfgnew=$ARGV[2]; if ("$cfgnew" eq "") { print("Missing parameters\n"); printf("\n"); printf("Syntax: copy_roles <CFG with source roles>\n"); printf(" <TARGET CFG to copy the roles to>\n"); printf(" <CFG New file Name>\n"); printf("\n"); printf("Example\n"); printf("copy_roles old.cfg new.cfg new_cfg.cfg\n"); exit(1); } if (!(-e $cfg1)) { print "File $cfg1 does not exist"; exit(1); } if (!(-e $cfg2)) { print "File $cfg1 does not exist"; exit(1); } print "Copy ALL roles from $cfg1.cfg to $cfg2.cfg\n"; open(A, $cfg2); @b=split(',',Action:); $udb2=$b[1]; chop($udb2); print "udb=$udb2\n"; @b=split(',',Action:); $rdb2=$b[1]; chop($rdb2); print "rdb=$rdb2\n"; close(A); print "\n"; open(A, ">a.sbt"); print A "<BATCH> \n"; print A " <COMMAND \n"; print A " ACTION=\"EXPORT CSV\"\n"; print A " CONFIG=\"$cfg1\"\n"; print A " ROLE=\"roles1.txt\"\n"; print A " USER_RES=\"user_res1.txt\"\n"; print A " USER_ROLE=\"user_role1.txt\"\n"; print A " ROLE_RES=\"role_res1.txt\"\n"; print A " ROLE_ROLE=\"role_role1.txt\"/>\n"; print A "</BATCH>\n"; close(A); print "Exporting $cfg1 started at ", `date`; system("sage.exe a.sbt"); open(A, ">b.sbt"); print A "<BATCH> \n"; print A " <COMMAND \n"; print A " ACTION=\"EXPORT CSV\"\n"; print A " CONFIG=\"$cfg2\"\n"; print A " ROLE=\"roles2.txt\"\n"; print A " USER_RES=\"user_res2.txt\"\n"; print A " USER_ROLE=\"user_role2.txt\"\n"; print A " ROLE_RES=\"role_res2.txt\"\n"; print A " ROLE_ROLE=\"role_role2.txt\"/>\n"; print A "</BATCH>\n"; close(A); print "Exporting $cfg2 started at ", `date`; system("sage.exe b.sbt"); system("cp roles1.txt roles3.txt"); system("cat roles2.txt >> roles3.txt"); system("cp user_role1.txt user_role3.txt"); system("cat user_role2.txt >> user_role3.txt"); system("cp role_res1.txt role_res3.txt"); system("cat role_res2.txt >> role_res3.txt"); system("cp role_role1.txt role_role3.txt"); system("cat role_role2.txt >> role_role3.txt"); open(A, ">c.sbt"); print A "<BATCH>\n"; print A " <COMMAND\n"; print A " ACTION=\"IMPORT CSV\"\n"; print A " CONFIG=\"$cfgnew\"\n"; print A " USERS_DB=\"$udb2\"\n"; print A " RES_DB=\"$rdb2\"\n"; print A " ROLE=\"roles3.txt\"\n"; print A " USER_RES=\"user_res2.txt\"\n"; print A " USER_ROLE=\"user_role3.txt\"\n"; print A " ROLE_RES=\"role_res3.txt\"\n"; print A " ROLE_ROLE=\"role_role3.txt\"\n"; print A " ROLEID_AS_NUM=\"FALSE\"/>\n"; print A "</BATCH>\n"; close(A); print "Importing $cfgnew started at ", `date`; system("sage.exe c.sbt"); print "Importing $cfgnew ended at ", `date`; exit(0);
Copyright © 2014 CA.
All rights reserved.
|
|