def addDataBridge(self,name,macStr,switchId,port): with MutexStore.getObjectLock(self.getLockIdentifier()): if self.networkInterfaces.filter(name=name, isBridge=True).count()> 0: raise Exception("Another data bridge with the same name already exists in this Server") netInt = NetworkInterface.createServerDataBridge(name,macStr,switchId,port) self.networkInterfaces.add(netInt) self.autoSave()
def __createEnslavedDataVMNetworkInterface(self,serverInterface): #Obtain macObj = self.__allocateMacFromSubscribedRanges() interface = NetworkInterface.createVMDataInterface(serverInterface.getName()+"-slave",macObj) #Enslave it serverInterface.attachInterfaceToBridge(interface) return interface
def setMgmtBridge(self,name,macStr): with MutexStore.getObjectLock(self.getLockIdentifier()): nInter = self.networkInterfaces.filter(isMgmt=True,isBridge=True) if nInter.count() == 1: mgmt = nInter.get() mgmt.setName(name) mgmt.setMacStr(macStr) elif nInter.count() == 0: mgmt = NetworkInterface.createServerMgmtBridge(name,macStr) self.networkInterfaces.add(mgmt) else: raise Exception("Unexpected length of management NetworkInterface query") self.autoSave()
def updateDataBridge(self,interface): with MutexStore.getObjectLock(self.getLockIdentifier()): if self.networkInterfaces.filter(id = interface.id).count()!= 1: raise Exception("Can not update bridge interface because it does not exist or id is duplicated") NetworkInterface.updateServerDataBridge(interface.id,interface.getName(),interface.getMacStr(),interface.getSwitchID(),interface.getPort())