def run(self, connection, max_end_time, args=None): if 'deployment_data' not in self.parameters: return connection if self.parameters["deployment_data"].get('installer_extra_cmd', None): if self.parameters.get('os', None) == "debian_installer": add_late_command( self.get_namespace_data(action='download-action', label='preseed', key='file'), self.parameters["deployment_data"]["installer_extra_cmd"]) if self.parameters.get('os', None) == "centos_installer": ip_addr = dispatcher_ip(self.job.parameters['dispatcher']) overlay = self.get_namespace_data(action='download-action', label='file', key='overlay') substitutions = { '{OVERLAY_URL}': 'tftp://' + ip_addr + '/' + overlay } post_command = substitute([ self.parameters["deployment_data"]["installer_extra_cmd"] ], substitutions) add_to_kickstart( self.get_namespace_data(action='download-action', label='preseed', key='file'), post_command[0]) return connection
def run(self, connection, args=None): if self.parameters["deployment_data"].get('installer_extra_cmd', None): if self.parameters.get('os', None) == "debian_installer": add_late_command(self.data['download_action']['preseed']['file'], self.parameters["deployment_data"]["installer_extra_cmd"]) if self.parameters.get('os', None) == "centos_installer": substitutions = {} substitutions['{OVERLAY_URL}'] = 'tftp://' + dispatcher_ip() + '/' + self.get_common_data('file', 'overlay') post_command = substitute([self.parameters["deployment_data"]["installer_extra_cmd"]], substitutions) add_to_kickstart(self.data['download_action']['preseed']['file'], post_command[0])
def run(self, connection, args=None): if self.parameters["deployment_data"].get('installer_extra_cmd', None): if self.parameters.get('os', None) == "debian_installer": add_late_command( self.data['download_action']['preseed']['file'], self.parameters["deployment_data"]["installer_extra_cmd"]) if self.parameters.get('os', None) == "centos_installer": substitutions = {} substitutions['{OVERLAY_URL}'] = 'tftp://' + dispatcher_ip( ) + '/' + self.get_common_data('file', 'overlay') post_command = substitute([ self.parameters["deployment_data"]["installer_extra_cmd"] ], substitutions) add_to_kickstart( self.data['download_action']['preseed']['file'], post_command[0])
def test_add_late_command(self): # Create preseed file with a few lines. with open('preseed.cfg', 'w') as preseedfile: preseedfile.write('d-i netcfg/dhcp_timeout string 60\n') preseedfile.write( 'd-i pkgsel/include string openssh-server build-essential\n') preseedfile.write('d-i finish-install/reboot_in_progress note\n') preseedfile = 'preseed.cfg' # Test adding new preseed/late_command line. extra_command = 'cmd1' installers.add_late_command(preseedfile, extra_command) file_content = open('preseed.cfg').read() self.assertTrue('d-i preseed/late_command string cmd1' in file_content) # Test appending the second command to existing presseed/late_command line. extra_command = 'cmd2 ;' installers.add_late_command(preseedfile, extra_command) file_content = open('preseed.cfg').read() self.assertTrue( 'd-i preseed/late_command string cmd1; cmd2 ;' in file_content) # Test if it strips off extra space and semi-colon. extra_command = 'cmd3' installers.add_late_command(preseedfile, extra_command) file_content = open('preseed.cfg').read() self.assertTrue( 'd-i preseed/late_command string cmd1; cmd2; cmd3' in file_content)