States rights… just not when it comes to the EPA

Let’s start this post by asking a pretty damn basic question:

Do the Republicans typically champion the rights of states or the rights of the federal government?

As any semi-informed reader may note, they Republicans consistently champion the rights of the states over that of the federal government. Oh wait. Unless it has to do with protecting the environment. Just take a look at this piece on CNN.

Bush’s cronies in his EPA “slapped down California’s bid for first-in-the-nation greenhouse gas limits on cars, trucks and SUVs, refusing the state a waiver that would have allowed those restrictions to take effect.” Specifically, it was cited that “The Bush administration is moving forward with a clear national solution — not a confusing patchwork of state rules[.]”

My ass. Bush is about as concerned with the environment as he is with retaining the credibility and prestige of the United States. This man has done absolutely nothing during his presidency but to fearmonger, destroy civil liberties, and to reduce the scope of American power and influence. Because, seriously, it’s way more important to regulate American morals than it is to lead the Free World. You squandered your opportunity, pretty boy.

Joe Biden got it right, George W. Bush, you are the most incompetent president in this country’s history.

Installing Windows xp on a xen domU

Unfortunately, even super-cool elite web 2.0 startups such as where I work have to deal with shitty browsers such as the ones made by Microsoft. (Let’s be fair, however, 99% of software churned out by the bloated Microsoft machine is shitty, not just the browsers.)So… we have to test the browsers. But wait, where do we do it? Who on earth wants to dedicate real hardware to running such lesser-born bits? No one, is the answer, but we can sacrifice a bit of space on a Xen instance to make it happen. Hence this post: How do I install Windows XP on a Xen instance?

It’s not hard, really. In my case, I’m using logical volumes via LVM to host my xen instances, so that’s what my example will outline. I’m also installing from a Windows XP CD which came with a computer no longer running such a crappy operating system. This assumes you have already created a Xen dom0 and have available space in some sort of volume group which I will call your_vg_name.

Create a logical volume to house your windows xp instance:
$ lvcreate --size 5G --name winxp01 your_vg_name

Now, in your dom0, use something like the following for your “winxp.cfg”. In my case, I have configuration for browser testing machines for ie6 and ie7. So this is an example ie6 machine config in /etc/xen:
rwoodrum@xen1test:/etc/xen$ cat ie6-01.cfg
kernel = "/usr/lib/xen-default/boot/hvmloader"
builder = 'hvm'
memory = '768'
name = "ie6-01"
vcpus = 1
vif = [ 'type=ioemu, bridge=br-xen' ]
disk = [ 'phy:/dev/xen/winxp01,ioemu:hdc,w' ,'phy:/dev/hda,ioemu:hda:cdrom,r']
device_model = '/usr/lib/xen-default/bin/qemu-dm'
cdrom='/dev/hda'
ne2000=0
boot='c'
sdl=0
vnc=1
vncviewer=1

On a debian box, make sure you have the xen-ioemu package installed.

In this example, /dev/xen/winxp01 is my logical volume. /dev/hda points to my cdrom drive where the winxp disk will boot the installer. I had difficulties in specifying this as anything other than “hda”, so give it a shot, even if your cdrom is definitely not at /dev/hda.

Once the installer boots, you should be able to connect to the “console” with a vncviewer such as krdc at the address of your dom0. Note that if you are installing multiple instances requiring the vnc console, you may have to specify a specific display. e.g. instead of just vnc://10.1.1.1, you may have to say vnc://10.1.1.1:23 if your local display is “23″. This notation uses that of krdc to address vnc clients.

Once you work through the installer, you set up the instance like normal and give it an ip address. From then on, you can simply access it via a remote desktop client and use it/destroy it to hearts content. Works great for browser testing.

I wrote this up quite a bit of time after I actually did all of this, so I realize I may have described some steps in a non-intuitive fashion. Please don’t hesitate to comment for details!

Good times with LVM snapshots

There’s a lot of good documentation out there already, but I’m going to go ahead and post this so that in 6 months or a year when I’ve forgotten it again, hopefully I’ll stumble upon my own explanation.

I was having some discussions with some people at work about more efficient database restores with mysql and at one point the discussion turned to LVM snapshots for mysql backups. I’ve used LVM for a long time but have never really used the snapshot volumes. (Now that I think of it, however, that’s something of a lie. I’ve used it to expedite building vm’s under Xen… but I digress.)

I had this conception in my head that an LVM snapshot == an LVM backup. It doesn’t. This may be a simple concept, but from all the documentation out there such as this great howtoforge writeup or the tldp documentation, one point seemed to be missing, at least for my simple brain: An LVM snapshot is NOT a backup. An LVM snapshot allows you to create a consistent backup.

So what is an LVM snapshot volume, you ask? An LVM snapshot works by creating another logical volume in the context of one that already exists. Subsequently, an exception log of i/o on the original volume is kept in the snapshot volume. This exception log is used in the context of the original logical volume to allow it to be read in a consistent state at any point in time during the life of the snapshot.

Say, for example, I have a Xen domU whose disk is on a logical volume /dev/xen/ops1test-disk. An LVM snapshot volume could be created like so:
$ sudo lvcreate --snapshot --size 1G --name test_snapshot /dev/xen/ops1test-disk

This creates a logical volume called test_snapshot (which will be in /dev/xen/test_snapshot in my case) with room for 1GB of changes to the original ops1test-disk volume. Depending on how much i/o the original volume is undergoing, this number can obviously be changed.

Now your snapshot can be mounted like normal while the original volume continues on its merry way.
$ sudo mount /dev/xen/test_snapshot /mnt

Once the snapshot volume is mounted, it will be read in a consistent state from the point in time that it is mounted. Any changes that have happened since the time of snapshot creation will be read from the exception log and any continuing changes will be noted in the exception log but won’t affect the consistent state that you’re currently reading from.

So now you can do the backup via normal means (whatever that may be). It could be done using backup software, dd, or tar, for example:
$ tar -pcvf ./test_snapshot_backup.tar.gz /mnt/test_snapshot

Once the backup is complete (or whatever else you’re doing with the snapshot), the snapshot should be removed to avoid consumption of resources. Remember that the exception log will continue until the snapshot volume is at capacity. Remove the snapshot like so:
$sudo lvremove /dev/xen/test_snapshot

Voila. Your backup is complete and consistent.

Joe Klein smackdown

As many people who may have stumbled upon this are probably aware, Joe Klein of Time Magazine (commonly known on the Time Swampland blog as Joke Line) tends to be fact challenged.

He portrays himself as an independent and sound judge of “tonedeaf” Democratic policies but pretty much is just another MSM panderer to the right.

So! It was with delight that in TWO consecutive issues of Dead Tree Time (12/17, 12/24) I saw smackdowns of his blatant disregard for accuracy by U.S. Lawmakers:

If you can stomach it, Joe’s original piece is here. Without further ado, the first smackdown:

Klein called the Democrats “Tonedeaf” for acting on the demands of the American people that we bring the Iraq war to a close. And he says we’re “well beyond stupid,” but he got most of the facts wrong about the debate over changing the Foreign Intelligence Surveillance Act (FISA). Klein falsely claimed that the bills supported by Democrats in the
House and Senate would require individualized warrants to wiretap calls made by foreign targets. Instead, the bills require such warrants only when the government targets Americans, something we should all agree is necessary. Klein was also flat-out wrong when he suggested that there is bipartisan agreement that the government should destroy any records on nontargeted Americans that it obtains using this broad new authority. In fact, the Administration and its allies are fighting against far more modest proposals to protect innocent Americans who are swept up in this new, essentially warrantless surveillance. For nearly 30 years, the secret FISA court has provided judicial supervision and oversight when the government carries out surveillance of Americans. President Bush ignored and bypassed that court and the law in approving a warrantless wiretapping program after Sept. 11. Only after the program was revealed to the public in December 2005 was the Administration forced to comply with the law. Now the Administration is asking for broad new powers that could very well lead to the collection of vast numbers of communications involving U.S. citizens at home. Congress must make sure that the new law requires independent court review and that it protects the privacy of innocent Americans, as required by the Constitution. That’s not tone-deaf; that’s our sworn and solemn duty.

Russ Feingold, U.S. Senator, Wisconsin

And the second:

Joe Klein recently criticized the RESTORE Act, also known as the Foreign Intelligence Surveillance Act (FISA), claiming that it “would require the surveillance of every foreign-terrorist target’s calls to be approved by the FISA court” [Dec. 3] This is incorrect. The RESTORE Act creates “basket” authorization to allow widespread surveillance of foreign powers (like al-Qaeda) and their agents. To prevent a repeat of the Bush Administration’s extralegal warrantless-wiretapping program, the court must approve the parameters of the group surveillance to ensure that warrants are still obtained for Americans’ communications. But no court orders are required for surveillance of foreigners reasonably believed to be outside the country. The bill simply will not make our intelligence agencies get thousands of warrants for foreign terrorists. The RESTORE Act’s blend of Executive Branch flexibility, court approval and congressional oversight is calibrated to ensure that the fight against terrorism is conducted in an efficient and constitutional manner. We would hope that Klein, having studied the RESTORE Act further, is no longer so confused as to continue to characterize our system of constitutional checks and balances as “well beyond stupid.”

John Conyers Jr.
and
Silvestre Reyes
Chairmen, House Committee on Judiciary and House Permanent Select
Committee on Intelligence

sortable lists and an intransigent dropOnEmpty

I spent a good deal of today banging my head against some scriptaculous sortable lists thingies to no avail. I seemed to have hit this snag where if I have a sortable list that either starts or later becomes empty, I can no longer drag anything to it. This makes me sad. Naturally I cannot share my sadness with the scriptaculous sortable lists demo because theirs works just fine. Before I caught the bus I spent a few fleeting moments inside of firebug to no avail. Web shit sucks.

I guess I’m not the only one, however, who has found that sortable dropOnEmpty isn’t behaving itself. As soon as I find the answer, which is no doubt me being somehow ignorant, I shall certainly spread the word.

Alas, my ongoing battle with Ruby and Rails will continue on the morrow.

Update: I’m not exactly sure of anything I did in particular, but this problem somehow solved itself. Here’s the relevant scriptaculous code in my previously won’t-droponempty view.

<p id="available_members_list"></p>
<p id="current_members_list"></p>
<input type="hidden" id="sortable_hidden" name="sortable_hidden"/>
<%= sortable_element(:available_members, :update => 'available_members_list', :dropOnEmpty => true,
:containment => ['available_members','current_members'],
:complete => visual_effect(:highlight, 'available_members')) %>
<%= sortable_element(:current_members, :update => 'current_members_list', :dropOnEmpty => true,
:containment => ['current_members','available_members'],
:complete => visual_effect(:highlight, 'current_members'),
:url => {:action => 'order'}) %>

changing konsole schema using dcop

In an effort to combat lameness, I’m not going to make a shitty inaugural post about nothing. I’ll get right to the point and make a useful post.

If you’ve ever found yourself sitting in front of a dozen konsoles to as many hosts, particularly if some of those are to production machines, you might also have found yourself about to type something Unfun at that production prompt. I decided I needed some visual cue to know that I’m on a production machine.

Enter my elite script ‘dcopssh.sh’ which wraps ssh via an alias inside of a couple of dcop calls.
—–

#!/bin/bash
#
# use this with an alias along the lines of:
# alias ssh='/home/rwoodrum/bin/dcopssh.sh'
#
if [ "$KONSOLE_DCOP_SESSION" ] && [[ $@ =~ "wad" ]]
then
   dcop ${KONSOLE_DCOP_SESSION} setSchema "scary_production.schema"
   ssh $@
   dcop ${KONSOLE_DCOP_SESSION} setSchema "normal_unscary.schema"
else
   ssh $@
fi

—–
The super fool-proof way that this works, is that I’m lucky enough to have a hostname convention in my production infrastructure (as opposed to a half-dozen test environments), and I can cue off of the hostname. In my case, I know that the string “wad” is going to appear in production hosts… but clearly you can make this as smart or as dumb (such as in my case) as you want.

Now when I ssh into my production machines from my KDE desktop, my konsoles turn an eerie set of colors as a visual cue that I’m on a machine in our production infrastructure and that I shouldn’t do something stupid. When I log out of the host in question, the schema reverts to the original. Yay, dcopssh!