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

Method addBridge

python/lib/cloudutils/serviceConfig.py:366–397  ·  view source on GitHub ↗
(self, brName, dev)

Source from the content-addressed store, hash-verified

364
365
366 def addBridge(self, brName, dev):
367 bash("ifdown %s" % dev.name)
368
369 if not os.path.exists(self.brCfgFile):
370 shutil.copy(self.devCfgFile, self.brCfgFile)
371
372 cfo = configFileOps(self.devCfgFile, self)
373 cfo.addEntry("STARTMODE", "auto")
374 if self.syscfg.env.bridgeType == "openvswitch":
375 if cfo.getEntry("IPADDR"):
376 cfo.rmEntry("IPADDR", cfo.getEntry("IPADDR"))
377 elif self.syscfg.env.bridgeType == "native":
378 # Bridge is linked to the dev in SUSE not the other way round
379 pass
380 else:
381 raise CloudInternalException("Unknown network.bridge.type %s" % self.syscfg.env.bridgeType)
382 cfo.save()
383
384 cfo = configFileOps(self.brCfgFile, self)
385 cfo.addEntry("STARTMODE", "auto")
386 if self.syscfg.env.bridgeType == "openvswitch":
387 if cfo.getEntry("LLADDR"):
388 cfo.rmEntry("LLADDR", cfo.getEntry("LLADDR"))
389 cfo.addEntry("BRIDGE_STP", "yes")
390 cfo.addEntry("OVS_BRIDGE", "yes")
391 elif self.syscfg.env.bridgeType == "native":
392 cfo.addEntry("BRIDGE", "yes")
393 else:
394 raise CloudInternalException("Unknown network.bridge.type %s" % self.syscfg.env.bridgeType)
395 # Bridge is linked to the dev in SUSE not the other way round
396 cfo.addEntry("BRIDGE_PORTS", dev.name)
397 cfo.save()
398
399 def config(self):
400 try:

Callers 1

writeToCfgFileMethod · 0.95

Calls 9

configFileOpsClass · 0.90
bashClass · 0.85
existsMethod · 0.65
copyMethod · 0.65
saveMethod · 0.65
addEntryMethod · 0.45
getEntryMethod · 0.45
rmEntryMethod · 0.45

Tested by

no test coverage detected