vsoapd

 view release on metacpan or  search on metacpan

sbin/vsoapc  view on Meta::CPAN

## Get signal names
use Config;
defined $Config{sig_name} || die "No sigs?";
my ( %signo, @signame, $i );
$i = 0;
foreach my $name ( split( ' ', $Config{sig_name} ) ) {
    $signo{$name} = $i;
    $signame[$i] = $name;
    $i++;
}

## Load the config file
my $config_file;
my $username = '';
my $password = undef;
my $curses = 0;
my $ip = '';
my $version = 0;
my $help = 0;

GetOptions('username|u=s' => \$username,
	   'password|p=s' => \$password,
	   'curses!'       => \$curses,
	   'version'      => \$version,
	   'config=s'     => \$config_file,
	   'debug|d+'     => \$DEBUG,
	   'help!'        => \$help
	   );

if ( defined $config_file ) {
    die "FATAL: config file: $config_file not found" unless ( -e $config_file );
} else {
    for my $etc_dir (@etc_dirs) {
        if ( -e "$etc_dir/vuser.conf" ) {
            $config_file = "$etc_dir/vuser.conf";
            last;
        }
    }
}

if ( not defined $config_file ) {
    die "Unable to find a vuser.conf file in "
      . join( ", ", @etc_dirs ) . ".\n";
}

my %cfg;
tie %cfg, 'Config::IniFiles', ( -file => $config_file );

our $log = VUser::Log->new(\%cfg, 'vsoapc');

if (not $DEBUG) {
    # Only load the debug from the config file if we haven't turned
    # debugging on from the cmd line    
    $DEBUG = VUser::ExtLib::strip_ws($cfg{'vuser'}{'debug'}) || 0;
    $DEBUG = VUser::ExtLib::check_bool($DEBUG) unless $DEBUG =~ /^\d+$/;
}
my $debug = $DEBUG;

if (not $username) {
    # Guess the username.
    $username = getlogin || (getpwuid($<))[0] || die "Unable to determine username. Use --username\n";
}

pod2usage() if $help;

if ($version) {
    print "Version: $VERSION\n";
    exit;
}

if (check_bool ($cfg{$c_sec}{'require authentication'}) and not $password) {
    print "Password: ";
    ReadMode('noecho'); # Turn off character echo
    $password = ReadLine(0);
    chomp $password;
    ReadMode(0); # Reset the tty
    print "\n";
}

print "vsoapc $VERSION\n" if $debug;

my $keyword = shift @ARGV || 'help';
my $action = shift @ARGV;

print "Keyword: $keyword Action: $action\n" if $DEBUG >= 1;

# Actions cannot start with -
if (defined $action
    and $action =~ /^-/) {
    unshift @ARGV, $action;
    $action = '';
}

$action = '' unless defined $action;

# Ok. Now it's time to do the action.
our $uri = strip_ws($cfg{$c_sec}{'uri'}) || 'urn:/VUser';
our $proxy = strip_ws($cfg{$c_sec}{'proxy'});
our $service = strip_ws($cfg{$c_sec}{'service'});

my $soap;
if ($service) {
    $log->log (LOG_INFO, "Attempting to connect to $service");
    $soap = SOAP::Lite->service($service);
} else {
    $log->log (LOG_INFO, "Attempting to connect to $proxy for $uri");
    $soap = SOAP::Lite
    -> uri ($uri)
    -> proxy ($proxy);
}

$log->log (LOG_DEBUG, "Credentials: %s, %s", $username, defined $password? $password : 'undef');

# Log sends back info in the SOAP headers including a ticket that
# is sent back through the headers for the other task functions
if ($debug) {
    use Data::Dumper; print Dumper $soap;
}
my $authinfo = $soap
    #SOAP::Lite->service($service)
    -> login ($username, $password)



( run in 1.045 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )