Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
b88d3909
Unverified
Commit
b88d3909
authored
Oct 16, 2018
by
fishyds
Committed by
GitHub
Oct 16, 2018
Browse files
Add ip address cached to resolve network issue (#220)
* Add ip address cached to resolve network issue
parent
9bb479bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
src/nni_manager/common/utils.ts
src/nni_manager/common/utils.ts
+14
-5
No files found.
src/nni_manager/common/utils.ts
View file @
b88d3909
...
...
@@ -245,18 +245,27 @@ function cleanupUnitTest(): void {
Container
.
restore
(
ExperimentStartupInfo
);
}
let
cachedipv4Address
:
string
=
''
;
/**
* Get IPv4 address of current machine
*/
function
getIPV4Address
():
string
{
let
ipv4Address
:
string
=
''
;
if
(
cachedipv4Address
&&
cachedipv4Address
.
length
>
0
)
{
return
cachedipv4Address
;
}
for
(
const
item
of
os
.
networkInterfaces
().
eth0
)
{
if
(
item
.
family
===
'
IPv4
'
)
{
ipv4Address
=
item
.
address
;
if
(
os
.
networkInterfaces
().
eth0
)
{
for
(
const
item
of
os
.
networkInterfaces
().
eth0
)
{
if
(
item
.
family
===
'
IPv4
'
)
{
cachedipv4Address
=
item
.
address
;
return
cachedipv4Address
;
}
}
}
else
{
throw
Error
(
'
getIPV4Address() failed because os.networkInterfaces().eth0 is undefined.
'
);
}
return
ipv4Address
;
throw
Error
(
'
getIPV4Address() failed because no valid IPv4 address found.
'
)
}
export
{
generateParamFileName
,
getMsgDispatcherCommand
,
getLogDir
,
getExperimentRootDir
,
...
...
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