(dev)
| 136 | |
| 137 | @staticmethod |
| 138 | def getDevInfo(dev): |
| 139 | if not networkConfig.isNetworkDev(dev): |
| 140 | logging.debug("dev: " + dev + " is not a network device") |
| 141 | raise CloudInternalException("dev: " + dev + " is not a network device") |
| 142 | |
| 143 | netmask = None |
| 144 | ipAddr = None |
| 145 | macAddr = None |
| 146 | |
| 147 | cmd = bash("ifconfig " + dev) |
| 148 | if not cmd.isSuccess(): |
| 149 | logging.debug("Failed to get address from ifconfig") |
| 150 | raise CloudInternalException("Failed to get network info by ifconfig %s"%dev) |
| 151 | |
| 152 | for line in cmd.getLines(): |
| 153 | if line.find("HWaddr") != -1: |
| 154 | macAddr = line.split("HWaddr ")[1].strip(" ") |
| 155 | elif line.find("inet ") != -1: |
| 156 | m = re.search(r"addr:([^\s]+)\s*Bcast:([^\s]+)\s*Mask:([^\s]+)", line) |
| 157 | if m is not None: |
| 158 | ipAddr = m.group(1).strip() |
| 159 | netmask = m.group(3).strip() |
| 160 | |
| 161 | if networkConfig.isBridgePort(dev): |
| 162 | type = "brport" |
| 163 | elif networkConfig.isBridge(dev) or networkConfig.isOvsBridge(dev): |
| 164 | type = "bridge" |
| 165 | else: |
| 166 | type = "dev" |
| 167 | |
| 168 | return networkConfig.devInfo(macAddr, ipAddr, netmask, None, type, dev) |
no test coverage detected