You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by Kai <l1...@gmail.com> on 2023/11/17 21:18:14 UTC

Adding scripts to startup/shutdown virtual machines

Hello,

I came across Guacamole some days ago and I'm quite impressed about how 
quick I got an example running.
Originally, I was planning on doing some connections to virtual machines 
behind a gateway by using a remote desktop client with some scripts, but 
the web solution can be more convenient.

As virtualization I use Proxmox and I have some dedicated VMs only 
running some old software without internet.
They also shouldn't be running all the time for power and performance 
reasons.
  I'm connecting to them by RDP and also tried this in Guacamole.

I currently use some easy scripts to startup and suspend the machines 
before and after a RDP session.
What could be the best way for me to integrate running some additional 
script? I looked at the wake-on-lan as example.
I saw that the client web application only collects these information 
and the server application does the waiting and sending within C code.

As I can easily control the Proxmox VMs by using the Proxmox Rest API, I 
only plan to integrate some http requests before showing the RDP and 
after closing it. My idea was to integrate these requests somewhere in 
the client web application, but I didn't see a good way, yet.
Are there suggestions what position would be best?

Thanks!
Kai

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Adding scripts to startup/shutdown virtual machines

Posted by Kai <l1...@gmail.com>.
Yes, in fact, the super.connect() comes below.
I tried not to flood with sources, but it makes sense for the connect 
function.

I thought I made a mistake not using "new 
GuacamoleConfiguration(config)", so I adjusted it.
Then I got into some other things I'm not sure of..

This is the current class, I made some prints and put the content behind:
public class ProxmoxConnection extends DelegatingConnection {
...
@Override
     public GuacamoleTunnel connect(GuacamoleClientInformation info, 
Map<String,String> tokens) throws GuacamoleException {
         System.out.println(getConfiguration().getParameters()); // -> 
{hostname=192.122.122.122, security=nla, ignore-cert=true, port=3389, 
username=user}
         System.out.println(getConfiguration().getParameterNames()); // 
-> []

         GuacamoleConfiguration currentConfig = new 
GuacamoleConfiguration(getConfiguration());

         System.out.println(currentConfig.getParameters()); // -> {}

         currentConfig.setParameter("hostname", "10.20.1.122");
         setConfiguration(currentConfig);
         System.out.println(getConfiguration().getParameters()); // -> 
{hostname=10.20.1.122}

         GuacamoleTunnel tunnel = super.connect(info, tokens);
         return tunnel;
     }
}

If I understood the GuacamoleConfiguration() constructor correctly, it 
should copy all the content from the old config by using 
getParameterNames(), but I don't get any content while getParameters() 
shows me the content of the parameters.
If I send the hostname manually, this is the only parameter. Am I 
initializing the configuration wrong?


I also copied all params manually for testing:
currentConfig.setParameter("hostname", "10.20.1.122");
currentConfig.setParameter("security", "nla");
currentConfig.setParameter("ignore-cert", "true");
currentConfig.setParameter("port", "3389");
currentConfig.setParameter("username", "user");

getConnectionID() and getProtocol() already provide the same value.
The connection didn't work anyway with a wrong test IP in the config and 
the adjusted one...


If it doesn't work at all I'll think about a DNS or something, but I 
thought it might be worth to ask how to do this properly..

Am 28.11.23 um 14:05 schrieb Nick Couchman:
> On Mon, Nov 27, 2023 at 6:11 PM Kai <l1...@gmail.com> wrote:
>
>     Thank you Nick, that brought me many steps forward!
>
>     I added some custom attributes and was able to read them out in my
>     class ProxmoxConnection extends DelegatingConnection using
>     super.getAttributes().
>     I got the http connection to the Proxmox API running, I just
>     didn't combine it all together, yet.
>
>     What I was wondering, sometimes the VM ip can get changed or just
>     isn't static.
>     I tried to adjust the hostname of the connection inside the
>     connect() function like this:
>     GuacamoleConfiguration currentConfig = super.getConfiguration();
>     currentConfig.setParameter("hostname", "10.20.1.122");
>     super.setConfiguration(currentConfig);
>
>     But it didn't change. Reading the source comments the
>     configuration might be read already.
>     Is there a good place to insert a hostname changing ?
>
>
> I would think that should work, but without seeing more complete code, 
> I'm not sure why it isn't working. I guess just make sure that you're 
> not calling the super.connect() prior to this block of code?
>
> -Nick

Re: Adding scripts to startup/shutdown virtual machines

Posted by Nick Couchman <vn...@apache.org>.
On Mon, Nov 27, 2023 at 6:11 PM Kai <l1...@gmail.com> wrote:

> Thank you Nick, that brought me many steps forward!
>
> I added some custom attributes and was able to read them out in my class
> ProxmoxConnection extends DelegatingConnection using super.getAttributes().
> I got the http connection to the Proxmox API running, I just didn't
> combine it all together, yet.
>
> What I was wondering, sometimes the VM ip can get changed or just isn't
> static.
> I tried to adjust the hostname of the connection inside the connect()
> function like this:
> GuacamoleConfiguration currentConfig = super.getConfiguration();
> currentConfig.setParameter("hostname", "10.20.1.122");
> super.setConfiguration(currentConfig);
>
> But it didn't change. Reading the source comments the configuration might
> be read already.
> Is there a good place to insert a hostname changing ?
>
>
I would think that should work, but without seeing more complete code, I'm
not sure why it isn't working. I guess just make sure that you're not
calling the super.connect() prior to this block of code?

-Nick

Re: Adding scripts to startup/shutdown virtual machines

Posted by Kai <l1...@gmail.com>.
Thank you Nick, that brought me many steps forward!

I added some custom attributes and was able to read them out in my class 
ProxmoxConnection extends DelegatingConnection using super.getAttributes().
I got the http connection to the Proxmox API running, I just didn't 
combine it all together, yet.

What I was wondering, sometimes the VM ip can get changed or just isn't 
static.
I tried to adjust the hostname of the connection inside the connect() 
function like this:
GuacamoleConfiguration currentConfig = super.getConfiguration();
currentConfig.setParameter("hostname", "10.20.1.122");
super.setConfiguration(currentConfig);

But it didn't change. Reading the source comments the configuration 
might be read already.
Is there a good place to insert a hostname changing ?

Thank you!
Kai

Am 25.11.23 um 16:17 schrieb Nick Couchman:
> On Thu, Nov 23, 2023 at 4:30 PM Kai <l1...@gmail.com> wrote:
>
>     I'm still struggling with the web frontend.
>
>     Can you point me to a documentation of how to manipulate the status
>     messages during startup of the remote desktop connection?
>
>
> The simplest thing to do is to change the translation strings for the 
> status message. Possibly right here:
>
> https://github.com/apache/guacamole-client/blob/687ae4976e84cb79a7de20ec35d3fe97dd30d5e2/guacamole/src/main/frontend/src/translations/en.json#L79
>
> You could change that string to something like: "Starting up VM and 
> connecting, this could take a few minutes..."
>
> (etc.). Beyond that, I'm not sure that there's a way to send back 
> arbitrary information. There's a facility for requesting required 
> information (used for authentication, mainly) and sending that 
> information back, but that deals mostly in connection parameters used 
> by guacd and not so much in client interaction between Tomcat and the 
> Web UI. More on that difference, below...
>
>
>     And for the web interface  configuration option:
>     I read and searched a lot, but I'm still not sure: Do I need to
>     adjust
>     the files like in src/main/frontend/src/app/settings?
>     Or do I create little files inside the extension to add functionality?
>
>     Defining the configuration parameters itself can be done inside
>     the Java
>     classes, if I understood correctly.
>
>
> It's important to distinguish between "Connection Attributes" and 
> "Connection Parameters" - Parameters are passed to guacd and used to 
> establish the connection, while Attributes remain entirely within 
> Guacamole Client. If you're doing all of the VM startup functionality 
> in Java classes within Guacamole Client, then these should be 
> connection attributes.
>
> To add connection attributes you do not need to directly modify the 
> web interface, you just need to create the correct fields in the Java 
> class. There are some existing Java classes that make use of this that 
> you can look at for guidance - like TOTPuser:
>
> https://github.com/apache/guacamole-client/blob/master/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/auth/totp/user/TOTPUser.java
>
> The attributes are defined at the top of the class, but you also need 
> to add and/or remove them in the getAttributes() and setAttributes() 
> methods. The TOTPUser class has one exception - the TOTP secret is 
> intentionally removed from the interface so that it cannot be viewed 
> (= compromised), so not everything in the TOTPUser class would be 
> something you need to do. Also, TOTPUser is, of course, a User class, 
> not a Connection class, but it should translate over pretty easily.
>
> -Nick

Re: Adding scripts to startup/shutdown virtual machines

Posted by Nick Couchman <vn...@apache.org>.
On Thu, Nov 23, 2023 at 4:30 PM Kai <l1...@gmail.com> wrote:

> I'm still struggling with the web frontend.
>
> Can you point me to a documentation of how to manipulate the status
> messages during startup of the remote desktop connection?
>

The simplest thing to do is to change the translation strings for the
status message. Possibly right here:

https://github.com/apache/guacamole-client/blob/687ae4976e84cb79a7de20ec35d3fe97dd30d5e2/guacamole/src/main/frontend/src/translations/en.json#L79

You could change that string to something like: "Starting up VM and
connecting, this could take a few minutes..."

(etc.). Beyond that, I'm not sure that there's a way to send back arbitrary
information. There's a facility for requesting required information (used
for authentication, mainly) and sending that information back, but that
deals mostly in connection parameters used by guacd and not so much in
client interaction between Tomcat and the Web UI. More on that difference,
below...


>
> And for the web interface  configuration option:
> I read and searched a lot, but I'm still not sure: Do I need to adjust
> the files like in src/main/frontend/src/app/settings?
> Or do I create little files inside the extension to add functionality?
>
> Defining the configuration parameters itself can be done inside the Java
> classes, if I understood correctly.
>
>
It's important to distinguish between "Connection Attributes" and
"Connection Parameters" - Parameters are passed to guacd and used to
establish the connection, while Attributes remain entirely within Guacamole
Client. If you're doing all of the VM startup functionality in Java classes
within Guacamole Client, then these should be connection attributes.

To add connection attributes you do not need to directly modify the web
interface, you just need to create the correct fields in the Java class.
There are some existing Java classes that make use of this that you can
look at for guidance - like TOTPuser:

https://github.com/apache/guacamole-client/blob/master/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/auth/totp/user/TOTPUser.java

The attributes are defined at the top of the class, but you also need to
add and/or remove them in the getAttributes() and setAttributes() methods.
The TOTPUser class has one exception - the TOTP secret is intentionally
removed from the interface so that it cannot be viewed (= compromised), so
not everything in the TOTPUser class would be something you need to do.
Also, TOTPUser is, of course, a User class, not a Connection class, but it
should translate over pretty easily.

-Nick

Re: Adding scripts to startup/shutdown virtual machines

Posted by Kai <l1...@gmail.com>.
I'm still struggling with the web frontend.

Can you point me to a documentation of how to manipulate the status 
messages during startup of the remote desktop connection?

And for the web interface  configuration option:
I read and searched a lot, but I'm still not sure: Do I need to adjust 
the files like in src/main/frontend/src/app/settings?
Or do I create little files inside the extension to add functionality?

Defining the configuration parameters itself can be done inside the Java 
classes, if I understood correctly.

Thank you!
Kai

Am 21.11.23 um 23:22 schrieb Kai:
> Okay, I found one mistake, I forgot to define the dist.xml file.
> Now I get the expected logs. Thank you!
>
> I created a "public class ProxmoxConnection extends 
> DelegatingConnection" now, which includes "public GuacamoleTunnel 
> connect()".
> According to the logs, I get a message now, when I connect to a remote 
> desktop. Looks to be the right position.
> For disconnecting I'll try the same.
>
> But additionally:
> Is it possible to add own messages then to the startup screen which 
> appears when I connect?
> Then I could make sure to get a status.
>
> A second thing would be: can I add some additional configuration tags 
> in the configuration web page of a remote desktop?
> From the history-recording-storage I saw that these configurations are 
> already shown in the web config without the plugin being loaded.
> I saw getTokens() for other configurations, but I'm not sure if it's 
> the right location and how I can add own configs that would be 
> available in the web config.
>
> Injecting and inheriting in this dimension is still new to me..
> Thanks!
>
> Kai
>
> Am 20.11.23 um 22:49 schrieb Michael Jumper:
>> On 11/20/2023 1:25 PM, Kai wrote:
>>> I made some further analyzing of the sources in order to understand 
>>> the structur of a plugin..
>>>
>>> The nearest extension I could find was 
>>> guacamole-history-recording-storage.
>>> I took this as starting point and created a 
>>> classProxmoxAuthenticationProviderextendsAbstractAuthenticationProvider
>>>
>>> As shown in the extension I made a function call to decorate:
>>> publicUserContextdecorate(UserContextcontext,
>>> AuthenticatedUserauthenticatedUser, Credentialscredentials)
>>> throwsGuacamoleException{
>>> returnnewProxmoxUserContext(context.self(), context);
>>> }
>>>
>>> That got to the classProxmoxUserContextextendsTokenInjectingUserContext
>>> privatestaticfinalLoggerlogger=LoggerFactory.getLogger(ProxmoxUserContext.class); 
>>>
>>> publicProxmoxUserContext(UsercurrentUser, UserContextcontext) {
>>> super(context);
>>> this.currentUser=currentUser;
>>> logger.warn("ProxmoxUserContext() ");
>>> }
>>>
>>> I got this to compile as a .jar file and included it into Guacamole.
>>>
>>> Getting the log, I saw that this plugin is loaded: "INFO 
>>>   o.a.g.extension.ExtensionModule - Extension "Proxmox machine 
>>> start/stop" (proxmox) loaded."
>>>
>>> I was expecting that my logger message would be shown at some point. 
>>> When would this extension be called?
>>
>> The function in question would be called after a successful login. 
>> You would see the message once for every UserContext associated with 
>> the user's session.
>>
>> Here is how the authentication and authorization flow works:
>>
>> (1) When a user attempts to log in, every installed extension is 
>> given an opportunity to accept or reject that attempt. If an 
>> extension accepts the attempt, it returns an AuthenticatedUser via 
>> its authenticateUser() function.
>>
>> (2) The AuthenticatedUser representing the user's now-validated 
>> identity is given to each installed extension via getUserContext(). 
>> Each extension now has the opportunity to provide data for that user 
>> via its own UserContext.
>>
>> (3) For each UserContext obtained in this way, each extension's 
>> decorate() function is invoked to allow those extensions to apply 
>> their own behavior around whatever is already provided by the 
>> UserContexts of other extensions.
>>
>> The UI presented to the user after they successfully log in is 
>> actually a transparently unified view of all the data available from 
>> however many UserContext objects apply to that user's session.
>>
>> - Mike
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
>> For additional commands, e-mail: user-help@guacamole.apache.org
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Adding scripts to startup/shutdown virtual machines

Posted by Kai <l1...@gmail.com>.
Okay, I found one mistake, I forgot to define the dist.xml file.
Now I get the expected logs. Thank you!

I created a "public class ProxmoxConnection extends 
DelegatingConnection" now, which includes "public GuacamoleTunnel 
connect()".
According to the logs, I get a message now, when I connect to a remote 
desktop. Looks to be the right position.
For disconnecting I'll try the same.

But additionally:
Is it possible to add own messages then to the startup screen which 
appears when I connect?
Then I could make sure to get a status.

A second thing would be: can I add some additional configuration tags in 
the configuration web page of a remote desktop?
 From the history-recording-storage I saw that these configurations are 
already shown in the web config without the plugin being loaded.
I saw getTokens() for other configurations, but I'm not sure if it's the 
right location and how I can add own configs that would be available in 
the web config.

Injecting and inheriting in this dimension is still new to me..
Thanks!

Kai

Am 20.11.23 um 22:49 schrieb Michael Jumper:
> On 11/20/2023 1:25 PM, Kai wrote:
>> I made some further analyzing of the sources in order to understand 
>> the structur of a plugin..
>>
>> The nearest extension I could find was 
>> guacamole-history-recording-storage.
>> I took this as starting point and created a 
>> classProxmoxAuthenticationProviderextendsAbstractAuthenticationProvider
>>
>> As shown in the extension I made a function call to decorate:
>> publicUserContextdecorate(UserContextcontext,
>> AuthenticatedUserauthenticatedUser, Credentialscredentials)
>> throwsGuacamoleException{
>> returnnewProxmoxUserContext(context.self(), context);
>> }
>>
>> That got to the classProxmoxUserContextextendsTokenInjectingUserContext
>> privatestaticfinalLoggerlogger=LoggerFactory.getLogger(ProxmoxUserContext.class); 
>>
>> publicProxmoxUserContext(UsercurrentUser, UserContextcontext) {
>> super(context);
>> this.currentUser=currentUser;
>> logger.warn("ProxmoxUserContext() ");
>> }
>>
>> I got this to compile as a .jar file and included it into Guacamole.
>>
>> Getting the log, I saw that this plugin is loaded: "INFO 
>>   o.a.g.extension.ExtensionModule - Extension "Proxmox machine 
>> start/stop" (proxmox) loaded."
>>
>> I was expecting that my logger message would be shown at some point. 
>> When would this extension be called?
>
> The function in question would be called after a successful login. You 
> would see the message once for every UserContext associated with the 
> user's session.
>
> Here is how the authentication and authorization flow works:
>
> (1) When a user attempts to log in, every installed extension is given 
> an opportunity to accept or reject that attempt. If an extension 
> accepts the attempt, it returns an AuthenticatedUser via its 
> authenticateUser() function.
>
> (2) The AuthenticatedUser representing the user's now-validated 
> identity is given to each installed extension via getUserContext(). 
> Each extension now has the opportunity to provide data for that user 
> via its own UserContext.
>
> (3) For each UserContext obtained in this way, each extension's 
> decorate() function is invoked to allow those extensions to apply 
> their own behavior around whatever is already provided by the 
> UserContexts of other extensions.
>
> The UI presented to the user after they successfully log in is 
> actually a transparently unified view of all the data available from 
> however many UserContext objects apply to that user's session.
>
> - Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
> For additional commands, e-mail: user-help@guacamole.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Adding scripts to startup/shutdown virtual machines

Posted by Michael Jumper <mj...@apache.org>.
On 11/20/2023 1:25 PM, Kai wrote:
> I made some further analyzing of the sources in order to understand the 
> structur of a plugin..
> 
> The nearest extension I could find was guacamole-history-recording-storage.
> I took this as starting point and created a 
> classProxmoxAuthenticationProviderextendsAbstractAuthenticationProvider
> 
> As shown in the extension I made a function call to decorate:
> publicUserContextdecorate(UserContextcontext,
> AuthenticatedUserauthenticatedUser, Credentialscredentials)
> throwsGuacamoleException{
> returnnewProxmoxUserContext(context.self(), context);
> }
> 
> That got to the classProxmoxUserContextextendsTokenInjectingUserContext
> privatestaticfinalLoggerlogger=LoggerFactory.getLogger(ProxmoxUserContext.class);
> publicProxmoxUserContext(UsercurrentUser, UserContextcontext) {
> super(context);
> this.currentUser=currentUser;
> logger.warn("ProxmoxUserContext() ");
> }
> 
> I got this to compile as a .jar file and included it into Guacamole.
> 
> Getting the log, I saw that this plugin is loaded: "INFO 
>   o.a.g.extension.ExtensionModule - Extension "Proxmox machine 
> start/stop" (proxmox) loaded."
> 
> I was expecting that my logger message would be shown at some point. 
> When would this extension be called?

The function in question would be called after a successful login. You 
would see the message once for every UserContext associated with the 
user's session.

Here is how the authentication and authorization flow works:

(1) When a user attempts to log in, every installed extension is given 
an opportunity to accept or reject that attempt. If an extension accepts 
the attempt, it returns an AuthenticatedUser via its authenticateUser() 
function.

(2) The AuthenticatedUser representing the user's now-validated identity 
is given to each installed extension via getUserContext(). Each 
extension now has the opportunity to provide data for that user via its 
own UserContext.

(3) For each UserContext obtained in this way, each extension's 
decorate() function is invoked to allow those extensions to apply their 
own behavior around whatever is already provided by the UserContexts of 
other extensions.

The UI presented to the user after they successfully log in is actually 
a transparently unified view of all the data available from however many 
UserContext objects apply to that user's session.

- Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Adding scripts to startup/shutdown virtual machines

Posted by Kai <l1...@gmail.com>.
I made some further analyzing of the sources in order to understand the 
structur of a plugin..

The nearest extension I could find was guacamole-history-recording-storage.
I took this as starting point and created a 
classProxmoxAuthenticationProviderextendsAbstractAuthenticationProvider

As shown in the extension I made a function call to decorate:
publicUserContextdecorate(UserContextcontext,
AuthenticatedUserauthenticatedUser, Credentialscredentials)
throwsGuacamoleException{
returnnewProxmoxUserContext(context.self(), context);
}

That got to the classProxmoxUserContextextendsTokenInjectingUserContext
privatestaticfinalLoggerlogger=LoggerFactory.getLogger(ProxmoxUserContext.class);
publicProxmoxUserContext(UsercurrentUser, UserContextcontext) {
super(context);
this.currentUser=currentUser;
logger.warn("ProxmoxUserContext() ");
}

I got this to compile as a .jar file and included it into Guacamole.

Getting the log, I saw that this plugin is loaded: "INFO 
  o.a.g.extension.ExtensionModule - Extension "Proxmox machine 
start/stop" (proxmox) loaded."

I was expecting that my logger message would be shown at some point. 
When would this extension be called?
Do I need to use a different extends class?

Inside of the class ProxmoxUserContext the next step would be to 
integrate the
publicDirectory<Connection> getConnectionDirectory() 
throwsGuacamoleException{
returnnewDecoratingDirectory<Connection>(super.getConnectionDirectory())
from the HistoryUserContext.java.

Would this be the right approach? I'm still quite unshure if that's the 
right way for the injection.

Thanks!

Am 18.11.23 um 01:01 schrieb Michael Jumper:
> On 11/17/2023 1:18 PM, Kai wrote:
>> Hello,
>>
>> I came across Guacamole some days ago and I'm quite impressed about 
>> how quick I got an example running.
>> Originally, I was planning on doing some connections to virtual 
>> machines behind a gateway by using a remote desktop client with some 
>> scripts, but the web solution can be more convenient.
>>
>> As virtualization I use Proxmox and I have some dedicated VMs only 
>> running some old software without internet.
>> They also shouldn't be running all the time for power and performance 
>> reasons.
>>   I'm connecting to them by RDP and also tried this in Guacamole.
>>
>> I currently use some easy scripts to startup and suspend the machines 
>> before and after a RDP session.
>> What could be the best way for me to integrate running some 
>> additional script? I looked at the wake-on-lan as example.
>> I saw that the client web application only collects these information 
>> and the server application does the waiting and sending within C code.
>>
>> As I can easily control the Proxmox VMs by using the Proxmox Rest 
>> API, I only plan to integrate some http requests before showing the 
>> RDP and after closing it. My idea was to integrate these requests 
>> somewhere in the client web application, but I didn't see a good way, 
>> yet.
>> Are there suggestions what position would be best?
>
> You can hook into the connection process for any connection by 
> leveraging decoration to wrap the connection objects returned by other 
> extensions:
>
> https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/AuthenticationProvider.html#decorate(org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.AuthenticatedUser,org.apache.guacamole.net.auth.Credentials) 
>
>
> https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/AuthenticationProvider.html#redecorate(org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.AuthenticatedUser,org.apache.guacamole.net.auth.Credentials) 
>
>
> Wrapping a Connection and its connect() implementation will allow you 
> to hook in before a connection is established, while overriding the 
> close() function of the returned GuacamoleTunnel will allow you to 
> hook into when the connection is closed down. You just need to make 
> sure that your implementation correctly *unwraps* any wrapped objects 
> before they are passed to Directory functions like update(), as 
> implementations may expect to receive objects of the same type that 
> they returned via a previous call to get(). You can use 
> DecoratingDirectory to make this much easier to do correctly:
>
> https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/DecoratingDirectory.html 
>
>
> It is also possible to inject arbitrary connection attributes at the 
> UserContext level such that administrators are presented with 
> additional configuration options when creating/updating a connection, 
> if that's something you're looking to do.
>
> - Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
> For additional commands, e-mail: user-help@guacamole.apache.org
>

Re: Adding scripts to startup/shutdown virtual machines

Posted by Kai <l1...@gmail.com>.
Thank you for your answer!
I started looking at the documentation, but I'm not sure, yet.

If I unserstand correctly, it would be best to write an extension.
The extension will override then predefined functions where I can put my 
additional functionality.
I assume I'll need to find the correct positions for my functions to start.

As Java is not a regular language of mine, could you hint me to to a 
position in the sources or offer a small example?
I wasn't able to find an example of the decorate functions, yet (I 
searched in the code for now).

Thanks!
Kai

Am 18.11.23 um 01:01 schrieb Michael Jumper:
> On 11/17/2023 1:18 PM, Kai wrote:
>> Hello,
>>
>> I came across Guacamole some days ago and I'm quite impressed about 
>> how quick I got an example running.
>> Originally, I was planning on doing some connections to virtual 
>> machines behind a gateway by using a remote desktop client with some 
>> scripts, but the web solution can be more convenient.
>>
>> As virtualization I use Proxmox and I have some dedicated VMs only 
>> running some old software without internet.
>> They also shouldn't be running all the time for power and performance 
>> reasons.
>>   I'm connecting to them by RDP and also tried this in Guacamole.
>>
>> I currently use some easy scripts to startup and suspend the machines 
>> before and after a RDP session.
>> What could be the best way for me to integrate running some 
>> additional script? I looked at the wake-on-lan as example.
>> I saw that the client web application only collects these information 
>> and the server application does the waiting and sending within C code.
>>
>> As I can easily control the Proxmox VMs by using the Proxmox Rest 
>> API, I only plan to integrate some http requests before showing the 
>> RDP and after closing it. My idea was to integrate these requests 
>> somewhere in the client web application, but I didn't see a good way, 
>> yet.
>> Are there suggestions what position would be best?
>
> You can hook into the connection process for any connection by 
> leveraging decoration to wrap the connection objects returned by other 
> extensions:
>
> https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/AuthenticationProvider.html#decorate(org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.AuthenticatedUser,org.apache.guacamole.net.auth.Credentials) 
>
>
> https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/AuthenticationProvider.html#redecorate(org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.AuthenticatedUser,org.apache.guacamole.net.auth.Credentials) 
>
>
> Wrapping a Connection and its connect() implementation will allow you 
> to hook in before a connection is established, while overriding the 
> close() function of the returned GuacamoleTunnel will allow you to 
> hook into when the connection is closed down. You just need to make 
> sure that your implementation correctly *unwraps* any wrapped objects 
> before they are passed to Directory functions like update(), as 
> implementations may expect to receive objects of the same type that 
> they returned via a previous call to get(). You can use 
> DecoratingDirectory to make this much easier to do correctly:
>
> https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/DecoratingDirectory.html 
>
>
> It is also possible to inject arbitrary connection attributes at the 
> UserContext level such that administrators are presented with 
> additional configuration options when creating/updating a connection, 
> if that's something you're looking to do.
>
> - Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
> For additional commands, e-mail: user-help@guacamole.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Adding scripts to startup/shutdown virtual machines

Posted by Michael Jumper <mj...@apache.org>.
On 11/17/2023 1:18 PM, Kai wrote:
> Hello,
> 
> I came across Guacamole some days ago and I'm quite impressed about how 
> quick I got an example running.
> Originally, I was planning on doing some connections to virtual machines 
> behind a gateway by using a remote desktop client with some scripts, but 
> the web solution can be more convenient.
> 
> As virtualization I use Proxmox and I have some dedicated VMs only 
> running some old software without internet.
> They also shouldn't be running all the time for power and performance 
> reasons.
>   I'm connecting to them by RDP and also tried this in Guacamole.
> 
> I currently use some easy scripts to startup and suspend the machines 
> before and after a RDP session.
> What could be the best way for me to integrate running some additional 
> script? I looked at the wake-on-lan as example.
> I saw that the client web application only collects these information 
> and the server application does the waiting and sending within C code.
> 
> As I can easily control the Proxmox VMs by using the Proxmox Rest API, I 
> only plan to integrate some http requests before showing the RDP and 
> after closing it. My idea was to integrate these requests somewhere in 
> the client web application, but I didn't see a good way, yet.
> Are there suggestions what position would be best?

You can hook into the connection process for any connection by 
leveraging decoration to wrap the connection objects returned by other 
extensions:

https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/AuthenticationProvider.html#decorate(org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.AuthenticatedUser,org.apache.guacamole.net.auth.Credentials)

https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/AuthenticationProvider.html#redecorate(org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.AuthenticatedUser,org.apache.guacamole.net.auth.Credentials)

Wrapping a Connection and its connect() implementation will allow you to 
hook in before a connection is established, while overriding the close() 
function of the returned GuacamoleTunnel will allow you to hook into 
when the connection is closed down. You just need to make sure that your 
implementation correctly *unwraps* any wrapped objects before they are 
passed to Directory functions like update(), as implementations may 
expect to receive objects of the same type that they returned via a 
previous call to get(). You can use DecoratingDirectory to make this 
much easier to do correctly:

https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/DecoratingDirectory.html

It is also possible to inject arbitrary connection attributes at the 
UserContext level such that administrators are presented with additional 
configuration options when creating/updating a connection, if that's 
something you're looking to do.

- Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org