<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 18, 2013 at 12:05 PM, Valentin Bud <span dir="ltr"><<a href="mailto:valentin.bud@gmail.com" target="_blank">valentin.bud@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Carlos,<div><br></div><div>I would gladly open a request if you and others from the community think this is useful.</div>


<div>I see this topic as a Request For Comments :-). </div><div>
<br></div><div>For me the NAME of the VM would prove useful to be available within CONTEXT. The NAME being the `onetemplate instantiate 8 --name NAME`</div><div><br></div><div>This way I could have the following template which the users could use:</div>



<div><br></div><div><div><div>CONTEXT=[</div><div>  CONTEXT_FILES_LOCATION="$CONTEXT_FILES_LOCATION",</div><div>  DOMAIN="$DOMAIN",</div><div>  FILES="$CONTEXT_FILES_LOCATION/$FQDN/ssh_host_rsa_key</div>



<div>  $CONTEXT_FILES_LOCATION/$FQDN/ssh_host_rsa_key.pub",</div><div>  FQDN="$HOSTNAME.$DOMAIN.",</div><div>  HOSTNAME="$HOSTNAME" ]</div><div>CONTEXT_FILES_LOCATION="/var/lib/cloud/context"</div>



<div>CPU="1"</div><div>DISK=[</div></div><div>  IMAGE="debian6-stable" ]</div><div>DISK=[</div><div>  IMAGE="vdb.$HOSTNAME.$DOMAIN" ]</div><div><div>DOMAIN="domain.tld"</div>
<div>GRAPHICS=[</div>
<div>  LISTEN="0.0.0.0",</div><div>  TYPE="vnc" ]</div></div><div>** HOSTNAME="$NAME"  **</div><div>MEMORY="2048"</div><div>NIC=[</div><div>  NETWORK="dev.domain.tld" ]</div>


<div><div>
OS=[</div><div>  ARCH="x86_64" ]</div><div>VCPU="4"</div><div><br></div></div><div>From Sunstone, at instantiation time you are asked to give the VM a name. That NAME could be used in the template also. Maybe NAME is not the proper way for this variable. </div>


</div></div></blockquote><div><br></div><div>I meant that maybe NAME is not the proper name for this variable. Another question would be: could I use a variable, DB_NAME for example, in the template and reference that from within IMAGE? I will try this today and come back with the results.</div>


<div><br></div><div>DB_NAME=dbtest</div><div style>HOSTNAME=$DB_NAME</div><div><br></div><div>DISK=[</div><div style>  IMAGE="vdb.$DB_NAME.domain.tld ]</div><div style><br></div><div style>I am trying to simplify the instantiation process for the users by providing the template and creating the second disk on the fly. In this way the user would only change the DB_NAME to a given name and everything would happen automagically behind the scenes.</div>

<div style><br></div><div style>For now, the user needs to clone a persistent image for the second disk, change the $HOSTNAME and the name of the second disk to the one previously cloned. After this two steps the user can instantiate the new VM. This process is prone to human errors. </div>

<div style><br></div><div style>If I could save the second disk and reference the DB_NAME from within IMAGE I would restrict all the attributes from the template besides DB_NAME and the process would be less prone to errors.</div>

<div style><br></div><div style>Does the above make any sense?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>
<div><br></div><div>The above applies to my use case. In my case each project I run on top of OpenNebula is a (sub)domain. </div><div><br></div><div>The above would ease the process of instantiating a new VM. Maybe I could even use a hook to create the second image on the fly at CREATE time, though I think OpenNebula would complain that the disk is missing. Haven't tested this yet. </div>


</div></div></blockquote><div><br></div><div>I am off the track here. It would be nice to be able to save the Volatile disks. In my use case we need to preserve the disk on which the DB lives for accounting purposes. I don't see a point in reinventing the wheel with a hook. </div>

<div><br></div><div style>Thanks for your input on this matter. </div><div style>Cheers and Goodwill,</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>
</div><div><br></div><div>Thoughts? Thanks.</div><div><br></div><div>Cheers and Goodwill,</div><div class="gmail_extra"><div><div><br><br><div class="gmail_quote">On Fri, May 17, 2013 at 4:47 PM, Carlos Martín Sánchez <span dir="ltr"><<a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I'm glad you found a way to make it work.</div><div><br></div><div>If it is really needed, we could add support to reference other context attributes. Please open a request If you still think it would be better.</div>





<div><br></div><div>Cheers,</div><div>Carlos</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">--<br>Join us at <a href="http://opennebulaconf.com" target="_blank">OpenNebulaConf2013</a> in Berlin, 24-26 September, 2013<br>





--<div>Carlos Martín, MSc<br>Project Engineer<br>OpenNebula - The Open-source Solution for Data Center Virtualization<div><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="http://www.OpenNebula.org" target="_blank">www.OpenNebula.org</a> | <a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a> | <a href="http://twitter.com/opennebula" target="_blank">@OpenNebula</a></span><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="mailto:cmartin@opennebula.org" style="color:rgb(42,93,176)" target="_blank"></a></span></div>





</div></div></div>
<br><br><div class="gmail_quote"><div><div>On Thu, May 16, 2013 at 2:14 PM, Valentin Bud <span dir="ltr"><<a href="mailto:valentin.bud@gmail.com" target="_blank">valentin.bud@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>

Hello Community,<br>
<br>
First of all, I apologise I forgot to say hi in my previous E-Mail :|.<br>
<div><div><br>
On Thu, May 16, 2013 at 10:28:14AM +0300, Valentin Bud wrote:<br>
> I am trying to reference the CONTEXT variables from within CONTEXT.<br>
><br>
> For example, I define the DOMAIN="domain.tld" and the HOSTNAME="host".<br>
> I would like to have a variable FQDN="$HOST.$DOMAIN.".<br>
><br>
> I have tried to achieve the above using the following in CONTEXT section<br>
> of the template.<br>
><br>
> Case I<br>
> --<br>
><br>
> $ onetemplate show vars<br>
><br>
> TEMPLATE CONTENTS<br>
> CONTEXT=[<br>
>   DOMAIN="domain.tld",<br>
>   FQDN="$DOMAIN.$HOSTNAME.",<br>
>   HOSTNAME="host" ]<br>
><br>
> [... output omitted for brevity ...]<br>
><br>
> Instantiating the template results in the following variables added to<br>
> the VM.<br>
><br>
> $ onevm show vars<br>
><br>
> VIRTUAL MACHINE TEMPLATE<br>
> CONTEXT=[<br>
>   DISK_ID="1",<br>
>   DOMAIN="domain.tld",<br>
>   *FQDN="..",*<br>
>   HOSTNAME="host",<br>
>   TARGET="hda" ]<br>
><br>
> Case II<br>
> --<br>
><br>
> $ onetemplate show vars<br>
><br>
> CONTEXT=[<br>
>   DOMAIN="domain.tld",<br>
>   FQDN="$CONTEXT[$DOMAIN].$CONTEXT[$HOSTNAME].",<br>
>   HOSTNAME="host" ]<br>
> [... output omitted for brevity ...]<br>
><br>
> Same result in the VM.<br>
><br>
> $ onevm show vars<br>
><br>
> VIRTUAL MACHINE TEMPLATE<br>
> CONTEXT=[<br>
>   DISK_ID="1",<br>
>   DOMAIN="domain.tld",<br>
>   *FQDN=".."*,<br>
>   HOSTNAME="host",<br>
>   TARGET="hda" ]<br>
> [... output omitted for brevity ...]<br>
><br>
> Is it possible to achieve what am I trying or should I search for a new<br>
> solution?<br>
><br>
> I have a simple use case. I am generating, via a hook, the ssh keys for<br>
> the VM in question. At boot I copy the keys from /mnt to /etc/ssh via<br>
> a crafted one-context script. Awesome mechanism by the way :-).<br>
><br>
> I am generating the keys in<br>
> CONTEXT_FILES_LOCATION=/var/lib/cloud/context/host.domain.tld.<br>
><br>
> I would like to use the following in the CONTEXT section:<br>
><br>
> CONTEXT=[<br>
> CONTEXT_FILES_LOCATION=/var/lib/cloud/context/host.domain.tld./,<br>
> DOMAIN="domain.tld",<br>
> FILES="$CONTEXT_FILES_LOCATION/$FQDN/ssh_host_rsa_key ...",<br>
> HOSTNAME="host",<br>
> FQDN="$HOSTNAME.$DOMAIN." ]<br>
><br>
> This makes the template much more dynamic. I would just change the HOSTNAME<br>
> and the paths would get generated dynamically.<br>
><br>
<br>
</div></div>Writing the HOSTNAME, DOMAIN, CONTEXT_FILES_LOCATION outside the CONTEXT<br>
section and referencing them from within CONTEXT works :-).<br>
<br>
Example<br>
<div>--<br>
<br>
$ onetemplate show vars<br>
<br>
TEMPLATE CONTENTS<br>
CONTEXT=[<br>
</div>  CONTEXT_FILES_LOCATION="$CONTEXT_FILES_LOCATION",<br>
  DOMAIN="$DOMAIN",<br>
  FILES="$CONTEXT_FILES_LOCATION/$FQDN/ssh_host_rsa_key<br>
  $CONTEXT_FILES_LOCATION/$FQDN/ssh_host_rsa_key.pub",<br>
  FQDN="$HOSTNAME.$DOMAIN.",<br>
  HOSTNAME="$HOSTNAME" ]<br>
CONTEXT_FILES_LOCATION="/var/lib/cloud/context"<br>
CPU="1"<br>
DISK=[<br>
  IMAGE="vars" ]<br>
DOMAIN="domain.tld"<br>
GRAPHICS=[<br>
  LISTEN="0.0.0.0",<br>
  TYPE="vnc" ]<br>
HOSTNAME="host"<br>
MEMORY="2048"<br>
NIC=[<br>
  NETWORK="host.domain.tld" ]<br>
OS=[<br>
  ARCH="x86_64" ]<br>
VCPU="4"<br>
<br>
After instantiating the machine I have the desired results.<br>
<div><br>
$ onevm show vars<br>
<br>
VIRTUAL MACHINE TEMPLATE<br>
CONTEXT=[<br>
</div>  CONTEXT_FILES_LOCATION="/var/lib/cloud/context",<br>
  DISK_ID="1",<br>
  DOMAIN="<a href="http://dev.corview.de" target="_blank">dev.corview.de</a>",<br>
  FILES="/var/lib/cloud/context//ssh_host_rsa_key<br>
  /var/lib/cloud/context//ssh_host_rsa_key.pub",<br>
  FQDN="vars.domain.tld.",<br>
  HOSTNAME="vars",<br>
  TARGET="hda" ]<br>
<br>
Now I can easily generate SSH host keys for each machine if this wasn't<br>
done already in a previous VM instantation.<br>
<br>
Thanks and sorry for the noise. If this is mentioned somewhere in the<br>
docs, my bad.<br>
<div><br>
Cheers and Goodwill,<br>
<br>
--<br>
Valentin Bud<br>
</div><a href="http://databus.pro/" target="_blank">http://databus.pro/</a> | <a href="mailto:valentin@databus.pro" target="_blank">valentin@databus.pro</a><br>
</div></div><div><div>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org" target="_blank">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
</div></div></blockquote></div><br></div>
</blockquote></div><br></div></div>--
</div><div class="gmail_extra">Valentin Bud</div><div class="gmail_extra"><a href="http://databus.pro" target="_blank">http://databus.pro</a> | <a href="mailto:valentin@databus.pro" target="_blank">valentin@databus.pro</a></div>

</div></blockquote></div></div></div>