Agent-TCLI-Package-Net

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

    license             => 'perl',
    dist_author         => 'Eric Hacker <hacker@cpan.org>',
    dist_abstract		=> 'Network tools for TCLI agents',
    dist_version_from   => 'lib/Agent/TCLI/Package/Net.pm',
    requires => {
		'Agent::TCLI'				 			=> '0.03',
		'POE::Component::Client::Ping' 			=> '0',
		'POE::Component::Client::Traceroute' 	=> '0',
		'POE::Component::Client::HTTP'		 	=> '0',
		'POE::Component::Client::SMTP'		 	=> '0',
		'POE::Component::Client::Keepalive'		=> '0',
		'POE::Component::Server::SimpleHTTP' 	=> '0',
		'Email::MIME::Creator'					=> '0',
		'File::Slurp'							=> '0',

		'FormValidator::Simple::Plugin::NetAddr::IP'	=> '0.01',
    	},
    create_makefile_pl => 'passthrough',
);

# This will cause it to pick up XML files

META.yml  view on Meta::CPAN

abstract: Network tools for TCLI agents
license: perl
resources:
  license: http://dev.perl.org/licenses/
requires:
  Agent::TCLI: 0.03
  Email::MIME::Creator: 0
  File::Slurp: 0
  FormValidator::Simple::Plugin::NetAddr::IP: 0.01
  POE::Component::Client::HTTP: 0
  POE::Component::Client::Keepalive: 0
  POE::Component::Client::Ping: 0
  POE::Component::Client::SMTP: 0
  POE::Component::Client::Traceroute: 0
  POE::Component::Server::SimpleHTTP: 0
provides:
  Agent::TCLI::Package::Net:
    file: lib/Agent/TCLI/Package/Net.pm
    version: 0.031
  Agent::TCLI::Package::Net::HTTP:
    file: lib/Agent/TCLI/Package/Net/HTTP.pm

lib/Agent/TCLI/Package/Net/HTTP.pm  view on Meta::CPAN


=cut

use warnings;
use strict;

use Object::InsideOut qw(Agent::TCLI::Package::Base);

use POE;
use POE::Component::Client::HTTP;
use POE::Component::Client::Keepalive;
use HTTP::Request::Common qw(GET POST);
use Agent::TCLI::Command;
use Agent::TCLI::Parameter;
use Getopt::Lucid qw(:all);

our $VERSION = '0.030.'.sprintf "%04d", (qw($Id: HTTP.pm 74 2007-06-08 00:42:53Z hacker $))[2];

=head2 ATTRIBUTES

The following attributes are accessible through standard <attribute>

lib/Agent/TCLI/Package/Net/HTTP.pm  view on Meta::CPAN


=cut

#my @session 	:Field
#				:Weak
#				:Type('POE::Session');

=item poco_cm

A POE connection manager session.
B<cm> will only accept POE::Component::Client::Keepalive type values.

=cut

my @poco_cm			:Field
					:All('poco_cm')
					:Type('POE::Component::Client::KeepaliveRaw' );

=item poco_http

The POE http client.
B<poco_http> will only accept POE::Component::Client::HTTP type values.

=cut
my @poco_http		:Field
					:All('poco_http')
					:Type('POE::Component::Client::HTTPRaw' );

lib/Agent/TCLI/Package/Net/HTTP.pm  view on Meta::CPAN

	if (!defined( $self->name ))
	{
		$kernel->yield('_start');
		return;
	}

	# There is only one command object per TCLI
    $kernel->alias_set($self->name);

	# Keep the cm session so we can shut it down
	$self->set(\@poco_cm , POE::Component::Client::Keepalive->new(
  		max_per_host => 4, 		# defaults to 4
  		max_open     => 128, 	# defaults to 128
  		keep_alive   => 15, 	# defaults to 15
  		timeout      => 120, 	# defaults to 120
	));

	$self->set(\@poco_http , POE::Component::Client::HTTP->spawn(
		Agent     => $self->user_agents,
		Alias     => 'http-client',                  # defaults to 'weeble'
		ConnectionManager => $poco_cm[$$self],
#		From      => 'spiffster@perl.org',  # defaults to undef (no header)
#		CookieJar => $cookie_jar,
#		Protocol  => 'HTTP/1.1',            # defaults to 'HTTP/1.1'

lib/Agent/TCLI/Package/Net/Ping.pm  view on Meta::CPAN

    This will only happen if there is no response from prior requests.
  type: Param
---
Agent::TCLI::Command:
  name: ping
  call_style: session
  command: tcli_ping
  contexts:
    ROOT: ping
  handler: ping
  help: check to see if a host is alive
  manual: >
    Ping will send an ICMP echo to a target, hoping to get an ICMP
    response before a timeout. One can ping multiple hosts concurrently.
  parameters:
    target:
    timeout:
    retry_count:
  required:
    target:
  topic: network

t/TCLI.Package.Net.Ping.t  view on Meta::CPAN

	'test_master'	=> $test_master,
	'addressee'		=> 'self',
);

is($test1->name,'tcli_ping', '$test1->name initialized');
my $test_c1 = $test1->commands();
is(ref($test_c1),'HASH', '$test1->commands is a hash');
my $test_c1_0 = $test_c1->{'ping'};
is($test_c1_0->name,'ping', '$test_c1_0->name loaded ok');
is($test_c1_0->usage,'ping target example.com', '$test_c1_0->usage ok');
is($test_c1_0->help,'check to see if a host is alive', '$test_c1_0->help ok');
is($test_c1_0->topic,'network', '$test_c1_0->topic ok');
is($test_c1_0->command,'tcli_ping', '$test_c1_0->command ok');
is($test_c1_0->handler,'ping', '$test_c1_0->handler ok');
is($test_c1_0->call_style,'session', '$test_c1_0->call_style ok');

$ping->like_body( 'ping show timeout',qr(timeout.*?10), 'ping show timeout');
$ping->like_body( 'ping show retry_count',qr(retry_count.*?1), 'ping show retry count');
$ping->like_body( 'ping show target',qr(#!undefined), 'ping show target not set');
$ping->ok( 'ping set target 127.0.0.1', 'ping set target');
$ping->like_body( 'ping show target',qr(target.*?127.0.0.1), 'ping show target');



( run in 0.849 second using v1.01-cache-2.11-cpan-df04353d9ac )