Instructions noVNC connection from another site.

werd

New Member
Dec 30, 2014
5
0
1
Sorry for my English.
I can not understand how to connect the console noVNC from another site.

Please give what some instructions, or at least specify the steps that connect. I use Proxmox 3.3.x, PHP5.4.
Once used pve2-api-php-client, but do not work on PHP5.4 CURL requests. noVNC newer and better, but how to connect? Instructions on the network can not find.

Thank you for your help.
 
You need to open your firewall on port 5900 tcp.

No. It`s true. But question is different. I looked inside source code from the console noVNC of the Proxmox

<script type="text/javascript">
if (typeof(PVE) === 'undefined') PVE = {};
PVE.UserName = 'xxx@pve';
PVE.CSRFPreventionToken = 'XXXXXXXXXXXXXXXXXXXXXXXXXX';
INCLUDE_URI='/novnc/include/';
</script>

How to get it to work on a remote server? Where to prescribe configuration 'hostname', 'username', 'password', 'realm', 'port', 'node', 'vmid' ?
Answer can help many people.
 
Last edited:
Yes. I want to display the console noVNC from a remote site personal account, to different virtual machines with Proxmox.
 
I have not tried this so I am afraid I cannot help you with this.

Have you tried the Perl API instead? It works here with latest Perl 5. (http://search.cpan.org/~djzort/Net-Proxmox-VE-0.006/lib/Net/Proxmox/VE.pm)

An example below for using Perl API to start a Spice terminal.
Code:
#!/usr/bin/env perl


use strict;
use warnings;
use FindBin qw($Bin);


use lib "$Bin";
use Net::Proxmox::VE;
use Data::Dumper;
use Getopt::Long;
use HTTP::Headers;
use HTTP::Request::Common qw(POST);


my $host     = undef;
my $username = undef;
my $password = undef;
my $all	     = 0;
my $debug    = undef;
my $help     = undef;


GetOptions (
    'h|host=s'	    => \$host,
    'u|username=s'  => \$username,
    'p|password=s'  => \$password,
    'a|all'	    => \$all,
    'debug'	    => \$debug,
    'help|?'	    => \$help,
) or die $!;


sub usage {
    my $exit = shift;
    print <<_HELP;
    Usage spice-cli --host|-h host --username|-u username
                    --password|-p password
		    [--debug] [--help|-?] [--all|-a] [action]
    action: list | term id
	    list	List nodes in cluster
	    id      vmid
	    term    Open spice terminal on 'id'
    --all:  List all VM's. Default is to list running VM's.
_HELP
    exit $exit;
}


usage(0) if $help;


do {
    print "Missing host, password, and username\n";
    usage(1);
} unless $host && $password && $username;


my $pve = Net::Proxmox::VE->new(
    host     => $host,
    username => $username,
    password => $password,
    debug    => $debug,
);


die "login failed\n"         unless $pve->login;
die "invalid login ticket\n" unless $pve->check_login_ticket;
die "unsupport api version\n" unless $pve->api_version_check;


sub get_resources {
    my $resources = $pve->get("/cluster/resources");
    my %items = ();


    foreach my $item (@$resources) {
	    next unless $item->{type} eq 'openvz' or $item->{type} eq 'qemu';


	    my $key = $item->{vmid};
	    $items{$key} = $item;
    }
	
    return \%items;
}


sub cmd_list {
    my $resources = shift;


    printf "%4s %6s %7s %-20s %s\n", 'vmid', 'type', 'status', 'node', 'name';
    print "\n";
    while ((my $id, my $vm) = each %$resources) {
	    next unless $vm->{type} eq 'openvz' or $vm->{type} eq 'qemu';
	    next unless $vm->{status} eq 'running' or $all;
		printf "%4s %6s %7s %-20s %s\n", $vm->{vmid}, $vm->{type}, $vm->{status}, $vm->{node}, $vm->{name};
	    #print Dumper($vm);
    }
}


sub cmd_term {
    my ($resources, $id) = @_;


    my $vm = $resources->{$id};


    my $ua = $pve->{ua};
    my $uri = $pve->url_prefix . '/api2/spiceconfig';
    $uri .= "/nodes/$vm->{node}/$vm->{id}/spiceproxy";
 
    my $request = HTTP::Request->new();
    $request->uri($uri);
    $request->header(
	'cookie' => 'PVEAuthCookie=' . $pve->{ticket}->{ticket});
    $request->header(
	'CSRFPreventionToken' => $pve->{ticket}->{CSRFPreventionToken});
    $request->method('POST');
    $request->content("proxy=$vm->{node}");
    my $response = $ua->request($request);


    if ($debug) {
        print $request->as_string, "\n";
        print $response->as_string, "\n";
    }
    if ( $response->is_success ) {
	    my $content = $response->decoded_content;
	    open (PROXY, '>/tmp/spiceproxy') or die "$!\n";
	    print PROXY $content;
	    close PROXY;


	    my $cmd = ('remote-viewer /tmp/spiceproxy > /dev/null 2>&1');
	    if (exec($cmd)) {
	        if ($? == -1) {
		        print "failed to execute: $!\n";
	        } elsif ($? & 127) {
		        printf "child died with signal %d, %s coredump\n",
		        ($? & 127),  ($? & 128) ? 'with' : 'without';
	        } else {
		        printf "child exited with value %d\n", $? >> 8;
	        }
	    }
    } else {
	    print "WARNING: request failed: " . $request->as_string . "\n";
	    print "WARNING: response status: " . $response->status_line . "\n";
    }
}


my $action = $ARGV[0];
my $id = undef;


usage(1) unless $action;


my $resources = get_resources;


if ($action =~ /list/) {
    cmd_list($resources);
} elsif ($action =~ /term/) {
    ($id = $ARGV[1]) or die 'missing id';
    cmd_term($resources, $id);
} else {
    print "$action: Unknown action\n";
    usage(1);
}
 
Thank you for the script, but it can not help me. PERL can not use. only PHP 5.5+ and Javascript.
Java applet pve2-api-php-client also does not fit, has a bug in php5.4 and php5.5 curl extension does not receive a response to a ticket is at work through methods php, maybe reason embeddedin curl openssl, but via the console:
Code:
curl -k -d "username=root@pam&password=yourpassword"  https://10.0.0.1:8006/api2/json/access/ticket
the answer comes with the ticket. Port 5900 is open. I have tried many approaches with methods curl in php5.4 / php5.5. In php 5.3 its worked.

Is it possible to use https://git.proxmox.com/?p=novnc-pv...701bc988479ec2aa217df291e9a90fb3b85b0;hb=HEAD
for my purpose? Tell me how to initialize the configuration for this script if its possibly. Sorry for my English.
 
Last edited: