

def _get_pod_ip(self, app_id):
    try:
        cmd = ['kubectl.sh', 'describe', 'pod', 'notebook-server', '--namespace={}'.format(app_id)]
        output = subprocess.check_output(cmd)
        ip_re = re.compile('IP:(?P<ip>.*)\n')
        ready_re = re.compile('State:\\s+(?P<ready>.*)')
        m = ip_re.search(output)
        if (not m):
            info_log(self.TAG, 'Could not extract IP from pod description')
            return None
        return m.group('ip').strip()
        ready = ready_re.search(output)
        if (not ready):
            warning_log(self.TAG, 'Extracted the pod IP, but the notebook container is not ready')
            return None
        else:
            status = ready.group('ready').lower().strip()
            debug_log(self.TAG, 'status: {}'.format(status))
            if (status != 'running'):
                info_log(self.TAG, 'Extracted the pod IP, but the notebook container is not ready')
                return None
    except subprocess.CalledProcessError as e:
        return None

dataset/ETHPy150Open binder-project/binder/binder/cluster.py KubernetesManager._get_pod_ip/original