Exemple #1
0
    def test_copy_and_delete_password_file_methods_are_called_for_user_with_password(
            self, changePasswordFileModeOnHost_method,
            deletePasswordFile_method, createDoneFiles_method,
            communicate_method, SSH_writeDoneToFile_method,
            SSH_writeLogToFile_method, SCP_writeLogToFile_method):
        SCP_writeLogToFile_method.return_value = None
        SSH_writeLogToFile_method.return_value = None
        SSH_writeDoneToFile_method.return_value = None
        communicate_method.return_value = ("", "")
        createDoneFiles_method.return_value = None

        deletePasswordFile_method.return_value = 0

        changePasswordFileModeOnHost_method.return_value = 0

        os.environ[AMBARI_PASSPHRASE_VAR_NAME] = ""
        bootstrap = BootStrap(["hostname"], "user", "sshKeyFile", "scriptDir",
                              "bootdir", "setupAgentFile", "ambariServer",
                              "centos6", None, "passwordFile")

        def side_effect():
            bootstrap.copyPasswordFile_called = True
            bootstrap.hostlist_to_remove_password_file = ["hostname"]
            return 0

        bootstrap.copyPasswordFile = side_effect
        ret = bootstrap.run()
        self.assertTrue(bootstrap.copyPasswordFile_called)
        self.assertTrue(deletePasswordFile_method.called)
        self.assertTrue(changePasswordFileModeOnHost_method.called)
Exemple #2
0
    def test_os_check_fail_fails_bootstrap_execution(self, pssh_run_method,
                                                     pssh_getstatus_method,
                                                     pscp_run_method,
                                                     pscp_getstatus_method,
                                                     createDoneFiles_method):

        c6hstr = "cent6host"
        c5hstr = "cent5host"

        def pscp_statuses():
            yield { # copyOsCheckScript call
                c6hstr : {
                  "exitstatus" : 0,
                  "log" : ""
                },
                c5hstr : {
                  "exitstatus" : 0,
                  "log" : ""
                },
              }
            while True:  # Next calls
                d = {}
                for host in bootstrap.successive_hostlist:
                    d[host] = {"exitstatus": 0, "log": ""}
                yield d

        def pssh_statuses():
            yield { # runOsCheckScript call
                c6hstr : {
                  "exitstatus" : 0,
                  "log" : ""
                },
                c5hstr : {
                  "exitstatus" : 1,
                  "log" : ""
                },
              }
            while True:  # Next calls
                d = {}
                for host in bootstrap.successive_hostlist:
                    d[host] = {"exitstatus": 0, "log": ""}
                yield d

        pscp_getstatus_method.side_effect = pscp_statuses().next
        pssh_getstatus_method.side_effect = pssh_statuses().next

        os.environ[AMBARI_PASSPHRASE_VAR_NAME] = ""
        bootstrap = BootStrap([c6hstr, c5hstr], "user", "sshKeyFile",
                              "scriptDir", "bootdir", "setupAgentFile",
                              "ambariServer", "centos6", None)
        ret = bootstrap.run()

        self.assertTrue(c5hstr not in bootstrap.successive_hostlist)
        self.assertTrue(c6hstr in bootstrap.successive_hostlist)
        self.assertTrue(pssh_run_method.call_count >= 2)
        self.assertTrue(pssh_getstatus_method.call_count >= 2)
        self.assertTrue(ret == 1)
Exemple #3
0
def run(*,
        verbose=False,
        sqlite_echo=False,
        skip_bootstrap=False,
        pytest_options=None):
    common.run(_LOGGER, verbose=verbose)
    os.environ['PIPENV_VENV_IN_PROJECT'] = "1"

    if sqlite_echo:
        os.environ['SQLITE_ECHO'] = "y"
    else:
        os.environ['SQLITE_ECHO'] = "n"

    os.environ['PYTEST_ADDOPTS'] = "--color=yes"

    if not skip_bootstrap:
        bootstrap.run(verbose=verbose)

    cmd = ["pipenv", "run", "pytest"]
    if pytest_options:
        cmd.append(pytest_options)

    common.run_cmd(_LOGGER, cmd, raw_log=True)
Exemple #4
0
    def test_os_check_performed(self, createDoneFiles_method,
                                copyOsCheckScript_method,
                                runOsCheckScript_method,
                                checkSudoPackage_method,
                                copyNeededFiles_method, runSetupAgent_method):
        createDoneFiles_method.return_value = None

        copyOsCheckScript_method.return_value = 0
        runOsCheckScript_method.return_value = 0
        checkSudoPackage_method.return_value = 0
        copyNeededFiles_method.return_value = 0
        runSetupAgent_method.return_value = 0

        os.environ[AMBARI_PASSPHRASE_VAR_NAME] = ""
        bootstrap = BootStrap(["hostname"], "user", "sshKeyFile", "scriptDir",
                              "bootdir", "setupAgentFile", "ambariServer",
                              "centos6", None)
        ret = bootstrap.run()
        self.assertTrue(copyOsCheckScript_method.called)
        self.assertTrue(runOsCheckScript_method.called)
        self.assertTrue(ret == 0)
Exemple #5
0
    def test_commands_without_password_are_called_for_passwordless_user(
            self, getMoveRepoFileWithoutPasswordCommand_method,
            getRunSetupWithoutPasswordCommand_method, createDoneFiles_method,
            communicate_method, SSH_writeDoneToFile_method,
            SSH_writeLogToFile_method, SCP_writeLogToFile_method):
        SCP_writeLogToFile_method.return_value = None
        SSH_writeLogToFile_method.return_value = None
        SSH_writeDoneToFile_method.return_value = None
        communicate_method.return_value = ("", "")
        createDoneFiles_method.return_value = None

        getRunSetupWithoutPasswordCommand_method.return_value = ""
        getMoveRepoFileWithoutPasswordCommand_method.return_value = ""

        os.environ[AMBARI_PASSPHRASE_VAR_NAME] = ""
        bootstrap = BootStrap(["hostname"], "user", "sshKeyFile", "scriptDir",
                              "bootdir", "setupAgentFile", "ambariServer",
                              "centos6", None)
        ret = bootstrap.run()
        self.assertTrue(getRunSetupWithoutPasswordCommand_method.called)
        self.assertTrue(getMoveRepoFileWithoutPasswordCommand_method.called)
#
# RTEMS Tools Project (http://www.rtems.org/)
# Copyright 2013 Chris Johns ([email protected])
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

from __future__ import print_function

import sys, os

try:
    import bootstrap
    bootstrap.run(sys.argv)
except ImportError:
    print("Incorrect Source Builder installation", file = sys.stderr)
    sys.exit(1)
Exemple #7
0
def run(*, verbose=False):
    common.run(_LOGGER, verbose=verbose)

    bootstrap.run(verbose=verbose)
Exemple #8
0
#
# RTEMS Tools Project (http://www.rtems.org/)
# Copyright 2013 Chris Johns ([email protected])
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

from __future__ import print_function

import sys, os

try:
    import bootstrap
    bootstrap.run(sys.argv)
except ImportError:
    print("Incorrect Source Builder installation", file=sys.stderr)
    sys.exit(1)
Exemple #9
0
        dialog = wx.MessageDialog(
                None,
                u'Fichier %s généré' % file_name,
                'Confirmation',
                style=wx.OK
                )
        dialog.ShowModal()

    def generate_paper_mailing_list(self, event):
        """Generate the email list for resubscription campain"""
        file_name = '../resubscription.csv'
        exporter = subscriber_exporter.ReSubscribeExporter(file_name)
        exporter.do_export()
        message = u"Fichier %s généré.\n" % file_name
        message += "Cliquer sur OK pour confirmer l'envoi "
        message += u"du courrier et mettre à jour la base."
        dialog = wx.MessageDialog(
                None,
                message,
                'Confirmation',
                style=wx.OK | wx.CANCEL
                )
        if dialog.ShowModal() == wx.ID_OK:
            gaabo_controler.update_mail_sent()

if __name__ == '__main__':
    bootstrap.run()
    prog = wx.App(0)
    frame = GaaboFrame(None, 'GAabo')
    prog.MainLoop()
Exemple #10
0
import argparse, json
import bootstrap, consts, helpers, outputter, entry, template

# ###################################################################### #
# ###################################################################### #
# ###################################################################### #

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('config', help="path to config file")
    parser.add_argument('command', help="new|build|clean")
    parser.add_argument('-v' , '--verbose'   , dest='verbose'     , action='store_true' )
    parser.add_argument('-f' , '--force'     , dest='force'       , action='store_true' )

    args = parser.parse_args()

    config = {}
    with open(args.config) as fp:
        config = json.load(fp)

    bootstrap.configure(config, args.verbose, args.force)
    bootstrap.run(args.command.upper())