Beispiel #1
0
 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')
Beispiel #2
0
 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()
Beispiel #3
0
 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')
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
0
 def GET(self, id):
     return data.pxe_config_details(id)
Beispiel #7
0
 def GET(self, id):
     return data.pxe_config_details(id)