Solaris-DeviceTree

 view release on metacpan or  search on metacpan

scripts/devtree  view on Meta::CPAN

  print_network();
} elsif( defined $bootinfo ) {
  print_bootinfo();
} elsif( defined $businfo ) {
  require Solaris::DeviceTree::Libdevinfo;
  my $libdevinfo_tree = Solaris::DeviceTree::Libdevinfo->new;
  require Solaris::DeviceTree::Filesystem;
  my $filesystem_tree = Solaris::DeviceTree::Filesystem->new;
  require Solaris::DeviceTree::PathToInst;
  my $path_to_inst_tree = Solaris::DeviceTree::PathToInst->new;
  print_businfo( indent => 1, node => make_overlay_tree() );
} else {
  pod2usage( 1 );
}

sub make_overlay_tree {
  require Solaris::DeviceTree::Libdevinfo;
  my $libdevinfo_tree = Solaris::DeviceTree::Libdevinfo->new;
  require Solaris::DeviceTree::Filesystem;
  my $filesystem_tree = Solaris::DeviceTree::Filesystem->new;
  require Solaris::DeviceTree::PathToInst;
  my $path_to_inst_tree = Solaris::DeviceTree::PathToInst->new;

  my $overlay_tree = Solaris::DeviceTree::Overlay->new(
    sources => {
      libdevinfo => $libdevinfo_tree,
      filesystem => $filesystem_tree,
      path_to_inst => $path_to_inst_tree,
    },
  );

  return $overlay_tree;
}


# -- Utility functions --

# Returns maximal length of all strings in the array.
sub maxlen {
  return 0 if( @_ == 0 );
  my $max = length shift;
  foreach (@_) {

scripts/devtree  view on Meta::CPAN

# Print the device tree.
sub print_tree {
  my %options = @_;
#  require Solaris::DeviceTree::Libdevinfo;
#  require Solaris::DeviceTree::PathToInst;
#  require Solaris::DeviceTree::Filesystem;
#  my $tree = new Solaris::DeviceTree::Libdevinfo;
#  my $tree = new Solaris::DeviceTree::PathToInst;
#  my $tree = new Solaris::DeviceTree::Filesystem;
  # TODO: -> Implement has_data_source
  my $tree = make_overlay_tree;

  if( defined $options{attr} && $options{attr} ne '' ) {
    $options{attr} = [ split( /,/, $options{attr} ) ];
  }

  if( defined $options{prop} && $options{prop} ne '' ) {
    $options{prop} = [ split( /,/, $options{prop} ) ];
  }

#print Dumper( %options );

scripts/devtree  view on Meta::CPAN

#    print "   Solaris path: ", $node->string, "\n";
  }
  print "\n";

}

# -- disk --

sub print_disk {
  require Solaris::DeviceTree::Overlay;
  my $tree = make_overlay_tree;

  # -> TODO: Select wheter all or only accessible disks should be printed
  # Criteria:
  # o has instance in the kernel
  # o has ctds
  foreach my $c (sort { $a->controller <=> $b->controller } $tree->controller_nodes) {
    print "+-";
    print "c", $c->controller if( defined $c->controller );
    print " (", $c->devfs_path, ")\n";
    foreach my $disk (sort { ($a->target || 0)*2 + ($a->lun || 0) <=>

scripts/devtree  view on Meta::CPAN

      print "| +-";
      print $disk->solaris_device || '';
      print " (", $disk->devfs_path, ")\n";
    }
  }
}

# -- tape --

sub print_tape {
  my $tree = make_overlay_tree;

  # -> TODO: Select wheter all or only accessible tapes should be printed
  # Criteria:
  # o has instance in the kernel
  # o has /dev/rmt
#  foreach my $disk ($tree->block_nodes) {
#    print $disk->devfs_path, "\n";
#  }
}

# -- Network --

sub print_network {
  my $tree = make_overlay_tree;

  # -> TODO: Historical network nodes only in /etc/path_to_inst should be honored

  print "The following network devices have been found:\n";
  foreach my $node (sort { $a->driver_name . $a->instance cmp $b->driver_name . $b->instance }
                    $tree->network_nodes) {
#    my $interface = $node->driver_name . $node->instance;
    my $interface = $node->solaris_device || '';
    print "+-", $interface, " (", $node->devfs_path, ")\n";
  }



( run in 4.655 seconds using v1.01-cache-2.11-cpan-49f99fa48dc )