Exemplo n.º 1
0
    def downgrade_argus_admin(cls, latestVersion, config, currVersion):
        from beaver.component.rollingupgrade.ruUpgrade import UpgradePerNode
        UpgradePerNode.reportProgress(
            '#### ranger-admin: downgrading to old version.. ####')
        # 'knox.crt'
        # 'cacertswithknox'
        node = Xa.getPolicyAdminHost()
        user = Machine.getAdminUser()
        xa_admin_stop_cmd = 'sudo service ranger-admin stop'
        xa_admin_start_cmd = 'sudo service ranger-admin start'

        UpgradePerNode.reportProgress(
            '#### ranger-admin: stopping with command %s ####' %
            xa_admin_stop_cmd)
        exit_code, stdout = Machine.runas(user,
                                          xa_admin_stop_cmd,
                                          host=node,
                                          logoutput=True)
        logger.info('****************** xa admin stop exit_code = ' +
                    str(exit_code))

        node = Xa.getPolicyAdminHost()
        from beaver.component.rollingupgrade.ruCommon import hdpSelect
        hdpSelect.changeVersion("ranger-admin", latestVersion, node)
        logger.info(
            '*************************** hdp-select to new version done = ')

        UpgradePerNode.reportProgress(
            '#### ranger-admin: starting with command %s ####' %
            xa_admin_start_cmd)
        exit_code, stdout = Machine.runas(user,
                                          xa_admin_start_cmd,
                                          host=node,
                                          logoutput=True)
        logger.info('****************** xa admin start exit_code = ' +
                    str(exit_code))
        logger.info('****************** xa admin start stdout = ' +
                    str(stdout))

        if exit_code == 0:
            UpgradePerNode.reportProgress(
                '#### ranger-admin: downgrade successful ####')
        else:
            UpgradePerNode.reportProgress(
                '#### ranger-admin: downgrade failed! startup exit_code=%d ####'
                % exit_code)
Exemplo n.º 2
0
    def downgrade_master(cls, latestVersion, config, currVersion):
        from beaver.component.xa import Xa
        from beaver.component.rollingupgrade.ruUpgrade import UpgradePerNode
        UpgradePerNode.reportProgress(
            '#### ranger-usersync: downgrading to old version.. ####')
        # 'knox.crt'
        # 'cacertswithknox'
        user = Machine.getAdminUser()
        xa_usersync_stop_cmd = 'sudo service ranger-usersync stop'
        xa_usersync_start_cmd = 'sudo service ranger-usersync start'

        node = Xa.getPolicyAdminHost()

        UpgradePerNode.reportProgress(
            '#### ranger-usersync: stopping with command %s ####' %
            xa_usersync_stop_cmd)
        exit_code, stdout = Machine.runas(user,
                                          xa_usersync_stop_cmd,
                                          host=node,
                                          logoutput=True)
        logger.info('****************** xa usersync stop exit_code = ' +
                    str(exit_code))

        from beaver.component.rollingupgrade.ruCommon import hdpSelect
        hdpSelect.changeVersion("ranger-usersync", latestVersion, node)
        logger.info(
            '*************************** hdp-select to new version done = ')

        UpgradePerNode.reportProgress(
            '#### ranger-usersync: starting with command %s ####' %
            xa_usersync_start_cmd)
        exit_code, stdout = Machine.runas(user,
                                          xa_usersync_start_cmd,
                                          host=node,
                                          logoutput=True)
        logger.info('****************** xa usersync start exit_code = ' +
                    str(exit_code))
        logger.info('****************** xa usersync start stdout = ' +
                    str(stdout))

        if exit_code == 0 and 'UnixAuthenticationService has started successfully.' in stdout:
            UpgradePerNode.reportProgress(
                '#### ranger-usersync: downgrade successful ####')
        else:
            UpgradePerNode.reportProgress(
                '#### ranger-usersync: downgrade failed! startup error_code=%d ####'
                % exit_code)
Exemplo n.º 3
0
    def upgrade_argus_admin(cls, latestVersion, config, currVersion):
        from beaver.component.rollingupgrade.ruUpgrade import UpgradePerNode
        UpgradePerNode.reportProgress('#### install argus admin. ####')
        # 'knox.crt'
        # 'cacertswithknox'
        node = Xa.getPolicyAdminHost()
        user = Machine.getAdminUser()
        xa_admin_stop_cmd = 'sudo service ranger-admin stop'
        xa_admin_start_cmd = 'sudo service ranger-admin start'
        ranger_old_version = '/usr/hdp/' + currVersion + '/ranger-admin/'
        ranger_new_version = '/usr/hdp/' + latestVersion + '/ranger-admin/'

        localTestWorkDir1 = os.path.join(Config.getEnv('ARTIFACTS_DIR'))
        knox_cert_files = '{knox.crt,cacertswithknox}'
        source_files_to_copy = os.path.join(ranger_old_version,
                                            knox_cert_files)
        command_copy_knoxcerts = 'cp -f %s %s' % (source_files_to_copy,
                                                  localTestWorkDir1)
        exit_code, stdout = Machine.runas(user,
                                          command_copy_knoxcerts,
                                          host=node,
                                          logoutput=True)
        logger.info(
            '*************************** admin copy command_copy_knoxcerts exit_code = '
            + str(exit_code))
        logger.info(
            '*************************** admin copy command_copy_knoxcerts stdout = '
            + str(stdout))

        exit_code, stdout = Machine.runas(user,
                                          xa_admin_stop_cmd,
                                          host=node,
                                          logoutput=True)
        logger.info('****************** xa admin stop exit_code = ' +
                    str(exit_code))

        source_properties_file = os.path.join(ranger_old_version,
                                              'install.properties')
        destination_properties_file = os.path.join(ranger_new_version,
                                                   'install.properties')
        command = 'cp -f %s %s' % (source_properties_file,
                                   destination_properties_file)
        exit_code, stdout = Machine.runas(user,
                                          command,
                                          host=node,
                                          logoutput=True)
        logger.info(
            '*************************** admin copy command exit_code = ' +
            str(exit_code))
        logger.info(
            '*************************** admin copy command stdout = ' +
            str(stdout))

        command = '(cd %s && export JAVA_HOME=%s && ./setup.sh)' % (
            ranger_new_version, Machine.getJavaHome())
        UpgradePerNode.reportProgress(
            '#### ranger-admin: installing new version with command %s ###' %
            command)
        exit_code, stdout = Machine.runas(user,
                                          command,
                                          host=node,
                                          logoutput=True)

        if exit_code == 0 and 'Installation of XASecure PolicyManager Web Application is completed.' in stdout:
            UpgradePerNode.reportProgress(
                '#### ranger-admin: installation successful ###')

            from beaver.component.rollingupgrade.ruCommon import hdpSelect
            hdpSelect.changeVersion("ranger-admin", latestVersion, node)
            logger.info(
                '*************************** ranger-admin: hdp-select to new version done = '
            )

            source_files_to_copy = os.path.join(localTestWorkDir1,
                                                knox_cert_files)
            command_copy_knoxcerts = 'cp -f %s %s' % (source_files_to_copy,
                                                      ranger_new_version)
            exit_code, stdout = Machine.runas(user,
                                              command_copy_knoxcerts,
                                              host=node,
                                              logoutput=True)
            logger.info(
                '*************************** admin copy command_copy_knoxcerts back exit_code = '
                + str(exit_code))
            logger.info(
                '*************************** admin copy command_copy_knoxcerts back stdout = '
                + str(stdout))

            UpgradePerNode.reportProgress(
                '#### ranger-admin: starting new version with command %s ###' %
                xa_admin_start_cmd)
            exit_code, stdout = Machine.runas(user,
                                              xa_admin_start_cmd,
                                              host=node,
                                              logoutput=True)
            logger.info('****************** xa admin start exit_code = ' +
                        str(exit_code))
            logger.info('****************** xa admin start stdout = ' +
                        str(stdout))

            if exit_code == 0:
                UpgradePerNode.reportProgress(
                    '#### ranger-admin: new version started successfully ####')
            else:
                UpgradePerNode.reportProgress(
                    '#### ranger-admin: failed to start new version! exit_code=%d ####'
                    % exit_code)
        else:
            logger.info(
                '****************** setup.sh script failed for admin ******* ')
            UpgradePerNode.reportProgress(
                '#### ranger-admin: installation of new version failed! exit_code=%d ###'
                % exit_code)
Exemplo n.º 4
0
    def upgrade_master(cls, latestVersion, config, currVersion):
        from beaver.component.xa import Xa
        from beaver.component.rollingupgrade.ruUpgrade import UpgradePerNode
        UpgradePerNode.reportProgress('#### install argus admin. ####')
        # 'knox.crt'
        # 'cacertswithknox'
        user = Machine.getAdminUser()
        xa_usersync_stop_cmd = 'sudo service ranger-usersync stop'
        xa_usersync_start_cmd = 'sudo service ranger-usersync start'
        ranger_old_version = '/usr/hdp/' + currVersion + '/ranger-usersync/'
        ranger_new_version = '/usr/hdp/' + latestVersion + '/ranger-usersync/'

        exit_code, stdout = Machine.runas(user,
                                          xa_usersync_stop_cmd,
                                          host=Xa.getPolicyAdminHost(),
                                          logoutput=True)
        logger.info('****************** xa usersync stop exit_code = ' +
                    str(exit_code))

        source_properties_file = os.path.join(ranger_old_version,
                                              'install.properties')
        destination_properties_file = os.path.join(ranger_new_version,
                                                   'install.properties')
        command = 'cp -f %s %s' % (source_properties_file,
                                   destination_properties_file)
        exit_code, stdout = Machine.runas(user,
                                          command,
                                          host=Xa.getPolicyAdminHost(),
                                          logoutput=True)
        logger.info(
            '*************************** usersync copy command exit_code = ' +
            str(exit_code))
        logger.info(
            '*************************** usersync copy command stdout = ' +
            str(stdout))

        command = '(cd %s && export JAVA_HOME=%s && ./setup.sh)' % (
            ranger_new_version, Machine.getJavaHome())
        UpgradePerNode.reportProgress(
            '#### ranger-usersync: installing new version with command %s ###'
            % command)
        exit_code, stdout = Machine.runas(user,
                                          command,
                                          host=Xa.getPolicyAdminHost(),
                                          logoutput=True)

        if exit_code == 0:
            UpgradePerNode.reportProgress(
                '#### ranger-usersync: installation successful ###')

            node = Xa.getPolicyAdminHost()
            from beaver.component.rollingupgrade.ruCommon import hdpSelect
            hdpSelect.changeVersion("ranger-usersync", latestVersion, node)
            logger.info(
                '*************************** hdp-select to new version done = '
            )

            UpgradePerNode.reportProgress(
                '#### ranger-usersync: starting new version with command %s ###'
                % xa_usersync_start_cmd)
            exit_code, stdout = Machine.runas(user,
                                              xa_usersync_start_cmd,
                                              host=node,
                                              logoutput=True)
            logger.info('****************** xa usersync start exit_code = ' +
                        str(exit_code))
            logger.info('****************** xa usersync start stdout = ' +
                        str(stdout))

            if exit_code == 0 and 'UnixAuthenticationService has started successfully.' in stdout:
                UpgradePerNode.reportProgress(
                    '#### ranger-usersync: new version started successfully ###'
                )
            else:
                UpgradePerNode.reportProgress(
                    '#### ranger-usersync: new version failed to start! exit_code=%d ###'
                    % exit_code)
        else:
            logger.info(
                '****************** setup.sh script failed for usersync ******* '
            )
            UpgradePerNode.reportProgress(
                '#### ranger-usersync: installation of new version failed! exit_code=%d ###'
                % exit_code)