def update(self, new_settings): """ Updates the settings for this cloud. :param new_settings: settings dictionary """ updated = False if "nios" in new_settings: nios = new_settings["nios"] # add ports for nio in nios: if nio in self._settings["nios"]: # port already created for this NIO continue nio_object = None if nio.lower().startswith("nio_udp"): nio_object = self._createNIOUDP(nio) if nio.lower().startswith("nio_gen_eth"): nio_object = self._createNIOGenericEthernet(nio) if nio.lower().startswith("nio_gen_linux"): nio_object = self._createNIOLinuxEthernet(nio) if nio.lower().startswith("nio_tap"): nio_object = self._createNIOTAP(nio) if nio.lower().startswith("nio_unix"): nio_object = self._createNIOUNIX(nio) if nio.lower().startswith("nio_vde"): nio_object = self._createNIOVDE(nio) if nio.lower().startswith("nio_null"): nio_object = self._createNIONull(nio) if nio_object is None: log.error( "Could not create NIO object from {}".format(nio)) continue port = Port(nio, nio_object, stub=True) port.setStatus(Port.started) self._ports.append(port) updated = True log.debug("port {} has been added".format(nio)) # delete ports for nio in self._settings["nios"]: if nio not in nios: for port in self._ports.copy(): if port.name() == nio: self._ports.remove(port) updated = True log.debug("port {} has been deleted".format(nio)) break self._settings["nios"] = new_settings["nios"].copy() if "name" in new_settings and new_settings["name"] != self.name(): self._settings["name"] = new_settings["name"] updated = True if updated: log.info("cloud {} has been updated".format(self.name())) self.updated_signal.emit()
def update(self, new_settings): """ Updates the settings for this cloud. :param new_settings: settings dictionary """ updated = False if "nios" in new_settings: nios = new_settings["nios"] # add ports for nio in nios: if nio in self._settings["nios"]: # port already created for this NIO continue nio_object = None if nio.lower().startswith("nio_udp"): nio_object = self._createNIOUDP(nio) if nio.lower().startswith("nio_gen_eth"): nio_object = self._createNIOGenericEthernet(nio) if nio.lower().startswith("nio_gen_linux"): nio_object = self._createNIOLinuxEthernet(nio) if nio.lower().startswith("nio_tap"): nio_object = self._createNIOTAP(nio) if nio.lower().startswith("nio_unix"): nio_object = self._createNIOUNIX(nio) if nio.lower().startswith("nio_vde"): nio_object = self._createNIOVDE(nio) if nio.lower().startswith("nio_null"): nio_object = self._createNIONull(nio) if nio_object is None: log.error("Could not create NIO object from {}".format(nio)) continue port = Port(nio, nio_object, stub=True) port.setStatus(Port.started) self._ports.append(port) updated = True log.debug("port {} has been added".format(nio)) # delete ports for nio in self._settings["nios"]: if nio not in nios: for port in self._ports.copy(): if port.name() == nio: self._ports.remove(port) updated = True log.debug("port {} has been deleted".format(nio)) break self._settings["nios"] = new_settings["nios"].copy() if "name" in new_settings and new_settings["name"] != self.name(): self._settings["name"] = new_settings["name"] updated = True if updated: log.info("cloud {} has been updated".format(self.name())) self.updated_signal.emit()
def update(self, new_settings): """ Updates the settings for this cloud. :param new_settings: settings dictionary """ updated = False if "nios" in new_settings: nios = new_settings["nios"] # add ports for nio in nios: if nio in self._settings["nios"]: # port already created for this NIO continue nio_object = self._allocateNIO(nio) if nio_object is None: continue port = Port(nio, nio_object, stub=True) port.setStatus(Port.started) self._ports.append(port) updated = True log.debug("port {} has been added".format(nio)) # delete ports for nio in self._settings["nios"]: if nio not in nios: for port in self._ports.copy(): if port.name() == nio: self._ports.remove(port) updated = True log.debug("port {} has been deleted".format(nio)) break self._settings["nios"] = new_settings["nios"].copy() if "name" in new_settings and new_settings["name"] != self.name(): self._settings["name"] = new_settings["name"] updated = True if updated: log.info("cloud {} has been updated".format(self.name())) self.updated_signal.emit()
def _addPorts(self, nios, ignore_existing_nio=False): """ Adds adapters. :param adapters: number of adapters """ # add ports for nio in nios: if ignore_existing_nio and nio in self._settings["nios"]: # port already created for this NIO continue nio_object = self._allocateNIO(nio) if nio_object is None: continue port = Port(nio, nio_object, stub=True) port.setStatus(Port.started) self._ports.append(port) log.debug("port {} has been added".format(nio))
def _addPorts(self, nios, ignore_existing_nio=False): """ Adds adapters. :param adapters: number of adapters """ # add ports for nio in nios: if ignore_existing_nio and nio in self._settings["nios"]: # port already created for this NIO continue nio_object = self._allocateNIO(nio) if nio_object is None: continue port = Port(nio, nio_object, stub=True) port.setStatus(Port.started) self._ports.append(port) log.debug("port {} has been added".format(nio))