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


Python Config.report_etcd_config方法代码示例

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


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

示例1: test_env_var_override

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
    def test_env_var_override(self):
        """
        Test environment variables override config options,
        """
        with mock.patch.dict("os.environ", {"FELIX_ETCDADDR": "9.9.9.9:1234",
                                            "FELIX_METADATAPORT": "999"}):
            config = Config("calico/felix/test/data/felix_section.cfg")

        host_dict = { "InterfacePrefix": "blah",
                      "StartupCleanupDelay": "42",
                      "MetadataAddr": "4.3.2.1",
                      "MetadataPort": "123" }

        global_dict = { "InterfacePrefix": "blah",
                        "StartupCleanupDelay": "99",
                        "MetadataAddr": "5.4.3.2",
                        "MetadataPort": "123" }
        with mock.patch('calico.common.complete_logging'):
            config.report_etcd_config(host_dict, global_dict)

        self.assertEqual(config.ETCD_ADDR, "9.9.9.9:1234")
        self.assertEqual(config.HOSTNAME, socket.gethostname())
        self.assertEqual(config.LOGFILE, "/log/nowhere.log")
        self.assertEqual(config.IFACE_PREFIX, "whatever")
        self.assertEqual(config.METADATA_PORT, 999)
        self.assertEqual(config.METADATA_IP, "1.2.3.4")
        self.assertEqual(config.STARTUP_CLEANUP_DELAY, 42)
开发者ID:kgrvamsi,项目名称:calico,代码行数:29,代码来源:test_config.py

示例2: test_ip_in_ip_enabled

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
 def test_ip_in_ip_enabled(self):
     test_values = [
         ("true", True),
         ("t", True),
         ("True", True),
         ("1", True),
         (1, True),
         ("yes", True),
         ("y", True),
         ("false", False),
         ("f", False),
         ("False", False),
         ("0", False),
         (0, False),
         ("no", False),
         ("n", False),
     ]
     for value, expected in test_values:
         with mock.patch('calico.common.complete_logging'):
             config = Config("calico/felix/test/data/felix_missing.cfg")
             cfg_dict = { "InterfacePrefix": "blah",
                          "IpInIpEnabled": value }
             config.report_etcd_config({}, cfg_dict)
             self.assertEqual(config.IP_IN_IP_ENABLED, expected,
                              "%r was mis-interpreted as %r" %
                              (value, config.IP_IN_IP_ENABLED))
开发者ID:sudeshm,项目名称:calico,代码行数:28,代码来源:test_config.py

示例3: test_default_config

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
    def test_default_config(self):
        """
        Test various ways of defaulting config.
        """
        files = [ "felix_missing.cfg", # does not exist
                  "felix_empty.cfg", # empty file
                  "felix_empty_section.cfg", # file with empty section
                  "felix_extra.cfg", # extra config is just logged
                  ]

        for filename in files:
            config = Config("calico/felix/test/data/%s" % filename)
            host_dict = { "InterfacePrefix": "blah",
                          "MetadataPort": 123 }
            global_dict = { "InterfacePrefix": "overridden",
                            "MetadataAddr": "1.2.3.4" }
            with mock.patch('calico.common.complete_logging'):
                config.report_etcd_config(host_dict, global_dict)

            # Test defaulting.
            self.assertEqual(config.ETCD_ADDR, "localhost:4001")
            self.assertEqual(config.HOSTNAME, socket.gethostname())
            self.assertEqual(config.IFACE_PREFIX, "blah")
            self.assertEqual(config.METADATA_PORT, 123)
            self.assertEqual(config.METADATA_IP, "1.2.3.4")
开发者ID:kgrvamsi,项目名称:calico,代码行数:27,代码来源:test_config.py

示例4: test_no_iface_prefix

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
 def test_no_iface_prefix(self):
     with mock.patch('calico.common.complete_logging'):
         config = Config("calico/felix/test/data/felix_missing.cfg")
     cfg_dict = {}
     with self.assertRaisesRegexp(ConfigException,
                     "Missing undefaulted value.*InterfacePrefix"):
         config.report_etcd_config({}, cfg_dict)
开发者ID:sudeshm,项目名称:calico,代码行数:9,代码来源:test_config.py

示例5: test_metadata_port_not_int

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
 def test_metadata_port_not_int(self):
     config = Config("calico/felix/test/data/felix_missing.cfg")
     cfg_dict = { "InterfacePrefix": "blah",
                  "MetadataAddr": "127.0.0.1",
                  "MetadataPort": "bloop" }
     with self.assertRaisesRegexp(ConfigException,
                                  "Field was not integer.*MetadataPort"):
         config.report_etcd_config({}, cfg_dict)
开发者ID:kgrvamsi,项目名称:calico,代码行数:10,代码来源:test_config.py

示例6: test_blank_metadata_addr

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
 def test_blank_metadata_addr(self):
     config = Config("calico/felix/test/data/felix_missing.cfg")
     cfg_dict = { "InterfacePrefix": "blah",
                  "MetadataAddr": "",
                  "MetadataPort": "123" }
     with self.assertRaisesRegexp(ConfigException,
                                  "Blank value.*MetadataAddr"):
         config.report_etcd_config({}, cfg_dict)
开发者ID:kgrvamsi,项目名称:calico,代码行数:10,代码来源:test_config.py

示例7: test_no_logfile

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
    def test_no_logfile(self):
        # Logging to file can be excluded by explicitly saying "none"
        config = Config("calico/felix/test/data/felix_missing.cfg")
        cfg_dict = { "InterfacePrefix": "blah",
                     "LogFilePath": "None" }
        with mock.patch('calico.common.complete_logging'):
            config.report_etcd_config({}, cfg_dict)

        self.assertEqual(config.LOGFILE, None)
开发者ID:kgrvamsi,项目名称:calico,代码行数:11,代码来源:test_config.py

示例8: test_ip_in_ip_enabled_bad

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
 def test_ip_in_ip_enabled_bad(self):
     with mock.patch('calico.common.complete_logging'):
         config = Config("calico/felix/test/data/felix_missing.cfg")
     cfg_dict = { "InterfacePrefix": "blah",
                  "IpInIpEnabled": "blah" }
     with self.assertRaisesRegexp(ConfigException,
                                  "Field was not a valid Boolean"
                                  ".*IpInIpEnabled"):
         config.report_etcd_config({}, cfg_dict)
开发者ID:sudeshm,项目名称:calico,代码行数:11,代码来源:test_config.py

示例9: test_bad_metadata_addr

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
 def test_bad_metadata_addr(self):
     config = Config("calico/felix/test/data/felix_missing.cfg")
     cfg_dict = { "InterfacePrefix": "blah",
                  "MetadataAddr": "bloop",
                  "MetadataPort": "123" }
     with self.assertRaisesRegexp(ConfigException,
                                  "Invalid or unresolvable.*MetadataAddr"):
         config.report_etcd_config({}, cfg_dict)
     self.m_gethostbyname.assert_has_calls([mock.call("bloop")])
开发者ID:kgrvamsi,项目名称:calico,代码行数:11,代码来源:test_config.py

示例10: test_bad_log_level

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
    def test_bad_log_level(self):
        for field in ("LogSeverityFile", "LogSeverityScreen", "LogSeveritySys"):
            config = Config("calico/felix/test/data/felix_missing.cfg")

            cfg_dict = { "LogInterfacePrefix": "blah",
                         field: "bloop" }
            with self.assertRaisesRegexp(ConfigException,
                                         "Invalid log level.*%s" % field):
                config.report_etcd_config({}, cfg_dict)
开发者ID:kgrvamsi,项目名称:calico,代码行数:11,代码来源:test_config.py

示例11: test_metadata_port_not_valid_1

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
 def test_metadata_port_not_valid_1(self):
     for i in (0, -1, 99999):
         log.debug("Test invalid metadata port %d", i)
         config = Config("calico/felix/test/data/felix_missing.cfg")
         cfg_dict = { "InterfacePrefix": "blah",
                      "MetadataAddr": "127.0.0.1",
                      "MetadataPort": i }
         with self.assertRaisesRegexp(ConfigException,
                                      "Invalid field value.*MetadataPort"):
             config.report_etcd_config({}, cfg_dict)
开发者ID:kgrvamsi,项目名称:calico,代码行数:12,代码来源:test_config.py

示例12: test_default_ipset_size

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
    def test_default_ipset_size(self):
        """
        Test that ipset size is defaulted if out of range.
        """
        with mock.patch("calico.common.complete_logging"):
            config = Config("calico/felix/test/data/felix_missing.cfg")
        cfg_dict = {"InterfacePrefix": "blah", "MaxIpsetSize": "0"}
        with mock.patch("calico.common.complete_logging"):
            config.report_etcd_config({}, cfg_dict)

        self.assertEqual(config.MAX_IPSET_SIZE, 2 ** 20)
开发者ID:elfchief,项目名称:calico,代码行数:13,代码来源:test_config.py

示例13: test_reporting_interval_not_int

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
 def test_reporting_interval_not_int(self):
     """
     Test exception is raised if status reporting interval is invalid.
     """
     with mock.patch('calico.common.complete_logging'):
         config = Config("calico/felix/test/data/felix_missing.cfg")
     cfg_dict = { "InterfacePrefix": "blah",
                  "ReportingIntervalSecs": "NaN"}
     with self.assertRaisesRegexp(ConfigException,
                                  "Field was not integer.*"):
         config.report_etcd_config({}, cfg_dict)
开发者ID:sudeshm,项目名称:calico,代码行数:13,代码来源:test_config.py

示例14: test_no_metadata

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
    def test_no_metadata(self):
        # Metadata can be excluded by explicitly saying "none"
        config = Config("calico/felix/test/data/felix_missing.cfg")

        cfg_dict = { "InterfacePrefix": "blah",
                     "MetadataAddr": "NoNe",
                     "MetadataPort": 123 }
        with mock.patch('calico.common.complete_logging'):
            config.report_etcd_config({}, cfg_dict)

        # Test defaulting.
        self.assertEqual(config.METADATA_IP, None)
        self.assertEqual(config.METADATA_PORT, None)
开发者ID:kgrvamsi,项目名称:calico,代码行数:15,代码来源:test_config.py

示例15: test_negative_reporting_interval

# 需要导入模块: from calico.felix.config import Config [as 别名]
# 或者: from calico.felix.config.Config import report_etcd_config [as 别名]
    def test_negative_reporting_interval(self):
        """
        Test that status reporting is disabled if interval time is negative.
        """
        with mock.patch('calico.common.complete_logging'):
            config = Config("calico/felix/test/data/felix_missing.cfg")
        cfg_dict = { "InterfacePrefix": "blah",
                     "ReportingIntervalSecs": -42,
                     "ReportingTTLSecs": 7 }
        with mock.patch('calico.common.complete_logging'):
            config.report_etcd_config({}, cfg_dict)

        self.assertEqual(config.REPORTING_INTERVAL_SECS, 0)
        self.assertEqual(config.REPORTING_TTL_SECS, 0)
开发者ID:sudeshm,项目名称:calico,代码行数:16,代码来源:test_config.py


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