def _init_vm(path, fields): for key, value in fields.items(): key = path + "/" + key if isinstance(value, dict): _init_vm(key, value) else: if isinstance(value, tuple): k, v = value if k not in hwconf or not hwconf[k]: value = "To be filled by O.E.M." else: if k not in config: config[k] = random.choice(hwconf[k]) value = config[k][v] # Some values have to be generated randomly. if value is not None: if value.startswith("<SERIAL>"): length = int(value.split()[-1]) value = random_serial(length) elif value.startswith("<UUID>"): value = random_uuid() if value is None: value = "To be filled by O.E.M." log.debug("Setting %r to %r.", key, value) ret = self.set_field(key, value) if ret: log.debug(ret)
def _init_vm(path, fields): for key, value in fields.items(): key = path + '/' + key if isinstance(value, dict): _init_vm(key, value) else: if isinstance(value, tuple): k, v = value if k not in hwconf or not hwconf[k]: value = 'To be filled by O.E.M.' else: if k not in config: config[k] = random.choice(hwconf[k]) value = config[k][v] # Some values have to be generated randomly. if value is not None: if value.startswith('<SERIAL>'): length = int(value.split()[-1]) value = random_serial(length) elif value.startswith('<UUID>'): value = random_uuid() if value is None: value = "To be filled by O.E.M." log.debug('Setting %r to %r.', key, value) ret = self.set_field(key, value) if ret: log.debug(ret)
def _init_vm(path, fields): for key, value in fields.items(): if path: key = path + '/' + key if isinstance(value, dict): _init_vm(key, value) else: if isinstance(value, tuple): k, v = value if k not in hwconf or not hwconf[k]: value = 'To be filled by O.E.M.' else: if k not in config: config[k] = random.choice(hwconf[k]) value = config[k][v] # Some values have to be generated randomly. if value is not None: if value.startswith('<SERIAL>'): length = int(value.split()[-1]) value = random_serial(length) elif value.startswith('<UUID>'): value = random_uuid() elif value.startswith('<HWCONF>'): value = os.path.join(HWCONF_PATH, \ value.split('/', 1)[1]) if value is None: value = "To be filled by O.E.M." log.debug('Setting %r to %r.', key, value) ret = self.set_field(key, value) if ret: log.debug(ret)