本文整理汇总了Python中blockade.config.BlockadeConfig类的典型用法代码示例。如果您正苦于以下问题:Python BlockadeConfig类的具体用法?Python BlockadeConfig怎么用?Python BlockadeConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BlockadeConfig类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_fail_2
def test_parse_fail_2(self):
containers = {
"c1": {"ima": "image1", "command": "/bin/bash"},
"c2": {"image": "image2", "links": ["c1"]}
}
d = dict(containers=containers)
with self.assertRaises(BlockadeConfigError):
BlockadeConfig.from_dict(d)
示例2: test_parse_with_start_delay_fail_nonnumeric
def test_parse_with_start_delay_fail_nonnumeric(self):
containers = {
"c1": {"image": "image1", "command": "/bin/bash",
"start_delay": "abc123"}
}
d = dict(containers=containers, network={})
with self.assertRaisesRegexp(BlockadeConfigError, "start_delay"):
BlockadeConfig.from_dict(d)
示例3: test_parse_with_start_delay_2
def test_parse_with_start_delay_2(self):
containers = {
"c1": {"image": "image1", "command": "/bin/bash",
"start_delay": 0.4}
}
d = dict(containers=containers, network={})
config = BlockadeConfig.from_dict(d)
self.assertEqual(len(config.containers), 1)
c1 = config.containers['c1']
self.assertEqual(c1.start_delay, 0.4)
示例4: test_parse_with_numeric_port
def test_parse_with_numeric_port(self):
containers = {
"c1": {"image": "image1", "command": "/bin/bash",
"expose": [10000]}
}
d = dict(containers=containers, network={})
config = BlockadeConfig.from_dict(d)
self.assertEqual(len(config.containers), 1)
c1 = config.containers['c1']
self.assertEqual(c1.expose_ports, [10000])
示例5: test_parse_with_publish_1
def test_parse_with_publish_1(self):
containers = {
"c1": {"image": "image1", "ports": {8080: 80}, "expose": [80]}
}
d = dict(containers=containers, network={})
config = BlockadeConfig.from_dict(d)
self.assertEqual(len(config.containers), 1)
c1 = config.containers['c1']
self.assertEqual(c1.expose_ports, [80])
self.assertEqual(c1.publish_ports, {'8080': '80'})
示例6: test_parse_with_env_1
def test_parse_with_env_1(self):
containers = {
"c1": {"image": "image1", "command": "/bin/bash",
"environment": {"HATS": 4, "JACKETS": "some"}}
}
d = dict(containers=containers, network={})
config = BlockadeConfig.from_dict(d)
self.assertEqual(len(config.containers), 1)
c1 = config.containers['c1']
self.assertEqual(c1.environment, {"HATS": "4", "JACKETS": "some"})
示例7: test_parse_with_multiple_cap_add
def test_parse_with_multiple_cap_add(self):
containers = {
"c1": {"image": "image1", "command": "/bin/bash",
"cap_add": ["NET_ADMIN", "MKNOD"]}
}
d = dict(containers=containers, network={})
config = BlockadeConfig.from_dict(d)
self.assertEqual(len(config.containers), 1)
c1 = config.containers['c1']
self.assertEqual(c1.cap_add, ["NET_ADMIN", "MKNOD"])
示例8: test_parse_with_volumes_4
def test_parse_with_volumes_4(self):
containers = {
"c1": {"image": "image1", "command": "/bin/bash",
"volumes": {"/some/mount": None}}
}
network = {}
d = dict(containers=containers, network=network)
config = BlockadeConfig.from_dict(d)
# default value should be there
self.assertEqual(len(config.containers), 1)
c1 = config.containers['c1']
self.assertEqual(c1.volumes, {"/some/mount": "/some/mount"})
示例9: test_parse_2
def test_parse_2(self):
containers = {
"c1": {"image": "image1", "command": "/bin/bash"}
}
network = {"flaky": "61%"}
d = dict(containers=containers, network=network)
config = BlockadeConfig.from_dict(d)
# default value should be there
self.assertIn("flaky", config.network)
self.assertEqual(config.network['flaky'], "61%")
# default value should be there
self.assertIn("slow", config.network)
示例10: test_parse_with_name
def test_parse_with_name(self):
containers = {
"c1": {"image": "image1", "command": "/bin/bash",
"container_name": "abc"}
}
network = {}
d = dict(containers=containers, network=network)
config = BlockadeConfig.from_dict(d)
# default value should be there
self.assertEqual(len(config.containers), 1)
c1 = config.containers['c1']
self.assertEqual(c1.container_name, "abc")
示例11: test_parse_1
def test_parse_1(self):
containers = {
"c1": {"image": "image1", "command": "/bin/bash"},
"c2": {"image": "image2", "links": ["c1"]}
}
d = dict(containers=containers)
config = BlockadeConfig.from_dict(d)
self.assertEqual(len(config.containers), 2)
self.assertEqual(config.containers["c1"].name, "c1")
self.assertEqual(config.containers["c1"].image, "image1")
self.assertEqual(config.containers["c1"].command, "/bin/bash")
self.assertEqual(config.containers["c2"].name, "c2")
self.assertEqual(config.containers["c2"].image, "image2")
示例12: test_parse_with_count_1
def test_parse_with_count_1(self):
containers = {
"db": {"image": "image1", "command": "/bin/bash", "count": 2},
"app": {"image": "image1", "command": "/bin/bash",
"container_name": "abc", "count": 3}
}
d = dict(containers=containers, network={})
config = BlockadeConfig.from_dict(d)
self.assertEqual(set(config.containers.keys()),
set(["db_1", "db_2", "app_1", "app_2", "app_3"]))
self.assertEqual(config.containers["app_1"].container_name, "abc_1")
self.assertEqual(config.containers["app_2"].container_name, "abc_2")
self.assertEqual(config.containers["app_3"].container_name, "abc_3")
示例13: create
def create(name):
if not request.headers['Content-Type'] == 'application/json':
abort(415)
if BlockadeManager.blockade_exists(name):
return 'Blockade name already exists', 400
# This will abort with a 400 if the JSON is bad
data = request.get_json()
config = BlockadeConfig.from_dict(data)
BlockadeManager.store_config(name, config)
b = BlockadeManager.get_blockade(name)
containers = b.create()
return '', 204