Example #1
0
 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
Example #2
0
 def run(self, connection, max_end_time):
     if "deployment_data" not in self.parameters:
         return connection
     if self.parameters["deployment_data"].get("installer_extra_cmd"):
         if self.parameters.get("os") == "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") == "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
Example #3
0
 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
Example #4
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)
        with open('preseed.cfg') as f_in:
            file_content = f_in.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)
        with open('preseed.cfg') as f_in:
            file_content = f_in.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)
        with open('preseed.cfg') as f_in:
            file_content = f_in.read()
            self.assertTrue('d-i preseed/late_command string cmd1; cmd2; cmd3'
                            in file_content)
Example #5
0
def test_installer_add_late_command(tmpdir):
    os.chdir(str(tmpdir))
    # 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)
    with open("preseed.cfg") as f_in:
        file_content = f_in.read()
        assert "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)
    with open("preseed.cfg") as f_in:
        file_content = f_in.read()
        assert "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)
    with open("preseed.cfg") as f_in:
        file_content = f_in.read()
        assert "d-i preseed/late_command string cmd1; cmd2; cmd3" in file_content
Example #6
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)
        with open('preseed.cfg') as f_in:
            file_content = f_in.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)
        with open('preseed.cfg') as f_in:
            file_content = f_in.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)
        with open('preseed.cfg') as f_in:
            file_content = f_in.read()
            self.assertTrue('d-i preseed/late_command string cmd1; cmd2; cmd3' in file_content)