1use utf8;
2package App::Netdisco::DB::Result::DeviceIp;
3
4
5use strict;
6use warnings;
7
8use base 'App::Netdisco::DB::Result';
9__PACKAGE__->table("device_ip");
10__PACKAGE__->add_columns(
11  "ip",
12  { data_type => "inet", is_nullable => 0 },
13  "alias",
14  { data_type => "inet", is_nullable => 0 },
15  "subnet",
16  { data_type => "cidr", is_nullable => 1 },
17  "port",
18  { data_type => "text", is_nullable => 1 },
19  "dns",
20  { data_type => "text", is_nullable => 1 },
21  "creation",
22  {
23    data_type     => "timestamp",
24    default_value => \"current_timestamp",
25    is_nullable   => 1,
26    original      => { default_value => \"now()" },
27  },
28);
29__PACKAGE__->set_primary_key("ip", "alias");
30
31
32
33=head1 RELATIONSHIPS
34
35=head2 device
36
37Returns the entry from the C<device> table to which this IP alias relates.
38
39=cut
40
41__PACKAGE__->belongs_to( device => 'App::Netdisco::DB::Result::Device', 'ip' );
42
43=head2 device_port
44
45Returns the Port on which this IP address is configured (typically a loopback,
46routed port or virtual interface).
47
48=cut
49
50__PACKAGE__->add_unique_constraint(['alias']);
51
52__PACKAGE__->belongs_to( device_port => 'App::Netdisco::DB::Result::DevicePort',
53  { 'foreign.port' => 'self.port', 'foreign.ip' => 'self.ip' } );
54
551;
56