ALT Linux Bugzilla
– Attachment 2266 Details for
Bug 13425
netams admintool doesn't support last changes in configuration protocol
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
Патч фиксирующий изменение конфигурационного протокола netams
netams-admin-3.4.0rc2-fix_proto.patch (text/plain), 14.25 KB, created by
Alexey V. Novikov
on 2007-11-14 15:43:27 MSK
(
hide
)
Description:
Патч фиксирующий изменение конфигурационного протокола netams
Filename:
MIME Type:
Creator:
Alexey V. Novikov
Created:
2007-11-14 15:43:27 MSK
Size:
14.25 KB
patch
obsolete
>diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/netams.cgi netams-3.4.0rc2/cgi-bin/admin/netams.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/netams.cgi 2007-05-13 17:30:50 +0400 >+++ netams-3.4.0rc2/cgi-bin/admin/netams.cgi 2007-11-14 10:54:25 +0300 >@@ -55,8 +55,8 @@ > $result=netams_read(); > @result=split("\n", $result); > >-$netams_version=substr($result[0], 14, 32); >-$netams_version=substr($netams_version, 0, index($netams_version, " root")); >+$netams_version=$result[0]; >+$netams_version=~s/^NeTAMS\s(.+)\s\S+\@.*$/$1/; > $run_time=substr($result[1], 10); > print ""; > ################################################ >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/policy.cgi netams-3.4.0rc2/cgi-bin/admin/policy.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/policy.cgi 2006-03-16 19:04:39 +0300 >+++ netams-3.4.0rc2/cgi-bin/admin/policy.cgi 2007-11-14 14:20:48 +0300 >@@ -17,13 +17,11 @@ > $name=$cgi->param("name_$oid"); > $tgt=$cgi->param("tgt_$oid"); > if ($name ne "" and $tgt ne "") { >- netams_send("service processor"); >- $result1=netams_read(); >- if ($cgi->param("set") ne "") { netams_send("policy oid $oid name $name target $tgt"); } >- elsif ($cgi->param("delete") ne "") { netams_send("no policy name $name"); } >- $result=netams_read(); >- netams_send("exit"); >- $result1=netams_read(); >+ my @cmds = ("enable","configure terminal","service processor"); >+ if ($cgi->param("set") ne "") { push(@cmds,"policy oid $oid name $name target $tgt"); } >+ elsif ($cgi->param("delete") ne "") { push(@cmds,"no policy name $name"); } >+ push(@cmds,("exit","exit","disable")); >+ netams_cmds(@cmds); > } > } > >@@ -31,12 +29,7 @@ > $pol_name=$cgi->param("name_new"); > $pol_tgt=$cgi->param("tgt_new"); > if ($pol_name ne "" and $pol_tgt ne "") { >- netams_send("service processor"); >- $result1=netams_read(); >- netams_send("policy name $pol_name target $pol_tgt"); >- $result=netams_read(); >- netams_send("exit"); >- $result1=netams_read(); >+ netams_cmds(("enable","configure terminal","service processor","policy name $pol_name target $pol_tgt","exit","exit","disable")); > } > } > >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/quota.cgi netams-3.4.0rc2/cgi-bin/admin/quota.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/quota.cgi 2004-12-03 00:38:06 +0300 >+++ netams-3.4.0rc2/cgi-bin/admin/quota.cgi 2007-11-14 14:19:18 +0300 >@@ -7,74 +7,58 @@ > require "netams.cgi"; > > $toppane= "<b>Quotas Management</b>"; >- >+ > netams_send("show quota list"); > $result=netams_read(); @s_units=split("\n", $result); > shift @s_units; >+ shift @s_units; > $p1="<b>Here the list of units with quota management ACTIVE:</b><br>"; > >- @s=split(/ /, $s_units[0]); %pairs=@s; >- foreach $s (keys %pairs) { >- $p1.="<a href='$url?action=quotas&oid=".$pairs{$s}."'>".$s."</a> "; >+ foreach $s (@s_units) { >+ @s=split(/\s/, $s); >+ $pairs{$s[0]}=$s[1]; >+ $p1.="<a href='$url?action=quotas&oid=".$s[1]."'>".$s[0]."</a> "; > } > $p1 .= "<br><hr>"; > >- if (($oid ne "000000") and (%pairs > 0) ) { >+ if (($oid ne "000000") and (%pairs > 0)) { > > # first process something if submitted > if ($cgi->param("act") ne "") { >- netams_send("service quota 0"); >- $result=netams_read(); >- netams_send("set oid $oid active"); >- $result=netams_read(); >- netams_send("exit"); $result=netams_read(); >+ netams_cmds(("enable","configure terminal","service quota","set oid $oid active","exit","exit","disable")); > } > > if ($cgi->param("deact") ne "") { >- netams_send("service quota 0"); >- $result=netams_read(); >- netams_send("set oid $oid inactive"); >- $result=netams_read(); >- netams_send("exit"); $result=netams_read(); >+ netams_cmds(("enable","configure terminal","service quota","set oid $oid inactive","exit","exit","disable")); > } > > if ($cgi->param("soft") ne "") { >- netams_send("service quota 0"); >- $result=netams_read(); > $soft_val=$cgi->param("soft_val"); > if ($soft_val > -1 and $soft_val <101) { >- netams_send("set oid $oid soft-treshold $soft_val"); >- $result=netams_read(); >+ netams_cmds(("enable","configure terminal","service quota","set oid $oid soft-treshold $soft_val","exit","exit","disable")); > } >- netams_send("exit"); $result=netams_read(); > } > > if ($cgi->param("notify") ne "") { >- netams_send("service quota 0"); >- $result=netams_read(); >+ my @cmds = ("enable","configure terminal","service quota"); > > $s=$cgi->param("notify_soft_owner"); if (defined $s) { $s="{owner}"; } > $sn=$cgi->param("notify_soft_name"); >- netams_send("set oid $oid notify soft {none}"); $result=netams_read(); >- netams_send("set oid $oid notify soft $s $sn"); $result=netams_read(); >+ push(@cmds,("set oid $oid notify soft {none}", "set oid $oid notify soft $s $sn")); > > $s=$cgi->param("notify_hard_owner"); if (defined $s) { $s="{owner}"; } > $sn=$cgi->param("notify_hard_name"); >- netams_send("set oid $oid notify hard {none}"); $result=netams_read(); >- netams_send("set oid $oid notify hard $s $sn"); $result=netams_read(); >+ push(@cmds,("set oid $oid notify hard {none}", "set oid $oid notify hard $s $sn")); > > $s=$cgi->param("notify_return_owner"); if (defined $s) { $s="{owner}"; } > $sn=$cgi->param("notify_return_name"); >- netams_send("set oid $oid notify return {none}"); $result=netams_read(); >- netams_send("set oid $oid notify return $s $sn"); $result=netams_read(); >- >- netams_send("exit"); $result=netams_read(); >+ push(@cmds,("set oid $oid notify return {none}", "set oid $oid notify return $s $sn")); >+ >+ push(@cmds,("exit","exit","disable")); >+ netams_cmds(@cmds); > } > > if ($cgi->param("quotas") ne "") { >- netams_send("service quota 0"); >- $result=netams_read(); >- > if (($t=$cgi->param("h_in"))!=0) { $x.="hour $t in "; } > if (($t=$cgi->param("h_out"))!=0) { $x.="hour $t out "; } > if (($t=$cgi->param("h_sum"))!=0) { $x.="hour $t sum "; } >@@ -94,22 +78,18 @@ > $x =~ s/-1/0/g; > > if ($x ne "") { >- netams_send("set oid $oid $x"); >- $result=netams_read(); >+ netams_cmds(("enable","configure terminal","service quota","set oid $oid $x","exit","exit","disable")); > } >- >- netams_send("exit"); $result=netams_read(); > } > #netams_send("service quota 0"); > #$result=netams_read(); > $cmd="show quota oid ".$oid; netams_send($cmd); >- $result=netams_readline(); @s_qu=split("\n", $result); >+ $result=netams_read(); @s_qu=split("\n", $result); > $p2 = "Current unit quota control status follows: <pre>$result</pre>\n"; >- $p2 =~ s/{owner}/[owner]/g; >+# $p2 =~ s/{owner}/[owner]/g; > > %pairs2 = reverse %pairs; >- >- if (-1 == index($s_qu[0], "ACTIVE")) {# -1 eq NOT, other=YES >+ if (-1 == index($s_qu[1], "ACTIVE")) {# -1 eq NOT, other=YES > $p1.="Current state for <b>".$pairs2{$oid}." [$oid]</b> is <b>INACTIVE</b>. <input type=submit name=act value='ACTIVATE IT'><br><hr>\n"; > } > else { >@@ -118,22 +98,22 @@ > > if ($s_qu[1] ne "") { # we have something here > >- $j=index($s_qu[0], "soft-treshold:"); >- $j=substr($s_qu[0], $j+14, 5); $j=$j+0; >+ $j=index($s_qu[1], "soft-treshold:"); >+ $j=substr($s_qu[1], $j+14, 5); $j=$j+0; > $p3="Current soft treshold is <b>$j%</b>. It means that after reaching of $j percents of some quota, the notification message could be sent.<br> You can specify another value here: <input type=text name=soft_val value=$j size=4><input type=submit name=soft value=Apply><br><hr>"; > >- $nss_s="checked" if (index($s_qu[1], "soft {owner}")!=-1); >- $nhs_s="checked" if (index($s_qu[1], "hard {owner}")!=-1); >- $nrs_s="checked" if (index($s_qu[1], "return {owner}")!=-1); >+ $nss_s="checked" if (index($s_qu[2], "soft owner")!=-1); >+ $nhs_s="checked" if (index($s_qu[2], "hard owner")!=-1); >+ $nrs_s="checked" if (index($s_qu[2], "return owner")!=-1); > >- $j=index($s_qu[1], "soft"); if (defined $nss_s) { $j+=13; } else { $j+=5; } >- $k=index($s_qu[1], ",", $j); $nso_s=substr($s_qu[1], $j, $k-$j); >+ $j=index($s_qu[2], "soft"); if (defined $nss_s) { $j+=11; } else { $j+=3; } >+ $k=index($s_qu[2], ",", $j); $nso_s=substr($s_qu[2], $j, $k-$j); > >- $j=index($s_qu[1], "hard"); if (defined $nhs_s) { $j+=13; } else { $j+=5; } >- $k=index($s_qu[1], ",", $j); $nho_s=substr($s_qu[1], $j, $k-$j); >+ $j=index($s_qu[2], "hard"); if (defined $nhs_s) { $j+=11; } else { $j+=3; } >+ $k=index($s_qu[2], ",", $j); $nho_s=substr($s_qu[2], $j, $k-$j); > >- $j=index($s_qu[1], "return"); if (defined $nrs_s) { $j+=15; } else { $j+=7; } >- $nro_s=substr($s_qu[1], $j); >+ $j=index($s_qu[2], "return"); if (defined $nrs_s) { $j+=12; } else { $j+=5; } >+ $nro_s=substr($s_qu[2], $j); > > $p4="Users and unit owners to be notified on quota actions. Select <b>owner</b> and/or type an existing <b>user</b> name.<br>\n"; > $p4.="<table border=1 width=80% cellpadding=3 cellspacing=0><tr align=center bgcolor=#cccccc><td><b>Soft reach</b></td><td><b>Hard reach</b></td><td><b>Return</b></td><td rowspan=2 valign=center><input type=submit name=notify value=Apply></td></tr>"; >@@ -142,10 +122,10 @@ > $p4.="<td>owner <input type=checkbox $nrs_s name=notify_return_owner><br>user: <input type=text name=notify_return_name value='".$nro_s."' size=10></td></tr></table>"; > $p4.="<br><hr>\n"; > >- $q_h_in=q_getval($result, "HOUR in:"); $q_h_out=q_getval($result, "HOUR out:"); $q_h_sum=q_getval($result, "HOUR sum:"); >- $q_d_in=q_getval($result, "DAY in:"); $q_d_out=q_getval($result, "DAY out:"); $q_d_sum=q_getval($result, "DAY sum:"); >- $q_w_in=q_getval($result, "WEEK in:"); $q_w_out=q_getval($result, "WEEK out:"); $q_w_sum=q_getval($result, "WEEK sum:"); >- $q_m_in=q_getval($result, "MONTH in:"); $q_m_out=q_getval($result, "MONTH out:"); $q_m_sum=q_getval($result, "MONTH sum:"); >+ $q_h_in=q_getval($result, "HOUR","in"); $q_h_out=q_getval($result, "HOUR","out"); $q_h_sum=q_getval($result, "HOUR","sum"); >+ $q_d_in=q_getval($result, "DAY","in"); $q_d_out=q_getval($result, "DAY","out"); $q_d_sum=q_getval($result, "DAY","sum"); >+ $q_w_in=q_getval($result, "WEEK","in"); $q_w_out=q_getval($result, "WEEK","out"); $q_w_sum=q_getval($result, "WEEK","sum"); >+ $q_m_in=q_getval($result, "MONTH","in"); $q_m_out=q_getval($result, "MONTH","out"); $q_m_sum=q_getval($result, "MONTH","sum"); > > $p5="You can change quota values here. Please specify '-1' if you wish to skip this quota.<br>\n"; > $p5.="<table border=1 width=80% cellpadding=3 cellspacing=0><tr align=center bgcolor=#cccccc><td> </td><td><b>IN</b></td><td><b>OUT</b></td><td><b>SUM</b></td><td rowspan=6 valign=center><input type=submit name=quotas value=Apply></td></tr>"; >@@ -173,11 +153,9 @@ > sub q_getval(){ > $s1=shift; > $s2=shift; >- $j=index($s1, $s2); >- if ($j == -1) { return 0; } >- $j2=index($s1, "hardquota ", $j); >- $j=$j2+10; >- $j2=index($s1, ' ratio', $j); >- $r=substr($s1, $j, $j2-$j); >- return "'$r'"; >+ $s3=shift; >+ my @s=grep(/^\s+$s2\s+$s3:.+hardquota/,split("\n",$s1)); >+ return 0 if $#s<0; >+ $s[0] =~ /quota\s(\d+(\.\d+)?[KMG]?)/; >+ return $1; > } >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/unit.cgi netams-3.4.0rc2/cgi-bin/admin/unit.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/unit.cgi 2006-03-16 19:04:39 +0300 >+++ netams-3.4.0rc2/cgi-bin/admin/unit.cgi 2007-11-14 14:16:21 +0300 >@@ -18,13 +18,8 @@ > # $righthead = "Unit OID: $oid"; > if ($action eq "list" or $action eq "remove") { # no units choosen > if ($action eq "remove") { >- netams_send("service processor 0"); >- $result=netams_read(); >- netams_send("no unit ".$cgi->param("unittype")." oid $oid"); >- $result=netams_read(); >+ netams_cmds(("enable","configure terminal","service processor","no unit ".$cgi->param("unittype")." oid $oid","exit","exit","disable")); > $p1="<b><i>Removing:</i></b> unit ".$cgi->param("unittype")." oid $oid<hr>\n"; >- netams_send("exit"); >- $result=netams_read(); > > if($have_radius eq "yes") { > use DBI; >@@ -90,20 +85,15 @@ > } # oid zero > else { > if ($action eq "new") { >- netams_send("service processor 0"); >- $result=netams_read(); >- netams_send("unit ".$cgi->param("unittype")." name ".$cgi->param("name")); >- $result=netams_read(); >- @tmp=split(/\s+/,$result); >- $oid=$tmp[3]; >+ my @result=netams_cmds(("enable","configure terminal","service processor","unit ".$cgi->param("unittype")." name ".$cgi->param("name"),"exit","exit","disable")); >+ @tmp=split(/\s+/,$result[4]); >+ $oid=$tmp[2]; > if ($oid eq "name") { >- $oid=$tmp[2]; >- $p2.="<b><i>Configure:</i></b> unit $tmp[1] oid $oid name $tmp[5]<hr>"; >- } else { >- $p2.="<b><i>Creating:</i></b> unit ".$cgi->param("unittype")." oid $oid name ".$cgi->param("name")."<hr>\n"; >+ $p2.="<b><i>Configure:</i></b> unit $tmp[0] oid $tmp[1] name $tmp[4]<hr>"; >+ } >+ else { >+ $p2.="<b><i>Creating:</i></b> unit ".$cgi->param("unittype")." oid $oid name ".$cgi->param("name")."<hr>\n"; > } >- netams_send("exit"); >- $result=netams_read(); > } > > getUnits(); >@@ -175,14 +165,9 @@ > } > > if($cmd ne "") { >- netams_send("service processor 0"); >- $result=netams_read(); > $cmd="unit ".$cgi->param("unittype")." oid $oid $cmd"; >- netams_send($cmd); >+ netams_cmds(("enable","configure terminal","service processor",$cmd,"exit","exit","disable")); > $p2.="<b><i>Applying:</i></b> $cmd <hr>"; >- $result=netams_read(); >- netams_send("exit"); >- $result=netams_read(); > } > > if($have_radius eq "yes" and $radius_update eq "yes" and $type eq "user") { >diff -uNr netams-3.4.0rc2.orig/cgi-bin/netams_api.pl netams-3.4.0rc2/cgi-bin/netams_api.pl >--- netams-3.4.0rc2.orig/cgi-bin/netams_api.pl 2007-05-13 17:30:47 +0400 >+++ netams-3.4.0rc2/cgi-bin/netams_api.pl 2007-11-14 13:51:17 +0300 >@@ -43,11 +43,14 @@ > sub netams_read { > my ($visible) = @_; > my $byte = ""; >- my $prev_byte = ""; >+ my $prev_byte2 = ""; >+ my $prev_byte1 = ""; > my $out_string = ""; > my $count = 0; >- while ( not ( $byte eq " " and ( $prev_byte eq "#" or $prev_byte eq ">" ) ) ) { >- $out_string .= $prev_byte = $byte; >+ while ( not ( $byte eq " " and ( $prev1_byte eq "#" or $prev1_byte eq ">" ) and ($prev2_byte eq "\n" or $prev2_byte eq ")") ) ) { >+ $prev2_byte = $prev1_byte; >+ $prev1_byte = $byte; >+ $out_string .= $byte; > $count = sysread(NETAMS_SOCKET, $byte, 1); > if (!defined $count) { sleep(1); next } > if ($count == 0) { last }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 13425
: 2266