MCPcopy Create free account
hub / github.com/apache/cloudstack / getDefaultNetwork

Method getDefaultNetwork

python/lib/cloudutils/networkConfig.py:43–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41 return devs
42 @staticmethod
43 def getDefaultNetwork():
44 cmd = bash("ip route show default | awk \'{print $3,$5}\'")
45 if not cmd.isSuccess():
46 logging.debug("Failed to get default route")
47 raise CloudRuntimeException("Failed to get default route")
48 output = cmd.getStdout().strip()
49 result = output.split(" ")
50 if len(result) < 2:
51 logging.debug("Output for the default route incomplete: %s. It should have been '<GATEWAY> <DEVICE>'" % output)
52 raise CloudRuntimeException("Output for the default route incomplete")
53 gateway = result[0]
54 dev = result[1]
55
56 pdi = networkConfig.getDevInfo(dev)
57 logging.debug("Found default network device:%s"%pdi.name)
58 pdi.gateway = gateway
59 return pdi
60
61 @staticmethod
62 def createBridge(dev, brName):

Callers 1

cfgNetworkMethod · 0.45

Calls 6

bashClass · 0.85
debugMethod · 0.80
getDevInfoMethod · 0.80
isSuccessMethod · 0.65
getStdoutMethod · 0.45

Tested by

no test coverage detected