예제 #1
0
    def pre_sysprep(self):
        """Disable first_logon_behaviour for testing purposes.

        Because first_logon_behaviour will control how the password
        should work on next logon, we could have troubles in tests,
        so this is always disabled, excepting tests which sets
        it manual to whatever they want.
        """
        introspection.set_config_option(
            option="first_logon_behaviour", value="no",
            execute_function=self._execute)

        # Patch the installation of cloudbaseinit in order to create
        # a file when the execution ends. We're doing this instead of
        # monitoring the service, because on some OSes, just checking
        # if the service is stopped leads to errors, due to the
        # fact that the service starts later on.
        python_dir = introspection.get_python_dir(self._execute)
        cbinit = ntpath.join(python_dir, 'Lib', 'site-packages',
                             'cloudbaseinit')

        # Get the shell patching script and patch the installation.
        cmd = ("powershell Invoke-Webrequest -uri "
               "{}/windows/patch_shell.ps1 -outfile "
               "C:\\patch_shell.ps1"
               .format(self._conf.argus.resources))
        self._execute(cmd)

        escaped = introspection.escape_path(cbinit)
        self._execute('powershell "C:\\\\patch_shell.ps1 \"{}\""'
                      .format(escaped))
예제 #2
0
    def test_escape_path(self):
        path = "(12 34))"
        expected_result = path
        for char in windows.ESC:
            expected_result = expected_result.replace(char, "`{}".format(char))

        result = windows.escape_path(path)

        self.assertEqual(result, expected_result)
예제 #3
0
    def test_escape_path(self):
        path = "(12 34))"
        expected_result = path
        for char in windows.ESC:
            expected_result = expected_result.replace(char, "`{}".format(char))

        result = windows.escape_path(path)

        self.assertEqual(result, expected_result)
예제 #4
0
    def pre_sysprep(self):
        super(CloudbaseinitCloudstackRecipe, self).pre_sysprep()

        python_dir = introspection.get_python_dir(self._execute)
        cbinit = ntpath.join(python_dir, 'Lib', 'site-packages',
                             'cloudbaseinit')

        # Install mock
        python = ntpath.join(python_dir, "python.exe")
        command = '"{}" -m pip install mock'
        self._execute(command.format(python))

        # Get the cloudstack patching script and patch the installation.
        cmd = ("powershell Invoke-Webrequest -uri "
               "{}/windows/patch_cloudstack.ps1 -outfile "
               "C:\\patch_cloudstack.ps1"
               .format(self._conf.argus.resources))
        self._execute(cmd)

        escaped = introspection.escape_path(cbinit)
        self._execute('powershell "C:\\\\patch_cloudstack.ps1 \"{}\""'
                      .format(escaped))