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


Python local_server_config.LocalServerConfig类代码示例

本文整理汇总了Python中gns3.local_server_config.LocalServerConfig的典型用法代码示例。如果您正苦于以下问题:Python LocalServerConfig类的具体用法?Python LocalServerConfig怎么用?Python LocalServerConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: updateLocalServerSettings

    def updateLocalServerSettings(self, new_settings):
        """
        Update the local server settings. Keep the key not in new_settings
        """
        old_settings = copy.copy(self._settings)
        if not self._settings:
            self._settings = new_settings
        else:
            self._settings.update(new_settings)
        self._port = self._settings["port"]
        LocalServerConfig.instance().saveSettings("Server", self._settings)

        # Settings have changed we need to restart the server
        if old_settings != self._settings:
            if self._settings["auto_start"]:
                # We restart the local server only if we really need. Auth can be hot change
                settings_require_restart = ('host', 'port', 'path')
                need_restart = False
                for s in settings_require_restart:
                    if old_settings.get(s) != self._settings.get(s):
                        need_restart = True

                if need_restart:
                    self.stopLocalServer(wait=True)

                self.localServerAutoStartIfRequire()
            # If the controller is remote:
            else:
                self.stopLocalServer(wait=True)

            if self._settings.get("host") is None:
                self._http_client = None
            else:
                self._http_client = HTTPClient(self._settings)
            Controller.instance().setHttpClient(self._http_client)
开发者ID:maherja,项目名称:gns3-gui,代码行数:35,代码来源:local_server.py

示例2: image_manager

def image_manager(tmpdir, images_dir):
    ImageManager._instance = None
    settings = LOCAL_SERVER_SETTINGS
    settings['images_path'] = str(images_dir)
    LocalServerConfig.instance().setConfigFile(str(tmpdir / "test.cfg"))
    with patch('gns3.local_server_config.LocalServerConfig.loadSettings', return_value=LOCAL_SERVER_SETTINGS):
        yield ImageManager.instance()
    ImageManager._instance = None
开发者ID:GNS3,项目名称:gns3-gui,代码行数:8,代码来源:test_image_manager.py

示例3: test_loadSettings_EmptySettings

def test_loadSettings_EmptySettings(tmpdir, local_server):

    with open(str(tmpdir / "test.cfg"), "w+") as f:
        f.write("")
    LocalServerConfig.instance().setConfigFile(str(tmpdir / "test.cfg"))

    assert local_server.localServerSettings()["port"] == 3080
    assert len(local_server.localServerSettings()["password"]) == 64
    assert local_server.localServerSettings()["user"] == "admin"
开发者ID:maherja,项目名称:gns3-gui,代码行数:9,代码来源:test_local_server.py

示例4: test_loadSettings

def test_loadSettings(tmpdir, local_server):
    with open(str(tmpdir / "test.cfg"), "w+") as f:
        f.write("""
[Server]
auth=True
user=world
password=hello""")

    LocalServerConfig.instance().setConfigFile(str(tmpdir / "test.cfg"))
    assert local_server.localServerSettings()["password"] == "hello"
开发者ID:maherja,项目名称:gns3-gui,代码行数:10,代码来源:test_local_server.py

示例5: _saveSettings

    def _saveSettings(self):
        """
        Saves the settings to the persistent settings file.
        """

        # save the settings
        LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings)
        server_settings = {"enable_hardware_acceleration": self._settings["enable_hardware_acceleration"],
                           "require_hardware_acceleration": self._settings["require_hardware_acceleration"]}
        LocalServerConfig.instance().saveSettings(self.__class__.__name__, server_settings)
开发者ID:GNS3,项目名称:gns3-gui,代码行数:10,代码来源:__init__.py

示例6: local_server

def local_server(local_server_path, tmpdir):
    with open(str(tmpdir / "test.cfg"), "w+") as f:
        f.write("""
[Server]
path={}""".format(local_server_path))

    LocalServerConfig.instance().setConfigFile(str(tmpdir / "test.cfg"))
    LocalServer._instance = None
    with patch("gns3.local_server.LocalServer.localServerAutoStartIfRequire"):
        local_server = LocalServer.instance()
        local_server._config_directory = str(tmpdir)
        yield local_server
开发者ID:maherja,项目名称:gns3-gui,代码行数:12,代码来源:test_local_server.py

示例7: _saveSettings

    def _saveSettings(self):
        """
        Saves the settings to the persistent settings file.
        """

        # save the settings
        LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings)

        # save some settings to the local server config file
        if sys.platform.startswith("linux"):
            server_settings = {
                "enable_kvm": self._settings["enable_kvm"],
            }

            LocalServerConfig.instance().saveSettings(self.__class__.__name__, server_settings)
开发者ID:GMarciales,项目名称:gns3-gui,代码行数:15,代码来源:__init__.py

示例8: getDirectory

    def getDirectory(self):
        """
        Returns the images directory path.

        :returns: path to the default images directory
        """

        return copy.copy(LocalServerConfig.instance().loadSettings("Server", LOCAL_SERVER_SETTINGS)['images_path'])
开发者ID:GNS3,项目名称:gns3-gui,代码行数:8,代码来源:image_manager.py

示例9: local_server_config

def local_server_config():
    from gns3.local_server_config import LocalServerConfig

    (fd, config_path) = tempfile.mkstemp()
    os.close(fd)

    LocalServerConfig._instance = LocalServerConfig(config_file=config_path)
    return LocalServerConfig.instance()
开发者ID:GNS3,项目名称:gns3-gui,代码行数:8,代码来源:conftest.py

示例10: _saveSettings

    def _saveSettings(self):
        """
        Saves the settings to the persistent settings file.
        """

        # save the settings
        LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings)

        if self._settings["vpcs_path"]:
            # save some settings to the server config file
            server_settings = {"vpcs_path": os.path.normpath(self._settings["vpcs_path"])}
            config = LocalServerConfig.instance()
            config.saveSettings(self.__class__.__name__, server_settings)
开发者ID:george7878099,项目名称:gns3-gui,代码行数:13,代码来源:__init__.py

示例11: _saveSettings

    def _saveSettings(self):
        """
        Saves the settings to the persistent settings file.
        """

        # save the settings
        LocalConfig.instance().saveSectionSettings(self.__class__.__name__, self._settings)

        # save some settings to the local server config file
        server_settings = {
            "allocate_aux_console_ports": self._settings["allocate_aux_console_ports"],
            "ghost_ios_support": self._settings["ghost_ios_support"],
            "sparse_memory_support": self._settings["sparse_memory_support"],
            "mmap_support": self._settings["mmap_support"],
        }

        if self._settings["dynamips_path"]:
            server_settings["dynamips_path"] = os.path.normpath(self._settings["dynamips_path"])
        config = LocalServerConfig.instance()
        config.saveSettings(self.__class__.__name__, server_settings)
开发者ID:AshokVardhn,项目名称:gns3-gui,代码行数:20,代码来源:__init__.py

示例12: localServerSettings

    def localServerSettings(self):
        """
        Returns the local server settings.

        :returns: local server settings (dict)
        """

        settings = LocalServerConfig.instance().loadSettings("Server", LOCAL_SERVER_SETTINGS)
        self._settings = copy.copy(settings)

        # user & password
        if settings["auth"] is True and not settings["user"].strip():
            settings["user"] = "admin"
            settings["password"] = self._passwordGenerate()

        # local GNS3 server path
        local_server_path = shutil.which(settings["path"].strip())
        if local_server_path is None:
            default_server_path = shutil.which("gns3server")
            if default_server_path is not None:
                settings["path"] = os.path.abspath(default_server_path)
        else:
            settings["path"] = os.path.abspath(local_server_path)

        # uBridge path
        ubridge_path = shutil.which(settings["ubridge_path"].strip())
        if ubridge_path is None:
            default_ubridge_path = shutil.which("ubridge")
            if default_ubridge_path is not None:
                settings["ubridge_path"] = os.path.abspath(default_ubridge_path)
        else:
            settings["ubridge_path"] = os.path.abspath(ubridge_path)

        if self._settings != settings:
            self.updateLocalServerSettings(settings)
        return settings
开发者ID:maherja,项目名称:gns3-gui,代码行数:36,代码来源:local_server.py


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