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


Python EthernetPort.setId方法代码示例

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


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

示例1: load

# 需要导入模块: from gns3.ports.ethernet_port import EthernetPort [as 别名]
# 或者: from gns3.ports.ethernet_port.EthernetPort import setId [as 别名]
    def load(self, node_info):
        """
        Loads an Ethernet switch representation
        (from a topology file).

        :param node_info: representation of the node (dictionary)
        """

        settings = node_info["properties"]
        name = settings.pop("name")

        # create the ports with the correct port numbers, IDs and settings
        if "ports" in node_info:
            ports = node_info["ports"]
            for topology_port in ports:
                port = EthernetPort(topology_port["name"])
                port.setPortNumber(topology_port["port_number"])
                port.setId(topology_port["id"])
                port.setStatus(EthernetPort.started)
                self._ports.append(port)
                self._settings["ports"][port.portNumber()] = {"type": topology_port["type"],
                                                          "vlan": topology_port["vlan"]}

        log.info("Ethernet switch {} is loading".format(name))
        self.setup(name)
开发者ID:madkrell,项目名称:gns3-gui,代码行数:27,代码来源:ethernet_switch.py

示例2: setup

# 需要导入模块: from gns3.ports.ethernet_port import EthernetPort [as 别名]
# 或者: from gns3.ports.ethernet_port.EthernetPort import setId [as 别名]
    def setup(self, name=None, device_id=None, initial_ports=[]):
        """
        Setups this Ethernet switch.

        :param name: optional name for this switch
        :param device_id: device identifier on the server
        :param initial_ports: ports to be automatically added when creating this switch
        """

        # let's create a unique name if none has been chosen
        if not name:
            name = self.allocateName("SW")

        if not name:
            self.error_signal.emit(self.id(), "could not allocate a name for this Ethernet switch")
            return

        self._settings["name"] = name
        if not initial_ports:
            # default configuration if no initial ports
            for port_number in range(1, 9):
                # add 8 ports
                initial_ports.append({"name": str(port_number),
                                      "port_number": port_number,
                                      "type": "access",
                                      "vlan": 1})

        # add initial ports
        for initial_port in initial_ports:
            port = EthernetPort(initial_port["name"])
            port.setPortNumber(initial_port["port_number"])
            if "id" in initial_port:
                port.setId(initial_port["id"])
            port.setStatus(EthernetPort.started)
            port.setPacketCaptureSupported(True)
            self._ports.append(port)
            self._settings["ports"][port.portNumber()] = {"type": initial_port["type"],
                                                          "vlan": initial_port["vlan"],
                                                          "ethertype": initial_port.get("ethertype", "")}

        params = {"name": name,
                  "device_type": "ethernet_switch"}
        if device_id:
            params["device_id"] = device_id
        self.httpPost("/dynamips/devices", self._setupCallback, body=params)
开发者ID:AJNOURI,项目名称:gns3-gui,代码行数:47,代码来源:ethernet_switch.py

示例3: setup

# 需要导入模块: from gns3.ports.ethernet_port import EthernetPort [as 别名]
# 或者: from gns3.ports.ethernet_port.EthernetPort import setId [as 别名]
    def setup(self, name=None, initial_ports=[]):
        """
        Setups this Ethernet switch.

        :param name: optional name for this switch
        :param initial_ports: ports to be automatically added when creating this switch
        """

        # let's create a unique name if none has been chosen
        if not name:
            name = self.allocateName("SW")

        if not name:
            self.error_signal.emit(self.id(), "could not allocate a name for this Ethernet switch")
            return

        if not initial_ports:
            # default configuration if no initial ports
            for port_number in range(1, 9):
                # add 8 ports
                initial_ports.append({"name": str(port_number),
                                      "port_number": port_number,
                                      "type": "access",
                                      "vlan": 1})

        # add initial ports
        for initial_port in initial_ports:
            port = EthernetPort(initial_port["name"])
            port.setPortNumber(initial_port["port_number"])
            if "id" in initial_port:
                port.setId(initial_port["id"])
            port.setStatus(EthernetPort.started)
            port.setPacketCaptureSupported(True)
            self._ports.append(port)
            self._settings["ports"][port.portNumber()] = {"type": initial_port["type"],
                                                          "vlan": initial_port["vlan"]}

        params = {"name": name}
        self._server.send_message("dynamips.ethsw.create", params, self._setupCallback)
开发者ID:Jatinamin,项目名称:gns3-gui,代码行数:41,代码来源:ethernet_switch.py


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