当前位置: 首页>>代码示例>>Python>>正文


Python EthernetPort.name方法代码示例

本文整理汇总了Python中gns3.ports.ethernet_port.EthernetPort.name方法的典型用法代码示例。如果您正苦于以下问题:Python EthernetPort.name方法的具体用法?Python EthernetPort.name怎么用?Python EthernetPort.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gns3.ports.ethernet_port.EthernetPort的用法示例。


在下文中一共展示了EthernetPort.name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from gns3.ports.ethernet_port import EthernetPort [as 别名]
# 或者: from gns3.ports.ethernet_port.EthernetPort import name [as 别名]
    def update(self, new_settings):
        """
        Updates the settings for this Ethernet switch.

        :param new_settings: settings dictionary
        """

        updated = False
        params = {}
        if "ports" in new_settings:
            ports_to_update = {}
            ports = new_settings["ports"]

            for port_number in ports.keys():
                if port_number in self._settings["ports"]:
                    if self._settings["ports"][port_number] != ports[port_number]:
                        for port in self._ports:
                            if port.portNumber() == port_number and not port.isFree():
                                ports_to_update[port_number] = ports[port_number]
                                break
                    continue
                port = EthernetPort(str(port_number))
                port.setPortNumber(port_number)
                port.setStatus(EthernetPort.started)
                port.setPacketCaptureSupported(True)
                self._ports.append(port)
                updated = True
                log.debug("port {} has been added".format(port_number))

            if ports_to_update:
                params["ports"] = []
                for port_number, info in ports_to_update.items():
                    info["port"] = port_number
                    params["ports"].append(info)
                updated = True

            # delete ports that are not configured
            for port_number in self._settings["ports"].keys():
                if port_number not in new_settings["ports"]:
                    for port in self._ports.copy():
                        if port.portNumber() == port_number:
                            self._ports.remove(port)
                            log.debug("port {} has been removed".format(port.name()))
                            break

            self._settings["ports"] = new_settings["ports"].copy()

        if "name" in new_settings and new_settings["name"] != self.name():
            if self.hasAllocatedName(new_settings["name"]):
                self.error_signal.emit(self.id(), 'Name "{}" is already used by another node'.format(new_settings["name"]))
                return
            params["name"] = new_settings["name"]
            updated = True

        if updated:
            log.debug("{} is being updated: {}".format(self.name(), params))
            self.httpPut("/dynamips/devices/{device_id}".format(device_id=self._device_id), self._updateCallback, body=params)
        else:
            log.info("{} has been updated".format(self.name()))
            self.updated_signal.emit()
开发者ID:AJNOURI,项目名称:gns3-gui,代码行数:62,代码来源:ethernet_switch.py

示例2: update

# 需要导入模块: from gns3.ports.ethernet_port import EthernetPort [as 别名]
# 或者: from gns3.ports.ethernet_port.EthernetPort import name [as 别名]
    def update(self, new_settings):
        """
        Updates the settings for this Ethernet switch.

        :param new_settings: settings dictionary
        """

        ports_to_update = {}
        ports = new_settings["ports"]
        updated = False
        for port_number in ports.keys():
            if port_number in self._settings["ports"]:
                if self._settings["ports"][port_number] != ports[port_number]:
                    for port in self._ports:
                        if port.portNumber() == port_number and not port.isFree():
                            ports_to_update[port_number] = ports[port_number]
                            break
                continue
            port = EthernetPort(str(port_number))
            port.setPortNumber(port_number)
            port.setStatus(EthernetPort.started)
            port.setPacketCaptureSupported(True)
            self._ports.append(port)
            updated = True
            log.debug("port {} has been added".format(port_number))

        params = {"id": self._ethsw_id}
        if ports_to_update:
            params["ports"] = {}
            for port_number, info in ports_to_update.items():
                params["ports"][port_number] = info
            updated = True

        if "name" in new_settings and new_settings["name"] != self.name():
            if self.hasAllocatedName(new_settings["name"]):
                self.error_signal.emit(self.id(), 'Name "{}" is already used by another node'.format(new_settings["name"]))
                return
            params["name"] = new_settings["name"]
            updated = True

        # delete ports that are not configured
        for port_number in self._settings["ports"].keys():
            if port_number not in new_settings["ports"]:
                for port in self._ports.copy():
                    if port.portNumber() == port_number:
                        self._ports.remove(port)
                        log.debug("port {} has been removed".format(port.name()))
                        break

        self._settings["ports"] = new_settings["ports"].copy()
        if updated:
            log.debug("{} is being updated: {}".format(self.name(), params))
            self._server.send_message("dynamips.ethsw.update", params, self._updateCallback)
开发者ID:Jatinamin,项目名称:gns3-gui,代码行数:55,代码来源:ethernet_switch.py


注:本文中的gns3.ports.ethernet_port.EthernetPort.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。