本文整理汇总了Python中lava_dispatcher.parser.JobParser.parse方法的典型用法代码示例。如果您正苦于以下问题:Python JobParser.parse方法的具体用法?Python JobParser.parse怎么用?Python JobParser.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lava_dispatcher.parser.JobParser
的用法示例。
在下文中一共展示了JobParser.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parameter_support
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def test_parameter_support(self): # pylint: disable=too-many-locals
data = self.factory.make_job_data()
test_block = [block for block in data['actions'] if 'test' in block][0]
smoke = test_block['test']['definitions'][0]
smoke['parameters'] = {
'VARIABLE_NAME_1': "first variable value",
'VARIABLE_NAME_2': "second value"
}
job = TestJob.from_yaml_and_user(yaml.dump(data), self.user)
job_def = yaml.load(job.definition)
job_ctx = job_def.get('context', {})
job_ctx.update({'no_kvm': True}) # override to allow unit tests on all types of systems
device = Device.objects.get(hostname='fakeqemu1')
device_config = device.load_configuration(job_ctx) # raw dict
parser = JobParser()
obj = PipelineDevice(device_config)
pipeline_job = parser.parse(job.definition, obj, job.id, None, "")
allow_missing_path(pipeline_job.pipeline.validate_actions, self,
'qemu-system-x86_64')
pipeline = pipeline_job.describe()
device_values = _get_device_metadata(pipeline['device'])
try:
testdata, _ = TestData.objects.get_or_create(testjob=job)
except (MultipleObjectsReturned):
self.fail('multiple objects')
for key, value in device_values.items():
if not key or not value:
continue
testdata.attributes.create(name=key, value=value)
retval = _get_action_metadata(pipeline['job']['actions'])
self.assertIn('test.0.common.definition.parameters.VARIABLE_NAME_2', retval)
self.assertIn('test.0.common.definition.parameters.VARIABLE_NAME_1', retval)
self.assertEqual(retval['test.0.common.definition.parameters.VARIABLE_NAME_1'], 'first variable value')
self.assertEqual(retval['test.0.common.definition.parameters.VARIABLE_NAME_2'], 'second value')
示例2: test_job_no_tags
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def test_job_no_tags(self):
with open(self.filename) as yaml_data:
alpha_data = yaml.load(yaml_data)
for vlan_key, _ in alpha_data['protocols'][VlandProtocol.name].items():
alpha_data['protocols'][VlandProtocol.name][vlan_key] = {'tags': []}
# removed tags from original job to simulate job where any interface tags will be acceptable
self.assertEqual(
alpha_data['protocols'][VlandProtocol.name],
{'vlan_one': {'tags': []}}
)
parser = JobParser()
job = parser.parse(yaml.dump(alpha_data), self.device, 4212, None, "")
job.logger = DummyLogger()
job.validate()
vprotocol = [vprotocol for vprotocol in job.protocols if vprotocol.name == VlandProtocol.name][0]
self.assertTrue(vprotocol.valid)
self.assertEqual(vprotocol.names, {'vlan_one': '4212vlanone'})
self.assertFalse(vprotocol.check_timeout(120, {'request': 'no call'}))
self.assertRaises(JobError, vprotocol.check_timeout, 60, 'deploy_vlans')
self.assertRaises(JobError, vprotocol.check_timeout, 60, {'request': 'deploy_vlans'})
self.assertTrue(vprotocol.check_timeout(120, {'request': 'deploy_vlans'}))
for vlan_name in job.parameters['protocols'][VlandProtocol.name]:
if vlan_name == 'yaml_line':
continue
self.assertIn(vlan_name, vprotocol.params)
self.assertIn('switch', vprotocol.params[vlan_name])
self.assertIn('port', vprotocol.params[vlan_name])
示例3: test_device_environment_validity
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def test_device_environment_validity(self): # pylint: disable=invalid-name
"""
Use non-YAML syntax a bit like existing device config syntax.
Ensure this syntax is picked up as invalid.
"""
data = """
# YAML syntax.
overrides:
DEBEMAIL = "[email protected]"
DEBFULLNAME: "Neil Williams"
"""
job_parser = JobParser()
device = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/bbb-01.yaml'))
sample_job_file = os.path.join(os.path.dirname(__file__), 'sample_jobs/uboot-ramdisk.yaml')
with open(sample_job_file) as sample_job_data:
job = job_parser.parse(
sample_job_data, device, 4212, None, "",
env_dut=data)
job.logger = DummyLogger()
self.assertEqual(
job.parameters['env_dut'],
data
)
with self.assertRaises(JobError):
job.validate()
示例4: create_b2260_job
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def create_b2260_job(self, filename):
device = NewDevice(os.path.join(os.path.dirname(__file__), "../devices/b2260-01.yaml"))
with open(os.path.join(os.path.dirname(__file__), filename)) as f_in:
parser = JobParser()
job = parser.parse(f_in, device, 456, None, "")
job.logger = DummyLogger()
return job
示例5: test_device_environment
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def test_device_environment(self):
data = """
# YAML syntax.
overrides:
DEBEMAIL: "[email protected]"
DEBFULLNAME: "Neil Williams"
"""
job_parser = JobParser()
device = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/bbb-01.yaml'))
sample_job_file = os.path.join(os.path.dirname(__file__), 'sample_jobs/uboot-ramdisk.yaml')
with open(sample_job_file) as sample_job_data:
job = job_parser.parse(
sample_job_data, device, 4212, None, "",
env_dut=data)
job.logger = DummyLogger()
self.assertEqual(
job.parameters['env_dut'],
data
)
job.validate()
boot_actions = [
action.internal_pipeline.actions for action in job.pipeline.actions if action.name == 'uboot-action'][0]
retry = [action for action in boot_actions if action.name == 'uboot-retry'][0]
boot_env = [action for action in retry.internal_pipeline.actions if action.name == 'export-device-env'][0]
found = False
for line in boot_env.env:
if 'DEBFULLNAME' in line:
found = True
# assert that the string containing a space still contains that space and is quoted
self.assertIn('\\\'Neil Williams\\\'', line)
self.assertTrue(found)
示例6: test_secondary_media
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def test_secondary_media(self):
"""
Test UBootSecondaryMedia validation
"""
job_parser = JobParser()
cubie = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/cubie1.yaml'))
sample_job_file = os.path.join(os.path.dirname(__file__), 'sample_jobs/cubietruck-removable.yaml')
sample_job_data = open(sample_job_file)
job = job_parser.parse(sample_job_data, cubie, 4212, None, "")
job.logger = DummyLogger()
job.validate()
sample_job_data.close()
uboot_action = [action for action in job.pipeline.actions if action.name == 'uboot-action' and action.parameters['namespace'] == 'boot2'][0]
u_boot_media = [action for action in uboot_action.internal_pipeline.actions if action.name == 'uboot-from-media' and action.parameters['namespace'] == 'boot2'][0]
self.assertIsInstance(u_boot_media, UBootSecondaryMedia)
self.assertEqual([], u_boot_media.errors)
self.assertEqual(u_boot_media.parameters['kernel'], '/boot/vmlinuz-3.16.0-4-armmp-lpae')
self.assertEqual(u_boot_media.parameters['kernel'], u_boot_media.get_namespace_data(
action='download-action', label='file', key='kernel'))
self.assertEqual(u_boot_media.parameters['ramdisk'], u_boot_media.get_namespace_data(
action='compress-ramdisk', label='file', key='ramdisk'))
self.assertEqual(u_boot_media.parameters['dtb'], u_boot_media.get_namespace_data(
action='download-action', label='file', key='dtb'))
# use the base class name so that uboot-from-media can pick up the value reliably.
self.assertEqual(u_boot_media.parameters['root_uuid'], u_boot_media.get_namespace_data(
action='bootloader-from-media', label='uuid', key='root'))
device = u_boot_media.get_namespace_data(action='storage-deploy', label='u-boot', key='device')
self.assertIsNotNone(device)
part_reference = '%s:%s' % (
job.device['parameters']['media']['usb'][device]['device_id'],
u_boot_media.parameters['boot_part']
)
self.assertEqual(part_reference, u_boot_media.get_namespace_data(
action=u_boot_media.name, label='uuid', key='boot_part'))
self.assertEqual(part_reference, "0:1")
示例7: test_extra_options
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def test_extra_options(self):
device = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/kvm01.yaml'))
kvm_yaml = os.path.join(os.path.dirname(__file__), 'sample_jobs/kvm-inline.yaml')
with open(kvm_yaml) as sample_job_data:
job_data = yaml.load(sample_job_data)
device['actions']['boot']['methods']['qemu']['parameters']['extra'] = yaml.load("""
- -smp
- 1
- -global
- virtio-blk-device.scsi=off
- -device virtio-scsi-device,id=scsi
- --append "console=ttyAMA0 root=/dev/vda rw"
""")
self.assertIsInstance(device['actions']['boot']['methods']['qemu']['parameters']['extra'][1], int)
parser = JobParser()
job = parser.parse(yaml.dump(job_data), device, 4212, None, "")
job.logger = DummyLogger()
job.validate()
boot_image = [action for action in job.pipeline.actions if action.name == 'boot-image-retry'][0]
boot_qemu = [action for action in boot_image.internal_pipeline.actions if action.name == 'boot-qemu-image'][0]
qemu = [action for action in boot_qemu.internal_pipeline.actions if action.name == 'execute-qemu'][0]
self.assertIsInstance(qemu.sub_command, list)
[self.assertIsInstance(item, str) for item in qemu.sub_command] # pylint: disable=expression-not-assigned
self.assertIn('virtio-blk-device.scsi=off', qemu.sub_command)
self.assertIn('1', qemu.sub_command)
self.assertNotIn(1, qemu.sub_command)
示例8: test_prompt_from_job
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def test_prompt_from_job(self): # pylint: disable=too-many-locals
"""
Support setting the prompt after login via the job
Loads a known YAML, adds a prompt to the dict and re-parses the job.
Checks that the prompt is available in the expect_shell_connection action.
"""
job = self.factory.create_job('sample_jobs/ipxe-ramdisk.yaml')
job.validate()
bootloader = [action for action in job.pipeline.actions if action.name == 'bootloader-action'][0]
retry = [action for action in bootloader.internal_pipeline.actions
if action.name == 'bootloader-retry'][0]
expect = [action for action in retry.internal_pipeline.actions
if action.name == 'expect-shell-connection'][0]
check = expect.parameters
device = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/x86-01.yaml'))
extra_yaml = os.path.join(os.path.dirname(__file__), 'sample_jobs/ipxe.yaml')
with open(extra_yaml) as data:
sample_job_string = data.read()
parser = JobParser()
sample_job_data = yaml.load(sample_job_string)
boot = [item['boot'] for item in sample_job_data['actions'] if 'boot' in item][0]
self.assertIsNotNone(boot)
sample_job_string = yaml.dump(sample_job_data)
job = parser.parse(sample_job_string, device, 4212, None, "")
job.logger = DummyLogger()
job.validate()
bootloader = [action for action in job.pipeline.actions if action.name == 'bootloader-action'][0]
retry = [action for action in bootloader.internal_pipeline.actions
if action.name == 'bootloader-retry'][0]
expect = [action for action in retry.internal_pipeline.actions
if action.name == 'expect-shell-connection'][0]
示例9: create_job
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def create_job(self, sample_job, device_file): # pylint: disable=no-self-use
device = NewDevice(os.path.join(os.path.dirname(__file__), device_file))
yaml = os.path.join(os.path.dirname(__file__), sample_job)
with open(yaml) as sample_job_data:
parser = JobParser()
job = parser.parse(sample_job_data, device, 4212, None, "")
job.logger = DummyLogger()
return job
示例10: create_job
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def create_job(self, filename, output_dir='/tmp'): # pylint: disable=no-self-use
device = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/mps2plus_01.yaml'))
y_file = os.path.join(os.path.dirname(__file__), filename)
with open(y_file) as sample_job_data:
parser = JobParser()
job = parser.parse(sample_job_data, device, 4212, None, "")
job.logger = DummyLogger()
return job
示例11: create_nexus5x_job
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def create_nexus5x_job(self, filename): # pylint: disable=no-self-use
device = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/nexus5x-01.yaml'))
fastboot_yaml = os.path.join(os.path.dirname(__file__), filename)
with open(fastboot_yaml) as sample_job_data:
parser = JobParser()
job = parser.parse(sample_job_data, device, 4212, None, "")
job.logger = DummyLogger()
return job
示例12: create_ssh_job
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def create_ssh_job(self, filename): # pylint: disable=no-self-use
device = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/ssh-host-01.yaml'))
kvm_yaml = os.path.join(os.path.dirname(__file__), filename)
with open(kvm_yaml) as sample_job_data:
parser = JobParser()
job = parser.parse(sample_job_data, device, 0, None, dispatcher_config="")
job.logger = DummyLogger()
return job
示例13: create_zcu102_job
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def create_zcu102_job(self, filename): # pylint: disable=no-self-use
device = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/xilinx-zcu102.yaml'))
zcu_yaml = os.path.join(os.path.dirname(__file__), filename)
with open(zcu_yaml) as sample_job_data:
parser = JobParser()
job = parser.parse(sample_job_data, device, 4212, None, "")
job.logger = DummyLogger()
return job
示例14: create_mustang_job
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def create_mustang_job(self, filename): # pylint: disable=no-self-use
device = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/mustang-grub-efi.yaml'))
y_file = os.path.join(os.path.dirname(__file__), filename)
with open(y_file) as sample_job_data:
parser = JobParser()
job = parser.parse(sample_job_data, device, 4212, None, "")
job.logger = DummyLogger()
return job
示例15: create_k64f_job_with_power
# 需要导入模块: from lava_dispatcher.parser import JobParser [as 别名]
# 或者: from lava_dispatcher.parser.JobParser import parse [as 别名]
def create_k64f_job_with_power(self, filename): # pylint: disable=no-self-use
device = NewDevice(os.path.join(os.path.dirname(__file__), '../devices/frdm-k64f-01-with-power.yaml'))
y_file = os.path.join(os.path.dirname(__file__), filename)
with open(y_file) as sample_job_data:
parser = JobParser()
job = parser.parse(sample_job_data, device, 5999, None, "")
job.logger = DummyLogger()
return job