コード例 #1
0
    def download_and_install(cls, build=-1, job='', pattern=r''):
        if build == 0:
            # keep current build
            return True

        if not pattern:
            pattern = cls.default_pattern

        if not job:
            job = cls.default_job

        installer = cls.create()
        lynx_controller = LynxCtrl()
        if job == "product":
            pattern = "mozypro-%ssetup" % (PlatformHelper.get_arch())
        else:
            #MozyEnterprise-rpm-64-1_5_0_5252.rpm
            pattern = "MozyEnterprise.*%s.*" % (PlatformHelper.get_arch())
        if not lynx_controller.is_client_installed(
        ):  # is client is not installed, then install
            print pattern
            installer.install(job, build, pattern)
        else:
            version = lynx_controller.get_client_version()
            if version.find("%s" % build) < 0:
                installer.uninstall()
                installer.install(job, build, pattern)
コード例 #2
0
    def install_fb(cls):
        installer = cls.download_fb()
        LogHelper.info("start to install")

        if PlatformHelper.is_Linux() and PlatformHelper.get_arch() == "deb-64":
            install_cmd = "dpkg -i %s" % installer
            cls.__set_fb_path("/etc/filebeat/")

        if PlatformHelper.is_Linux() and PlatformHelper.get_arch() == "deb-32":
            install_cmd = "rpm -vi %s" % installer
            cls.__set_fb_path("/etc/filebeat/")

        if PlatformHelper.is_win():
            import zipfile
            win_fb_dir = "C:\\filebeat"
            target = os.path.join(win_fb_dir, "filebeat-5.2.0-windows-x86_64")
            installcommnd = os.path.join(target,
                                         "install-service-filebeat.ps1")

            zip_ref = zipfile.ZipFile(installer, 'r')
            zip_ref.extractall(win_fb_dir)
            zip_ref.close()
            # FileHelper.rename()

            install_cmd = "powershell.exe %s" % (installcommnd)

            cls.__set_fb_path(target)

            cmd_output = CmdHelper.runas_admin(install_cmd)
            return cmd_output
            # # TODO: Unzip to start" service
            # install_cmd = "to be implemented"
            # win_fb_dir = "C:\\filebeat"
            # if not FileHelper.dir_exist(win_fb_dir):
            #     FileHelper.create_directory(win_fb_dir)
            # cls.__set_fb_path(win_fb_dir)
            # install_cmd = "unzip %s -C %s" % (installer, win_fb_dir)

        if PlatformHelper.is_mac():
            mac_fb_dir = "/filebeat"
            if not FileHelper.dir_exist(mac_fb_dir):
                FileHelper.create_directory(mac_fb_dir)

            cls.__set_fb_path(mac_fb_dir)

            install_cmd = "tar xzvf %s -C %s" % (installer, mac_fb_dir)

        cmd_output = CmdHelper.run(install_cmd)
        LogHelper.info(cmd_output)
コード例 #3
0
    def download_fb(
        cls,
        product=None,
        dry_run=False,
    ):

        current_platform = PlatformHelper.get_system()
        fb_site = "https://artifacts.elastic.co/downloads/beats/filebeat/"
        package_name = ""

        if current_platform == "Linux" and PlatformHelper.get_arch(
        ) == "deb-64":
            package_name = 'filebeat-5.2.0-amd64.deb'

        if current_platform == "Linux" and PlatformHelper.get_arch(
        ) == "deb-32":
            package_name = 'filebeat-5.2.0-i386.deb'

        if current_platform == "Windows":
            package_name = 'filebeat-5.2.0-windows-x86_64.zip'

        if current_platform == "Darwin":
            package_name = 'filebeat-5.2.0-darwin-x86_64.tar.gz'

        installer_dir = ConfigAdapter.get_installer_path(product)

        cls.package_name = package_name
        installer_path = os.path.join(installer_dir, package_name)
        url = fb_site + package_name
        LogHelper.info("installer_path is " + installer_path)
        LogHelper.info("package url is " + url)

        if not FileHelper.dir_exist(installer_dir):
            FileHelper.create_directory(installer_dir)

        if FileHelper.file_exist(installer_path):
            FileHelper.delete_file(installer_path)

        if not dry_run:
            downloaded_package = urllib2.urlopen(url)
            LogHelper.info("download result is %s" % downloaded_package)
            with open(installer_path, 'wb') as output:
                output.write(downloaded_package.read())

        return installer_path