I created a customized version of the Script plugin which includes three metrics (each of which passes a different command line option to the script). I want to add multiple resources using this plugin (executing the same script) but each with different environment variables to modify the behaviour. However I get the following error:
A Script Server with the specified connection properties was already in inventory.
Can can I create a reusable script plugin like this but apply it to different resources? It seems that I would have to clone the plugin jar file multiple jars to work around this error (or at the very least change the executable each time)
See attached rhq-plugin.xml
Al Amyot | Consultant Sierra Systems
(eHealth): 204-926-4257 (T): 204-942-2575 (F): 204-942-2047 444 St. Mary Avenue, Suite 1050 Winnipeg, MB R3C 3T1
Management Consulting | System Integration | Managed Services website: www.SierraSystems.com http://www.sierrasystems.com/
This email and/or any documents in this transmission is intended for the addressee(s) only and may contain legally privileged or confidential information. Any unauthorized use, disclosure, distribution, copying or dissemination is strictly prohibited. If you receive this transmission in error, please notify the sender immediately and return the original.
Ce courriel et tout document dans cette transmission est destiné à la personne ou aux personnes à qui il est adressé. Il peut contenir des informations privilégiées ou confidentielles. Toute utilisation, divulgation, distribution, copie, ou diffusion non autorisée est strictement défendue. Si vous n'êtes pas le destinataire de ce message, veuillez en informer l'expéditeur immédiatement et lui remettre l'original.
On 10/08/2010 04:14 PM, Al Amyot wrote:
A Script Server with the specified connection properties was already in inventory.
Remember that each resource has unique resource keys for a unique parent. This means if you have a parent resource A, all direct children of that resource A that are of the same type must have different resource keys.
In your case, you have a platform resource with child script resources - since the script resources are of the same type, they have to have unique resource keys.
Make sure your plugin discovery component defines unique resource keys. IIRC, the script plugin's resource key is the full path to the script. If you only have one script in one location, you can only have one script resource in inventory under that platform resource.
Since the full path to the script is not unique in your case (the same script is used multiple times), you have to come up with an algorithm that calculates a canonical resource key that is unique across all your script resources and customize your discovery component class.
For example, if you have environment variables whose values are different, you can calculate a hash (md5 or sha for example) and append that hashcode to the full path to the script - those two should make unique resource keys.
That's just one example how you can do it. The point is - your resource keys must be unique - if they are not, you cannot manually add more than one script resource.
IIRC, the script plugin's resource key is the full path to the script.
This is the code I'm talking about - from ScriptDiscoveryComponent:
---
DiscoveredResourceDetails details = new DiscoveredResourceDetails(discoveryContext.getResourceType(), executable, new File(executable).getName(), version, description, pluginConfig, null);
---
That second argument to the details constructor ("executable") is the key - and its the path to the script file as defined in the plugin configuration. This is not unique if you want more than one resource accessing the same script. you need to pass in a new resource key that is unique, whatever "unique" is as per your custom requirements.
Thanks John. That is what I suspected.
One problem with customizing the resource discovery based on the environment variable (which would be desirable in my case), is that the "Add New" button for adding environment variables does not work until AFTER the new resource is saved and edited, which is too late to be used in creating the resource key.
Is this a defect in the presentation code?
Al Amyot | Consultant Sierra Systems
(eHealth): 204-926-4257 (T): 204-942-2575 (F): 204-942-2047 444 St. Mary Avenue, Suite 1050 Winnipeg, MB R3C 3T1
Management Consulting | System Integration | Managed Services website: www.SierraSystems.com
-----Original Message----- From: rhq-users-bounces@lists.fedorahosted.org [mailto:rhq-users-bounces@lists.fedorahosted.org] On Behalf Of John Mazzitelli Sent: Friday, October 08, 2010 3:25 PM To: rhq-users@lists.fedorahosted.org Subject: Re: Reusing the script plugin
On 10/08/2010 04:14 PM, Al Amyot wrote:
A Script Server with the specified connection properties was already in inventory.
Remember that each resource has unique resource keys for a unique parent. This means if you have a parent resource A, all direct children of that resource A that are of the same type must have different resource keys.
In your case, you have a platform resource with child script resources - since the script resources are of the same type, they have to have unique resource keys.
Make sure your plugin discovery component defines unique resource keys. IIRC, the script plugin's resource key is the full path to the script. If you only have one script in one location, you can only have one script resource in inventory under that platform resource.
Since the full path to the script is not unique in your case (the same script is used multiple times), you have to come up with an algorithm that calculates a canonical resource key that is unique across all your script resources and customize your discovery component class.
For example, if you have environment variables whose values are different, you can calculate a hash (md5 or sha for example) and append that hashcode to the full path to the script - those two should make unique resource keys.
That's just one example how you can do it. The point is - your resource keys must be unique - if they are not, you cannot manually add more than one script resource. _______________________________________________ rhq-users mailing list rhq-users@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/rhq-users
This email and/or any documents in this transmission is intended for the addressee(s) only and may contain legally privileged or confidential information. Any unauthorized use, disclosure, distribution, copying or dissemination is strictly prohibited. If you receive this transmission in error, please notify the sender immediately and return the original.
Ce courriel et tout document dans cette transmission est destiné à la personne ou aux personnes à qui il est adressé. Il peut contenir des informations privilégiées ou confidentielles. Toute utilisation, divulgation, distribution, copie, ou diffusion non autorisée est strictement défendue. Si vous n'êtes pas le destinataire de ce message, veuillez en informer l'expéditeur immédiatement et lui remettre l'original.
Hmm... are you saying that when you go to manually add a resource, you can't add things to the plugin configuration (e.g. the configuration editor where you enter the config settings that get passed to the discovery component)?
That sounds like a bug - write up a bugzilla on that with some replication procedures that illustrate the problem:
https://bugzilla.redhat.com/enter_bug.cgi?product=RHQ%20Project
On 10/12/2010 10:11 AM, Al Amyot wrote:
Thanks John. That is what I suspected.
One problem with customizing the resource discovery based on the environment variable (which would be desirable in my case), is that the "Add New" button for adding environment variables does not work until AFTER the new resource is saved and edited, which is too late to be used in creating the resource key.
Is this a defect in the presentation code?
Al Amyot | Consultant Sierra Systems
(eHealth): 204-926-4257 (T): 204-942-2575 (F): 204-942-2047 444 St. Mary Avenue, Suite 1050 Winnipeg, MB R3C 3T1
Management Consulting | System Integration | Managed Services website: www.SierraSystems.com
-----Original Message----- From: rhq-users-bounces@lists.fedorahosted.org [mailto:rhq-users-bounces@lists.fedorahosted.org] On Behalf Of John Mazzitelli Sent: Friday, October 08, 2010 3:25 PM To: rhq-users@lists.fedorahosted.org Subject: Re: Reusing the script plugin
On 10/08/2010 04:14 PM, Al Amyot wrote:
A Script Server with the specified connection properties was already in inventory.
Remember that each resource has unique resource keys for a unique parent. This means if you have a parent resource A, all direct children of that resource A that are of the same type must have different resource keys.
In your case, you have a platform resource with child script resources - since the script resources are of the same type, they have to have unique resource keys.
Make sure your plugin discovery component defines unique resource keys. IIRC, the script plugin's resource key is the full path to the script. If you only have one script in one location, you can only have one script resource in inventory under that platform resource.
Since the full path to the script is not unique in your case (the same script is used multiple times), you have to come up with an algorithm that calculates a canonical resource key that is unique across all your script resources and customize your discovery component class.
For example, if you have environment variables whose values are different, you can calculate a hash (md5 or sha for example) and append that hashcode to the full path to the script - those two should make unique resource keys.
That's just one example how you can do it. The point is - your resource keys must be unique - if they are not, you cannot manually add more than one script resource. _______________________________________________ rhq-users mailing list rhq-users@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/rhq-users
This email and/or any documents in this transmission is intended for the addressee(s) only and may contain legally privileged or confidential information. Any unauthorized use, disclosure, distribution, copying or dissemination is strictly prohibited. If you receive this transmission in error, please notify the sender immediately and return the original.
Ce courriel et tout document dans cette transmission est destiné à la personne ou aux personnes à qui il est adressé. Il peut contenir des informations privilégiées ou confidentielles. Toute utilisation, divulgation, distribution, copie, ou diffusion non autorisée est strictement défendue. Si vous n'êtes pas le destinataire de ce message, veuillez en informer l'expéditeur immédiatement et lui remettre l'original.
rhq-users@lists.stg.fedorahosted.org