

def _register_proxy_route(self, app_id):
    num_retries = 30
    pause = 1
    for i in range(num_retries):
        ip = self._get_pod_ip(app_id)
        time.sleep(1)
        if ip:
            (base_url, token) = self._read_proxy_info()
            body = {
                'target': (('http://' + ip) + ':8888'),
            }
            h = {
                'Authorization': 'token {}'.format(token),
            }
            proxy_url = ((base_url + '/') + app_id)
            debug_log(self.TAG, 'body: {}, headers: {}, proxy_url: {}'.format(body, h, proxy_url))
            try:
                r = requests.post(proxy_url, data=json.dumps(r), headers=h)
                if (r.status_code == 201):
                    info_log(self.TAG, 'Proxying {} to {}'.format(proxy_url, (ip + ':8888')))
                    return True
                else:
                    raise Exception('could not register route with proxy server')
            except requests.exceptions.ConnectionError:
                error_log(self.TAG, 'could not connect to proxy server')
                pass
        info_log(self.TAG, 'App not yet assigned an IP address. Waiting for {} seconds...'.format(pause))
        time.sleep(pause)
    return False

dataset/ETHPy150Open binder-project/binder/binder/cluster.py KubernetesManager._register_proxy_route/VarMisuse@146/208 `body`->`r`