Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
56b43e80
Commit
56b43e80
authored
Jan 16, 2018
by
Leigh B Stoller
Browse files
Left this out of previous commit
98ca9432
parent
a9f92d1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
protogeni/lib/GeniEvent.pm.in
View file @
56b43e80
#
!/usr/bin/perl -w
#
#
Copyright
(
c
)
2008
-
2016
University
of
Utah
and
the
Flux
Group
.
#
Copyright
(
c
)
2008
-
2016
,
2018
University
of
Utah
and
the
Flux
Group
.
#
#
{{{
GENIPUBLIC
-
LICENSE
#
...
...
@@ -61,31 +61,62 @@ my $BOSSNODE = "@BOSSNODE@";
my
$
OURDOMAIN
=
"@OURDOMAIN@"
;
my
$
MAINSITE
=
@
TBMAINSITE
@;
my
$
MYURN
=
"urn:publicid:IDN+${OURDOMAIN}+authority+cm"
;
#
Portal
SSL
pubsubd
running
on
this
host
:
port
my
$
CLUSTER_PORTAL
=
"@CLUSTER_PORTAL@"
;
my
$
CLUSTER_PUBSUBD_SSLPORT
=
"@CLUSTER_PUBSUBD_SSLPORT@"
;
my
$
CERTFILE
=
"$TB/etc/emulab.pem"
;
my
$
KEYFILE
=
"$TB/etc/emulab.key"
;
my
$
GeniEventHande
;
#
#
Want
just
one
of
these
.
#
my
$
GeniEventHandle
;
#
#
Create
a
connection
to
the
local
clusterd
,
which
is
going
to
forward
#
events
to
the
mothership
.
#
See
below
for
explanation
.
#
sub
Create
($;$
$
)
sub
Create
($;$)
{
my
($
class
,
$
server
,
$
port
)
=
@
_
;
$
server
=
"localhost"
if
(
!defined($server));
$
port
=
(
defined
($
port
)
?
":$port"
:
""
);
my
$
url
=
my
$
URL
=
"elvin://${server}${port}"
;
my
$
handle
=
event_register
($
URL
,
0
);
return
undef
if
(
!$handle);
my
($
class
,
$
handle
)
=
@
_
;
my
$
self
=
{};
#
#
At
the
Portal
all
of
these
events
go
to
the
local
SSL
pubsubd
since
#
that
is
where
aptevent_daemon
is
listening
.
On
a
standalone
site
#
all
of
the
events
go
to
the
local
regular
pubsubd
,
which
is
where
#
aptevent_daemon
is
listening
.
#
#
At
a
remote
cluster
,
things
are
more
complicated
.
The
event
might
be
#
for
a
Portal
slice
or
it
might
be
a
locally
created
slice
.
If
its
for
#
a
locally
created
slice
,
the
events
need
to
go
to
the
local
pubsubd
#
which
is
where
aptevent_daemon
is
listening
,
but
if
the
slice
is
a
#
Portal
slice
,
the
event
needs
to
go
back
to
the
Portal
SSL
pubsubd
.
#
But
we
do
not
want
dozens
of
different
senders
to
the
Portal
pubsubd
,
#
it
would
be
better
if
there
was
just
one
sender
.
So
send
them
to
the
#
local
pubsubd
,
the
igevent_daemon
will
pick
it
up
and
decide
if
it
#
needs
to
be
forwarded
based
on
the
slice
domain
.
#
if
(
!defined($handle)) {
if
($
CLUSTER_PORTAL
ne
""
&&
$
CLUSTER_PORTAL
eq
$
BOSSNODE
)
{
my
$
URL
=
"elvin://localhost:${CLUSTER_PUBSUBD_SSLPORT}"
;
$
handle
=
event_register_withssl
($
URL
,
0
,
$
CERTFILE
,
$
KEYFILE
);
}
else
{
my
$
URL
=
"elvin://localhost"
;
$
handle
=
event_register
($
URL
,
0
);
}
return
undef
if
(
!$handle);
$
self
->{
'EXTERNAL'
}
=
0
;
}
else
{
#
Mark
as
an
external
handle
,
we
do
not
want
to
mess
with
it
.
$
self
->{
'EXTERNAL'
}
=
1
;
}
$
self
->{
'HANDLE'
}
=
$
handle
;
bless
($
self
,
$
class
);
$
GeniEventHandle
=
$
self
;
return
$
self
;
}
...
...
@@ -93,7 +124,7 @@ sub DESTROY
{
my
$
self
=
shift
;
if
(
defined
($
self
->{
'HANDLE'
}))
{
if
(
defined
($
self
->{
'HANDLE'
})
&&
!$self->{'EXTERNAL'}
) {
event_unregister
($
self
->{
'HANDLE'
});
$
self
->{
'HANDLE'
}
=
undef
;
}
...
...
@@ -109,15 +140,16 @@ sub SendEvent($$)
#
print
STDERR
Dumper
($
hash
);
if
(
!ref($self)) {
if
(
!defined($GeniEventHande)) {
$
GeniEventHande
=
GeniEvent
->
Create
();
if
(
!defined($GeniEventHande)) {
if
(
!defined($GeniEventHand
l
e)) {
GeniEvent
->
Create
();
if
(
!defined($GeniEventHand
l
e)) {
print
STDERR
"Could not register with event server
\n
"
;
return
-
1
;
}
}
}
my
$
handle
=
(
ref
($
self
)
?
$
self
->{
'HANDLE'
}
:
$
GeniEventHande
->{
'HANDLE'
});
my
$
handle
=
(
ref
($
self
)
?
$
self
->{
'HANDLE'
}
:
$
GeniEventHandle
->{
'HANDLE'
});
my
$
tuple
=
address_tuple_alloc
();
if
(
!defined($tuple)) {
print
STDERR
"Could not allocate tuple
\n
"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment