| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::bif::pull::identity; |
|
2
|
41
|
|
|
41
|
|
10257
|
use strict; |
|
|
41
|
|
|
|
|
89
|
|
|
|
41
|
|
|
|
|
1281
|
|
|
3
|
41
|
|
|
41
|
|
228
|
use warnings; |
|
|
41
|
|
|
|
|
101
|
|
|
|
41
|
|
|
|
|
1490
|
|
|
4
|
41
|
|
|
41
|
|
56965
|
use AnyEvent; |
|
|
41
|
|
|
|
|
212341
|
|
|
|
41
|
|
|
|
|
1324
|
|
|
5
|
41
|
|
|
41
|
|
19268
|
use Bif::Sync::Client; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Bif::Mo; |
|
7
|
|
|
|
|
|
|
use Coro; |
|
8
|
|
|
|
|
|
|
use DBIx::ThinSQL qw/qv/; |
|
9
|
|
|
|
|
|
|
use Log::Any '$log'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.1.5_7'; |
|
12
|
|
|
|
|
|
|
extends 'App::bif'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub run { |
|
15
|
|
|
|
|
|
|
my $self = shift; |
|
16
|
|
|
|
|
|
|
my $opts = $self->opts; |
|
17
|
|
|
|
|
|
|
my $cv = AE::cv; |
|
18
|
|
|
|
|
|
|
my $dbw = $self->dbw; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$opts->{message} ||= "Importing identity from $opts->{location}"; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$|++; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $error; |
|
25
|
|
|
|
|
|
|
my $client = Bif::Sync::Client->new( |
|
26
|
|
|
|
|
|
|
name => $opts->{location}, |
|
27
|
|
|
|
|
|
|
db => $dbw, |
|
28
|
|
|
|
|
|
|
location => $opts->{location}, |
|
29
|
|
|
|
|
|
|
debug => $opts->{debug}, |
|
30
|
|
|
|
|
|
|
debug_bifsync => $opts->{debug_bifsync}, |
|
31
|
|
|
|
|
|
|
on_update => sub { |
|
32
|
|
|
|
|
|
|
my $client = shift; |
|
33
|
|
|
|
|
|
|
$self->lprint( $client->name . ': ' . $_[0] ); |
|
34
|
|
|
|
|
|
|
}, |
|
35
|
|
|
|
|
|
|
on_error => sub { |
|
36
|
|
|
|
|
|
|
$error = shift; |
|
37
|
|
|
|
|
|
|
$cv->send; |
|
38
|
|
|
|
|
|
|
}, |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $fh = select; |
|
42
|
|
|
|
|
|
|
my $coro = async { |
|
43
|
|
|
|
|
|
|
select $fh; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
eval { |
|
46
|
|
|
|
|
|
|
$dbw->txn( |
|
47
|
|
|
|
|
|
|
sub { |
|
48
|
|
|
|
|
|
|
$|++; |
|
49
|
|
|
|
|
|
|
my $status = $client->bootstrap_identity; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
unless ( $status eq 'IdentityImported' ) { |
|
52
|
|
|
|
|
|
|
$dbw->rollback; |
|
53
|
|
|
|
|
|
|
$error = |
|
54
|
|
|
|
|
|
|
"unexpected IdentityImported status received: $status"; |
|
55
|
|
|
|
|
|
|
return; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my ( $iid, $uuid, $name, $sn ) = $dbw->xlist( |
|
59
|
|
|
|
|
|
|
select => [ |
|
60
|
|
|
|
|
|
|
'bifkv.identity_id', |
|
61
|
|
|
|
|
|
|
'"u" || substr(n.uuid,1,8) AS uuid', |
|
62
|
|
|
|
|
|
|
'e.name', 'i.shortname', |
|
63
|
|
|
|
|
|
|
], |
|
64
|
|
|
|
|
|
|
from => 'bifkv', |
|
65
|
|
|
|
|
|
|
inner_join => 'nodes n', |
|
66
|
|
|
|
|
|
|
on => 'n.id = bifkv.identity_id', |
|
67
|
|
|
|
|
|
|
inner_join => 'identities i', |
|
68
|
|
|
|
|
|
|
on => 'i.id = n.id', |
|
69
|
|
|
|
|
|
|
inner_join => 'entities e', |
|
70
|
|
|
|
|
|
|
on => 'e.id = i.id', |
|
71
|
|
|
|
|
|
|
where => { key => 'self' }, |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
print "\n"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
}; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
if ($@) { |
|
80
|
|
|
|
|
|
|
$error = $@; |
|
81
|
|
|
|
|
|
|
print "\n"; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
return $cv->send; |
|
85
|
|
|
|
|
|
|
}; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$cv->recv; |
|
88
|
|
|
|
|
|
|
$client->disconnect; |
|
89
|
|
|
|
|
|
|
return $self->err( 'Unknown', $error ) if $error; |
|
90
|
|
|
|
|
|
|
return $self->ok('PullIdentity'); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
|
94
|
|
|
|
|
|
|
__END__ |