Beispiel #1
0
    def install(bundle):
        if not os.path.isfile("/usr/share/clear/bundles/" + str(bundle)) and \
            not os.path.isfile("/usr/share/clear/bundles/"
                               "openstack-all-in-one"):
            LOG.info("Installing {0} bundle".format(bundle))
            cmd = "clr_bundle_add -V {0}".format(bundle)
            if(os.path.isfile("/bin/swupd")):
                cmd = "swupd bundle-add -V {0}".format(bundle)

            try:
                stdout, stderr = util.run_command(cmd)
                if stderr:
                    LOG.error("swupd bundle-add: {0}\n{1}"
                              .format(stdout, stderr))
            except Exception:
                LOG.error("clearstack: cannot install"
                          " {0} bundle".format(bundle))
Beispiel #2
0
    def secure_installation(self, user, password):
        LOG.debug("calling mariadb secure installation")
        try:
            """ test if mysql has a password """
            util.run_command("mysql -u{0} -e \"\"".format(user), debug=False)
            """ Secure the database service """
            util.run_command('mysqladmin -u root password "{0}"'
                             .format(password, debug=False))
            util.run_command('mysql -u root -p"{0}" -e "UPDATE mysql.user '
                             'SET Password=PASSWORD(\'{0}\') '
                             'WHERE User=\'root\'"'
                             .format(password, debug=False))
            util.run_command('mysql -u root -p"{0}" -e "DELETE FROM '
                             'mysql.user WHERE User=\'root\' AND Host '
                             ' NOT IN (\'localhost\', \'127.0.0.1\', '
                             '\'::1\')"'
                             .format(password, debug=False))
            util.run_command('mysql -u root -p"{0}" -e "DELETE FROM '
                             'mysql.user WHERE User=\'\'"'
                             .format(password, debug=False))
            util.run_command('mysql -u root -p"{0}" -e "DELETE FROM mysql.db '
                             'WHERE Db=\'test\' OR Db=\'test\_%\'"'
                             .format(password, debug=False))
            util.run_command('mysql -u root -p"{0}" -e '
                             '"FLUSH PRIVILEGES"'
                             .format(password, debug=False))
        except:
            pass

        try:
            """ verify the password """
            util.run_command("mysql -u{0} -p{1} -e \"\""
                             .format(user, password), debug=False)
        except:
            LOG.error("clearstack: cannot connect to mysql database,"
                      " the password is incorrect")
            return sys.exit(1)