Send Netdot-users mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://osl.uoregon.edu/mailman/listinfo/netdot-users
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Netdot-users digest..."
Today's Topics:
1. Re: RESTful interface questions (Patrick Landry)
----------------------------------------------------------------------
Message: 1
Date: Tue, 12 Feb 2013 11:12:23 -0600 (CST)
From: Patrick Landry <[email protected]>
Subject: Re: [Netdot-users] RESTful interface questions
To: [email protected]
Message-ID:
<18576789.1756.1360689139159.JavaMail.javamailuser@localhost>
Content-Type: text/plain; charset="utf-8"
----- Original Message -----
> On 11. 02. 2013 20:43, Patrick Landry wrote:
> > One thing I did find was that in order to update a host you need to
> > include the 'name' parameter in the data portion of the POST.
> > Unless
> > this is a requirement of the Netdot-Client-REST module only, the
> > manual is incomplete in this regard.
> Thats odd. It works for me. I tried this:
I am attempting to update a host (DNS record). It is easy to code it such that
it works.
CODE:
my $hostname = 'testing3';
my $host;
my $hostrrid;
my $netdot = Netdot::Client::REST->new(
server =>'http://cannon.private.my.domain/netdot',
username => 'pml4791',
password => 'mca1304cwyl',
);
print "CREATE HOST\n";
my $data = {};
$data->{'zone'} = 'private.my.domain';
$data->{'info'} = "This is a comment";
$data->{'subnet'} = '10.35.4.0/24';
eval {$netdot->post('host?name='.$hostname, $data);};
if ($@) {
print "Error creating host: $hostname \$data:\n", Dumper($data), $@;
}
else {
print "SUCCESS create\n";
}
$host = $netdot->get("host?name=$hostname");
($hostrrid) = keys %{$host->{RR}};
print Dumper($host);
print "UPDATE HOST WITHOUT PROVIDING HOSTNAME\n";
$data = {};
$data->{info} = "This is a new comment";
eval {$netdot->post('host?rrid='.$hostrrid, $data);};
if ($@) {
print "Error#1 updating host: $hostrrid \$data:\n", Dumper($data), $@;
}
else {
print "SUCCESS update 1\n";
}
$host = $netdot->get("host?name=$hostname");
($hostrrid) = keys %{$host->{RR}};
print Dumper($host);
print "UPDATE HOST PROVIDING HOSTNAME\n";
$data = {};
$data->{name} = $hostname;
$data->{info} = "This is a new comment";
eval {$netdot->post('host?rrid='.$hostrrid, $data);};
if ($@) {
print "Error#2 updating host: $hostrrid \$data:\n", Dumper($data), $@;
}
else {
print "SUCCESS update 2\n";
}
my $host = $netdot->get("host?name=$hostname");
($hostrrid) = keys %{$host->{RR}};
print Dumper($host);
OUTPUT:
CREATE HOST
SUCCESS create
$VAR1 = {
'RR' => {
'1701' => {
'info' => 'This is a comment',
'auto_update' => '0',
'zone' => 'private.my.domain',
'name' => 'testing3',
'active' => '1',
'modified' => '2013-02-12 11:05:00',
'created' => '2013-02-12 11:05:00',
'expiration' => '',
'zone_xlink' => 'Zone/11'
}
},
'Ipblock' => {
'1285344' => {
'used_by' => '0',
'status' => 'Static',
'use_network_broadcast' => '0',
'status_xlink' => 'IpblockStatus/6',
'last_seen' => '2013-02-04 11:48:25',
'interface' => '0',
'parent_xlink' => 'Ipblock/9526',
'first_seen' => '2013-02-04 11:48:25',
'address' => '10.35.4.12',
'owner' => '0',
'info' => '',
'parent' => '10.35.4.0/24',
'version' => '4',
'vlan' => '0',
'description' => '',
'prefix' => '32'
}
}
};
UPDATE HOST WITHOUT PROVIDING HOSTNAME
Error#1 updating host: 1701 $data:
$VAR1 = {
'info' => 'This is a new comment'
};
File does not exist: Bad request: $e at
/usr/local/share/perl5/Netdot/Client/REST.pm line 203
$VAR1 = {
'RR' => {
'1701' => {
'info' => 'This is a comment',
'auto_update' => '0',
'zone' => 'private.my.domain',
'name' => 'testing3',
'active' => '1',
'modified' => '2013-02-12 11:05:00',
'created' => '2013-02-12 11:05:00',
'expiration' => '',
'zone_xlink' => 'Zone/11'
}
},
'Ipblock' => {
'1285344' => {
'used_by' => '0',
'status' => 'Static',
'use_network_broadcast' => '0',
'status_xlink' => 'IpblockStatus/6',
'last_seen' => '2013-02-04 11:48:25',
'interface' => '0',
'parent_xlink' => 'Ipblock/9526',
'first_seen' => '2013-02-04 11:48:25',
'address' => '10.35.4.12',
'owner' => '0',
'info' => '',
'parent' => '10.35.4.0/24',
'version' => '4',
'vlan' => '0',
'description' => '',
'prefix' => '32'
}
}
};
UPDATE HOST PROVIDING HOSTNAME
SUCCESS update 2
$VAR1 = {
'RR' => {
'1701' => {
'info' => 'This is a new comment',
'auto_update' => '0',
'zone' => 'private.my.domain',
'name' => 'testing3',
'active' => '1',
'modified' => '2013-02-12 11:05:00',
'created' => '2013-02-12 11:05:00',
'expiration' => '',
'zone_xlink' => 'Zone/11'
}
},
'Ipblock' => {
'1285344' => {
'used_by' => '0',
'status' => 'Static',
'use_network_broadcast' => '0',
'status_xlink' => 'IpblockStatus/6',
'last_seen' => '2013-02-04 11:48:25',
'interface' => '0',
'parent_xlink' => 'Ipblock/9526',
'first_seen' => '2013-02-04 11:48:25',
'address' => '10.35.4.12',
'owner' => '0',
'info' => '',
'parent' => '10.35.4.0/24',
'version' => '4',
'vlan' => '0',
'description' => '',
'prefix' => '32'
}
}
};
--
patrick
Patrick Landry
University of Louisiana at Lafayette
Director, University Computer Support Services
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://osl.uoregon.edu/pipermail/netdot-users/attachments/20130212/9cc6e61a/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Landry, Patrick.vcf
Type: text/directory
Size: 11870 bytes
Desc: not available
Url :
http://osl.uoregon.edu/pipermail/netdot-users/attachments/20130212/9cc6e61a/attachment.bin
------------------------------
_______________________________________________
Netdot-users mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-users
End of Netdot-users Digest, Vol 51, Issue 4
*******************************************