line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::LDAP::Command::Add::Host; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use Modern::Perl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
598
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with qw( App::LDAP::Role::Command |
8
|
|
|
|
|
|
|
App::LDAP::Role::Bindable ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has base => ( |
11
|
|
|
|
|
|
|
is => "rw", |
12
|
|
|
|
|
|
|
isa => "Str", |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Term::Prompt; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use App::LDAP::LDIF::Host; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub run { |
20
|
|
|
|
|
|
|
my ($self) = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $hostname = $self->extra_argv->[2] or die "no hostname specified"; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
die "host $hostname already exists" if App::LDAP::LDIF::Host->search( |
25
|
|
|
|
|
|
|
base => config()->{nss_base_hosts}->[0], |
26
|
|
|
|
|
|
|
scope => config()->{nss_base_hosts}->[1], |
27
|
|
|
|
|
|
|
filter => "cn=$hostname", |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $ip = prompt('x', 'ip address:', '', ''); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $host = App::LDAP::LDIF::Host->new( |
33
|
|
|
|
|
|
|
base => $self->base // config()->{nss_base_hosts}->[0], |
34
|
|
|
|
|
|
|
cn => [$hostname], |
35
|
|
|
|
|
|
|
ipHostNumber => $ip, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$host->save; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$host; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
44
|
|
|
|
|
|
|
no Moose; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |