Wednesday, January 29, 2014

Understanding The PXE Boot Process

At my job, like most places, the servers we use are located in rooms or buildings other than where we are located.  Its not always feasable to be "AT" the server to do an install.  In fact, in our new environment, it is definitely not something that could happen without wasting the time to get down to the data center.

As those who have worked with HP rack mounted machines, they have an iLO (integrated Lights Out) interface to allow you to get to the machine remotely.  Its pretty nice to have this ability, I have to say, but using it does take a bit of learning the interface (which means keeping a reference list of commands is truly handy).

When we start up a machine for the first time, the only thing that the machine knows about itself is its MAC address, so when we turn it on, it broadcasts for a DHCP address.  Our DNS server picks up the request, matches the MAC to an entry in its tables and throws the assigned IP at the machine.

I know this article is about the PXE boot process, but I wanted to at least back up a touch and start at the beginning of our process.   The reason I did this is because of the MAC address.  Its actually quite important in the PXE boot process.  PXE is actually an acronym that stands for Preboot Execution Environment.  While there are a number of ways to network boot, this article only covers this method (as this is what we are using).  The reason I am covering this is because when you are in an environment that uses PXE booting along with things like kickstart, cobbler and puppet to get machines up, running and installed (as we do), then understanding each part of the process is critical for troubleshooting any issues that arise. 

In order to do PXE booting, you need a NIC that is PXE capable.  The reason for this is that PXE makes the NIC act as a boot device.  When you turn on the machine (whether sitting at the machine or doing it remotely, you need to watch the boot process and at the appropriate time, select to network boot.  Depending on what type of machine your on, your options will probably different so I am not going to say what key sequence you need to hit.  Simply watch the screen for the prompts.  If you miss it, reboot and try again. 

When you select network boot, the machine (actually the NIC) sends out a request to the DHCP server.  The DHCP server responds, returning an IP address for the client (that should be pre-setup) and also the address of the TFTP server and the location of the boot files on the server and the boot image (called pxelinux.0).

The machine then contacts the TFTP server, retrieves the pxelinux.0 image and executes it.  The boot image searches in the pxelinux.cfg directory on the server for boot config files that match the machine that is trying to boot.  There is an order to which the search for that file is performed:

- The first thing searched for is a file named with the MAC address of the machine.  The filename uses a '-' in place of the ':' that usually makes up a MAC address.
- If the file with the MAC is not found, then the search takes the IP of the machine, converts it to uppercase hex, which produces a string of 8 alpha-numeric characters.  The search then uses that hex string and searches for a file with that name.  If it doesn't find it, it then removes one character from the end and searches for a file with that new name.  It does this consecutively, each time removing a character from the hex string. 

Here is what the search process would look like:

/pxelinux.cfg/01-ff-aa-63-33-aa-dc
/pxelinux.cfg/D067A25B
/pxelinux.cfg/D067A25
/pxelinux.cfg/D067A2
/pxelinux.cfg/D067A
/pxelinux.cfg/D067
/pxelinux.cfg/D06
/pxelinux.cfg/D0
/pxelinux.cfg/D


If it does not find any profiles, then the boot process will then present a menu with a list of profiles (for us at least).  It should never actually get to that point.  If it does, then you need to check:

- that you have the MAC address correct in the DNS server.
- if you are using cobbler, then check that all machine information in cobbler is correct.

 I hope this allows you to better understand the PXE boot process.   I find it extremely useful. 







Monday, January 13, 2014

No Audio Via AirPlay From Macbook To Apple TV

For Christmas, my wife's work gave everyone Apple TV's.  I was excited to hook it up and play with it and in fact was quite impressed with it right off.  After playing for a bit I tried to play a movie I had on my Macbook Pro.  While the video was mirrored over to our TV via AirPlay, the audio seemed to stay with the laptop.  Talk about odd.

I tried a couple of things (disconnecting and reconnecting from AirPlay, rebooting, etc).  I then did some Googling and discovered a post on the Apple Support forums that said to run the following:

sudo killall coreaudiod

After I ran that, I was able to play the video I wanted to (via VLC Media player) AND hear the audio on the TV.  Woo Hoo!    Some reported that they had to reboot as well, but for me, I just had to run the above command before starting up VLC media player.

Best part of the forum post I found was that NOBODY from Apple Support posted the work around.  It was one of the users that had discovered it and posted it.

Thursday, January 09, 2014

Upgrade To Mac OSx 10.9.1 Breaks pip

As with any upgrade to an operating system, you need to make sure that the things you use do not break.  Unfortunately, the breaks that happen are not always immediately apparent.

I decided to start playing with virtualenv (for creating virtual environments in python).  I was following a tutorial guide on virtualenv, the first steps being to install virtualenv using pip, which I have had installed on the machine for quite some time.

I attempted to run the command to install virtualenv:

sudo pip install virtualenv
and upon doing so I was met with the following message:

Wheel installs require setuptools >= 0.8 for dist-info support.
pip's wheel support requires setuptools >= 0.8 for dist-info support.
This made my eyebrow cock a bit as I know that pip was working only a week ago when I installed a couple of modules using it.  I thought quick, trying to determine what might have changed and then I remembered the OSx upgrade that I just did.  Awesome, they broke pip.

I'll admit that I went a bit of a long way around on this one, mostly because I wanted to make sure that other things weren't broken.  I thought quick about what, other than pip, I used to install things.  There is easy_install and also brew.

I decided to try 'sudo easy_install --upgrade pip' to see if that would resolve my pip issues.  It kindly told me it was already the most current verstion.   Awesome.

I then ran a 'brew update'.  Formulas were updated, but nothing major.  I then ran 'brew doctor'.  This provoded a lot more output of things.  I have a couple of apps that needed updtating, but the thing that stood out is there was also a complaint in its output about setuptools.  The output suggested running 'xcode-select --install' to resolve the setuptools issue, so I ran it.  The run took a few minutes, but did complete successfully.  I tried to again run the install command for virtualenv and STILL received the same error.  More research was obviously needed.

I Googled the error and found a StackOverflow post with the error that exactly matched what I had.  Per the most upvoted reply, I ran the following:

sudo pip install setuptools --no-use-wheel --upgrade

Then, for giggles, I started up XCode.  This immediately informed me that that there were updates that were needing to be done and applied, so I opted for them.  Once that completed, which took about 10 minutes, I went back and ran the install command for virtualenv.  Success!!!  WOO HOO!!!

The lesson here, if you upgrade, be prepared for things to break.  I found that it was my development tools that took the hit this time.  I have tested a number of other applications that I have on this machine, but nothing else seems to have any issues.  Hopefully your experience is a bit smoother.

Sunday, January 05, 2014

Modifying The Python Module Search Path

After having done a fair amount of programming in Perl, I decided a while ago that while learning Python, I wanted to not only learn the details of the language, but also make sure that I try and do things in a manner that is both easy to re-figure out later, and is also not considered an awful practice by the community.

Currently, while working on a project, I have been researching adding a directory to the module search path in Python.  While reading the module documentation, it was mentioned that one of the easiest things to do is to just add a path to the PYTHONPATH system variable.  That would be a fantastically easy thing to do, except I logged into a few different systems where I have python installed, and not one of them had that variable set.  (Those systems included both Linux and Mac OSx operating systems for those curious).

To be honest, I didn't want to venture down the path of determining all of the path's that should be set in that variable as it could be many.  So, I started up the python interpreter, imported the sys module and then printed the path like so:

> python
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path

This printed out quite a long list of path's that python used to search for modules.  So, now I needed a way to add a directory to that list, so that I could place all of the home grown modules for my project in one place and reference it in the search path.

After thinking back to a few weeks ago, I remember a method that a colleague used in a script that he had written and after doing a little testing with some of that code, came up with the following method to do what I needed to:

#!/usr/bin/env python 
import os
import sys 
modulesDir  = "lib"
prog    = os.path.abspath(__file__)
cwd     = os.path.dirname(prog)
libDir = os.path.join(cwd,modulesDir)
sys.path.append(libDir)
For the above solution, you replace "lib' with whatever you called the directory.  This assumes that you have main directory where your primary script resides, and in there is a subdirectory holding your modules.  It nicely appends that directory to your search path.  I am not sure if its the prettiest or most acceptable way to accomplish this, but it does the job.  If someone knows of a better, more acceptable way, I would definitely be interested in listening to their explanation.




Saturday, January 04, 2014

Does that site have an RSS feed?

A while ago I gave our daughter my old DroidX phone and since then, she has increased her use of it.  She now has a free texting app that she uses with her friends (not that I am completely comfortable with it, but, baby steps), and today, discovered the news widget, which grabs article title and summary from rss feeds.  

Well, I found the sites for the tween/teen magazines she reads and after examining all the different areas of each site (having my IQ drop with each link click), I determined that I really needed a more definitive way to find the rss feed links for the site(s).

So, on a whim, I opened up the page source for the main page of each site and searched for "rss".  What do you know, if there is an rss feed, its typically mentioned in there.  Good stuff to know if you have tweens/teens and need to set this stuff up for them.  


Friday, January 03, 2014

URL For This Blog

A little while ago, I purchased a domain that I liked, and that goes along with the naming of my site (ParsedContent).  Although I had bought it, I unfortunately did not have the time to implement anything with the domain.  

So, about a month ago, while doing some work before bed, I got a bug up my preverbal butt and decided to set up the domain to point to this blog.  

So, without any more ado, the URL that you can use to get to this blog is http://www.parsed.co/.  Please note that the 'www' portion is necessary as it is required by Google when setting up a URL for your blog.  If you remove it, you will get a pretty, blank white page.

Thursday, January 02, 2014

Free Hosting (a.k.a. Yes, you can use Amazon AWS for free)

When I started at the job that I have now (and absolutely love), I got my first foray into the world of Amazon AWS.  Before starting here, I did not have any experience in the cloud, but cannot say that I was not absolutely intrigued by it.  Sure I had a Dropbox account and Bitcasa account, among others, but that's not the type of cloud experience I am referring to.

Amazon AWS (which stands for Amazon Web Services) is Amazon's cloud services platform.  There are an absolutely plethora of companies that use it on a daily basis, including Amazon, which uses it for its own store.

Sure, to use it there is quite a bit of a learning curve associated, but believe it or not, its not that difficult, it just requires the time to dedicate to learn it.  Amazon keeps quite an array of documentation for you to reference and learn from, and if you or your company have enough in the budget to support it, they have training available around the country.

But, believe it or not, one does not have to spend a cent in order to get started with Amazon AWS, so long as you stay within their guidelines, which are outlined on their Free Tier page.

You could use it to setup a website (even database backed) and have it up and running for a full year before you have to pay a cent to Amazon.  That is truer than you think.  Amazon gives you 750 free hours a month of free running instance time.  Which means, unless they decide to extend the number of days in the calendar for each month, you can leave your single instance running 24x7 without going over.

Amazon has quite an incredible cloud platform to work with, but be careful, because once you start paying, if you do not monitor your activity, the bill can grow exponentially.  But that's not to say it cannot be done, it is done every day by companies that use untold amounts of amazon's services.

I hope you not only enjoyed this article, but that you let curiosity be your guide and try the cloud.  Its quite fun.
 
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.