示例#1
0
    def build_url(self, params):
        _errors = []
        version = ''
        server = ''
        names = []

        # replace "v" with version
        # replace p with product
        tmp = {}
        for k in params:
            value = params[k]
            if k == "v":
                tmp["version"] = value
            elif k == "p":
                tmp["version"] = value
            else:
                tmp[k] = value
        params = tmp

        ok = True
        if not "version" in params:
            _errors.append(errors["INVALID-PARAMS"])
            ok = False
        else:
            version = params["version"]

        if ok:
            if not "product" in params:
                _errors.append(errors["INVALID-PARAMS"])
                ok = False
        if ok:
            if not "server" in params:
                _errors.append(errors["INVALID-PARAMS"])
                ok = False
            else:
                server = params["server"]

        if ok:
            if "toy" in params:
                toy = params["toy"]
            else:
                toy = ""


        if ok:
            mb_alias = ["membase", "membase-server", "mbs", "mb"]
            cb_alias = ["couchbase", "couchbase-server", "cb"]
            css_alias = ["couchbase-single", "couchbase-single-server", "css"]

            if params["product"] in mb_alias:
                names = ['membase-server-enterprise', 'membase-server-community']
            elif params["product"] in cb_alias:
                if "type" in params and params["type"].lower() in "couchbase-server-community":
                    names = ['couchbase-server-community']
                elif "type" in params and params["type"].lower() in "couchbase-server-enterprise":
                    names = ['couchbase-server-enterprise']
                else:
                    names = ['couchbase-server-enterprise', 'couchbase-server-community']
            elif params["product"] in css_alias:
                names = ['couchbase-single-server-enterprise', 'couchbase-single-server-community']
            else:
                ok = False
                _errors.append(errors["INVALID-PARAMS"])
        remote_client = RemoteMachineShellConnection(server)
        info = remote_client.extract_remote_info()
        remote_client.disconnect()
        if ok:
            builds, changes = BuildQuery().get_all_builds()
            releases_version = ["1.6.5.4", "1.7.0", "1.7.1", "1.7.1.1"]
            for name in names:
                if version in releases_version:
                     build = BuildQuery().find_membase_release_build(deliverable_type=info.deliverable_type,
                                                                     os_architecture=info.architecture_type,
                                                                     build_version=version,
                                                                     product='membase-server-enterprise')
                else:
                    build = BuildQuery().find_build(builds, name, info.deliverable_type,
                                                    info.architecture_type, version, toy=toy)

                if build:
                    if 'amazon' in params:
                        type = info.type.lower()
                        if type == 'windows' and version in releases_version:
                            build.url = build.url.replace("http://builds.hq.northscale.net",
                                                          "https://s3.amazonaws.com/packages.couchbase")
                            build.url = build.url.replace("enterprise", "community")
                            build.name = build.name.replace("enterprise", "community")
                        else:
                            build.url = build.url.replace("http://builds.hq.northscale.net",
                                                          "http://packages.northscale.com")
                            build.url = build.url.replace("enterprise", "community")
                            build.name = build.name.replace("enterprise", "community")
                    return build

            _errors.append(errors["BUILD-NOT-FOUND"])
        msg = "unable to find a build for product {0} version {1} for package_type {2}"
        raise Exception(msg.format(names, version, info.deliverable_type))
示例#2
0
    def build_url(self, params):
        _errors = []
        version = ""
        server = ""
        openssl = ""
        names = []
        url = ""
        direct_build_url = None

        # replace "v" with version
        # replace p with product
        tmp = {}
        for k in params:
            value = params[k]
            if k == "v":
                tmp["version"] = value
            elif k == "p":
                tmp["version"] = value
            else:
                tmp[k] = value
        params = tmp

        ok = True
        if not "version" in params and len(params["version"]) < 5:
            _errors.append(errors["INVALID-PARAMS"])
            ok = False
        else:
            version = params["version"]

        if ok:
            if not "product" in params:
                _errors.append(errors["INVALID-PARAMS"])
                ok = False
        if ok:
            if not "server" in params:
                _errors.append(errors["INVALID-PARAMS"])
                ok = False
            else:
                server = params["server"]

        if ok:
            if "toy" in params:
                toy = params["toy"]
            else:
                toy = ""

        if ok:
            if "openssl" in params:
                openssl = params["openssl"]

        if ok:
            if "url" in params and params["url"] != "":
                direct_build_url = params["url"]
        if ok:
            mb_alias = ["membase", "membase-server", "mbs", "mb"]
            cb_alias = ["couchbase", "couchbase-server", "cb"]
            css_alias = ["couchbase-single", "couchbase-single-server", "css"]
            moxi_alias = ["moxi", "moxi-server"]

            if params["product"] in mb_alias:
                names = ["membase-server-enterprise", "membase-server-community"]
            elif params["product"] in cb_alias:
                if "type" in params and params["type"].lower() in "couchbase-server-community":
                    names = ["couchbase-server-community"]
                elif "type" in params and params["type"].lower() in "couchbase-server-enterprise":
                    names = ["couchbase-server-enterprise"]
                else:
                    names = ["couchbase-server-enterprise", "couchbase-server-community"]
            elif params["product"] in css_alias:
                names = ["couchbase-single-server-enterprise", "couchbase-single-server-community"]
            elif params["product"] in moxi_alias:
                names = ["moxi-server"]
            else:
                ok = False
                _errors.append(errors["INVALID-PARAMS"])
            if "1" in openssl:
                names = [
                    "couchbase-server-enterprise_centos6",
                    "couchbase-server-community_centos6",
                    "couchbase-server-enterprise_ubuntu_1204",
                    "couchbase-server-community_ubuntu_1204",
                ]
            if "toy" in params:
                names = ["couchbase-server-enterprise"]

        remote_client = RemoteMachineShellConnection(server)
        info = remote_client.extract_remote_info()
        remote_client.disconnect()
        if ok:
            timeout = 300
            if "timeout" in params:
                timeout = int(params["timeout"])
            releases_version = ["1.6.5.4", "1.7.0", "1.7.1", "1.7.1.1", "1.8.0"]
            cb_releases_version = [
                "1.8.1",
                "2.0.0",
                "2.0.1",
                "2.1.0",
                "2.1.1",
                "2.2.0",
                "2.5.0",
                "2.5.1",
                "2.5.2",
                "3.0.0",
                "3.0.1",
                "3.0.2",
                "3.0.3",
                "3.1.0",
            ]
            build_repo = MV_LATESTBUILD_REPO
            if toy is not "":
                build_repo = CB_REPO
            elif version[:5] not in COUCHBASE_VERSION_2 and version[:5] not in COUCHBASE_VERSION_3:
                if version[:3] in CB_VERSION_NAME:
                    build_repo = CB_REPO + CB_VERSION_NAME[version[:3]] + "/"
                else:
                    sys.exit("version is not support yet")
            for name in names:
                if version[:5] in releases_version:
                    build = BuildQuery().find_membase_release_build(
                        deliverable_type=info.deliverable_type,
                        os_architecture=info.architecture_type,
                        build_version=version,
                        product="membase-server-enterprise",
                    )
                elif version[:5] in cb_releases_version:
                    build = BuildQuery().find_membase_release_build(
                        deliverable_type=info.deliverable_type,
                        os_architecture=info.architecture_type,
                        build_version=version,
                        product=name,
                        os_version=info.distribution_version,
                    )
                else:
                    builds, changes = BuildQuery().get_all_builds(
                        version=version,
                        timeout=timeout,
                        direct_build_url=direct_build_url,
                        deliverable_type=info.deliverable_type,
                        architecture_type=info.architecture_type,
                        edition_type=name,
                        repo=build_repo,
                        toy=toy,
                        distribution_version=info.distribution_version.lower(),
                        distribution_type=info.distribution_type.lower(),
                    )
                    build = BuildQuery().find_build(
                        builds,
                        name,
                        info.deliverable_type,
                        info.architecture_type,
                        version,
                        toy=toy,
                        openssl=openssl,
                        direct_build_url=direct_build_url,
                        distribution_version=info.distribution_version.lower(),
                        distribution_type=info.distribution_type.lower(),
                    )

                if build:
                    if "amazon" in params:
                        type = info.type.lower()
                        if type == "windows" and version in releases_version:
                            build.url = build.url.replace(
                                "http://builds.hq.northscale.net", "https://s3.amazonaws.com/packages.couchbase"
                            )
                            build.url = build.url.replace("enterprise", "community")
                            build.name = build.name.replace("enterprise", "community")
                        else:
                            """ since url in S3 insert version into it, we need to put version
                                in like ..latestbuilds/3.0.0/... """
                            cb_version = version[:5]
                            build.url = build.url.replace(
                                "http://builds.hq.northscale.net/latestbuilds",
                                "http://packages.northscale.com/latestbuilds/{0}".format(cb_version),
                            )
                            """ test enterprise version """
                            # build.url = build.url.replace("enterprise", "community")
                            # build.name = build.name.replace("enterprise", "community")
                    """ check if URL is live """
                    remote_client = RemoteMachineShellConnection(server)
                    if remote_client.is_url_live(build.url):
                        return build
                    else:
                        sys.exit("ERROR: URL is not good. Check URL again")
            _errors.append(errors["BUILD-NOT-FOUND"])
        msg = "unable to find a build for product {0} version {1} for package_type {2}"
        raise Exception(msg.format(names, version, info.deliverable_type))
示例#3
0
    def build_url(self, params):
        _errors = []
        version = ''
        server = ''
        openssl = ''
        names = []
        url = ''
        direct_build_url = None

        # replace "v" with version
        # replace p with product
        tmp = {}
        for k in params:
            value = params[k]
            if k == "v":
                tmp["version"] = value
            elif k == "p":
                tmp["version"] = value
            else:
                tmp[k] = value
        params = tmp

        ok = True
        if not "version" in params and len(params["version"]) < 5:
            _errors.append(errors["INVALID-PARAMS"])
            ok = False
        else:
            version = params["version"]

        if ok:
            if not "product" in params:
                _errors.append(errors["INVALID-PARAMS"])
                ok = False
        if ok:
            if not "server" in params:
                _errors.append(errors["INVALID-PARAMS"])
                ok = False
            else:
                server = params["server"]

        if ok:
            if "toy" in params:
                toy = params["toy"]
            else:
                toy = ""

        if ok:
            if "openssl" in params:
                openssl = params["openssl"]

        if ok:
            if "url" in params and params["url"] != "":
                direct_build_url = params["url"]
        if ok:
            mb_alias = ["membase", "membase-server", "mbs", "mb"]
            cb_alias = ["couchbase", "couchbase-server", "cb"]
            css_alias = ["couchbase-single", "couchbase-single-server", "css"]
            moxi_alias = ["moxi", "moxi-server"]

            if params["product"] in mb_alias:
                names = ['membase-server-enterprise', 'membase-server-community']
            elif params["product"] in cb_alias:
                if "type" in params and params["type"].lower() in "couchbase-server-community":
                    names = ['couchbase-server-community']
                elif "type" in params and params["type"].lower() in "couchbase-server-enterprise":
                    names = ['couchbase-server-enterprise']
                else:
                    names = ['couchbase-server-enterprise', 'couchbase-server-community']
            elif params["product"] in css_alias:
                names = ['couchbase-single-server-enterprise', 'couchbase-single-server-community']
            elif params["product"] in moxi_alias:
                names = ['moxi-server']
            else:
                ok = False
                _errors.append(errors["INVALID-PARAMS"])
            if "1" in openssl:
                names = ['couchbase-server-enterprise_centos6', 'couchbase-server-community_centos6', \
                         'couchbase-server-enterprise_ubuntu_1204', 'couchbase-server-community_ubuntu_1204']
            if "toy" in params:
                if "1" in openssl:
                    names = ['couchbase-server-community_cent64']
                else:
                    names = ['couchbase-server-community_cent58']

        remote_client = RemoteMachineShellConnection(server)
        info = remote_client.extract_remote_info()
        remote_client.disconnect()
        if ok:
            timeout = 300
            if "timeout" in params:
                timeout = int(params["timeout"])
            releases_version = ["1.6.5.4", "1.7.0", "1.7.1", "1.7.1.1", "1.8.0"]
            cb_releases_version = ["1.8.1", "2.0.0", "2.0.1", "2.1.0", "2.1.1", "2.2.0", "2.5.0", "2.5.1"]
            for name in names:
                if version in releases_version:
                    build = BuildQuery().find_membase_release_build(deliverable_type=info.deliverable_type,
                                                                     os_architecture=info.architecture_type,
                                                                     build_version=version,
                                                                     product='membase-server-enterprise')
                elif version in cb_releases_version:
                    build = BuildQuery().find_membase_release_build(deliverable_type=info.deliverable_type,
                                                                     os_architecture=info.architecture_type,
                                                                     build_version=version,
                                                                     product=name)
                else:
                    builds, changes = BuildQuery().get_all_builds(version=version, timeout=timeout, \
                                      direct_build_url=direct_build_url, \
                                      deliverable_type=info.deliverable_type, \
                                      architecture_type=info.architecture_type, \
                                      edition_type=name, \
                                      repo=MV_LATESTBUILD_REPO, toy=toy, \
                                      distribution_version=info.distribution_version.lower())
                    build = BuildQuery().find_build(builds, name, info.deliverable_type, \
                                                    info.architecture_type, version, toy=toy, \
                                                    openssl=openssl, direct_build_url=direct_build_url, \
                                                    distribution_version=info.distribution_version.lower())

                if build:
                    if 'amazon' in params:
                        type = info.type.lower()
                        if type == 'windows' and version in releases_version:
                            build.url = build.url.replace("http://builds.hq.northscale.net",
                                                          "https://s3.amazonaws.com/packages.couchbase")
                            build.url = build.url.replace("enterprise", "community")
                            build.name = build.name.replace("enterprise", "community")
                        else:
                            """ since url in S3 insert version into it, we need to put version
                                in like ..latestbuilds/3.0.0/... """
                            cb_version = version[:5]
                            build.url = build.url.replace("http://builds.hq.northscale.net/latestbuilds",
                                        "http://packages.northscale.com/latestbuilds/{0}".format(cb_version))
                            """ test enterprise version """
                            #build.url = build.url.replace("enterprise", "community")
                            #build.name = build.name.replace("enterprise", "community")
                    return build
            _errors.append(errors["BUILD-NOT-FOUND"])
        msg = "unable to find a build for product {0} version {1} for package_type {2}"
        raise Exception(msg.format(names, version, info.deliverable_type))
示例#4
0
    def build_url(self, params):
        _errors = []
        version = ''
        server = ''
        openssl = ''
        names = []
        url = ''
        direct_build_url = None

        # replace "v" with version
        # replace p with product
        tmp = {}
        for k in params:
            value = params[k]
            if k == "v":
                tmp["version"] = value
            elif k == "p":
                tmp["version"] = value
            else:
                tmp[k] = value
        params = tmp

        ok = True
        if not "version" in params and len(params["version"]) < 5:
            _errors.append(errors["INVALID-PARAMS"])
            ok = False
        else:
            version = params["version"]

        if ok:
            if not "product" in params:
                _errors.append(errors["INVALID-PARAMS"])
                ok = False
        if ok:
            if not "server" in params:
                _errors.append(errors["INVALID-PARAMS"])
                ok = False
            else:
                server = params["server"]

        if ok:
            if "toy" in params:
                toy = params["toy"]
            else:
                toy = ""

        if ok:
            if "openssl" in params:
                openssl = params["openssl"]

        if ok:
            if "url" in params and params["url"] != "":
                direct_build_url = params["url"]
        if ok:
            mb_alias = ["membase", "membase-server", "mbs", "mb"]
            cb_alias = ["couchbase", "couchbase-server", "cb"]
            css_alias = ["couchbase-single", "couchbase-single-server", "css"]
            moxi_alias = ["moxi", "moxi-server"]

            if params["product"] in mb_alias:
                names = ['membase-server-enterprise', 'membase-server-community']
            elif params["product"] in cb_alias:
                if "type" in params and params["type"].lower() in "couchbase-server-community":
                    names = ['couchbase-server-community']
                elif "type" in params and params["type"].lower() in "couchbase-server-enterprise":
                    names = ['couchbase-server-enterprise']
                else:
                    names = ['couchbase-server-enterprise', 'couchbase-server-community']
            elif params["product"] in css_alias:
                names = ['couchbase-single-server-enterprise', 'couchbase-single-server-community']
            elif params["product"] in moxi_alias:
                names = ['moxi-server']
            else:
                ok = False
                _errors.append(errors["INVALID-PARAMS"])
            if "1" in openssl:
                names = ['couchbase-server-enterprise_centos6', 'couchbase-server-community_centos6', \
                         'couchbase-server-enterprise_ubuntu_1204', 'couchbase-server-community_ubuntu_1204']
            if "toy" in params:
                if "1" in openssl:
                    names = ['couchbase-server-community_cent64']
                else:
                    names = ['couchbase-server-community_cent58']

        remote_client = RemoteMachineShellConnection(server)
        info = remote_client.extract_remote_info()
        remote_client.disconnect()
        if ok:
            timeout = 300
            if "timeout" in params:
                timeout = int(params["timeout"])
            releases_version = ["1.6.5.4", "1.7.0", "1.7.1", "1.7.1.1", "1.8.0"]
            cb_releases_version = ["1.8.1", "2.0.0", "2.0.1", "2.1.0", "2.1.1", "2.2.0", "2.5.0", "2.5.1"]
            build_repo = MV_LATESTBUILD_REPO
            if version[:3] == "3.5":
                build_repo = SHERLOCK_BUILD_REPO
            for name in names:
                if version in releases_version:
                    build = BuildQuery().find_membase_release_build(deliverable_type=info.deliverable_type,
                                                                     os_architecture=info.architecture_type,
                                                                     build_version=version,
                                                                     product='membase-server-enterprise')
                elif version in cb_releases_version:
                    build = BuildQuery().find_membase_release_build(deliverable_type=info.deliverable_type,
                                                                     os_architecture=info.architecture_type,
                                                                     build_version=version,
                                                                     product=name)
                else:
                    builds, changes = BuildQuery().get_all_builds(version=version, timeout=timeout, \
                                      direct_build_url=direct_build_url, \
                                      deliverable_type=info.deliverable_type, \
                                      architecture_type=info.architecture_type, \
                                      edition_type=name, \
                                      repo=build_repo, toy=toy, \
                                      distribution_version=info.distribution_version.lower(), \
                                      distribution_type=info.distribution_type.lower())
                    build = BuildQuery().find_build(builds, name, info.deliverable_type, \
                                                    info.architecture_type, version, toy=toy, \
                                                    openssl=openssl, direct_build_url=direct_build_url, \
                                                    distribution_version=info.distribution_version.lower(), \
                                                    distribution_type=info.distribution_type.lower())

                if build:
                    if 'amazon' in params:
                        type = info.type.lower()
                        if type == 'windows' and version in releases_version:
                            build.url = build.url.replace("http://builds.hq.northscale.net",
                                                          "https://s3.amazonaws.com/packages.couchbase")
                            build.url = build.url.replace("enterprise", "community")
                            build.name = build.name.replace("enterprise", "community")
                        else:
                            """ since url in S3 insert version into it, we need to put version
                                in like ..latestbuilds/3.0.0/... """
                            cb_version = version[:5]
                            build.url = build.url.replace("http://builds.hq.northscale.net/latestbuilds",
                                        "http://packages.northscale.com/latestbuilds/{0}".format(cb_version))
                            """ test enterprise version """
                            #build.url = build.url.replace("enterprise", "community")
                            #build.name = build.name.replace("enterprise", "community")
                    """ check if URL is live """
                    remote_client = RemoteMachineShellConnection(server)
                    if remote_client.is_url_live(build.url):
                        return build
                    else:
                        sys.exit("ERROR: URL is not good. Check URL again")
            _errors.append(errors["BUILD-NOT-FOUND"])
        msg = "unable to find a build for product {0} version {1} for package_type {2}"
        raise Exception(msg.format(names, version, info.deliverable_type))