~ubuntu-branches/ubuntu/wily/torrus/wily-proposed

« back to all changes in this revision

Viewing changes to perllib/Torrus/DevDiscover/ALU_Timetra.pm

  • Committer: Package Import Robot
  • Author(s): Bernhard Schmidt
  • Date: 2014-10-05 21:16:04 UTC
  • mfrom: (1.2.5)
  • mto: (6.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: package-import@ubuntu.com-20141005211604-qqkvq1k0uqiv3bvk
Tags: upstream-2.08
ImportĀ upstreamĀ versionĀ 2.08

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#  along with this program; if not, write to the Free Software
18
18
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19
19
 
20
 
# $Id$
21
20
# Stanislav Sinyagin <ssinyagin@yahoo.com>
22
21
#
23
22
 
28
27
package Torrus::DevDiscover::ALU_Timetra;
29
28
 
30
29
use strict;
 
30
use warnings;
 
31
 
31
32
use Torrus::Log;
32
33
 
33
34
 
101
102
            &Torrus::DevDiscover::RFC2863_IF_MIB::addInterfaceFilter
102
103
                ($devdetails, \%essInterfaceFilter);
103
104
 
104
 
            $dd->setMaxMsgSize($devdetails, 65535, {'only_v1_and_v2' => 1});
105
 
            
106
105
            return 1;
107
106
        }
108
107
        else
132
131
 
133
132
    # Get port descriptions
134
133
    {
135
 
        my $oid = $dd->oiddef('tmnxPortDescription');
136
 
        
137
 
        my $portDescrTable = $session->get_table( -baseoid => $oid );        
138
 
        my $prefixLen = length( $oid ) + 1;
139
 
 
140
 
        while( my( $oid, $descr ) = each %{$portDescrTable} )
 
134
        my $table = $dd->walkSnmpTable('tmnxPortDescription');
 
135
        while( my( $ifIndex, $descr ) = each %{$table} )
141
136
        {
142
 
            my $ifIndex = substr( $oid, $prefixLen );
143
137
            if( defined( $data->{'interfaces'}{$ifIndex} ) )
144
138
            {
145
139
                $data->{'interfaces'}{$ifIndex}{'tmnxPortDescription'} =
156
150
    
157
151
    # Get customers
158
152
    {
159
 
        my $oid = $dd->oiddef('custDescription');
160
 
        my $custDescrTable = $session->get_table( -baseoid => $oid );        
161
 
        my $prefixLen = length( $oid ) + 1;
162
 
        
163
 
        while( my( $oid, $descr ) = each %{$custDescrTable} )
 
153
        my $table = $dd->walkSnmpTable('custDescription');
 
154
        while( my( $custId, $descr ) = each %{$table} )
164
155
        {
165
 
            my $custId = substr( $oid, $prefixLen );
166
156
            $data->{'timetraCustDescr'}{$custId} = $descr;
167
157
        }
168
158
    }
170
160
    
171
161
    # Get Service Descriptions
172
162
    {
173
 
        my $oid = $dd->oiddef('svcDescription');
174
 
        my $svcDescrTable = $session->get_table( -baseoid => $oid );        
175
 
        my $prefixLen = length( $oid ) + 1;
176
 
 
177
 
        while( my( $oid, $descr ) = each %{$svcDescrTable} )
 
163
        my $table = $dd->walkSnmpTable('svcDescription');
 
164
        while( my( $svcId, $descr ) = each %{$table} )
178
165
        {
179
 
            my $svcId = substr( $oid, $prefixLen );
180
166
            $data->{'timetraSvc'}{$svcId} = {
181
167
                'description' => $descr,
182
168
                'sap' => [],
186
172
 
187
173
    # Get mapping of Services to Customers
188
174
    {
189
 
        my $oid = $dd->oiddef('svcCustId');
190
 
        my $svcCustIdTable = $session->get_table( -baseoid => $oid );        
191
 
        my $prefixLen = length( $oid ) + 1;
192
 
        
193
 
        while( my( $oid, $custId ) = each %{$svcCustIdTable} )
 
175
        my $table = $dd->walkSnmpTable('svcCustId');
 
176
        while( my( $svcId, $custId ) = each %{$table} )
194
177
        {
195
 
            my $svcId = substr( $oid, $prefixLen );
196
 
            
197
178
            $data->{'timetraCustSvc'}{$custId}{$svcId} = 1;
198
179
            $data->{'timetraSvcCust'}{$svcId} = $custId;
199
180
        }
202
183
    
203
184
    # Get port encapsulations
204
185
    {
205
 
        my $oid = $dd->oiddef('tmnxPortEncapType');
206
 
        
207
 
        my $portEncapTable = $session->get_table( -baseoid => $oid );        
208
 
        my $prefixLen = length( $oid ) + 1;
209
 
 
210
 
        while( my( $oid, $encap ) = each %{$portEncapTable} )
 
186
        my $table = $dd->walkSnmpTable('tmnxPortEncapType');
 
187
        while( my( $ifIndex, $encap ) = each %{$table} )
211
188
        {
212
 
            my $ifIndex = substr( $oid, $prefixLen );
213
189
            if( defined( $data->{'interfaces'}{$ifIndex} ) )
214
190
            {
215
191
                $data->{'interfaces'}{$ifIndex}{'tmnxPortEncapType'} = $encap;
220
196
    
221
197
    # Get SAP information
222
198
    {
223
 
        my $oid = $dd->oiddef('sapDescription');
224
 
        
225
 
        my $sapDescrTable = $session->get_table( -baseoid => $oid );        
226
 
        my $prefixLen = length( $oid ) + 1;
227
 
 
228
 
        while( my( $oid, $descr ) = each %{$sapDescrTable} )
 
199
        my $table = $dd->walkSnmpTable('sapDescription');
 
200
        while( my( $sapFullID, $descr ) = each %{$table} )
229
201
        {
230
 
            my $sapFullID = substr( $oid, $prefixLen );
231
 
 
232
202
            my ($svcId, $ifIndex, $sapEncapValue) =
233
203
                split(/\./o, $sapFullID);
234
204
 
339
309
                next;
340
310
            }
341
311
            
342
 
            my $param = {
 
312
            my $custParam = {
343
313
                'precedence' => 100000 - $custId,
344
314
                'comment'    => $data->{'timetraCustDescr'}{$custId},
345
315
                'timetra-customer-id' => $custId,
346
316
            };
347
317
            
348
318
            my $custNode =
349
 
                $cb->addSubtree( $customersNode, $custId, $param,
 
319
                $cb->addSubtree( $customersNode, $custId, $custParam,
350
320
                                 ['ALU_Timetra::alu-timetra-customer']);
351
321
            
352
322
            my $precedence = 10000;
371
341
                        }
372
342
                        
373
343
                        my $sapDescr = $sap->{'description'};
374
 
                        if( length( $sapDescr ) == 0 )
 
344
                        if( not defined($sapDescr) or $sapDescr eq '' )
375
345
                        {
376
 
                            $sapDescr = $data->{'timetraSvc'}{$svcId}->{
377
 
                                'description'};
 
346
                            $sapDescr =
 
347
                                $data->{'timetraSvc'}{$svcId}->{'description'};
378
348
                        }
379
349
 
380
350
                        my $subtreeName = $sap->{'name'};
381
351
                        $subtreeName =~ s/\W/_/go;
382
352
 
383
353
                        my $comment = '';
384
 
                        if( length( $sapDescr ) > 0 )
 
354
                        if( defined($sapDescr) and $sapDescr ne '' )
385
355
                        {
386
356
                            $comment = $sapDescr;
387
357
                        }
388
358
 
389
359
                        my $legend = '';                        
390
360
                        
391
 
                        if( length($data->{'timetraCustDescr'}{$custId}) > 0 )
 
361
                        my $custDescr = $data->{'timetraCustDescr'}{$custId};
 
362
                        if( defined($custDescr) and $custDescr ne '' )
392
363
                        {
393
364
                            $legend .= 'Customer:' .
394
 
                                $devdetails->screenSpecialChars
395
 
                                ( $data->{'timetraCustDescr'}{$custId} ) . ';';
 
365
                                $devdetails->screenSpecialChars( $custDescr ) .
 
366
                                ';';
396
367
                        }
397
 
                        
398
 
                        if( length($data->{'timetraSvc'}{$svcId}->{
399
 
                            'description'}) > 0 )
 
368
 
 
369
                        my $svcDescr =
 
370
                            $data->{'timetraSvc'}{$svcId}->{'description'};
 
371
                        if( defined($svcDescr) and $svcDescr ne '' )
400
372
                        {
401
373
                            $legend .= 'Service:' .
402
 
                                $devdetails->screenSpecialChars
403
 
                                ( $data->{'timetraSvc'}{$svcId}->{
404
 
                                    'description'} ) . ';';
 
374
                                $devdetails->screenSpecialChars( $svcDescr ) .
 
375
                                ';';
405
376
                        }
406
377
                        
407
378
                        $legend .= 'SAP: ' .
408
379
                            $devdetails->screenSpecialChars( $sap->{'name'} );
409
380
                        
410
381
                        
411
 
                        my $param = {
 
382
                        my $sapParam = {
412
383
                            'comment'          => $comment,
413
384
                            'timetra-sap-id'   => $sapID,
414
385
                            'timetra-sap-name' => $sap->{'name'},
417
388
                            'legend'           => $legend,
418
389
                        };
419
390
 
420
 
                        $cb->addSubtree( $custNode, $subtreeName, $param,
 
391
                        $cb->addSubtree( $custNode, $subtreeName, $sapParam,
421
392
                                         ['ALU_Timetra::alu-timetra-sap']);
422
393
                    }
423
394
                }
424
395
            }                            
425
396
        }
426
 
    }    
 
397
    }
 
398
    
 
399
    return;
427
400
}
428
401
 
429
402
 
466
439
    my $data = $devdetails->data();
467
440
    my @ret = keys %{$data->{'timetraSap'}};
468
441
 
469
 
    return( sort {$a<=>$b} @ret );
 
442
    return( sort @ret );
470
443
}
471
444
 
472
445
 
511
484
        Error('Unknown ALU_SAP selector attribute: ' . $attr);
512
485
        $value = '';
513
486
    }        
514
 
        
515
 
    
 
487
          
516
488
    return eval( '$value' . ' ' . $operator . '$checkval' ) ? 1:0;
517
489
}
518
490
 
544
516
    my $arg = shift;
545
517
 
546
518
    my $data = $devdetails->data();
547
 
    my $objref;
548
519
    
549
520
    if( not $knownSelectorActions{$action} )
550
521
    {
556
527
    {
557
528
        $data->{'timetraSap'}{$object}{'excluded'} = 1;
558
529
    }
 
530
    return;
559
531
}   
560
532
 
561
533
1;