Пример #1
0
    def _set_up_proxy_server(cluster: Cluster, cluster_config, proxy_server):
        proxy_name = "squid-" + cluster_config.cluster_name.suffix
        port = infra_utils.scan_for_free_port(consts.DEFAULT_PROXY_SERVER_PORT)

        host_ip = str(IPNetwork(cluster.nodes.controller.get_machine_cidr()).ip + 1)
        no_proxy = ",".join([cluster.nodes.controller.get_machine_cidr(), cluster_config.service_network_cidr,
                             cluster_config.cluster_network_cidr,
                             f".{str(cluster_config.cluster_name)}.redhat.com"])

        # todo cluster.config will be property as part of MGMT-7060 - need to replace cluster._config.is_ipv6 with
        #  cluster.config.is_ipv6
        proxy = proxy_server(name=proxy_name, port=port, dir=proxy_name, host_ip=host_ip,
                             is_ipv6=cluster._config.is_ipv6)
        cluster.set_proxy_values(http_proxy=proxy.address, https_proxy=proxy.address, no_proxy=no_proxy)
        install_config = cluster.get_install_config()
        proxy_details = install_config.get("proxy")
        assert proxy_details and proxy_details.get("httpProxy") == proxy.address
        assert proxy_details.get("httpsProxy") == proxy.address
Пример #2
0
    def _set_up_proxy_server(cluster: Cluster, cluster_config: ClusterConfig,
                             proxy_server):
        proxy_name = "squid-" + cluster_config.cluster_name.suffix
        port = infra_utils.scan_for_free_port(consts.DEFAULT_PROXY_SERVER_PORT)

        machine_cidr = cluster.get_primary_machine_cidr()
        host_ip = str(IPNetwork(machine_cidr).ip + 1)

        no_proxy = []
        no_proxy += [
            str(cluster_network.cidr)
            for cluster_network in cluster_config.cluster_networks
        ]
        no_proxy += [
            str(service_network.cidr)
            for service_network in cluster_config.service_networks
        ]
        no_proxy += [machine_cidr]
        no_proxy += [f".{str(cluster_config.cluster_name)}.redhat.com"]
        no_proxy = ",".join(no_proxy)

        proxy = proxy_server(name=proxy_name,
                             port=port,
                             dir=proxy_name,
                             host_ip=host_ip,
                             is_ipv6=cluster.nodes.is_ipv6)
        cluster_proxy_values = models.Proxy(http_proxy=proxy.address,
                                            https_proxy=proxy.address,
                                            no_proxy=no_proxy)
        cluster.set_proxy_values(proxy_values=cluster_proxy_values)
        install_config = cluster.get_install_config()
        proxy_details = install_config.get("proxy") or install_config.get(
            "Proxy")
        assert proxy_details, str(install_config)
        assert (
            proxy_details.get("httpsProxy") == proxy.address
        ), f"{proxy_details.get('httpsProxy')} should equal {proxy.address}"