<%doc> -- Device Worksheet -- Interface for viewing/updating a particular Device and all its relevant info in one page % <%attr> title => 'Device' section => 'Management' % % %####################################################################### %# %# Args section %# %####################################################################### <%args> $user => $ui->get_current_user($r) $id => undef $search => undef $edit => undef $editgen => undef $editloc => undef $editcomments => undef $editmgmt => undef $editattr => undef $editips => undef $add_ip => undef $add_ip_int => undef $add_ip_address => undef $editints => undef $editdevbgp => undef $editbgp => undef $ipsort => "address" $ifsort => "number" $peersort => "ip" $showvlan => "all" $intadd => undef $intaddnum => undef $overwrite_if_descr => undef $if_auto_dns => undef $submit => undef $view => "Basics" $deviceadd => undef $newhost => undef $newip => undef $toporoot => Netdot->config->get('NMS_DEVICE') $topodepth_up => 1 $topodepth_down => 1 $topovlans => 0 $toponames => 0 $specific_vlan => 0 $stp_number => undef $state_digest => undef $_action => undef % % % %####################################################################### %# %# INIT section %# %####################################################################### % <%init> my $DEBUG = 0; my %cssitem = ( 0 => "formtablec1", 1 => "formtablec2" ); my $maxselect = 100; my $o = undef; my $ci = 0; my $name; my %ifvlans; my %vlans; my $fqdn; my (@arp_caches, @fwt); my @modules; my %ifacecolors = ( manual => "cccccc", removed => "ff8e8e", ); print '%ARGS is
', Dumper(%ARGS), '

' if $DEBUG; # Check if user can access this section # We don't want average users seeing this page, its only for admins and operators. # Users have a special limited page user_device.html my $manager = $ui->get_permission_manager($r); unless ( $manager && $manager->can($user, "access_section", 'device.html') ){ $m->comp('/generic/error.mhtml', error=>"You don't have permission to access this page"); } if ( $id ){ unless ($o = Device->retrieve($id)){ $m->comp('/generic/error.mhtml', error=>"Could not retrieve Device with id $id"); } } if ( $o ){ if( $intadd ){ eval { $o->add_interfaces($intaddnum) }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>$e); } }elsif( defined $overwrite_if_descr ){ if ( $overwrite_if_descr == 0 || ($submit && ($submit eq 'confirm')) ){ eval { $o->set_overwrite_if_descr($overwrite_if_descr); }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>$e); } undef($submit); }elsif ( $overwrite_if_descr == 1 ){ $m->comp('/generic/confirm.html', %ARGS, target =>'../management/device.html', message =>'Any currently saved interface descriptions will be overwritten by '. 'SNMP-fetched data the next time the device is discovered. Are you sure?', ); } }elsif ( defined $if_auto_dns ){ eval { $o->set_interfaces_auto_dns($if_auto_dns); }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>$e); } }elsif ( $add_ip eq 'Add' ){ eval { $o->add_ip($add_ip_address, $add_ip_int) }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>$e); } $add_ip = undef; } } if( $deviceadd && $newhost ){ if ( Device->search(name=>$newhost) ){ # It's already there print "

Device $newhost already exists in DB"; $m->abort; }else{ # Minimal info to create device manually eval { $o = Device->insert({name=>$newhost, snmp_managed=>0, canautoupdate=>0}); }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>$e); } } }elsif( $submit ){ # insert/update my $new_digest; if ( $o ){ $new_digest = $o->get_digest(); } eval { Netdot::Model->do_transaction( sub{ if ( $state_digest && $new_digest && ($state_digest ne $new_digest) ){ $ui->throw_user("This device changed while you were editing"); } $ui->form_to_db(%ARGS); }); }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>$e); } # Re-read $o to avoid seeing the old values $o = undef; $o = Device->retrieve($id); } if ( $o && $o->name ){ $name = (defined $o->name->name) ? $o->name->name : "Name N/A!"; $fqdn = $name . "." . $o->name->zone->name; $id = $o->id; }elsif ( ! $search ){ $m->comp('/generic/error.mhtml', error=>"Device undefined or no name set"); } if ( $view eq "Interfaces" || $view eq "Topology" || $view eq "All" ){ # Build a hash of Interface Vlans foreach my $if ( $o->interfaces ){ if ( my @ifv = $if->vlans ){ foreach my $ifv ( @ifv ){ my $vid = $ifv->vlan->vid; $ifvlans{$if}{$vid} = ""; $vlans{$vid} = $ifv->vlan->id; } } } } my $refresh_url = "device.html?id=$id&view=$view";

%####################################################################### %# %# Device view section %# %#######################################################################
Device: <% $fqdn %>  [HTTP] [HTTPS]
[refresh] % if ( $o->snmp_managed ){ % if ( $manager && $manager->can($user, 'edit', $o) ){ [snmp-update] % } % } % if ( $manager && $manager->can($user, 'delete', $o) ){ [delete] % }
%####################################################################### %# %# Navigation Bar %# %#######################################################################
%####################################################################### %# %# Basics %# %####################################################################### % if ( $view eq "Basics" || $view eq "All" ){ % if ( $editgen || $editloc || $editcomments || $editmgmt ) {
% }
General
% if ( $editgen ) { % my $digest = $o->get_digest(); % }else{ % if ( $manager && $manager->can($user, "edit", $o) ){ [edit] % }else{   % } % }
<%perl> my (@field_headers, @cell_data); $ui->add_to_fields(o=>$o, edit=>$editgen, fields=>['name', 'aliases'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['host.html', '']); $ui->add_to_fields(o=>$o, edit=>$editgen, fields=>['asset_id',], linkpages=>['view.html'], field_headers=>\@field_headers, cell_data=>\@cell_data); if ( my $asset = $o->asset_id ){ push( @field_headers, $ui->col_descr_link('Product', 'type', 'Type:') ); push( @cell_data, &{sub{ my $pr; if ( ($pr = $asset->product_id) && $pr->type ){ ''.$pr->type->name.""; } }} ); push( @field_headers, $ui->col_descr_link('Asset', 'physaddr', 'Base MAC:') ); push( @cell_data, &{sub{ if ( my $phy = $asset->physaddr ){ ''.$phy->address.""; } }} ); push( @field_headers, $ui->col_descr_link('Asset', 'custom_serial', 'Custom S/N:') ); push( @cell_data, $asset->custom_serial); push( @field_headers, $ui->col_descr_link('Asset', 'inventory_number', 'Inventory:') ); push( @cell_data, $asset->inventory_number); } $ui->add_to_fields(o=>$o, edit=>$editgen, fields=>['os'], field_headers=>\@field_headers, cell_data=>\@cell_data, ); my $os_used = pop @cell_data; my $latest_os = $o->product->latest_os if $o->product; if ( !$editgen && $latest_os && ($os_used ne $latest_os) ){ push (@cell_data, $os_used . " (Recommended OS: " . $latest_os . ")"); }else{ push (@cell_data, $os_used); } $ui->add_to_fields(o=>$o, edit=>$editgen, fields=>['extension'], field_headers=>\@field_headers, cell_data=>\@cell_data, ); <& /generic/attribute_table.mhtml, field_headers=>\@field_headers, data=>\@cell_data, width=>"2", headercolwidth=>"15%", datacolwidth=>"35%" &>
Location/Contacts
% if ($editloc){ % }else{ % if ( $manager && $manager->can($user, "edit", $o) ){ [edit] % }else{   % } % }
<%perl> (@field_headers, @cell_data) = (); $ui->add_to_fields(o=>$o, edit=>$editloc, fields=>['owner', 'used_by'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','view.html','view.html']); my @devcontacts = $o->contacts; push( @field_headers, $ui->table_descr_link('DeviceContacts', 'Contacts:') ); push( @cell_data, $ui->select_multiple(object=>$o, joins=>\@devcontacts, join_table=>"DeviceContacts", this_field=>"device", other_table=>"ContactList", other_field=>"contactlist", isEditing=>$editloc, action=>"delete", makeLink=>1, linkPage=>"contactlist.html", returnAsVar=>1 ) ); push( @field_headers, $ui->col_descr_link('Device', 'site', 'Site:') ); push( @cell_data, &{sub{ my $js = sprintf("onChange=\"jsrsSendqueryNM('Room', 'Device__%d__room', this.options[selectedIndex].text);\"", $o->id); $ui->select_lookup(object=>$o, column=>"site", lookup=>"Site", edit=>$editloc, linkPage=>"view.html", htmlExtra=>$js, returnAsVar=>1) }} ); my @rooms; if ( $o->site ){ @rooms = sort { $a->name cmp $b->name } $o->site->rooms; } push( @field_headers, $ui->col_descr_link('Device', 'room', 'Room:') ); push( @cell_data, &{sub{ $ui->select_lookup(object=>$o, column=>"room", lookup=>"Room", edit=>$editloc, defaults=>\@rooms, makeLink=>1, linkPage=>"view.html", returnAsVar=>1) }} ); { my @fields = ('rack'); $ui->add_to_fields(o=>$o, edit=>$editloc, fields=>\@fields, field_headers=>\@field_headers, cell_data=>\@cell_data); } <& /generic/attribute_table.mhtml, width=>"2", field_headers=>\@field_headers, data=>\@cell_data &>
Management
% if ($editmgmt){ % }else{ % if ( $manager && $manager->can($user, "edit", $o) ){ [edit] % }else{   % } % }
<%perl> (@field_headers, @cell_data) = (); $ui->add_to_fields(o=>$o, edit=>0, fields=>['date_installed', 'last_updated'], field_headers=>\@field_headers, cell_data=>\@cell_data); { my @fields = ('oobname','oobnumber','monitored', 'monitoring_path_cost', 'customer_managed', 'monitor_config', 'monitor_config_group', 'down_from', 'down_until', 'snmp_managed', 'auto_dns'); $ui->add_to_fields(o=>$o, edit=>$editmgmt, fields=>\@fields, field_headers=>\@field_headers, cell_data=>\@cell_data); push( @field_headers, $ui->col_descr_link('Device', 'layers', 'Layers:') ); push( @cell_data, &{sub{ my @layers; if ( @layers = $o->list_layers ){ sprintf("%s", ( join ', ', @layers)); } }} ); } $ui->add_to_fields(o=>$o, edit=>0, fields=>['ipforwarding'], field_headers=>\@field_headers, cell_data=>\@cell_data); if ( $o->snmp_managed ){ my @fields = ('snmp_version', 'community', 'snmp_bulk', 'canautoupdate', 'snmp_polling', 'collect_arp', 'collect_fwt', 'collect_stp', 'snmp_conn_attempts', 'snmp_down'); $ui->add_to_fields(o=>$o, edit=>$editmgmt, fields=>\@fields, field_headers=>\@field_headers, cell_data=>\@cell_data); @fields = ('last_arp', 'last_fwt', 'sysname', 'syslocation', 'sysdescription'); $ui->add_to_fields(o=>$o, edit=>0, fields=>\@fields, field_headers=>\@field_headers, cell_data=>\@cell_data); } if ( $o->snmp_version eq "3" ){ my @fields = ('snmp_authkey', 'snmp_authprotocol', 'snmp_privkey', 'snmp_privprotocol', 'snmp_securitylevel', 'snmp_securityname' ); $ui->add_to_fields(o=>$o, edit=>$editmgmt, fields=>\@fields, field_headers=>\@field_headers, cell_data=>\@cell_data); } # Add the snmp_target IP. We want to show only the device IPs when editing # Do not retrieve all the IPs unless we are indeed editing if ( $o->snmp_managed ){ my %tmp; if ( $editmgmt ){ my $ips = $o->get_ips(); %tmp = $ui->form_field(object=>$o, column=>"snmp_target", defaults=>$ips, edit=>$editmgmt); }else{ %tmp = $ui->form_field(object=>$o, column=>"snmp_target", edit=>$editmgmt); } push( @field_headers, $tmp{label} ); push( @cell_data, $tmp{value} ); } <& /generic/attribute_table.mhtml, width=>"4", field_headers=>\@field_headers, data=>\@cell_data &>
Comments
% if ( $editcomments ){ % }else{ % if ( $manager && $manager->can($user, "edit", $o) ){ [edit] % }else{   % } % }
<%perl> my %tmp; %tmp = $ui->form_field(object=>$o, column=>"info", edit=>$editcomments, htmlExtra=>'cols="80" rows="10"'); print $tmp{value};
% if ( $editgen || $editloc || $editcomments || $editmgmt ) {
% } % my @attributes = $o->attributes;
Custom Attributes
% if ( $manager && $manager->can($user, 'edit', $o) ){ % if ( @attributes ) { [edit] % } [add] % }else{   % }
<& /generic/sortresults.mhtml, object=>\@attributes, withedit=>$editattr, return_args=>"?id=$id" &>
% } %####################################################################### %# %# Interfaces section %# %####################################################################### % my (@headers, @rows, @row, @rowstyles); %if ( $view eq "Interfaces" || $view eq "All" ){ <%perl> my $ifs = $o->interfaces_by($ifsort); # # Store values in a hash first. Thay way we can quicly verify if # at least one of the interfaces has that field set to some value # and decide whether to add that column or not # my %intinfo; foreach my $if ( @$ifs ){ foreach my $field ( qw/jack room_char jack_char description neighbor/ ){ if ( defined($if->$field) ){ $intinfo{$field}{$if->id} = $if->$field; } } } # Use this var to avoid checking for permissions for each int my $can_edit = ($manager && $manager->can($user, "edit", $o))? 1 : 0; ### Headers my @closet_jacks; (@headers, @rows) = (); if ( $editints ){ push @headers, '[del]'; } push @headers, 'Number'; push @headers, 'Name'; if ( ! $editints ){ push @headers, 'Speed'; push @headers, 'VLAN'; push @headers, 'Status'; } push @headers, 'Mon?'; push @headers, 'SNMP?'; if ( exists $intinfo{jack} || $editints ){ push @headers, 'Jack(cable)'; my @closets = $o->room->closets if ( $o->room ); foreach my $cl ( @closets ) { push @closet_jacks, $cl->horizontalcables; } @closet_jacks = sort { $a->get_label cmp $b->get_label } @closet_jacks; } if ( exists $intinfo{room_char} || $editints ){ push @headers, 'Room'; } if ( exists $intinfo{jack_char} || $editints ){ push @headers, 'Jack'; } if ( exists $intinfo{description} || $editints ){ push @headers, 'Descr.'; } push @headers, 'Neighbor'; ### Actual data foreach my $if ( @$ifs ){ next if ( !exists $ifvlans{$if}{$showvlan} && $showvlan ne "all" ); my (@row) = (); if ( $editints ){ push @row, 'id . "__delete" . '" >'; } push @row, $ui->form_field(object=>$if, column=>"number", edit=>$editints, htmlExtra=>"style=\"width: 5em;\"", linkPage=>"interface.html", returnValOnly=>1); push @row, $ui->form_field(object=>$if, column=>"name", edit=>$editints, htmlExtra=>"style=\"width: 10em;\"", linkPage=>"interface.html", returnValOnly=>1); if ( !$editints ){ push @row, $if->speed_pretty; push @row, &{sub{ my $ac = ""; if ( exists $ifvlans{$if} ){ if ( (keys %{$ifvlans{$if}} > 3) ) { my $rc = "\n"; }else{ my @links; foreach my $v ( keys %{$ifvlans{$if}} ){ push @links, sprintf("%s", $vlans{$v}, $v ); } $ac .= join ', ', @links; } $ac; } }}; push @row, $ui->form_field(object=>$if, column=>"oper_status", edit=>$editints, returnValOnly=>1); } push @row, $ui->form_field(object=>$if, column=>"monitored", edit=>$editints, returnValOnly=>1); push @row, $ui->form_field(object=>$if, column=>"snmp_managed", edit=>$editints, returnValOnly=>1); if ( exists $intinfo{jack} || $editints ){ my %args = (object=>$if, column=>"jack", linkPage=>"view.html", edit=>$editints, returnValOnly=>1); if ( @closet_jacks && (scalar(@closet_jacks) <= $ui->config->get('DEFAULT_SELECTMAX')) ){ $args{defaults} = \@closet_jacks; } push @row, $ui->form_field(%args); } if ( exists $intinfo{room_char} || $editints ){ push @row, $ui->form_field(object=>$if, column=>"room_char", edit=>$editints, htmlExtra =>"style=\"width: 4em;\"", returnValOnly=>1); } if ( exists $intinfo{jack_char} || $editints ){ push @row, $ui->form_field(object=>$if, column=>"jack_char", edit=>$editints, htmlExtra =>"style=\"width: 7em;\"", returnValOnly=>1); } if ( exists $intinfo{description} || $editints ){ push @row, $ui->form_field(object=>$if, column=>"description", edit=>$editints, returnValOnly=>1); } my $ac = ""; if ( exists $intinfo{neighbor}{$if->id} ){ $ac = $ui->form_field(object=>$if, column=>"neighbor", edit=>$editints, linkPage=>1, returnValOnly=>1); $ac .= "
"; } if ( !$editints && $can_edit ){ # Do not allow user to add neighbors on virtual interfaces if ( $if->type ne "53" && $if->type ne "propVirtual" ){ $ac .= "[add]"; } } push @row, $ac; push @rows, \@row; my $doc_status = $if->doc_status; if ( exists $ifacecolors{$doc_status} ){ push @rowstyles, "background-color: #$ifacecolors{$doc_status};"; }else{ push @rowstyles, ""; } } #foreach
Interfaces
% if ( $editints ){
% }else{ VLAN view:
Legend: % foreach my $status ( keys %ifacecolors ){ <% $status %> % }    % if ( $manager && $manager->can($user, "edit", $o) ){ [edit] % } % }
<& /generic/data_table.mhtml, field_headers=>\@headers, data=>\@rows, rowstyle=>\@rowstyles &>
% if ( $editints ){ % }
% if ( ! $editints && ($view eq "Interfaces" || $view eq "All") ){ % if ( $manager && $manager->can($user, 'edit', $o) ){
Options
 

Manually interfaces

SNMP Updates Overwrite Descriptions:

% } % }
% if ($editints){ % } % } # if view eq "Interfaces" %####################################################################### %# %# Modules %# %####################################################################### % if ( $view eq "Modules" || $view eq "All"){ <%perl> my %modules; if ( @modules ){ foreach my $m ( @modules ) { if ( $m->contained_in ){ push @{$modules{$m->contained_in}{children}}, $m; }else{ push @{$modules{root}}, $m; } } } print "
", Dumper(%modules), "
" if $DEBUG;
Device Modules (<% scalar @modules %>)
<& .show_modules, modules=>\%modules, objects=>$modules{root} &>
% } <%def .show_modules> <%args> $modules $objects
<& /generic/sortresults.mhtml, object=>$objects, view => "row" , sort=>0 &> % foreach my $obj ( @$objects ){ % if ( defined $modules->{$obj->number}{children} ){ % # Order by position % my @children = sort { $a->pos <=> $b->pos } @{$modules->{$obj->number}{children}};
Module <% $obj->number %> contains:
 
<& .show_modules, modules=>$modules, objects=>\@children &>
% } % }
%####################################################################### %# %# IP info %# %####################################################################### % if ( $view eq "IP" || $view eq "All" ){ % # Get all ip address info % my $ips; % if ( $o && $ipsort ){ % $ips = $o->get_ips(sort_by=>$ipsort); % }
IPs
% if ( $editips ) {
% } % if ( !$editips && !$add_ip ){ % if ( $manager && $manager->can($user, "edit", $o) ){ [edit] [add] % } % }
<%perl> if (scalar @$ips){ (@headers, @rows, @row) = (); @headers = ('Address', 'Subnet', 'Interface', 'DNS Name(s)', 'Services', ); my $can_edit = ($manager && $manager->can($user, "edit", $o))? 1 : 0; foreach my $ip ( @$ips ){ next if ( ! exists $ifvlans{$ip->interface}{$showvlan} && $showvlan ne "all" ); my (@row) = (); push( @row, &{sub{ my $a = ""; if ($editips){ $a .= 'id . "__delete" . '" >[del] '; $a .= $ip->address ; $a .= '
'; }else{ $a .= '' . $ip->address . '
'; } $a; }} ); push( @row, &{sub{ my $a = ""; if ( $ip->parent ){ if ($editips){ $a .= $ip->parent->address . '/' . $ip->parent->prefix ; }else{ $a .= '' . $ip->parent->address . '/' . $ip->parent->prefix . '
'; } } $a; }} ); push( @row, &{sub{ my @ints = $o->interfaces; $ui->select_lookup(object=>$ip, table=>"Ipblock", column=>'interface', lookup=>"Interface", defaults=>\@ints, edit=>$editips, returnAsVar=>1, linkPage=>"interface.html"); }} ); push( @row, &{sub{ my $a = ""; if ( $ip->a_records ){ foreach my $ar ( $ip->a_records ){ # Don't let user delete the RR that the Device name points to # otherwise a referential integrity error would happen if ( $editips && ($ar->rr->id != $o->name->id) ){ $a .= 'rr->id . "__delete" . '" >[del] '; } $a .= $ui->form_field(object=>$ar->rr, column=>"name", edit=>0, linkPage=>"host.html", returnValOnly=>1); } } $a; }} ); push( @row, &{sub{ my $a = ""; if ( scalar ($ip->services) ){ foreach my $ipsrv ($ip->services){ if ( $editips ){ $a .= 'id . "__delete" . '" > [del] '; } $a .= '' . $ipsrv->service->name . ''; $a .= '
'; } } if ( !$editips && $can_edit ){ $a .= "[add]"; } $a; }} ); push( @rows, \@row ); }# foreach $m->comp('/generic/data_table.mhtml', field_headers=>\@headers, data=>\@rows ); } # endif scalar @ips if ( !$editips ){ (@headers, @rows) = (); if ( $add_ip ){ # Let user add a new IP <%perl> @headers = ( 'Address', 'Interface' ); (@row) = (); push( @row, &{sub{ my $ac = ""; $ac .= ''; $ac; }} ); push( @row, &{sub{ my $ac = ""; $ac .= ''; $ac; }} ); push( @rows, \@row ); } $m->comp('/generic/data_table.mhtml', field_headers=>\@headers, data=>\@rows ); if ( $add_ip ){ print '

'; print ''; print ''; } } if ( $editips || $add_ip ) { print ''; }

% if ( !$editips && !$add_ip ){
Options
 
% if ( $manager && $manager->can($user, 'edit', $o) ){

Set Auto DNS on all IP interfaces to:

% }
% }
% } %####################################################################### %# %# BGP Peers %# %####################################################################### % if ( $view eq "BGP" || $view eq "All"){ % my (@field_headers, @cell_data); % push( @field_headers, "BGP ID: " ); % push( @cell_data, $ui->form_field(object=>$o, column=>"bgpid", edit=>$editdevbgp, returnValOnly=>1) ); % push( @field_headers, "BGP Local AS: " ); % push( @cell_data, $ui->form_field(object=>$o, column=>"bgplocalas", edit=>$editdevbgp, returnValOnly=>1) );
Device BGP Info
% if ( $editdevbgp ) {
% }else{ % if ( $manager && $manager->can($user, "edit", $o) ){ [edit] % } % }
<& /generic/attribute_table.mhtml, field_headers=>\@field_headers, data=>\@cell_data &> % if ( $editdevbgp ) { % }
<%perl> my $ipeers = $o->get_bgp_peers(type=>"internal", sort=>$peersort); my $epeers = $o->get_bgp_peers(type=>"external", sort=>$peersort); my $whois_url = Netdot->config->get('BGP_AS_WHOIS_URL'); % if ( $ipeers || $epeers ){
BGP Peers
% if ( $editbgp ) {
% }else{ % if ( $manager && $manager->can($user, "edit", $o) ){ [edit] % } % }
<%perl> (@headers, @rows) = (); push( @headers, 'Remote IP' ); push( @headers, 'ID' ); push( @headers, 'Entity' ); push( @headers, 'AS Name' ); push( @headers, 'AS Number' ); push( @headers, 'Monitored?' ); if ( $epeers ){ push @rows, ["External (eBGP)", "", "", "", "", ""]; foreach my $peer ( @$epeers ){ my (@row) = (); push( @row, $ui->form_field(object=>$peer, column=>"bgppeeraddr", edit=>$editbgp, linkPage=>"view.html", returnValOnly=>1) ); push( @row, $peer->bgppeerid ); push( @row, '' . $peer->entity->name . '' ); push( @row, $peer->entity->asname ); my $asn = $peer->entity->asnumber; if ( $whois_url && !($asn >= 64512 && $asn <= 65535) ){ my $url = $whois_url; $url =~ s//$asn/; push( @row, "$asn" ); }else{ push( @row, $asn ); } push( @row, $ui->radio_group_boolean(object=>$peer, column=>"monitored", edit=>$editbgp, returnAsVar=>1) ); push( @rows, \@row ); } push @rows, [" ", "", "", "", "", ""]; } if ( $ipeers ){ push @rows, ["Internal (iBGP)", "", "", "", "", ""]; foreach my $peer (@$ipeers){ my (@row) = (); push( @row, $ui->form_field(object=>$peer, column=>"bgppeeraddr", edit=>$editbgp, linkPage=>"view.html", returnValOnly=>1) ); push( @row, $peer->bgppeerid ); push( @row, '' . $peer->entity->name . '' ); push( @row, $peer->entity->asname ); if ( $whois_url ){ my $asn = $peer->entity->asnumber; my $url = $whois_url; $url =~ s//$asn/; push( @row, "$asn" ); }else{ push( @row, $peer->entity->asnumber ); } push( @row, $ui->radio_group_boolean(object=>$peer, column=>"monitored", edit=>$editbgp, returnAsVar=>1) ); push( @rows, \@row ); } } <& /generic/data_table.mhtml, field_headers=>\@headers, data=>\@rows &> % if ( $editbgp ) { % }
% } % } %####################################################################### %# %# STP %# %####################################################################### % if ( $view eq "STP" || $view eq "All"){ % my (@field_headers, @cell_data); % # General info % if ( my $asset = $o->asset_id ){ % $ui->add_to_fields(o=>$asset, edit=>0, fields=>['physaddr'], % field_headers=>\@field_headers, cell_data=>\@cell_data, % linkpages=>['mac.html']); % } % my @fields = ('stp_enabled', 'stp_type'); % if ( $o->stp_type eq 'mst' ){ % # MST info % push @fields, ('stp_mst_region', 'stp_mst_rev', 'stp_mst_digest'); % } % $ui->add_to_fields(o=>$o, edit=>0, fields=>\@fields, field_headers=>\@field_headers, % cell_data=>\@cell_data);
Spanning Tree Info
 
<& /generic/attribute_table.mhtml, field_headers=>\@field_headers, data=>\@cell_data &>
% # Instance Info % my @instances; % if ( @instances = $o->stp_instances ){
STP Instances
% foreach my $stp_inst ( sort { $a->number <=> $b->number } @instances) { % }
Number Device Root Port Root Bridge Bridge Priority STP Graph
  <% $stp_inst->number %>   <% $fqdn %> <% $stp_inst->root_port %> <% $stp_inst->root_bridge %> <% $stp_inst->bridge_priority %>   [Graph It]
% } % if ( defined($stp_number) ) {
Spanning Tree Graph (Instance: <% $stp_number %>)
% print $ui->build_device_stp_graph_html(id=>$id, number=>$stp_number, view=>$view, % web_path=>$r->dir_config('NetdotPath') );
% } % } %####################################################################### %# %# Topology %# %####################################################################### % % if ( $view eq "Topology" || $view eq "All" ){ % Note: Depths greater than 2 may take a long time to render

Show Vlans? Show this Vlan only? Show Interface Names? Depth up Depth down Reference Point  
> >
Topology - Layer 2
% $toporoot = Device->search(name=>$toporoot)->first || % $m->comp('/generic/error.mhtml', error=>"Cannot find root device: $toporoot"); % print $ui->build_device_topology_graph_html(id=>$id, view=>$view, root=>$toporoot->id, % depth_up=>$topodepth_up, depth_down=>$topodepth_down, % web_path=>$r->dir_config('NetdotPath'), % show_vlans=>$topovlans, show_names=>$toponames, % specific_vlan=>$specific_vlan);
% } # End Topology stuff %####################################################################### %# %# ARP %# %####################################################################### % % if ( $view eq "ARP" || $view eq "All" ){ %
ARP Caches
<& /generic/sortresults.mhtml, object => \@arp_caches , view => "row" , sort=>0 &>
% } % % %####################################################################### %# %# FWT %# %####################################################################### % % if ( $view eq "FWT" || $view eq "All" ){ %
Forwarding Tables
<& /generic/sortresults.mhtml, object => \@fwt , view => "row" , sort=>0&>
% } % % %####################################################################### %# %# History %# %####################################################################### % % if ( $view eq "History" || $view eq "All" ){ % my @h_objs = $o->get_history; %
History
<& /generic/sortresults.mhtml, object => \@h_objs , view => "row" &>
% } % % %####################################################################### %# %# Circuit %# %####################################################################### %if ( $view eq "Circuit" || $view eq "All" ){
Circuits
<& /generic/sortresults.mhtml, object => \@circuits , view => "row" &>
%} %################################################################ %# Access Rights %################################################################ <%perl> if ( $view eq "Rights" || $view eq "All" ){ my @arights = AccessRight->search(object_class=>'Device', object_id=>"$o"); my @urights = map { $_->user_rights } @arights; my @grights = map { $_->group_rights } @arights; my @all_rights = ( @urights, @grights); % if ( $manager && $manager->can($user, "access_section", 'device.html:edit_rights') ){
Access Rights
  % if ( $edit ne 'edit_rights' ){ % if ( $manager && $manager->can($user, 'edit', $o) ){ % if ( @all_rights ){ [edit] % } [add] % } % }
<%perl> if ( $_action eq 'VIEW_ADD_RIGHTS' ){ my $user_type = $user->getAttribute('USER_TYPE'); if ( $user_type eq "Admin" ) { $m->comp('/generic/access_right_form.html', showheader=>1, object_class=>'Device', object_id=>$o->id, return_comp=>$m->current_comp->path, return_id=>$o->id); }else { $m->comp('/generic/error.mhtml', error=>"You don't have permission to manage rights!"); } }elsif ( $edit eq 'edit_rights' ){ $m->comp('/generic/sortresults.mhtml', object=>\@urights, withedit=>1, return_args=>"?id=$o"); $m->comp('/generic/sortresults.mhtml', object=>\@grights, withedit=>1, return_args=>"?id=$o"); }elsif ( @all_rights ) { $m->comp('/management/list_rights.mhtml', rights=>\@all_rights, show_object=>0); }
% } % }