<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div><span>Hi Javier,</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>Thanks for the example with using $NAME in the SET_HOSTNAME context variable that for sure helps not having one template per VM. Although I already see the next problem, you can't have spaces in your VM name but that's a detail :) </span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida
Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>I totally agree regarding the dynamic hostname based on the PTR DNS record of the VM, it should not be a default but only activated through a context variable, like you mention DNS_HOSTNAME variable is fine. Right now no other ideas just as simple as possible by doing a reverse lookup on the first/main IP of the VM should be enough I would say.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica
Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>I guess the "host" command would be the one which should always be available. I have seen cases where there was no "dig" installed on a base linux installation and "nslookup" is sort of fading out. In the worst case if the host command does not exist nothing happens or it could fallback to dig.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>Greetings,</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida
Grande,sans-serif; background-color: transparent; font-style: normal;"><span>ML<br></span></div><div style="display: block;" class="yahoo_quoted"> <br> <br> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Thursday, February 27, 2014 4:27 PM, Javier Fontan <jfontan@opennebula.org> wrote:<br> </font> </div> <div class="y_msg_container">On Thu, Feb 27, 2014 at 2:13 PM, ML mail <<a shape="rect" ymailto="mailto:mlnospam@yahoo.com" href="mailto:mlnospam@yahoo.com">mlnospam@yahoo.com</a>> wrote:<br clear="none"><br clear="none">> You are right I had to define the HOSTNAME variable in the template context<br clear="none">> and not as a tag in the already running VM. This means that I can't share<br
clear="none">> templates among VMs, which is a bit stupid of course. With this solution you<br clear="none">> need one template per VM.<br clear="none"><br clear="none">Not exactly. The value of custom variables can be a dynamic one [1] so<br clear="none">for example you can set the hostname to the name of the VM:<br clear="none"><br clear="none">SET_HOSTNAME="$NAME"<br clear="none"><br clear="none">or even a mix of static and dynamic data:<br clear="none"><br clear="none">SET_HOSTNAME="$NIC[IP].domain.com"<br clear="none"><br clear="none">[1] <a shape="rect" href="http://docs.opennebula.org/stable/user/virtual_machine_setup/cong.html#using-template-variables" target="_blank">http://docs.opennebula.org/stable/user/virtual_machine_setup/cong.html#using-template-variables</a><br clear="none"><br clear="none">> I see the issue with the HOSTNAME environment variable which is actually set<br clear="none">> at bootup of Linux so no problem with me
for using a name such as<br clear="none">> SET_HOSTNAME like you suggest.<br clear="none"><br clear="none">Good, I'll go with this.<br clear="none"><br clear="none">> What do you think about having that same script also defining the hostname<br clear="none">> dynamically (if none was defined with the SET_HOSTNAME context variable)<br clear="none">> based on a DNS reverse lookup if the IP address of the VM has a PTR record?<br clear="none"><br clear="none">I think it's a nice feature but it should only be set if the users<br clear="none">asks for it. For example, if some VM has a hardcoded hostname a user<br clear="none">does not expect it to be changed in case SET_HOSTNAME is not defined.<br clear="none">Another variable can be added like DNS_HOSTNAME=yes or even better,<br clear="none">specifying the IP where to get the name from:<br clear="none"><br clear="none">DNS_HOSTNAME="$NIC[IP, NETWORK=\"Public\"]"<br clear="none"><br
clear="none">Any better idea?<br clear="none"><br clear="none">I'm not sure which command to use to do the reverse lookup. One that<br clear="none">is in most of the distributions like host, nslookup or dig.<br clear="none"><br clear="none">Cheers<br clear="none"><br clear="none">><br clear="none">><br clear="none">><br clear="none">> On Thursday, February 27, 2014 12:27 PM, Javier Fontan<br clear="none">> <<a shape="rect" ymailto="mailto:jfontan@opennebula.org" href="mailto:jfontan@opennebula.org">jfontan@opennebula.org</a>> wrote:<br clear="none">> Hi,<br clear="none">><br clear="none">> ML, I think you should add it in the template context section, custom<br clear="none">> variables.<br clear="none">><br clear="none">> I am adding scripts to configure the hostname in the context phase.<br clear="none">> These are simple scripts (one for rpm and other for deb based distros)<br clear="none">> that do just
what you've commented, call hostname and modify the conf<br clear="none">> file. [1]<br clear="none">><br clear="none">> I've just found a problem with it and it is calling the configuration<br clear="none">> variable "HOSTNAME". The shell automatically sets HOSTNAME and even if<br clear="none">> we don't specify it so it's a bit tricky to check wether the user<br clear="none">> intents to configure the hostname or leave it as it is.<br clear="none">><br clear="none">> I am proposing to use the custom variable "SET_HOSTNAME" to configure<br clear="none">> the host name. What do you think?<br clear="none">><br clear="none">> Concerning the addition of scripts in the context package, there is a<br clear="none">> guide in both the documentation [2] and the source code [3] on how to<br clear="none">> create custom packages. Having the required dependencies it's fairly<br clear="none">> easy to add or modify the
configuration script you may need.<br clear="none">><br clear="none">> Cheers<br clear="none">><br clear="none">> [1] <a shape="rect" href="http://dev.opennebula.org/issues/2453" target="_blank">http://dev.opennebula.org/issues/2453</a><br clear="none">> [2]<br clear="none">> <a shape="rect" href="http://docs.opennebula.org/stable/user/virtual_machine_setup/cong.html#generating-custom-contextualization-packages" target="_blank">http://docs.opennebula.org/stable/user/virtual_machine_setup/cong.html#generating-custom-contextualization-packages</a><br clear="none">> [3]<br clear="none">> <a shape="rect" href="https://github.com/OpenNebula/one/tree/master/share/scripts/context-packages" target="_blank">https://github.com/OpenNebula/one/tree/master/share/scripts/context-packages</a><br clear="none">><br clear="none">> On Thu, Feb 27, 2014 at 8:02 AM, ML mail <<a shape="rect" ymailto="mailto:mlnospam@yahoo.com"
href="mailto:mlnospam@yahoo.com">mlnospam@yahoo.com</a>> wrote:<br clear="none">>> Regarding the hostname script that's exactly what I did, I also tried to<br clear="none">>> redeploy this persistent image. Where exactly did you set the HOSTNAME<br clear="none">>> variable? I have setted it in the tags of that specific VM (where I would<br clear="none">>> also add the SSH_PUBLIC_KEY variable). But that might be wrong?<br clear="none">>><br clear="none">>> Regards,<br clear="none">>> ML<br clear="none">>><br clear="none">>><br clear="none">>> On Thursday, February 27, 2014 2:47 AM, "Campbell, Bill"<br clear="none">>> <<a shape="rect" ymailto="mailto:bcampbell@axcess-financial.com" href="mailto:bcampbell@axcess-financial.com">bcampbell@axcess-financial.com</a>> wrote:<br clear="none">>> For item 1, no that should do it, just make sure it's executable and it<br
clear="none">>> should run. (the vmcontext init.d script will run all scripts in the<br clear="none">>> /etc/one-context.d directory in order). I set this up for Ubuntu, but I'm<br clear="none">>> pretty sure Debian is the same when it comes to setting the hostname. You<br clear="none">>> mention you reboot the VM, you may have to redeploy (as the context script<br clear="none">>> is already generated from your previous deployment package).<br clear="none">>><br clear="none">>> For item 2, you could include it in your base image, or in the example<br clear="none">>> provided, add it to the files repository along with that init.sh script,<br clear="none">>> and<br clear="none">>> then assign both files to the template. This way the files will be<br clear="none">>> included<br clear="none">>> with the context information, will copy the ##-script over to the<br
clear="none">>> instance,<br clear="none">>> and restart the vmcontext service.<br clear="none">>><br clear="none">>> ________________________________<br clear="none">>> From: "ML mail" <<a shape="rect" ymailto="mailto:mlnospam@yahoo.com" href="mailto:mlnospam@yahoo.com">mlnospam@yahoo.com</a>><br clear="none">>> To: "users" <<a shape="rect" ymailto="mailto:users@lists.opennebula.org" href="mailto:users@lists.opennebula.org">users@lists.opennebula.org</a>><br clear="none">>> Sent: Wednesday, February 26, 2014 11:12:08 AM<br clear="none">>> Subject: Re: [one-users] ONE context package<br clear="none">>><br clear="none">>> Hi Bill,<br clear="none">>><br clear="none">>> Thanks for your answer and example scripts. I have a few more questions or<br clear="none">>> issues regarding your examples:<br clear="none">>><br clear="none">>> - I tried out your small
hostname script which I have copied on my Debian<br clear="none">>> 7<br clear="none">>> VM under /etc/one-context.d/98-hostname. I have then set in my VM a tag<br clear="none">>> called HOSTNAME with a value and rebooted the VM. Unfortunately the<br clear="none">>> hostname<br clear="none">>> did not get changed. Did I miss something here?<br clear="none">>><br clear="none">>> - I suppose I would have to re-create the one-context package manually if<br clear="none">>> I<br clear="none">>> would like to include the aforementioned 98-hostname script in the<br clear="none">>> official<br clear="none">>> one-context package, correct? or I could manually copy it into my image<br clear="none">>> before deploying it?<br clear="none">>><br clear="none">>> Regards,<br clear="none">>> ML<br clear="none">>><br clear="none">>><br clear="none">>><br
clear="none">>> On Wednesday, February 26, 2014 3:08 PM, "Campbell, Bill"<br clear="none">>> <<a shape="rect" ymailto="mailto:bcampbell@axcess-financial.com" href="mailto:bcampbell@axcess-financial.com">bcampbell@axcess-financial.com</a>> wrote:<br clear="none">>> We don't have the automatic lookup from DNS (that would rely on the DNS<br clear="none">>> record being created first prior to VM deployment), but we use a script<br clear="none">>> that<br clear="none">>> is placed in our base images /etc/one-context.d/ directory that does this<br clear="none">>> (which relies on option 2 as you mention below, a HOSTNAME context<br clear="none">>> variable):<br clear="none">>><br clear="none">>> #!/bin/bash<br clear="none">>><br clear="none">>> if [ -f /mnt/context.sh ]; then<br clear="none">>> . /mnt/context.sh<br clear="none">>> else<br clear="none">>> exit 0<br
clear="none">>> fi<br clear="none">>> hostname $HOSTNAME<br clear="none">>> echo $HOSTNAME > /etc/hostname<br clear="none">>><br clear="none">>> exit 0<br clear="none">>><br clear="none">>> The above example is for our Ubuntu instances, so it may need to be<br clear="none">>> modified<br clear="none">>> for RHEL or SUSE based virtuals, if that's what you use.<br clear="none">>><br clear="none">>> In addition, if using 4.4, use the files datastore and create an 'init.sh'<br clear="none">>> script that can then load up additional files that you assign to the<br clear="none">>> template (so you don't need to manually update each image). We use an<br clear="none">>> init.sh script like this to inject new configuration/contextualization<br clear="none">>> options so we don't need to update our base image very often:<br clear="none">>><br
clear="none">>><br clear="none">>> #!/bin/sh<br clear="none">>> #<br clear="none">>> # OpenNebula Init Script<br clear="none">>> #<br clear="none">>> # init.sh<br clear="none">>> #<br clear="none">>> # Copies additional context scripts to the appropriate directory<br clear="none">>> #<br clear="none">>> ## Set environment<br clear="none">>> SOURCE=/mnt<br clear="none">>> DEST=/etc/one-context.d<br clear="none">>><br clear="none">>> if [ -f /etc/redhat-release ]; then<br clear="none">>> OSVERSION=RHEL<br clear="none">>> else<br clear="none">>> OSVERSION=UBUNTU<br clear="none">>> fi<br clear="none">>> if [ -f /usr/bin/rsync ]; then<br clear="none">>> echo "Applying additional contextualization scripts..."<br clear="none">>> else<br clear="none">>> if [ "$OSVERSION" != "UBUNTU" ]; then<br clear="none">>> yum -y install
rsync<br clear="none">>> else<br clear="none">>> apt-get update && apt-get -y install rsync<br clear="none">>> fi<br clear="none">>> fi<br clear="none">>><br clear="none">>> ## Copy Files. This will IGNORE any *.sh files in the source/destination<br clear="none">>> directories, as all context scripts<br clear="none">>> ## should NOT have the .sh extension.<br clear="none">>> for i in $(ls $SOURCE --ignore=*.sh)<br clear="none">>> do<br clear="none">>> if [ -f $DEST/$i ]; then<br clear="none">>> echo "$i exists in context directory. Skipping..."<br clear="none">>> else<br clear="none">>> rsync -au $SOURCE/$i /etc/one-context.d/<br clear="none">>> chown root.root /etc/one-context.d/*<br clear="none">>> chmod 700 /etc/one-context.d/*<br clear="none">>> service vmcontext restart<br clear="none">>> fi<br clear="none">>> done<br
clear="none">>> exit 0<br clear="none">>><br clear="none">>> This will check the OS Version and install the appropriate package. It<br clear="none">>> will<br clear="none">>> NOT copy any file that has the .sh extension, but if you follow the<br clear="none">>> context<br clear="none">>> script standard of ##-<scriptname> then you can add additional context<br clear="none">>> upon<br clear="none">>> deployment. Rudimentary, sure, but works well enough for us.<br clear="none">>><br clear="none">>><br clear="none">>> ________________________________<br clear="none">>> From: "ML mail" <<a shape="rect" ymailto="mailto:mlnospam@yahoo.com" href="mailto:mlnospam@yahoo.com">mlnospam@yahoo.com</a>><br clear="none">>> To: <a shape="rect" ymailto="mailto:users@lists.opennebula.org" href="mailto:users@lists.opennebula.org">users@lists.opennebula.org</a><br
clear="none">>> Sent: Wednesday, February 26, 2014 5:39:46 AM<br clear="none">>> Subject: [one-users] ONE context package<br clear="none">>><br clear="none">>> Hi,<br clear="none">>><br clear="none">>> I am very happy with the ONE context package for automated<br clear="none">>> contextualization<br clear="none">>> on Debian and CentOS but I miss one feature: automatically and manually<br clear="none">>> setting the hostname of the VM.<br clear="none">>><br clear="none">>> Basically it would be great to have the following two options:<br clear="none">>><br clear="none">>> - automatically set the hostname of the VM based doing a reverse DNS<br clear="none">>> lookup<br clear="none">>> on the IP address, for example I have as reverse DNS entry<br clear="none">>> "one-vm-1-0-16-172.mydomain.com" then the hostname of my VM would be<br clear="none">>>
automatically set to "one-vm-1-0-16-172".<br clear="none">>> - using a HOSTNAME tag in the VM to manually enter a hostname and<br clear="none">>> overriding<br clear="none">>> the automatic hostname attribution described above<br clear="none">>><br clear="none">>> What do you think?<br clear="none">>><br clear="none">>> Regards,<br clear="none">>> ML<br clear="none">>><br clear="none">>> _______________________________________________<br clear="none">>> Users mailing list<br clear="none">>> <a shape="rect" ymailto="mailto:Users@lists.opennebula.org" href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br clear="none">>> <a shape="rect" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br clear="none">>><br clear="none">>><br clear="none">>>
NOTICE: Protect the information in this message in accordance with the<br clear="none">>> company's security policies. If you received this message in error,<br clear="none">>> immediately notify the sender and destroy all copies.<br clear="none">>><br clear="none">>><br clear="none">>> _______________________________________________<br clear="none">>> Users mailing list<br clear="none">>> <a shape="rect" ymailto="mailto:Users@lists.opennebula.org" href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br clear="none">>> <a shape="rect" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br clear="none">><br clear="none">>><br clear="none">>><br clear="none">>><br clear="none">>> _______________________________________________<br clear="none">>> Users mailing
list<br clear="none">>> <a shape="rect" ymailto="mailto:Users@lists.opennebula.org" href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br clear="none">>> <a shape="rect" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br clear="none">>><br clear="none">>><br clear="none">>> NOTICE: Protect the information in this message in accordance with the<br clear="none">>> company's security policies. If you received this message in error,<br clear="none">>> immediately notify the sender and destroy all copies.<br clear="none">>><br clear="none">>><br clear="none">>> _______________________________________________<br clear="none">>> Users mailing list<br clear="none">>> <a shape="rect" ymailto="mailto:Users@lists.opennebula.org"
href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br clear="none">>> <a shape="rect" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br clear="none">>><br clear="none">>><br clear="none">>><br clear="none">>> _______________________________________________<br clear="none">>> Users mailing list<br clear="none">>> <a shape="rect" ymailto="mailto:Users@lists.opennebula.org" href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br clear="none">>> <a shape="rect" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br clear="none">><br clear="none">>><br clear="none">><br clear="none">><br clear="none">><br clear="none">> --<br clear="none">> Javier
Fontán Muiños<br clear="none">> Developer<br clear="none">> OpenNebula - The Open Source Toolkit for Data Center Virtualization<br clear="none">> www.OpenNebula.org | @OpenNebula | github.com/jfontan<div class="yqt7998688587" id="yqtfd15517"><br clear="none">><br clear="none"><br clear="none"><br clear="none"><br clear="none">-- <br clear="none">Javier Fontán Muiños<br clear="none">Developer<br clear="none">OpenNebula - The Open Source Toolkit for Data Center Virtualization<br clear="none">www.OpenNebula.org | @OpenNebula | github.com/jfontan</div><br><br></div> </div> </div> </div> </div></body></html>