Dynamic Session Creation

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic Session Creation

Felix Wolfheimer-2
Hi all,
 
I'm currently trying to figure out if and how a dynamic session creation mechanism can be implemented in a Guacamole extension. Let's say I have a bunch of machines which can host graphical desktop sessions and I have a script based mechanism to initiate the request to create such a graphical session on one of the machines and add the information about the session into the guacamole_db (SQL). If a user, who doesn't own a graphical session yet, logs in to Guacamole, I'd like to trigger/call the script in the backend which creates the session and adds the information to the guacamole_db. 
 
I've looked through the extension mechanisms in Guacamole and it seems that event listeners could be used to trigger the mechanism in the backend on user login. Has someone knowing the architecture of Guacamole an idea whether 
 
- the user will be connected to the just created session, if the session creation is done in a listener on an "AuthenticationSuccessEvent" happens,
- there's any way of informing the user about what's going on in the backend from within such a listener function (e.g., display a banner "Session creation pending. Please be patient." or something similar, until the session is ready for connection).
 
Thanks for any answer or tip.
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Session Creation

vnick
On Sat, May 19, 2018 at 1:13 PM, Felix Wolfheimer <[hidden email]> wrote:
Hi all,
 
I'm currently trying to figure out if and how a dynamic session creation mechanism can be implemented in a Guacamole extension. Let's say I have a bunch of machines which can host graphical desktop sessions and I have a script based mechanism to initiate the request to create such a graphical session on one of the machines and add the information about the session into the guacamole_db (SQL). If a user, who doesn't own a graphical session yet, logs in to Guacamole, I'd like to trigger/call the script in the backend which creates the session and adds the information to the guacamole_db. 

Can you explain a little more what kind of graphical session you're talking about, here, and why the creation of the session needs to be scripted?  I'm presuming you're talking some sort of VNC session, since RDP doesn't usually require any setup, but maybe you can clarify this a bit?  Even for VNC you can set it up with xinetd such that sessions get created when users connect, so some additional information here on what exactly you're trying to do would be helpful.
 
 
I've looked through the extension mechanisms in Guacamole and it seems that event listeners could be used to trigger the mechanism in the backend on user login. Has someone knowing the architecture of Guacamole an idea whether 
 
- the user will be connected to the just created session, if the session creation is done in a listener on an "AuthenticationSuccessEvent" happens,
- there's any way of informing the user about what's going on in the backend from within such a listener function (e.g., display a banner "Session creation pending. Please be patient." or something similar, until the session is ready for connection).
  

You should be able to implement an extension which implements the AuthenticationSuccessEvent and performs whatever action you'd like to do upon authentication.  Your extension should also be able to make the connection happen automatically - in addition to writing the event listener implementation, you'll likely need to write some AngularJS code and perhaps even a REST endpoint in order to pass information about the newly-created session between the Java back-end and the web browser front-end and make the connection happen, but this should be doable.  It's definitely a little bit involved, but it all sounds doable.

Sounds like you're already reading the manual, which should be a good place to find that information, so I'd just continue to look through that and the existing code to figure out how to do what you're trying to do.  You can also e-mail back here with any specific questions you might have and the community will jump in and help as we can :-).

-Nick
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Session Creation

Felix Wolfheimer-2
Hi Nick,

thanks for your answer. Yes, I was talking about VNC sessions on Linux.
 The scenario I have in mind is a cloud deployment with auto-scaling
functionality: 

There's one instance where guacamole is installed. This instance is
small, cheap, and runs 24/7. The applications used in the VNC sessions
require decent 3D rendering performance and, thus, I want to host them
on GPU instances. These instances are expensive and so I would like to
only spin them up when there's demand for a session. I have a mechanism
that can submit a script (which creates a VNC session) to a scheduling
system (e.g. SLURM). This scheduling system is connected with an
autoscaling mechanism, e.g., cfncluster, which starts session host
instances if there's demand. The session starts on the new instance,
and the session information is added to the guacamole_db. 
This is why I was thinking the it would be great to have a mechanism to
trigger the submission of the session creation script to the scheduling
system when a user logs in. As the start of an instance needs a moment,
I would like to have some way to inform the user about what's going on
in the background. 

As you confirmed that something like this may work, I'll look a bit
more into the Guacamole extension mechanism.

Best regards

Felix  


signature.asc (501 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Session Creation

vnick
On Sun, May 20, 2018 at 4:58 PM, Felix Wolfheimer <[hidden email]> wrote:
Hi Nick,

thanks for your answer. Yes, I was talking about VNC sessions on Linux.
 The scenario I have in mind is a cloud deployment with auto-scaling
functionality: 

There's one instance where guacamole is installed. This instance is
small, cheap, and runs 24/7. The applications used in the VNC sessions
require decent 3D rendering performance and, thus, I want to host them
on GPU instances. These instances are expensive and so I would like to
only spin them up when there's demand for a session. I have a mechanism
that can submit a script (which creates a VNC session) to a scheduling
system (e.g. SLURM). This scheduling system is connected with an
autoscaling mechanism, e.g., cfncluster, which starts session host
instances if there's demand. The session starts on the new instance,
and the session information is added to the guacamole_db. 
This is why I was thinking the it would be great to have a mechanism to
trigger the submission of the session creation script to the scheduling
system when a user logs in. As the start of an instance needs a moment,
I would like to have some way to inform the user about what's going on
in the background. 


That makes sense.  You should be able to do something like this in a Guacamole extension - monitor the number of users connected to a particular connection or connection group, and then trigger something every time there's a connect or disconnect.  I would imagine the most useful thing would be event listeners:


If you trigger an action every time a connection is established or terminated, you can scale it in such a way that you always have 1 or more spare instances running (depending on how frequently and quickly you expect users to connect), and that would do the trick.  If you wanted to go even leaner than that, you could trigger it at user logon/logoff such that an instance was started when a user logged on to Guacamole, and, if there was sufficient time between logon and the user attempting to connect, this might work, as well, without having to keep as many (any?) spare instances.

The other option is to use an external load balancer to accomplish this and then just point Guacamole at the load balancer.  I'm all for implementing cool extensions for Guacamole, but this may have some benefits, particularly in cloud-type environments where you're given these tools.  I'm thinking of AWS where you can do EC2 + Elastic Load Balancer (ELB) and ELB will actually manage the number of spare EC2 instances for you.  The plus side to this is that, at least in the case of AWS, it's already implemented.  You can also do some similar stuff with a load balancer like HAProxy, where you can look at the current user count vs. maximum count and start up or shut down instances with a script of some sort based on that.  I've done this in the past and it worked reasonably well.

Anyway, plenty of possibilities for you - post back and let us know what you do and how it works!

-Nick