MCPcopy Create free account
hub / github.com/apache/mesos / getNonLoopbackIP

Function getNonLoopbackIP

src/tests/utils.cpp:196–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194
195
196Try<net::IP::Network> getNonLoopbackIP()
197{
198 Try<set<string>> links = net::links();
199 if (links.isError()) {
200 return Error(
201 "Unable to retrieve interfaces on this host: " +
202 links.error());
203 }
204
205 foreach (const string& link, links.get()) {
206 Result<net::IP::Network> hostNetwork =
207 net::IP::Network::fromLinkDevice(link, AF_INET);
208
209 if (hostNetwork.isError()) {
210 return Error(
211 "Unable to find a non-loopback address: " +
212 hostNetwork.error());
213 }
214
215 if (hostNetwork.isSome() &&
216 (hostNetwork.get() != net::IP::Network::LOOPBACK_V4())) {
217 return hostNetwork.get();
218 }
219 }
220
221 return Error("No non-loopback addresses available on this host");
222}
223
224} // namespace tests {
225} // namespace internal {

Callers 3

SetUpMethod · 0.85
TEST_FFunction · 0.85
TEST_PFunction · 0.85

Calls 4

errorMethod · 0.65
linksFunction · 0.50
ErrorFunction · 0.50
isErrorMethod · 0.45

Tested by

no test coverage detected