| 1 | package Net::Netconf::Manager; | ||
| 2 | |||
| 3 | use Carp; | ||
| 4 | our $VERSION ='0.01'; | ||
| 5 | |||
| 6 | # This instantiates a Junoscript or a Netconf device depending on the 'server' | ||
| 7 | # specified. Default is Netconf. | ||
| 8 | sub new | ||
| 9 | { | ||
| 10 | my($class, %args) = @_; | ||
| 11 | my $self = { %args }; | ||
| 12 | my $device = undef; | ||
| 13 | |||
| 14 | # Junoscript session | ||
| 15 | if (defined $self->{'server'} && $self->{'server'} eq 'junoscript') { | ||
| 16 | eval 'require JUNOS::Device'; | ||
| 17 | if ($@) { | ||
| 18 | croak 'Error: ' . $@; | ||
| 19 | } | ||
| 20 | $device = new JUNOS::Device(%args); | ||
| 21 | } else { # Netconf session | ||
| 22 | eval 'require Net::Netconf::Device'; | ||
| 23 | if ($@) { | ||
| 24 | croak 'Error: ' . $@; | ||
| 25 | } | ||
| 26 | $device = new Net::Netconf::Device(%args); | ||
| 27 | } | ||
| 28 | $device; | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; | ||
| 32 | |||
| 33 | __END__ |