Changeset 36337 for trunk/tools/neb_rawOTA_host_scan.pl
- Timestamp:
- Dec 2, 2013, 5:05:35 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/tools/neb_rawOTA_host_scan.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/neb_rawOTA_host_scan.pl
r36313 r36337 21 21 ) or die "Unable to connect to database $DBI::errstr\n"; 22 22 23 my ($host,$min_ins_id,$verbose,$limit );23 my ($host,$min_ins_id,$verbose,$limit,$continue); 24 24 $min_ins_id = 0; 25 25 $verbose = 0; 26 26 $limit = 10000; 27 $continue = 0; 27 28 28 29 GetOptions( … … 31 32 'verbose|v' => \$verbose, 32 33 'limit|l=s' => \$limit, 34 'continue|c' => \$continue, 33 35 ) or pod2usage( 2 ); 34 36 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; … … 66 68 67 69 # Get the files on this host 68 69 my $ins_id_sth = "SELECT ins_id,so_id,uri FROM instance WHERE vol_id = ${vol_id} AND ins_id > $min_ins_id LIMIT $limit"; 70 my $r_ins = $db->selectall_arrayref( $ins_id_sth ); 71 my $last_ins_id = 0; 72 foreach $rr (@{ $r_ins }) { 73 my ($ins_id,$so_id,$uri) = @{ $rr }; 74 if ($verbose) { 70 my $number = 0; 71 do { 72 my $ins_id_sth = "SELECT ins_id,so_id,uri FROM instance WHERE vol_id = ${vol_id} AND ins_id > $min_ins_id LIMIT $limit"; 73 my $r_ins = $db->selectall_arrayref( $ins_id_sth ); 74 my $last_ins_id = 0; 75 $number = 0; 76 foreach $rr (@{ $r_ins }) { 77 my ($ins_id,$so_id,$uri) = @{ $rr }; 78 if ($verbose) { 75 79 # print (" $ins_id $so_id $uri\n"); 76 } 77 if ($uri !~ /ota...fits/) { next; } 78 my $have_b_node = 0; 79 my ($ext_id,$occ_id,$oth_id,$name,$value) = ('',0,0,'',''); 80 my $rr2; 81 82 my $so_id_sth = "SELECT ext_id,so_id,vol_id,ins_id,name,value FROM storage_object JOIN instance USING(so_id) LEFT JOIN storage_object_xattr USING(so_id) WHERE so_id = ${so_id} AND ins_id != ${ins_id} AND (name IS NULL OR name = 'user.copies')"; 83 84 my $r_so = $db->selectall_arrayref( $so_id_sth ); 85 86 foreach $rr2 (@{ $r_so }) { 87 ($ext_id,$so_id,$occ_id,$oth_id,$name,$value) = @{ $rr2 }; 80 } 81 $number++; 82 $last_ins_id = $ins_id; 83 if ($uri !~ /ota...fits/) { next; } 84 my $have_b_node = 0; 85 my ($ext_id,$occ_id,$oth_id,$name,$value) = ('',0,0,'',''); 86 my $rr2; 88 87 89 unless(defined($name)) { 90 $name = 'UNDEF'; 91 $value = 1; 92 } 93 94 if ($name eq 'user.copies') { 95 if ($value == 1) { 88 my $so_id_sth = "SELECT ext_id,so_id,vol_id,ins_id,name,value FROM storage_object JOIN instance USING(so_id) LEFT JOIN storage_object_xattr USING(so_id) WHERE so_id = ${so_id} AND ins_id != ${ins_id} AND (name IS NULL OR name = 'user.copies')"; 89 90 my $r_so = $db->selectall_arrayref( $so_id_sth ); 91 92 foreach $rr2 (@{ $r_so }) { 93 ($ext_id,$so_id,$occ_id,$oth_id,$name,$value) = @{ $rr2 }; 94 95 unless(defined($name)) { 96 $name = 'UNDEF'; 97 $value = 1; 98 } 99 100 if ($name eq 'user.copies') { 101 if ($value == 1) { 102 $have_b_node = 1; 103 } 104 } 105 else { 96 106 $have_b_node = 1; 97 107 } 108 109 if (defined($b_nodes{$occ_id})) { 110 $have_b_node = 1; 111 } 112 if ($verbose) { 113 print(" $number $ext_id $so_id $occ_id $oth_id $have_b_node $name $value\n"); 114 } 115 116 if ($have_b_node == 1) { 117 last; 118 } 98 119 } 99 else { 100 $have_b_node = 1; 120 if ($oth_id) { 121 if ($have_b_node != 1) { 122 my $rep_host = int(rand() + 0.5) + 4; 123 my $rep_part = int(rand(3)); 124 my $rep_vol = "ippb0" . $rep_host . "." . $rep_part; 125 126 print("neb-replicate --volume $rep_vol $ext_id\n"); 127 system("neb-replicate --volume $rep_vol $ext_id"); 128 } 101 129 } 102 103 if (defined($b_nodes{$occ_id})) { 104 $have_b_node = 1; 130 $last_ins_id = $ins_id; 131 } 132 print "## LAST: $last_ins_id $number\n"; 133 print "## TRY: neb_rawOTA_host_scan.pl --host $host --limit $limit --min $last_ins_id\n"; 134 if ($continue) { 135 if ($verbose) { 136 print("RESET $min_ins_id -> $last_ins_id $number\n"); 105 137 } 106 if ($verbose) { 107 print(" $ext_id $so_id $occ_id $oth_id $have_b_node $name $value\n"); 108 } 109 110 if ($have_b_node == 1) { 111 last; 112 } 138 $min_ins_id = $last_ins_id; 113 139 } 114 if ($oth_id) { 115 if ($have_b_node != 1) { 116 my $rep_host = int(rand() + 0.5) + 4; 117 my $rep_part = int(rand(3)); 118 my $rep_vol = "ippb0" . $rep_host . "." . $rep_part; 119 120 print("neb-replicate --volume $rep_vol $ext_id\n"); 121 system("neb-replicate --volume $rep_vol $ext_id"); 122 } 123 } 124 $last_ins_id = $ins_id; 125 } 126 print "## LAST: $last_ins_id\n"; 127 print "## TRY: neb_rawOTA_host_scan.pl --host $host --limit $limit --min $last_ins_id\n"; 128 140 } while ($continue && $number != 0);
Note:
See TracChangeset
for help on using the changeset viewer.
