[one-users] Template parameters arguments to hook script?
Ruben S. Montero
rsmontero at opennebula.org
Thu Aug 16 16:01:22 PDT 2012
Hi,
On Fri, Aug 17, 2012 at 12:20 AM, reeuwijk <reeuwijk at few.vu.nl> wrote:
> Hello Gary,
>
> Thanks for the reply, but as far as I know not all templates are XML yet,
> the old text format that I used in my examples is also still supported.
> Would your approach work for those too?
>
The solution described by Gary is the way to go. Although templates can be
defined in plain text, they are stored and treat (at the API level) as XML
documents.
>
> Also, I need some extra hints with respect to the DS or TM scripts you
> mention. I've tried to locate them in the OpenNebula sources, but I have
> frankly no idea what you are referring to.
>
>
To check for an example of how to extract the information from a shell
script just grep the sources for xpath.rb
> (And lastly, I am still hoping that OpenNebula has a simpler way to access
> such variables, rather than using xpath on the template file.)
>
>
It may seems to be more complicated but from a programmatic point of view
is not that bad. On the other hand, this method to pass information is much
more robust (e.g. to variables with spaces or characters with an special
meaning for the shell...) and as you can get anything is much more flexible.
> Again, thanks for your help!
>
> --
> Kees
>
> On 16 Aug 2012, at 12:20, Gary S. Cuozzo <gary at isgsoftware.net> wrote:
>
> > Hi,
> > I believe the $TEMPLATE is actually a base64 encoded version of the
> entire XML document with all the variable in it. That is how the DS/TM
> stuff works. If you look in any of the DS or TM scripts, you can
> copy/paste the xpath related lines to access any variables you want.
> >
> > If you want to see the exact structure, you can get the base64 encoded
> stream from the oned.log and run it through the base64 command to see the
> xml which is encoded.
> >
> > Something like: echo "encoded stream here" | base64
> >
> > Hope that helps. I have not used hooks, but I have used this to develop
> custom DS/TM drivers.
> > gary
> >
> >
> > ----- Original Message -----
> > From: "reeuwijk" <reeuwijk at few.vu.nl>
> > To: "opennebula users" <users at lists.opennebula.org>
> > Sent: Thursday, August 16, 2012 10:12:54 AM
> > Subject: [one-users] Fwd: Template parameters arguments to hook script?
> >
> > Hi,
> >
> > I want to pass some parameters from OpenNebula templates to a hook
> script.
> >
> > In OpenNebula 2.2 I could use something like
> >
> > CONTEXT = [
> > :
> > SERVER = "bla"
> > :
> > ]
> >
> > and then in oned.conf I could use a hook script with something like:
> >
> > VM_HOOK = [
> > arguments = " … $CONTEXT[SERVER] …"
> > ]
> >
> > and the hook script would be invoked with the value I defined in CONTEXT.
> >
> > Unfortunately, it seems that OpenNebula 3.6 does not support this any
> longer. Instead of the value defined in CONTEXT, the expression '$CONTEXT'
> is replaced with the empty string, so the hook script of the example always
> gets the string [SERVER].
> >
> > From the documentation it is not entirely clear to me whether the
> mechanism I used for 2.2 is supported at all. The webpage at
> http://opennebula.org/documentation:rel3.6:oned_conf only mentions access
> to $VMID and $TEMPLATE and nothing else, so I may have been using an
> undocumented feature of OpenNebula 2.2.
> >
> > However, limiting access to only those two variables seems overly
> restrictive to me, so for now I am assuming more is possible. But exactly
> what is allowed, and what is not?
> >
> > --
> > Kees van Reeuwijk
> >
> >
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.opennebula.org
> > http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
> > _______________________________________________
> > Users mailing list
> > Users at lists.opennebula.org
> > http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
--
Dr. Ruben Santiago Montero
Associate Professor (Profesor Titular), Complutense University of Madrid
URL: http://dsa-research.org/doku.php?id=people:ruben
Weblog: http://blog.dsa-research.org/?author=7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20120817/bd2e2c0a/attachment-0003.htm>
More information about the Users
mailing list