def test_add(self): self.write_config('this is my config') scripts.pxe_config_script(['add', 'testy', '-m' 'TEST', '-c', 'test-config']) self.assertEqual(data.pxe_config_details('testy'), {'details':{'description':'TEST', 'contents':'this is my config', 'active':True, 'name':'testy'}}) self.assertStdout('this is my')
def show_details(name): deets = data.pxe_config_details(name)['details'] print "** Name:", deets[ 'name'], '(inactive)' if not deets['active'] else '' print "** Description:", deets['description'] print "** Contents:" print deets['contents'].strip()
def test_modify(self): self.write_config('this is my config') add_pxe_config('testy') scripts.pxe_config_script(['modify', 'testy', '-m' 'TEST', '-c', 'test-config', '--inactive']) self.assertEqual(data.pxe_config_details('testy'), {'details':{'description':'TEST', 'contents':'this is my config', 'active':False, 'name':'testy'}}) self.assertStdout('this is my')
def set_pxe(device_name, pxe_config_name, boot_config): """ Set up the PXE configuration for the device as directed. Note that this does *not* reboot the device. """ logger.info('setting pxe config for %s to %s%s' % (device_name, pxe_config_name, ' with boot config' if boot_config else '')) image_details = data.pxe_config_details(pxe_config_name)['details'] pxe_config_contents = image_details['contents'] # Write out the config file device_config_path = _get_device_config_path(device_name) device_config_dir = os.path.dirname(device_config_path) if not os.path.exists(device_config_dir): os.makedirs(device_config_dir) # apply ipaddress substitution to the config contents pxe_config_contents = pxe_config_contents.replace('%IPADDRESS%', config.get('server', 'ipaddress')) open(device_config_path, "w").write(pxe_config_contents)
def set_pxe(device_name, pxe_config_name, boot_config): """ Set up the PXE configuration for the device as directed. Note that this does *not* reboot the device. """ logger.info('setting pxe config for %s to %s%s' % (device_name, pxe_config_name, ' with boot config' if boot_config else '')) image_details = data.pxe_config_details(pxe_config_name)['details'] pxe_config_contents = image_details['contents'] # Set the config in the database before writing to disk. data.set_device_config(device_name, pxe_config_name, boot_config) # Write out the config file device_config_path = _get_device_config_path(device_name) device_config_dir = os.path.dirname(device_config_path) if not os.path.exists(device_config_dir): os.makedirs(device_config_dir) # apply ipaddress substitution to the config contents pxe_config_contents = pxe_config_contents.replace('%IPADDRESS%', config.get('server', 'ipaddress')) open(device_config_path, "w").write(pxe_config_contents)
def GET(self, id): return data.pxe_config_details(id)