On 02/20/2014 04:06 PM, Koen Vanoppen wrote: > Thanx, for the answer. But he successfully created a ticket and received > a number, but when he then starts the client again, as asked ( "Connect > to the client again (again, r-v will ask for the password in a pop-up > window):" ) He has to give a password. Maybe important. The username > field is empty and can't be modified. > > > Kind regards, > > Koen >
Find attached a complete example of how to do this with the python SDK. This generates a remote-viewer configuration file like the GUI does. Note that you will need the latest version of the SKD, 3.4.0.4, as otherwise the all_content parameter required to get the subject of the certificate of the host isn't available. > > 2014-02-20 16:03 GMT+01:00 Yedidyah Bar David <d...@redhat.com > <mailto:d...@redhat.com>>: > > *From: *"Koen Vanoppen" <vanoppen.k...@gmail.com > <mailto:vanoppen.k...@gmail.com>> > *To: *users@ovirt.org <mailto:users@ovirt.org> > *Sent: *Thursday, February 20, 2014 4:56:10 PM > *Subject: *[Users] (no subject) > > Hey Guys, > > I'm back ;-). This time I have a question from one of our > programmers. > He's trying this: > > http://www.ovirt.org/How_to_Connect_to_SPICE_Console_Without_Portal#Connecting_Using_REST_API > > But he bumps into this: > > Connect to the client again (again, r-v will ask for the > password in a pop-up window): > > bash$ *remote-viewer --spice-ca-file ${CA_FILE} --spice-host-subject > "${SUBJECT}" spice://${HOST}/?port=${PORT}\&tls-port=${SPORT}* > > Now, the question is.... What's the password? Or where can I find it? > > > I think you need to set it with setVmTicket - see that page for an > example. > -- > Didi > > > > > _______________________________________________ > Users mailing list > Users@ovirt.org > http://lists.ovirt.org/mailman/listinfo/users > -- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.
#!/usr/bin/python import os import ovirtsdk.api import ovirtsdk.xml import subprocess import tempfile import urllib # The parameters to connect to the engine: engine_host = "rhel.example.com" engine_port = 443 engine_user = "admin@internal" engine_password = "redhat123" # The name of the vm: vm_name = "myvm" # A template to generate the viewer configuration file: config_template = """\ [virt-viewer] type={type} host={host} port={port} password={password} tls-port={tls_port} fullscreen=0 title={title} enable-smartcard=0 enable-usb-autoshare=1 delete-this-file=1 usb-filter=-1,-1,-1,-1,0 tls-ciphers=DEFAULT host-subject={tls_subject} ca={ca} toggle-fullscreen=shift+f11 release-cursor=shift+f12 secure-channels=main;inputs;cursor;playback;record;display;usbredir;smartcard """ # Connect to the API: api_url = "https://{host}:{port}/api".format( host=engine_host, port=engine_port ) api = ovirtsdk.api.API( url=api_url, username=engine_user, password=engine_password, insecure=True, debug=True ) # Download the CA certificate, as we need to pass this to the viewer so that it # will trust the SSL certificate of the host: ca_url = "https://{host}:{port}/ca.crt".format( host=engine_host, port=engine_port ) ca_path, _ = urllib.urlretrieve(ca_url) with open(ca_path, "r") as ca_file: ca_content = ca_file.read() ca_content = ca_content.replace("\n", "\\n") # Find the VM and get the display details: vm = api.vms.get(name=vm_name, all_content=True) display = vm.get_display() # Request a ticket for the display of the VM: ticket_result = vm.ticket() ticket = ticket_result.get_ticket() # Create the viewer configuration: config_content = config_template.format( type=display.get_type(), host=display.get_address(), port=display.get_port(), password=ticket.get_value(), tls_port=display.get_secure_port(), title=vm_name, tls_subject=display.get_certificate().get_subject(), ca=ca_content ) config_fd, config_path = tempfile.mkstemp() with os.fdopen(config_fd, "w") as config_file: config_file.write(config_content) # Run the viewer: subprocess.call(["remote-viewer", config_path])
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users