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

Class CsDevice

systemvm/debian/opt/cloud/bin/cs/CsAddress.py:262–312  ·  view source on GitHub ↗

Configure Network Devices

Source from the content-addressed store, hash-verified

260
261
262class CsDevice:
263
264 """ Configure Network Devices """
265
266 def __init__(self, dev, config):
267 self.devlist = []
268 self.dev = dev
269 self.buildlist()
270 self.table = ''
271 self.tableNo = ''
272 if dev != '':
273 self.tableNo = dev[3:]
274 self.table = "Table_%s" % dev
275 self.fw = config.get_fw()
276 self.cl = config.cmdline()
277
278 def configure_rp(self, enable=True):
279 """
280 Configure Reverse Path Filtering
281 """
282 filename = "/proc/sys/net/ipv4/conf/%s/rp_filter" % self.dev
283 if enable:
284 CsHelper.updatefile(filename, "1\n", "w")
285 else:
286 CsHelper.updatefile(filename, "0\n", "w")
287
288 def buildlist(self):
289 """
290 List all available network devices on the system
291 """
292 self.devlist = []
293 for line in open('/proc/net/dev'):
294 vals = line.lstrip().split(':')
295 if (not vals[0].startswith("eth")):
296 continue
297 self.devlist.append(vals[0])
298
299 def waitfordevice(self, timeout=2):
300 count = 0
301 while count < timeout:
302 if self.dev in self.devlist:
303 return True
304 time.sleep(1)
305 count += 1
306 self.buildlist()
307 logging.error(
308 "Device %s cannot be configured - device was not found", self.dev)
309 return False
310
311 def list(self):
312 return self.devlist
313
314
315class CsIP:

Callers 6

compareMethod · 0.85
processMethod · 0.85
post_configureMethod · 0.85
post_config_changeMethod · 0.85
_redundant_onMethod · 0.85
set_primaryMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected