def pre_sysprep(self):
        super(BaseNextLogonRecipe, self).pre_sysprep()

        introspection.set_config_option(
            option="first_logon_behaviour",
            value=self.behaviour,
            execute_function=self._execute)
Beispiel #2
0
    def pre_sysprep(self):
        super(BaseNextLogonRecipe, self).pre_sysprep()

        introspection.set_config_option(
            option="first_logon_behaviour",
            value=self.behaviour,
            execute_function=self._execute)
    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.
        resource_location = "windows/patch_shell.ps1"
        params = r' "{}"'.format(cbinit)
        self._backend.remote_client.manager.execute_powershell_resource_script(
            resource_location=resource_location, parameters=params)

        # Prepare Something specific for the OS
        self._backend.remote_client.manager.specific_prepare()
Beispiel #4
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))
 def pre_sysprep(self):
     super(CloudbaseinitWinrmRecipe, self).pre_sysprep()
     introspection.set_config_option(
         option="plugins",
         value="cloudbaseinit.plugins.windows.winrmcertificateauth."
               "ConfigWinRMCertificateAuthPlugin,"
               "cloudbaseinit.plugins.windows.winrmlistener."
               "ConfigWinRMListenerPlugin",
         execute_function=self._execute)
    def pre_sysprep(self):
        super(CloudbaseinitMockServiceRecipe, self).pre_sysprep()
        LOG.info("Inject guest IP for mocked service access.")

        # Append service IP as a config option.
        address = self.pattern.format(util.get_local_ip())
        introspection.set_config_option(option=self.config_entry,
                                        value=address,
                                        execute_function=self._execute)
Beispiel #7
0
 def pre_sysprep(self):
     super(CloudbaseinitWinrmRecipe, self).pre_sysprep()
     introspection.set_config_option(
         option="plugins",
         value="cloudbaseinit.plugins.windows.winrmcertificateauth."
               "ConfigWinRMCertificateAuthPlugin,"
               "cloudbaseinit.plugins.windows.winrmlistener."
               "ConfigWinRMListenerPlugin",
         execute_function=self._execute)
Beispiel #8
0
    def pre_sysprep(self):
        super(CloudbaseinitMockServiceRecipe, self).pre_sysprep()
        LOG.info("Inject guest IP for mocked service access.")

        # Append service IP as a config option.
        address = self.pattern.format(util.get_local_ip())
        introspection.set_config_option(option=self.config_entry,
                                        value=address,
                                        execute_function=self._execute)
    def pre_sysprep(self):
        super(CloudbaseinitMaasRecipe, self).pre_sysprep()

        required_fields = (
            "maas_oauth_consumer_key",
            "maas_oauth_consumer_secret",
            "maas_oauth_token_key",
            "maas_oauth_token_secret",
        )

        for field in required_fields:
            introspection.set_config_option(option=field, value="secret",
                                            execute_function=self._execute)
Beispiel #10
0
    def pre_sysprep(self):
        super(CloudbaseinitMaasRecipe, self).pre_sysprep()

        required_fields = (
            "maas_oauth_consumer_key",
            "maas_oauth_consumer_secret",
            "maas_oauth_token_key",
            "maas_oauth_token_secret",
        )

        for field in required_fields:
            introspection.set_config_option(option=field, value="secret",
                                            execute_function=self._execute)
 def pre_sysprep(self):
     super(CloudbaseinitKeysRecipe, self).pre_sysprep()
     introspection.set_config_option(
         option="plugins",
         value="cloudbaseinit.plugins.windows.createuser."
               "CreateUserPlugin,"
               "cloudbaseinit.plugins.windows.setuserpassword."
               "SetUserPasswordPlugin,"
               "cloudbaseinit.plugins.common.sshpublickeys."
               "SetUserSSHPublicKeysPlugin,"
               "cloudbaseinit.plugins.windows.winrmlistener."
               "ConfigWinRMListenerPlugin,"
               "cloudbaseinit.plugins.windows.winrmcertificateauth."
               "ConfigWinRMCertificateAuthPlugin",
         execute_function=self._execute)
Beispiel #12
0
 def pre_sysprep(self):
     super(CloudbaseinitKeysRecipe, self).pre_sysprep()
     introspection.set_config_option(
         option="plugins",
         value="cloudbaseinit.plugins.windows.createuser."
               "CreateUserPlugin,"
               "cloudbaseinit.plugins.windows.setuserpassword."
               "SetUserPasswordPlugin,"
               "cloudbaseinit.plugins.common.sshpublickeys."
               "SetUserSSHPublicKeysPlugin,"
               "cloudbaseinit.plugins.windows.winrmlistener."
               "ConfigWinRMListenerPlugin,"
               "cloudbaseinit.plugins.windows.winrmcertificateauth."
               "ConfigWinRMCertificateAuthPlugin",
         execute_function=self._execute)
Beispiel #13
0
    def test_set_config_option(self, mock_cbinit_dir, mock_join):
        mock_cbinit_dir.return_value = "fake dir"
        mock_join.return_value = mock.sentinel

        option = mock.sentinel
        value = mock.sentinel
        execute_function = mock.Mock()

        windows.set_config_option(option, value, execute_function)

        mock_cbinit_dir.assert_called_once_with(execute_function)
        mock_join.assert_called_once_with("fake dir", "conf",
                                          "cloudbase-init.conf")
        cmd = ('((Get-Content {0!r}) + {1!r}) | Set-Content {0!r}'.format(
            mock_join.return_value, "{} = {}".format(option, value)))
        execute_function.assert_called_with(cmd, command_type=util.POWERSHELL)
    def test_set_config_option(self, mock_cbinit_dir, mock_join):
        mock_cbinit_dir.return_value = "fake dir"
        mock_join.return_value = mock.sentinel

        option = mock.sentinel
        value = mock.sentinel
        execute_function = mock.Mock()

        windows.set_config_option(option, value, execute_function)

        mock_cbinit_dir.assert_called_once_with(execute_function)
        mock_join.assert_called_once_with("fake dir", "conf",
                                          "cloudbase-init.conf")
        cmd = ('((Get-Content {0!r}) + {1!r}) | Set-Content {0!r}'.
               format(mock_join.return_value,
                      "{} = {}".format(option, value)))
        execute_function.assert_called_with(cmd, command_type=util.POWERSHELL)