本文整理汇总了Python中dockertest.containers.DockerContainers.get_unique_name方法的典型用法代码示例。如果您正苦于以下问题:Python DockerContainers.get_unique_name方法的具体用法?Python DockerContainers.get_unique_name怎么用?Python DockerContainers.get_unique_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dockertest.containers.DockerContainers
的用法示例。
在下文中一共展示了DockerContainers.get_unique_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(simple, self).initialize()
config.none_if_empty(self.config)
# Get free name
docker_containers = DockerContainers(self)
name = docker_containers.get_unique_name()
self.sub_stuff['container_name'] = name
示例2: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(stop_base, self).initialize()
# Prepare a container
docker_containers = DockerContainers(self.parent_subtest)
prefix = self.config["stop_name_prefix"]
name = docker_containers.get_unique_name(prefix, length=4)
self.sub_stuff['container_name'] = name
config.none_if_empty(self.config)
if self.config.get('run_options_csv'):
subargs = [arg for arg in
self.config['run_options_csv'].split(',')]
subargs.append("--name %s" % name)
fin = DockerImage.full_name_from_defaults(self.config)
subargs.append(fin)
subargs.append("bash")
subargs.append("-c")
subargs.append(self.config['exec_cmd'])
container = AsyncDockerCmd(self, 'run', subargs)
self.sub_stuff['container_cmd'] = container
container.execute()
time.sleep(self.config['wait_start'])
# Prepare the "stop" command
if self.config.get('stop_options_csv'):
subargs = [arg for arg in
self.config['stop_options_csv'].split(',')]
subargs.append(name)
self.sub_stuff['stop_cmd'] = DockerCmd(self, 'stop', subargs)
示例3: _init_container
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def _init_container(self):
""" Create, store in self.stuff and execute container """
try:
fin = DockerImage.full_name_from_defaults(self.config)
except ValueError:
raise DockerTestNAError("Empty test image name configured,"
"did you set one for this test?")
docker_containers = DockerContainers(self)
name = docker_containers.get_unique_name()
self.stuff['container_name'] = name
if self.config.get('run_options_csv'):
subargs = [arg for arg in
self.config['run_options_csv'].split(',')]
else:
subargs = []
subargs.append("--name %s" % name)
subargs.append(fin)
subargs.append("bash")
container = NoFailDockerCmd(self, 'run', subargs)
self.stuff['container_cmd'] = container
container.execute()
if self.config.get('attach_options_csv'):
subargs = [arg for arg in
self.config['attach_options_csv'].split(',')]
else:
subargs = []
subargs.append(name)
container = AsyncDockerCmd(self, 'attach', subargs)
self.stuff['container_cmd'] = container # overwrites finished cmd
stdin = os.pipe()
self.stuff['container_stdin'] = stdin[1]
container.execute(stdin[0])
示例4: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(run_memory_base, self).initialize()
docker_containers = DockerContainers(self.parent_subtest)
image = DockerImage.full_name_from_defaults(self.config)
unit_list = ['', 'b', 'B', 'k', 'K', 'm', 'M', 'g', 'G']
memory_list = []
self.sub_stuff['name'] = []
args = []
if self.config['expect_success'] == "PASS":
memory_value = str(self.config['memory_value'])
if memory_value is not '0':
for unit in unit_list:
memory_list.append(memory_value + unit)
else:
memory_list.append('0')
else:
memory_list.append(self.config['memory_min_invalid'])
memory_list.append(self.config['memory_max_invalid'])
memory_list.append(self.config['memory_invalid'])
for memory in memory_list:
prefix = self.config['memory_name_prefix']
name = docker_containers.get_unique_name(prefix, length=4)
if self.config['expect_success'] == "PASS":
self.sub_stuff['name'].append(name)
args.append(self.combine_subargs(name,
memory,
image,
'/bin/bash'))
self.sub_stuff['subargs'] = args
self.sub_stuff['container_memory'] = memory_list
self.sub_stuff['cgroup_memory'] = []
self.sub_stuff['result'] = []
示例5: _init_container
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def _init_container(self):
""" Create, store in self.stuff and execute container """
docker_containers = DockerContainers(self)
prefix = self.config["container_name_prefix"]
name = docker_containers.get_unique_name(prefix, length=4)
self.stuff['container_name'] = name
if self.config.get('run_options_csv'):
subargs = [arg for arg in
self.config['run_options_csv'].split(',')]
else:
subargs = []
subargs.append("--name %s" % name)
fin = DockerImage.full_name_from_defaults(self.config)
subargs.append(fin)
subargs.append("bash")
container = NoFailDockerCmd(self, 'run', subargs)
self.stuff['container_cmd'] = container
container.execute()
if self.config.get('attach_options_csv'):
subargs = [arg for arg in
self.config['attach_options_csv'].split(',')]
else:
subargs = []
subargs.append(name)
container = AsyncDockerCmd(self, 'attach', subargs)
self.stuff['container_cmd'] = container # overwrites finished cmd
stdin = os.pipe()
self.stuff['container_stdin'] = stdin[1]
container.execute(stdin[0])
示例6: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(simple, self).initialize()
self._init_stuff()
config.none_if_empty(self.config)
# Get free name
prefix = self.config["container_name_prefix"]
docker_containers = DockerContainers(self.parent_subtest)
name = docker_containers.get_unique_name(prefix, length=4)
self.sub_stuff['container_name'] = name
示例7: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(diff_base, self).initialize()
dc = DockerContainers(self)
name = self.sub_stuff['name'] = dc.get_unique_name()
fin = DockerImage.full_name_from_defaults(self.config)
subargs = ['--name=%s' % (name), fin]
subargs = subargs + self.config['command'].split(',')
nfdc = DockerCmd(self, 'run', subargs)
mustpass(nfdc.execute())
示例8: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(flag, self).initialize()
self.stuff["containter_name"] = []
self.stuff["subargs"] = []
self.stuff["cmdresult"] = []
docker_containers = DockerContainers(self)
self.logdebug("Generating ramdom name will take 1 minute")
cname = docker_containers.get_unique_name("docker", "test", 4)
self.stuff["containter_name"] = cname
示例9: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(run_attach_stdout, self).initialize()
dc = DockerContainers(self.parent_subtest)
self.sub_stuff["rand_name"] = rand_name = dc.get_unique_name()
self.sub_stuff["rand_data"] = utils.generate_random_string(8)
self.sub_stuff["subargs"].insert(0, "--name=\"%s\"" % rand_name)
attach_options = self.config['attach_options_csv'].split(',')
attach_options.append(rand_name)
self.sub_stuff['attach_options'] = attach_options
self.sub_stuff["rpipe"], self.sub_stuff["wpipe"] = os.pipe()
示例10: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(diff_base, self).initialize()
dc = DockerContainers(self.parent_subtest)
scn = self.__class__.__name__
name = self.sub_stuff['name'] = dc.get_unique_name(prefix=scn)
fin = DockerImage.full_name_from_defaults(self.config)
subargs = ['--name=%s' % (name), fin]
subargs = subargs + self.config['command'].split(',')
nfdc = NoFailDockerCmd(self, 'run', subargs)
nfdc.execute()
示例11: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
"""
Runs one container
"""
super(kill_bad_base, self).initialize()
# Prepare a container
docker_containers = DockerContainers(self.parent_subtest)
name = docker_containers.get_unique_name()
self.sub_stuff['container_name'] = name
config.none_if_empty(self.config)
self._init_container(name)
time.sleep(self.config.get('wait_start', 3))
示例12: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(syslog, self).initialize()
dc = DockerContainers(self)
scn = self.__class__.__name__
name = self.stuff["container_name"] = dc.get_unique_name(prefix=scn)
self.stuff['name'] = '--name=%s' % name
self.stuff['fin'] = DockerImage.full_name_from_defaults(self.config)
self.stuff['params'] = '-v /dev/log:/dev/log'
now = datetime.datetime.now()
time = now.strftime("%Y-%m-%d %H:%M:%S")
self.stuff["msg"] = "SYSLOGTEST at time: %s" % time
self.stuff['testcmds'] = 'logger %s' % self.stuff["msg"]
示例13: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(syslog, self).initialize()
if not os.path.isfile(self.config['syslogfile']):
raise DockerTestNAError("Couldn't find system log: %s"
% self.config['syslogfile'])
dc = DockerContainers(self)
name = self.stuff["container_name"] = dc.get_unique_name()
self.stuff['name'] = '--name=%s' % name
self.stuff['fin'] = DockerImage.full_name_from_defaults(self.config)
self.stuff['params'] = '-v /dev/log:/dev/log'
now = datetime.datetime.now()
time = now.strftime("%Y-%m-%d %H:%M:%S")
self.stuff["msg"] = "SYSLOGTEST at time: %s" % time
self.stuff['testcmds'] = 'logger %s' % self.stuff["msg"]
示例14: init_subargs
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def init_subargs(self):
"""
Initialize basic arguments that will use for start container
Will return a list 'args'
"""
docker_containers = DockerContainers(self)
image = DockerImage.full_name_from_defaults(self.config)
name = docker_containers.get_unique_name()
self.sub_stuff['name'] = name
bash_cmd = self.config['bash_cmd']
args = ["--name=%s" % name]
args += get_as_list(self.config['run_args_csv'])
args += [image, bash_cmd]
return args
示例15: initialize
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import get_unique_name [as 别名]
def initialize(self):
super(simple, self).initialize()
# Test container setup
dc = DockerContainers(self)
c_name = dc.get_unique_name()
self.sub_stuff["containers"].append(c_name)
self.init_test_container(c_name)
# export/import command setup
di = DockerImages(self)
i_name = di.get_unique_name(c_name) # easier debugging
self.sub_stuff["images"].append(i_name)
subdct = {"container": c_name, "image": i_name}
export_cmd_args = self.config['export_cmd_args'].strip() % subdct
import_cmd_args = self.config['import_cmd_args'].strip() % subdct
self.init_ei_dockercmd(export_cmd_args, import_cmd_args)