

def _vpn_dict(self, context, project_id, instance):
    elevated = context.elevated()
    rv = {
        'project_id': project_id,
    }
    if (not instance):
        rv['state'] = 'pending'
        return rv
    rv['instance_id'] = instance.uuid
    rv['created_at'] = utils.isotime(instance.created_at)
    nw_info = compute_utils.get_nw_info_for_instance(instance)
    if (not nw_info):
        return rv
    vif = nw_info[0]
    ips = [ip for ip in vif.fixed_ips() if (ip['version'] == 4)]
    if ips:
        rv['internal_ip'] = ips[0]['address']
    elevated.project_id = project_id
    network = self.network_api.get(elevated, vif['network']['id'])
    if network:
        vpn_ip = network['vpn_public_address']
        vpn_port = network['vpn_public_port']
        rv['public_ip'] = vpn_ip
        rv['public_port'] = vpn_port
        if (vpn_ip and vpn_port):
            if utils.vpn_ping(vpn_ip, vpn_port):
                rv['state'] = 'running'
            else:
                rv['state'] = 'down'
        else:
            rv['state'] = 'invalid'
    return rv

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/cloudpipe.py CloudpipeController._vpn_dict/original