Next Topic

Previous Topic

Book Contents

Logout

Log out of the BVE API server.

$return_value = $obj->Logout;

This method sends a logout command to the BVE API server and closes the already established TCP connection to $host_name_or_ip, which was defined using the new method.

On timeout or other connection errors, the return value is 0 and details on the error are available via the GetErrorMsg method. On success, a non-zero return value is provided.

Examples: Connect, Log In, Create a DGE, Log Out

This example creates a connection to localhost, logs in, creates a new DGE, and logs out.

use Zyrion qw(Provisioning);
my $obj = new Zyrion::Provisioning(Host=>"localhost");
my $return_value = $obj->
Login(User=>"admin",Password=>"changeme") \|\|
die "ERROR: ", $obj->[GetErrorMsg], "\n";
$obj->[CreateDGE](dgeName=>"Local DGE",
Host=>"192.168.100.200",
locationName=>"Local Network",
softLimit=>100) \|\|
die "ERROR: ", $obj->[GetErrorMsg], "\n";
$obj->Logout;

Note that the optional parameter softLimit was specified, but hardLimit was not, in which case the default value would be used.

In the following example, the same login sequence is used, but now a new device is being created on the previously created DGE, and then a list of existing devices is generated:

use Zyrion qw(Provisioning);
my $obj = new Zyrion::Provisioning(Host=>"localhost");
my $return_value = $obj->
Login(User=>"admin",Password=>"changeme") \|\|
die "ERROR: ", $obj->[GetErrorMsg], "\n";
my %param = ();
$param{deviceName} = "my test device";
$param{address} = "192.168.200.50";
$param{locationName} = "Local Network";
$param{snmpCid} = "public";
$param{comment} = "my workstation";
$param{devicetype} = "unix";
$obj->[CreateDevice](%param) ¦¦
die "ERROR: ", $obj->[GetErrorMsg], "\n";
$obj->[ListDevice](deviceName=>'my \*');
if ($obj->[GetResultCount]) {
my $result_ref = $obj->[GetResultRef]();
foreach my $serial_num (keys %{ $result_ref }) {
print "device with serial number ${serial_num} ..\n";
foreach my $object_param (keys %{ $result_ref->{$serial_num} }) {
$param_value = $result_ref->{$serial_num}->{$object_param};
print "\t\t${object_param} = ${param_value}\n";
}
}
}
$obj->Logout;

Note that in this case, while creating the device, instead of providing named parameters, a hash of parameters was used.