2010/12/11

Cheapass Host Profile

Small project I am working on. It is java based, so you will need to install it (see the previous post on howto use the cheapass host profile on your vma)

Cheapass host profile isn't a full replacement for Host profile. Instead it allows you to create one xml with a lot of setting in it which you can the use to generate host specific configuration scripts. You can download the package from https://sites.google.com/site/tendertechie/home/chp.tar.gz?attredirects=0&d=1

When you download the tar you will need to extract it using the following command
tar -xzvf chp.tar.gz
This will create a subdirectory cheaphostprofile. Enter it by executing
cd cheaphostprofile


In the directory there a two important things. First of all the config.xml. This is an example xml of all possible "configurations" at this point. The xml is quite easy to understand. The other thing in the directory is the run script. If you run this command a script directory should be generated with a script for each esx host you specified and a runall script to run all the other scripts. Execute it by executing the following command
./run

In the backend, the cheaphostprofile is just a "wrapper" around fmpp. This is a template engine. The added value of cheaphostprofile is the preconfigured template for a script executable in a vMA. For more information about the fmpp, go to there website (lmgtfy). The template is under chp/src/autoconfig.cfg .

Installing jre on vMA

Title says it all! I needed some java on my vMA (for a purpose I'll blogging about later on). First of all getting the JRE. You can download it from
You will need the x64 rpm

I transfered the binary to my vMA via scp, but ofcourse any other method like wget for http transfers or ftp will do.

After I got it on my vMA I chmodded it
chmod +x jre-6u22-linux-x64-rpm.bin.sh
This makes it "executable"

Then I ran the executable
sudo ./jre-6u22-linux-x64-rpm.bin.sh
You will need to enter your password so you can execute the install as root (admin)

When the installation is done, you will need to configure the JAVA_HOME variable. You can do this by executing
sh -c 'echo "export JAVA_HOME=/usr/java/latest/" >> /etc/profile'

Logging out and in should then complete the installation

2010/12/08

Youtube API via Javascript and XML

Very quick post because I am no longer in the mood of writing anything, but I just wanted to share this with the world :)

Probably full of bugs and so on but I was "just" (5hours) having fun with some javascript youtube hacking. Here is the code http://users.telenet.be/narcose/yt/youtubequery.html

You can find everything you need in http://users.telenet.be/narcose/yt/ . Most interesting is probably the json response you can use to get more data out of the queries.

(Important, you will need to upload the html to a webserver because otherwise some callbacks from flash won't work as they would be redirected to local files and this is not allowed for some reason. Also, my code only seems to work in Safari/Firefox!)

2010/12/01

Netextender corrupts mDNSResponder

A great way to start the day. My boss had some problems with his mac today. He wasn't able to surf at all. I checked all the layers and stranded at the highest level :).
  • nslookup www.google.com resolved the domain (same with dig)
  • ping 8.8.8.8 replied
  • ping www.google.com did not reply (can not resolve hostname)
  • internet in a VM worked correctly
I was quite sure that it had something to do with the way Mac OS X resolved the domain names. I also quickly learned that mDNSresponder is responsible for DNS since 10.6.4. Focusing on that I stumbled onto an article where NetExtender corrupts the xml that the services uses to boot. Since we were using NetExtender I thought I should give it a shot. First of all I copied my own xml from my working mac to a usb stick
sudo cp /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist /Volumes/stickname/

I then went in console at my boss computer (spotlight > terminal) and executed the sudo su command to enter root mode , the sh# prompt should appear. I entered the correct directory
  • cd /System/Library/LaunchDaemons/
and checked the files
  • ls -al com.apple.mDNSResponder*
This showed up 3 files, the regular plist file an nxbk file and the helper file which is not important.

I then compared the nxbk file and the regular file with the one back upped from my computer by using diff
  • diff com.apple.mDNSResponder.plist /Volumes/stickname/com.apple.mDNSResponder.plist
  • diff com.apple.mDNSResponder.plist.nxbk /Volumes/stickname/com.apple.mDNSResponder.plist
The nxbk file made by netextender before altering the plist was completely the same as the one I had on my USB stick. I decided that netExtender had corrupted the plist file so shut down the service, copying back the backup and relaunching the service could be a solution. So I executed the following (actually I backed up the files by cping them to /Users/someuser/)
  • launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
  • rm com.apple.mDNSResponder.plist
  • mv com.apple.mDNSResponder.plist.nxbk com.apple.mDNSResponder.plist
  • launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
After that everything was working again.

BTW here is an output of my plist



2010/11/29

ESX disconnects from vCenter and Corrupt IBM ESXi embedded sticks

Sometime ago I was installing a vCenter and connecting the the ESX hosts. The host kept disconnecting after 1 minute or something. Reconnecting helped for 1 minute. The problem? I thought I disabled the firewall but this wasn't the case. The firewall was blocking the incoming connections. Disabling the firewall completely solved the problem. This leaves me to believe that the heart-beating is done in all directions ESX to ESX but also ESX to vCenter and vice versa ... interesting.

Another great thing I encountered is a corrupted ESXi embedded IBM USB stick. The ESX hosts was asking for a Diagnostic dump partition. This was strange because I worked with the sticks before and they never needed one (dumping on a local partition / vicfg-dumpart -l to show). Also installing the VMware tools was giving errors about missing the cd's. Watching under the / root partition (unsupported mode/ls -al) was not showing the /store partition. After examining a "working" and a "non-working" ESXi and comparing the fdisk -l output, I noticed that a partition was missing. I reinstalled the ESXi with the recovery cd that you get when buying the embedded USB keys, fixed the problem.

I attached some screenshots so you can see the differences. The last partition (store partition was missing 615 to 900)





2010/11/16

XMLHttpRequest not refreshing

I have been playing for some days now with writing some interacting javascript (dynamic forms and so on). Although I already did that in the past I had never played around with the XMLHttpRequest object. To overcome that I tried the XMLHttpRequest so that I could split up data from the javascript code.

One thing I noticed was that the xml request was cached by IE. I tried refreshing the page but this didn't help. The only thing I could do was surf manually to the xml and refresh it so that the cache was updated. This ofcourse was not acceptable. I found two solutions that worked for me.

The first solution was creating a hidden iframe that showed the xml. When you refresh the page, it also refreshes the iframe and thus the cache is updated. Not elegant but it works for not so dynamic pages. Here is an example

<div style="visibility:hidden;display:none"><iframe src="http://tendertechie.tries.technology.com/myxml.xml" id="resframe"></iframe></div>

*** btw if you want to post html code like this but don't want it to be interpreted on blogger.com, you can change the lesser then sign < by the html equivalent &lt; and ofcourse the > by &gt; . To show this code again I used &ampgt; :D


The second one I came up with was while I was driving my car. I was thinking about an old webbased game I used to play (http://cq2.speedxs.nl/indexnl.php). I remembered that while traveling, the webmaster added a ?move=c first in the url and then a ?move=q for the following request. The pattern was constantly alternating. This allowed the page to be refreshed without having caching problems. When I came home I tried to add ?upd=randomdata to my xml url and see if it would display the data correctly (this was the case). This led me to believe that I could refresh the data by adding random new data every time I requested an xml. And was is more "random" then time (read is always different). I came up with the following code

function getXMLDocViaMethod(url,method,reload)
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if(reload)
{
var d = new Date();
url = url+"?updch="+d.getTime();
}
xmlhttp.open(method,url,false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
return xmlDoc;
}

If you want to read more about xmlhttprequest, I suggest using the w3schools site. They have good examples that you can interactively try out. Here is a quick link!

2010/10/24

MOB

I have always been a big scripting fan. Scripts make the IT-admin-life so much easier. That is why I always am shocked when IT guys say they hate scripting.

When ESX 4.1 was released I was very happy to hear that VMware is now supporting kickstart scripting in ESXi. Trying it out, I found liam his article about kickstart scripting ESXi (http://www.virtuallyghetto.com/2010/09/automating-esxi-41-kickstart-tips.html). If you don't know liam, you have been living under a rock. This guy is one of the best vmware scripters out there and is quite famous for his perl linkedclone script.

One of the cool things he mentions is tip 7 on how to execute vi api commands via the mob web interface. Playing around with it I made some -hopefully useful- scripts for everybody to play with.
  • date.py : set the date and time
  • dns.py : to set your hostname,dns servers, domain and searchdomains
  • domain.py : join your ESXi hosts to a domain
  • maintmode.py : to enter/exit maintenaince mode
  • gateway.py : to alter your gateway
  • service.py : to start/stop/auto on or off a service like for example ntpd
  • ntp.py : configure ntp servers and on or off of the service
The scripts use the simplymob.py to do the webhandling (so that i didn't have the copy it all over again). The script has to be in the same location of the script you are using.

You can find all the files here