[Users] UI Plugin issue when switching main tabs

Hi, I'm working on an UI plugin to integrate Nagios/Icinga into oVirt Engine and made some progress, but have an issue when switching the main tabs. I use VirtualMachineSelectionChange to create URL with name of vm (and HostSelectionChange for hosts). Name is used in my backend code (Perl) for fetching monitoring status. Here's the code of VirtualMachineSelectionChange: VirtualMachineSelectionChange: function() { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); } Everything works fine as long as I stay in Virtual Machine main tab. When switching to e.g. Disks and back to Virtual Machines again the JavaScript code of start.html isn't processed anymore (or cached (?) as the my generated URL with last vm name will still be sent back to my Perl backend) - added alert() to test this. oVirt Engine version: ovirt-engine-3.2.0-1.20130118.gitd102d6f.fc18.noarch Full code of start.hml: http://pastebin.com/iEY6dA6F Thanks a lot for your help, René

I'll let Vojtech (cc-ed) to give a more accurate answer, but, trying to narrow down the issue: when you switch to a different main tab and then back to the VM main tab, and change the selection in there, does it work? (Trying to understand if the problem is only when doing the switch, and it works afterwards, or not). Thank you, Oved ----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: users@ovirt.org Sent: Sunday, January 20, 2013 11:07:13 PM Subject: [Users] UI Plugin issue when switching main tabs
Hi,
I'm working on an UI plugin to integrate Nagios/Icinga into oVirt Engine and made some progress, but have an issue when switching the main tabs.
I use VirtualMachineSelectionChange to create URL with name of vm (and HostSelectionChange for hosts). Name is used in my backend code (Perl) for fetching monitoring status.
Here's the code of VirtualMachineSelectionChange:
VirtualMachineSelectionChange: function() { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); }
Everything works fine as long as I stay in Virtual Machine main tab. When switching to e.g. Disks and back to Virtual Machines again the JavaScript code of start.html isn't processed anymore (or cached (?) as the my generated URL with last vm name will still be sent back to my Perl backend) - added alert() to test this.
oVirt Engine version: ovirt-engine-3.2.0-1.20130118.gitd102d6f.fc18.noarch
Full code of start.hml: http://pastebin.com/iEY6dA6F
Thanks a lot for your help, René
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

When switching back to vm main tab changing the selection doesn't work. No matter which VM I select the VirtualMachineSelectionChange function isn't called again (as my debug alert window doesn't appear), but the last vm I selected before switching to another main tab is cached in variable vmName... It works again after restarting engine-service. I just tested your foreman plugin and it seems that this one is working as expected. Regards, René -----Original message-----
From:Oved Ourfalli <ovedo@redhat.com> Sent: Monday 21st January 2013 14:56 To: René Koch <r.koch@ovido.at> Cc: users@ovirt.org; Vojtech Szocs <vszocs@redhat.com> Subject: Re: [Users] UI Plugin issue when switching main tabs
I'll let Vojtech (cc-ed) to give a more accurate answer, but, trying to narrow down the issue: when you switch to a different main tab and then back to the VM main tab, and change the selection in there, does it work? (Trying to understand if the problem is only when doing the switch, and it works afterwards, or not).
Thank you, Oved ----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: users@ovirt.org Sent: Sunday, January 20, 2013 11:07:13 PM Subject: [Users] UI Plugin issue when switching main tabs
Hi,
I'm working on an UI plugin to integrate Nagios/Icinga into oVirt Engine and made some progress, but have an issue when switching the main tabs.
I use VirtualMachineSelectionChange to create URL with name of vm (and HostSelectionChange for hosts). Name is used in my backend code (Perl) for fetching monitoring status.
Here's the code of VirtualMachineSelectionChange:
VirtualMachineSelectionChange: function() { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); }
Everything works fine as long as I stay in Virtual Machine main tab. When switching to e.g. Disks and back to Virtual Machines again the JavaScript code of start.html isn't processed anymore (or cached (?) as the my generated URL with last vm name will still be sent back to my Perl backend) - added alert() to test this.
oVirt Engine version: ovirt-engine-3.2.0-1.20130118.gitd102d6f.fc18.noarch
Full code of start.hml: http://pastebin.com/iEY6dA6F
Thanks a lot for your help, René
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

Found your bug (I think): You don't check in your code whether there is a selection (if (arguments.length == 1) for example, if you want to act only when one is selected). You'll probably want to do similar logic to the Foreman plugin, setting the sub-tab content URL only in case one VM is selected, and setting the URL properly. The fact that your alert won't show is that you call arguments[0].name, and it fails when nothing is selected... and I guess that's the case when you switch tabs. Didn't check it out, but please check it out... and let me know what you found :-) Oved ----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Monday, January 21, 2013 6:05:47 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
When switching back to vm main tab changing the selection doesn't work.
No matter which VM I select the VirtualMachineSelectionChange function isn't called again (as my debug alert window doesn't appear), but the last vm I selected before switching to another main tab is cached in variable vmName... It works again after restarting engine-service.
I just tested your foreman plugin and it seems that this one is working as expected.
Regards, René
-----Original message-----
From:Oved Ourfalli <ovedo@redhat.com> Sent: Monday 21st January 2013 14:56 To: René Koch <r.koch@ovido.at> Cc: users@ovirt.org; Vojtech Szocs <vszocs@redhat.com> Subject: Re: [Users] UI Plugin issue when switching main tabs
I'll let Vojtech (cc-ed) to give a more accurate answer, but, trying to narrow down the issue: when you switch to a different main tab and then back to the VM main tab, and change the selection in there, does it work? (Trying to understand if the problem is only when doing the switch, and it works afterwards, or not).
Thank you, Oved ----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: users@ovirt.org Sent: Sunday, January 20, 2013 11:07:13 PM Subject: [Users] UI Plugin issue when switching main tabs
Hi,
I'm working on an UI plugin to integrate Nagios/Icinga into oVirt Engine and made some progress, but have an issue when switching the main tabs.
I use VirtualMachineSelectionChange to create URL with name of vm (and HostSelectionChange for hosts). Name is used in my backend code (Perl) for fetching monitoring status.
Here's the code of VirtualMachineSelectionChange:
VirtualMachineSelectionChange: function() { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); }
Everything works fine as long as I stay in Virtual Machine main tab. When switching to e.g. Disks and back to Virtual Machines again the JavaScript code of start.html isn't processed anymore (or cached (?) as the my generated URL with last vm name will still be sent back to my Perl backend) - added alert() to test this.
oVirt Engine version: ovirt-engine-3.2.0-1.20130118.gitd102d6f.fc18.noarch
Full code of start.hml: http://pastebin.com/iEY6dA6F
Thanks a lot for your help, René
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

Thanks a lot for your input - it was really helpfu! I added a check for argument.length and now it's working as expected. The working code is: VirtualMachineSelectionChange: function() { if (arguments.length == 1) { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); } } Btw, do you know if I can get the name of a host instead the hostname/ip? arguments[0].name; gives me the IP address (value of webadmin column "hostname/ip") but not the name (column "name") - (I always use ips instead of dns names for hypervisors)... Thanks, René -----Original message-----
From:Oved Ourfalli <ovedo@redhat.com> Sent: Tuesday 22nd January 2013 19:34 To: René Koch <r.koch@ovido.at> Cc: users@ovirt.org Subject: Re: [Users] UI Plugin issue when switching main tabs
Found your bug (I think): You don't check in your code whether there is a selection (if (arguments.length == 1) for example, if you want to act only when one is selected).
You'll probably want to do similar logic to the Foreman plugin, setting the sub-tab content URL only in case one VM is selected, and setting the URL properly.
The fact that your alert won't show is that you call arguments[0].name, and it fails when nothing is selected... and I guess that's the case when you switch tabs. Didn't check it out, but please check it out... and let me know what you found :-)
Oved
----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Monday, January 21, 2013 6:05:47 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
When switching back to vm main tab changing the selection doesn't work.
No matter which VM I select the VirtualMachineSelectionChange function isn't called again (as my debug alert window doesn't appear), but the last vm I selected before switching to another main tab is cached in variable vmName... It works again after restarting engine-service.
I just tested your foreman plugin and it seems that this one is working as expected.
Regards, René
-----Original message-----
From:Oved Ourfalli <ovedo@redhat.com> Sent: Monday 21st January 2013 14:56 To: René Koch <r.koch@ovido.at> Cc: users@ovirt.org; Vojtech Szocs <vszocs@redhat.com> Subject: Re: [Users] UI Plugin issue when switching main tabs
I'll let Vojtech (cc-ed) to give a more accurate answer, but, trying to narrow down the issue: when you switch to a different main tab and then back to the VM main tab, and change the selection in there, does it work? (Trying to understand if the problem is only when doing the switch, and it works afterwards, or not).
Thank you, Oved ----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: users@ovirt.org Sent: Sunday, January 20, 2013 11:07:13 PM Subject: [Users] UI Plugin issue when switching main tabs
Hi,
I'm working on an UI plugin to integrate Nagios/Icinga into oVirt Engine and made some progress, but have an issue when switching the main tabs.
I use VirtualMachineSelectionChange to create URL with name of vm (and HostSelectionChange for hosts). Name is used in my backend code (Perl) for fetching monitoring status.
Here's the code of VirtualMachineSelectionChange:
VirtualMachineSelectionChange: function() { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); }
Everything works fine as long as I stay in Virtual Machine main tab. When switching to e.g. Disks and back to Virtual Machines again the JavaScript code of start.html isn't processed anymore (or cached (?) as the my generated URL with last vm name will still be sent back to my Perl backend) - added alert() to test this.
oVirt Engine version: ovirt-engine-3.2.0-1.20130118.gitd102d6f.fc18.noarch
Full code of start.hml: http://pastebin.com/iEY6dA6F
Thanks a lot for your help, René
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Tuesday, January 22, 2013 1:51:58 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
Thanks a lot for your input - it was really helpfu!
I added a check for argument.length and now it's working as expected. The working code is:
VirtualMachineSelectionChange: function() { if (arguments.length == 1) { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); } }
Btw, do you know if I can get the name of a host instead the hostname/ip? arguments[0].name; gives me the IP address (value of webadmin column "hostname/ip") but not the name (column "name") - (I always use ips instead of dns names for hypervisors)...
I don't think you can currently do that. The plan is to expose all the attributes of the entity that are exposed via REST, also in the plugin api, but currently that's not the case. Not sure why it doesn't return the name itself (don't know if it is a bug, or it is "as designed"), but anyway, other properties will be exposed in the future.
Thanks, René
-----Original message-----
From:Oved Ourfalli <ovedo@redhat.com> Sent: Tuesday 22nd January 2013 19:34 To: René Koch <r.koch@ovido.at> Cc: users@ovirt.org Subject: Re: [Users] UI Plugin issue when switching main tabs
Found your bug (I think): You don't check in your code whether there is a selection (if (arguments.length == 1) for example, if you want to act only when one is selected).
You'll probably want to do similar logic to the Foreman plugin, setting the sub-tab content URL only in case one VM is selected, and setting the URL properly.
The fact that your alert won't show is that you call arguments[0].name, and it fails when nothing is selected... and I guess that's the case when you switch tabs. Didn't check it out, but please check it out... and let me know what you found :-)
Oved
----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Monday, January 21, 2013 6:05:47 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
When switching back to vm main tab changing the selection doesn't work.
No matter which VM I select the VirtualMachineSelectionChange function isn't called again (as my debug alert window doesn't appear), but the last vm I selected before switching to another main tab is cached in variable vmName... It works again after restarting engine-service.
I just tested your foreman plugin and it seems that this one is working as expected.
Regards, René
-----Original message-----
From:Oved Ourfalli <ovedo@redhat.com> Sent: Monday 21st January 2013 14:56 To: René Koch <r.koch@ovido.at> Cc: users@ovirt.org; Vojtech Szocs <vszocs@redhat.com> Subject: Re: [Users] UI Plugin issue when switching main tabs
I'll let Vojtech (cc-ed) to give a more accurate answer, but, trying to narrow down the issue: when you switch to a different main tab and then back to the VM main tab, and change the selection in there, does it work? (Trying to understand if the problem is only when doing the switch, and it works afterwards, or not).
Thank you, Oved ----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: users@ovirt.org Sent: Sunday, January 20, 2013 11:07:13 PM Subject: [Users] UI Plugin issue when switching main tabs
Hi,
I'm working on an UI plugin to integrate Nagios/Icinga into oVirt Engine and made some progress, but have an issue when switching the main tabs.
I use VirtualMachineSelectionChange to create URL with name of vm (and HostSelectionChange for hosts). Name is used in my backend code (Perl) for fetching monitoring status.
Here's the code of VirtualMachineSelectionChange:
VirtualMachineSelectionChange: function() { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); }
Everything works fine as long as I stay in Virtual Machine main tab. When switching to e.g. Disks and back to Virtual Machines again the JavaScript code of start.html isn't processed anymore (or cached (?) as the my generated URL with last vm name will still be sent back to my Perl backend) - added alert() to test this.
oVirt Engine version: ovirt-engine-3.2.0-1.20130118.gitd102d6f.fc18.noarch
Full code of start.hml: http://pastebin.com/iEY6dA6F
Thanks a lot for your help, René
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

On 22/01/2013 14:06, Oved Ourfalli wrote:
----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Tuesday, January 22, 2013 1:51:58 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
Thanks a lot for your input - it was really helpfu!
I added a check for argument.length and now it's working as expected. The working code is:
VirtualMachineSelectionChange: function() { if (arguments.length == 1) { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); } }
Btw, do you know if I can get the name of a host instead the hostname/ip? arguments[0].name; gives me the IP address (value of webadmin column "hostname/ip") but not the name (column "name") - (I always use ips instead of dns names for hypervisors)...
I don't think you can currently do that. The plan is to expose all the attributes of the entity that are exposed via REST, also in the plugin api, but currently that's not the case. Not sure why it doesn't return the name itself (don't know if it is a bug, or it is "as designed"), but anyway, other properties will be exposed in the future.
but it sounds like a bug in the mapping of id/name for the current uiplugin infra (maybe vojtech mapped the wrong field). assuming restapi returns host name for the name field, uiplugin should return it as well.
Thanks, René
-----Original message-----
From:Oved Ourfalli <ovedo@redhat.com> Sent: Tuesday 22nd January 2013 19:34 To: René Koch <r.koch@ovido.at> Cc: users@ovirt.org Subject: Re: [Users] UI Plugin issue when switching main tabs
Found your bug (I think): You don't check in your code whether there is a selection (if (arguments.length == 1) for example, if you want to act only when one is selected).
You'll probably want to do similar logic to the Foreman plugin, setting the sub-tab content URL only in case one VM is selected, and setting the URL properly.
The fact that your alert won't show is that you call arguments[0].name, and it fails when nothing is selected... and I guess that's the case when you switch tabs. Didn't check it out, but please check it out... and let me know what you found :-)
Oved
----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Monday, January 21, 2013 6:05:47 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
When switching back to vm main tab changing the selection doesn't work.
No matter which VM I select the VirtualMachineSelectionChange function isn't called again (as my debug alert window doesn't appear), but the last vm I selected before switching to another main tab is cached in variable vmName... It works again after restarting engine-service.
I just tested your foreman plugin and it seems that this one is working as expected.
Regards, René
-----Original message-----
From:Oved Ourfalli <ovedo@redhat.com> Sent: Monday 21st January 2013 14:56 To: René Koch <r.koch@ovido.at> Cc: users@ovirt.org; Vojtech Szocs <vszocs@redhat.com> Subject: Re: [Users] UI Plugin issue when switching main tabs
I'll let Vojtech (cc-ed) to give a more accurate answer, but, trying to narrow down the issue: when you switch to a different main tab and then back to the VM main tab, and change the selection in there, does it work? (Trying to understand if the problem is only when doing the switch, and it works afterwards, or not).
Thank you, Oved ----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: users@ovirt.org Sent: Sunday, January 20, 2013 11:07:13 PM Subject: [Users] UI Plugin issue when switching main tabs
Hi,
I'm working on an UI plugin to integrate Nagios/Icinga into oVirt Engine and made some progress, but have an issue when switching the main tabs.
I use VirtualMachineSelectionChange to create URL with name of vm (and HostSelectionChange for hosts). Name is used in my backend code (Perl) for fetching monitoring status.
Here's the code of VirtualMachineSelectionChange:
VirtualMachineSelectionChange: function() { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); }
Everything works fine as long as I stay in Virtual Machine main tab. When switching to e.g. Disks and back to Virtual Machines again the JavaScript code of start.html isn't processed anymore (or cached (?) as the my generated URL with last vm name will still be sent back to my Perl backend) - added alert() to test this.
oVirt Engine version: ovirt-engine-3.2.0-1.20130118.gitd102d6f.fc18.noarch
Full code of start.hml: http://pastebin.com/iEY6dA6F
Thanks a lot for your help, René
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

On 23/01/2013 04:32, Itamar Heim wrote:
On 22/01/2013 14:06, Oved Ourfalli wrote:
----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Tuesday, January 22, 2013 1:51:58 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
Thanks a lot for your input - it was really helpfu!
I added a check for argument.length and now it's working as expected. The working code is:
VirtualMachineSelectionChange: function() { if (arguments.length == 1) { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); } }
Btw, do you know if I can get the name of a host instead the hostname/ip? arguments[0].name; gives me the IP address (value of webadmin column "hostname/ip") but not the name (column "name") - (I always use ips instead of dns names for hypervisors)...
I don't think you can currently do that. The plan is to expose all the attributes of the entity that are exposed via REST, also in the plugin api, but currently that's not the case. Not sure why it doesn't return the name itself (don't know if it is a bug, or it is "as designed"), but anyway, other properties will be exposed in the future.
but it sounds like a bug in the mapping of id/name for the current uiplugin infra (maybe vojtech mapped the wrong field). assuming restapi returns host name for the name field, uiplugin should return it as well.
hmmm, i wonder if the shellinabox uiplugin relies on this bug. once it is fixed, it will need to fetch the ip via rest or assume the name is resolvable for ssh.

----- Original Message -----
From: "Itamar Heim" <iheim@redhat.com> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org, "Daniel Erez" <derez@redhat.com> Sent: Wednesday, January 23, 2013 2:33:53 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
On 23/01/2013 04:32, Itamar Heim wrote:
On 22/01/2013 14:06, Oved Ourfalli wrote:
----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Tuesday, January 22, 2013 1:51:58 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
Thanks a lot for your input - it was really helpfu!
I added a check for argument.length and now it's working as expected. The working code is:
VirtualMachineSelectionChange: function() { if (arguments.length == 1) { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); } }
Btw, do you know if I can get the name of a host instead the hostname/ip? arguments[0].name; gives me the IP address (value of webadmin column "hostname/ip") but not the name (column "name") - (I always use ips instead of dns names for hypervisors)...
I don't think you can currently do that. The plan is to expose all the attributes of the entity that are exposed via REST, also in the plugin api, but currently that's not the case. Not sure why it doesn't return the name itself (don't know if it is a bug, or it is "as designed"), but anyway, other properties will be exposed in the future.
but it sounds like a bug in the mapping of id/name for the current uiplugin infra (maybe vojtech mapped the wrong field). assuming restapi returns host name for the name field, uiplugin should return it as well.
hmmm, i wonder if the shellinabox uiplugin relies on this bug. once it is fixed, it will need to fetch the ip via rest or assume the name is resolvable for ssh.
Yes, the shellinabox uiplugin indeed relies on it. I thought it was intentional rather than a bug... Can we simply add a new property to the JSON object? I.e. obj.setProperty("hostname", ((VDS) businessEntity).gethost_name()); //$NON-NLS-1$ (in addition to: obj.setProperty("name", ((VDS) businessEntity).getvds_name()); //$NON-NLS-1$)

Hi guys,
I thought it was intentional rather than a bug...
No, this was my mistake :) it's a bug. Should be fixed by http://gerrit.ovirt.org/#/c/11420 Thanks Daniel for fixing this. Vojtech ----- Original Message ----- From: "Daniel Erez" <derez@redhat.com> To: "Itamar Heim" <iheim@redhat.com> Cc: users@ovirt.org, "Oved Ourfalli" <ovedo@redhat.com>, "Vojtech Szocs" <vszocs@redhat.com> Sent: Wednesday, January 23, 2013 2:48:23 PM Subject: Re: [Users] UI Plugin issue when switching main tabs ----- Original Message -----
From: "Itamar Heim" <iheim@redhat.com> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org, "Daniel Erez" <derez@redhat.com> Sent: Wednesday, January 23, 2013 2:33:53 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
On 23/01/2013 04:32, Itamar Heim wrote:
On 22/01/2013 14:06, Oved Ourfalli wrote:
----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Tuesday, January 22, 2013 1:51:58 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
Thanks a lot for your input - it was really helpfu!
I added a check for argument.length and now it's working as expected. The working code is:
VirtualMachineSelectionChange: function() { if (arguments.length == 1) { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); } }
Btw, do you know if I can get the name of a host instead the hostname/ip? arguments[0].name; gives me the IP address (value of webadmin column "hostname/ip") but not the name (column "name") - (I always use ips instead of dns names for hypervisors)...
I don't think you can currently do that. The plan is to expose all the attributes of the entity that are exposed via REST, also in the plugin api, but currently that's not the case. Not sure why it doesn't return the name itself (don't know if it is a bug, or it is "as designed"), but anyway, other properties will be exposed in the future.
but it sounds like a bug in the mapping of id/name for the current uiplugin infra (maybe vojtech mapped the wrong field). assuming restapi returns host name for the name field, uiplugin should return it as well.
hmmm, i wonder if the shellinabox uiplugin relies on this bug. once it is fixed, it will need to fetch the ip via rest or assume the name is resolvable for ssh.
Yes, the shellinabox uiplugin indeed relies on it. I thought it was intentional rather than a bug... Can we simply add a new property to the JSON object? I.e. obj.setProperty("hostname", ((VDS) businessEntity).gethost_name()); //$NON-NLS-1$ (in addition to: obj.setProperty("name", ((VDS) businessEntity).getvds_name()); //$NON-NLS-1$)

Hi René, sorry for my very late reply, and thanks to Oved for helping with this issue. As Oved suggested, you should always check 'arguments' before accessing entities from it. The reason why VirtualMachineSelectionChange event stopped working for your plugin after you switch away from VM tab and into VM tab again, is because when you switch again into VM tab, VM table selection is cleared and VirtualMachineSelectionChange is triggered with empty 'arguments'. Since your plugin does 'arguments[0].name' regardless of 'arguments.length', this throws uncaught exception, and WebAdmin puts your plugin out of service as per the standard plugin lifecycle. In future, I'm planning to add new event handler function (e.g. 'Error') that will allow your plugin to detect such uncaught exceptions, but for now you have to ensure your plugin doesn't throw such exceptions. (Maybe you can use JavaScript console to detect such errors that happen within the plugin iframe.)
Btw, do you know if I can get the name of a host instead the hostname/ip?
This is a bug, it's fixed by http://gerrit.ovirt.org/#/c/11420/ so that 'vm.name' returns the value of name column, and 'vm.hostname' returns the hostname/IP. Regards, Vojtech ----- Original Message ----- From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Tuesday, January 22, 2013 10:51:58 PM Subject: Re: [Users] UI Plugin issue when switching main tabs Thanks a lot for your input - it was really helpfu! I added a check for argument.length and now it's working as expected. The working code is: VirtualMachineSelectionChange: function() { if (arguments.length == 1) { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); } } Btw, do you know if I can get the name of a host instead the hostname/ip? arguments[0].name; gives me the IP address (value of webadmin column "hostname/ip") but not the name (column "name") - (I always use ips instead of dns names for hypervisors)... Thanks, René -----Original message-----
From:Oved Ourfalli <ovedo@redhat.com> Sent: Tuesday 22nd January 2013 19:34 To: René Koch <r.koch@ovido.at> Cc: users@ovirt.org Subject: Re: [Users] UI Plugin issue when switching main tabs
Found your bug (I think): You don't check in your code whether there is a selection (if (arguments.length == 1) for example, if you want to act only when one is selected).
You'll probably want to do similar logic to the Foreman plugin, setting the sub-tab content URL only in case one VM is selected, and setting the URL properly.
The fact that your alert won't show is that you call arguments[0].name, and it fails when nothing is selected... and I guess that's the case when you switch tabs. Didn't check it out, but please check it out... and let me know what you found :-)
Oved
----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: "Oved Ourfalli" <ovedo@redhat.com> Cc: users@ovirt.org Sent: Monday, January 21, 2013 6:05:47 PM Subject: Re: [Users] UI Plugin issue when switching main tabs
When switching back to vm main tab changing the selection doesn't work.
No matter which VM I select the VirtualMachineSelectionChange function isn't called again (as my debug alert window doesn't appear), but the last vm I selected before switching to another main tab is cached in variable vmName... It works again after restarting engine-service.
I just tested your foreman plugin and it seems that this one is working as expected.
Regards, René
-----Original message-----
From:Oved Ourfalli <ovedo@redhat.com> Sent: Monday 21st January 2013 14:56 To: René Koch <r.koch@ovido.at> Cc: users@ovirt.org; Vojtech Szocs <vszocs@redhat.com> Subject: Re: [Users] UI Plugin issue when switching main tabs
I'll let Vojtech (cc-ed) to give a more accurate answer, but, trying to narrow down the issue: when you switch to a different main tab and then back to the VM main tab, and change the selection in there, does it work? (Trying to understand if the problem is only when doing the switch, and it works afterwards, or not).
Thank you, Oved ----- Original Message -----
From: "René Koch" <r.koch@ovido.at> To: users@ovirt.org Sent: Sunday, January 20, 2013 11:07:13 PM Subject: [Users] UI Plugin issue when switching main tabs
Hi,
I'm working on an UI plugin to integrate Nagios/Icinga into oVirt Engine and made some progress, but have an issue when switching the main tabs.
I use VirtualMachineSelectionChange to create URL with name of vm (and HostSelectionChange for hosts). Name is used in my backend code (Perl) for fetching monitoring status.
Here's the code of VirtualMachineSelectionChange:
VirtualMachineSelectionChange: function() { var vmName = arguments[0].name; alert(vmName); // Reload VM Sub Tab api.setTabContentUrl('vms-monitoring', conf.url + '?subtab=vms&name=' + encodeURIComponent(vmName)); }
Everything works fine as long as I stay in Virtual Machine main tab. When switching to e.g. Disks and back to Virtual Machines again the JavaScript code of start.html isn't processed anymore (or cached (?) as the my generated URL with last vm name will still be sent back to my Perl backend) - added alert() to test this.
oVirt Engine version: ovirt-engine-3.2.0-1.20130118.gitd102d6f.fc18.noarch
Full code of start.hml: http://pastebin.com/iEY6dA6F
Thanks a lot for your help, René
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
participants (5)
-
Daniel Erez
-
Itamar Heim
-
Oved Ourfalli
-
René Koch
-
Vojtech Szocs