Exemplo n.º 1
0
 def on_entry(self):
     self.machine.clear_counter()
     try:
         data.get_pxe_config_for_device(self.machine.device_name,
                                        'self-test')
     except data.NotFound:
         self.machine.goto_state(pc_power_cycling)
     else:
         data.set_device_config(self.machine.device_name, 'self-test', '')
         self.machine.goto_state(pxe_power_cycling)
Exemplo n.º 2
0
 def on_please_image(self, args):
     try:
         data.get_pxe_config_for_device(self.machine.device_name,
                                        args['image'])
         self.logger.info('writing image %s, boot config %s to db' %
                          (args['image'], args['boot_config']))
         data.set_device_config(self.machine.device_name,
                                args['image'],
                                args['boot_config'])
         self.machine.goto_state(start_pxe_boot)
     except data.NotFound:
         self.logger.error('cannot image device')
Exemplo n.º 3
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)
Exemplo n.º 4
0
 def on_please_pxe_boot(self, args):
     self.logger.info('writing pxe_config %s, boot config %s to db' %
                      (args['pxe_config'], args['boot_config']))
     data.set_device_config(self.machine.device_name, args['pxe_config'],
                            args['boot_config'])
     self.machine.goto_state(start_pxe_boot)
Exemplo n.º 5
0
 def on_please_pxe_boot(self, args):
     self.logger.info('writing pxe_config %s, boot config %s to db' % (args['pxe_config'], args['boot_config']))
     data.set_device_config(self.machine.device_name,
             args['pxe_config'],
             args['boot_config'])
     self.machine.goto_state(start_pxe_boot)
Exemplo n.º 6
0
 def on_entry(self):
     self.machine.clear_counter()
     data.set_device_config(self.machine.device_name, 'maintenance', '')
     self.machine.goto_state(pxe_power_cycling)