Thursday, November 17. 2011
Simple puppet file based "fact" definition and facter plugin
I ran into a situation with puppet where we needed very simple file based facts. I googled around and oddly didn't find anything. Here is what I came up with that met my needs.
A file resource ensures /etc/facter/facts exists and purges recursively. A definition drops a file into that dir so that the name of the fact is the name of the file, and the contents of the fact are the contents of the file. The puppet masters are configured to deploy plugins - EG: http://docs.puppetlabs.com/guides/plugins_in_modules.html
See below for code.
The facts ruby facter plugin (modules/facts/lib/facter/facts.rb):
The definition which provides "fact" (fact.pp):
And finally the file resource that sets up the /etc/facter/facts area:
You can use this easily like this:
If you want to see these facts when you manually run facter from the cli, you should set your environment variable for facter lib (syntax for bash):
A file resource ensures /etc/facter/facts exists and purges recursively. A definition drops a file into that dir so that the name of the fact is the name of the file, and the contents of the fact are the contents of the file. The puppet masters are configured to deploy plugins - EG: http://docs.puppetlabs.com/guides/plugins_in_modules.html
See below for code.
The facts ruby facter plugin (modules/facts/lib/facter/facts.rb):
path="/etc/facter/facts"
if File.directory? "#{path}"
Dir.foreach(path) do |entry|
entry.chomp
if File.file? "#{path}/#{entry}"
Facter.add(entry) do
setcode do
contents = File.read("#{path}/#{entry}")
contents.chomp
end
end
end
end
end
The definition which provides "fact" (fact.pp):
# Provide arbitrary named facts - cannot match name of facter plugin (from
# module path)
#
#
# Example
#
# fact { "sysadmin1": value => "My Name" }
# fact { "sysadmin2": value => "Your Name" }
# fact { "support": value => "Group Name" }
# fact { "restricted": value => "true" }
#
define fact ($ensure=present,
$value='NOSRC') {
$factsdir = "/etc/facter/facts"
case $ensure {
absent: {
file { "$factsdir/$name": ensure => absent }
}
present: {
case $value {
'NOSRC': {
fail "value required for fact define"
}
default: {
file { "$factsdir/$name":
content => "$value\n",
require => File[$factsdir],
}
}
}
}
default: { crit "Invalid ensure value: $ensure." }
}
}
And finally the file resource that sets up the /etc/facter/facts area:
file {
"/etc/facter":
ensure => directory;
"/etc/facter/facts":
ensure => directory,
require => File["/etc/facter"],
recurse => true,
force => true,
purge => true;
}
You can use this easily like this:
fact { "support": value => "SHARED" }If you want to see these facts when you manually run facter from the cli, you should set your environment variable for facter lib (syntax for bash):
export FACTERLIB=/var/lib/puppet/lib/facter
Thursday, April 28. 2011
Applescript to stop mail.app from checking when screensaver is on
I realized over the last months that when I run Apple's Mail.app on my desktop and on my laptop both at the same time, IMAP continues to resync or show me incorrect information until I resync it. Mail checks were taking over 5min sometimes. This might just be isolated to Zimbra mail, but it was pretty annoying. To remedy this situation, I wrote the following applescript (saved as an application, run on login). This has solved my problem nicely.
on run
idle
end run
on idle
tell application "System Events"
if exists (process "ScreenSaverEngine") then
my takeMailOffline()
else
my takeMailOnline()
end if
end tell
return 150 -- seconds = 2.5 minutes
end idle
on quit
continue quit
end quit
on takeMailOffline()
tell application "Mail"
set fetches automatically to false
end tell
end takeMailOffline
on takeMailOnline()
tell application "Mail"
set fetches automatically to true
end tell
end takeMailOnline
Thursday, November 11. 2010
gensystemid with RHEL6
For those of you trying to sync RHEL6 with mrepo, you will need to update gensystemid first (similar to what I did here).
Copy this text into a new file named gensystemid.diff and run:
After applying the patch, you can use this to get a new systemid for rhel6Server-i386 (assuming the dir already exists) by running:
--------------------------------------------------------------------------
--- /usr/bin/gensystemid.old 2010-11-11 16:49:46.000000000 -0800
+++ /usr/bin/gensystemid 2008-08-14 17:51:19.000000000 -0700
@@ -19,9 +19,6 @@
def checkrelease(release, arch):
releases = {
+ '6Server': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
+ '6Client': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
+ '6Workstation': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
'5Server': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
'5Client': ('i386', 'ia64', 'x86_64'),
'4AS': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
Copy this text into a new file named gensystemid.diff and run:
patch < gensystemid.diff
After applying the patch, you can use this to get a new systemid for rhel6Server-i386 (assuming the dir already exists) by running:
gensystemid -r 6Server -a i386 /var/mrepo/rhel6Server-i386/
--------------------------------------------------------------------------
--- /usr/bin/gensystemid.old 2010-11-11 16:49:46.000000000 -0800
+++ /usr/bin/gensystemid 2008-08-14 17:51:19.000000000 -0700
@@ -19,9 +19,6 @@
def checkrelease(release, arch):
releases = {
+ '6Server': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
+ '6Client': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
+ '6Workstation': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
'5Server': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
'5Client': ('i386', 'ia64', 'x86_64'),
'4AS': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
mrepo gensystemid + RHEL6
For those of you trying to sync RHEL6 with mrepo, you will need to update gensystemid first (similar to what I did here).
Copy this text into a new file named gensystemid.diff and run:
After applying the patch, you can use this to get a new systemid for rhel6Server-i386 (assuming the dir already exists) by running:
--------------------------------------------------------------------------
--- /usr/bin/gensystemid.old 2010-11-11 16:49:46.000000000 -0800
+++ /usr/bin/gensystemid 2008-08-14 17:51:19.000000000 -0700
@@ -19,9 +19,6 @@
def checkrelease(release, arch):
releases = {
+ '6Server': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
+ '6Client': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
+ '6Workstation': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
'5Server': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
'5Client': ('i386', 'ia64', 'x86_64'),
'4AS': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
Copy this text into a new file named gensystemid.diff and run:
patch < gensystemid.diff
After applying the patch, you can use this to get a new systemid for rhel6Server-i386 (assuming the dir already exists) by running:
gensystemid -r 6Server -a i386 /var/mrepo/rhel6Server-i386/
--------------------------------------------------------------------------
--- /usr/bin/gensystemid.old 2010-11-11 16:49:46.000000000 -0800
+++ /usr/bin/gensystemid 2008-08-14 17:51:19.000000000 -0700
@@ -19,9 +19,6 @@
def checkrelease(release, arch):
releases = {
+ '6Server': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
+ '6Client': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
+ '6Workstation': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
'5Server': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
'5Client': ('i386', 'ia64', 'x86_64'),
'4AS': ('i386', 'ia64', 'ppc', 's390', 's390x', 'x86_64'),
Thursday, April 8. 2010
How to repair an E1 error a Schwin 418 elliptical
E1 error seems to indicate that the servo which controls the elliptical resistance is stuck. Here is how I fixed this (without using a "crank puller", which would be quicker by far).
You will need a very short phillips screw driver (snub nose), a long phillips screw driver, an allen key set, and crescent wrench.
- Remove the batteries from the unit.
- Remove the screws from the plastic housing (with the long phillips screw driver) on the left side. Do not forget the phillips screws at the front - they are smaller screws so don't mix them with the others. This will allow the plastic housing to flex and move around, but not come entirely off.
- Using the crescent wrench, remove the nut holding the left pedal to the crank. Carefully note the order of the washers on the crank attachment.
- Using the allen key, remove the little pedal attachment piece on the left crank arm.
- Using the short phillips screw driver, carefully reach inside the plastic housing on the top and remove the four screws holding the plastic plate on the outside of the fly wheel/crank. You will need to rotate the crank wheel to reach each of the four screws in turn on the inside of the case.
- Pull off the plastic cover for the wheel.
- Reinsert batteries and gently help the revealed cable (bottom) retract the magnet plate. In my case, the servo worked fine again after helping it retract the magnet plate that was somehow stuck/wedged.
If your little servo motor is dead (or the little gears are stripped), you can find a replacement online for about $50 with shipping.
Reverse steps to re-assemble.
You will need a very short phillips screw driver (snub nose), a long phillips screw driver, an allen key set, and crescent wrench.
- Remove the batteries from the unit.
- Remove the screws from the plastic housing (with the long phillips screw driver) on the left side. Do not forget the phillips screws at the front - they are smaller screws so don't mix them with the others. This will allow the plastic housing to flex and move around, but not come entirely off.
- Using the crescent wrench, remove the nut holding the left pedal to the crank. Carefully note the order of the washers on the crank attachment.
- Using the allen key, remove the little pedal attachment piece on the left crank arm.
- Using the short phillips screw driver, carefully reach inside the plastic housing on the top and remove the four screws holding the plastic plate on the outside of the fly wheel/crank. You will need to rotate the crank wheel to reach each of the four screws in turn on the inside of the case.
- Pull off the plastic cover for the wheel.
- Reinsert batteries and gently help the revealed cable (bottom) retract the magnet plate. In my case, the servo worked fine again after helping it retract the magnet plate that was somehow stuck/wedged.
If your little servo motor is dead (or the little gears are stripped), you can find a replacement online for about $50 with shipping.
Reverse steps to re-assemble.
How to replace a LCD display for a Toshiba A135 laptop
First, purchase your replacement LCD display for your exact model of Toshiba A135. I found mine for about $110 with shipping.
There are five screws hidden beneath rubber bumpers around the screen. Carefully use a small flat screwdriver to remove the pencil eraser sized rubber bumpers - one at each corner, with the fifth at the top center. Make sure you carefully remove the sticky stuff they used to adhere the bumper to the screw as well. Set these carefully aside.
Remove the five screws and set them aside.
Gently press down at the inside plastic frame until it pops out slightly. Gently press towards the center of the screen at the sides of the inside plastic frame until it pops out.
Carefully separate the front and back plastic shell around the screen. Set the front plastic frame aside. You may need to loosen some of the white tape used to keep wires attached to the rear plastic shell. Gently lower the rear plastic shell away from the LCD, but leave as many wires attached as possible.
On the back of the LCD there is a large cable. Carefully pull up the tape that holds this cable in place and pull the cable down to remove it. You will also have another piece of white tape on the back of the LCD to peel back. The tape is important - don't tear it or get your fingers in it to remove its stick!
At one end you will see a set of a few wires plugged into a piece still attached to the rear plastic shell. Unplug this.
No wires should still be plugged into the LCD anywhere at this point.
Around the LCD there are six small screws. Remove these and set them aside. You now have now removed the old LCD.
Reverse this process to re-assemble.
* You may want to use some blue LockTite (which can be found at hardware stores) for the screws as you replace them. Additionally, you might need a little rubber cement to re-attach the rubber bumpers at the last step. If you do not re-attach these bumpers, your screen will quickly become scratched by your keyboard touching it when the lid is closed.
Good luck!
There are five screws hidden beneath rubber bumpers around the screen. Carefully use a small flat screwdriver to remove the pencil eraser sized rubber bumpers - one at each corner, with the fifth at the top center. Make sure you carefully remove the sticky stuff they used to adhere the bumper to the screw as well. Set these carefully aside.
Remove the five screws and set them aside.
Gently press down at the inside plastic frame until it pops out slightly. Gently press towards the center of the screen at the sides of the inside plastic frame until it pops out.
Carefully separate the front and back plastic shell around the screen. Set the front plastic frame aside. You may need to loosen some of the white tape used to keep wires attached to the rear plastic shell. Gently lower the rear plastic shell away from the LCD, but leave as many wires attached as possible.
On the back of the LCD there is a large cable. Carefully pull up the tape that holds this cable in place and pull the cable down to remove it. You will also have another piece of white tape on the back of the LCD to peel back. The tape is important - don't tear it or get your fingers in it to remove its stick!
At one end you will see a set of a few wires plugged into a piece still attached to the rear plastic shell. Unplug this.
No wires should still be plugged into the LCD anywhere at this point.
Around the LCD there are six small screws. Remove these and set them aside. You now have now removed the old LCD.
Reverse this process to re-assemble.
* You may want to use some blue LockTite (which can be found at hardware stores) for the screws as you replace them. Additionally, you might need a little rubber cement to re-attach the rubber bumpers at the last step. If you do not re-attach these bumpers, your screen will quickly become scratched by your keyboard touching it when the lid is closed.
Good luck!
Sunday, March 28. 2010
Zucchini pancakes
Here's my recipe for zucchini pancakes. Personally, I like to include lots of zucchini and lately I've been using mostly whole wheat flower in this recipe. These pancakes come out very moist. These are slightly sweet (not savory) and go well with your normal butter and syrup, jelly, yogurt or applesauce.
Combine dry ingredients (sift if you have the time), add eggs, oil, butter and milk and mix until the big lumps are broken up. Add more milk if you want thinner pancakes. Add shredded zucchini and mix in by hand with a spoon.
Cook pancakes as usual, but but be careful to not make them too thick so they don't cook all the way through.
Makes 4-6 large pan-sized pancakes.
2 eggs
1 3/4 Cups flour (you can use mostly whole wheat flower, but you will have to make the pancakes thinner with more liquid to make them cook through)
1 1/2 tsp sugar
1/2 tsp salt
4 Tablespoons oil
1/4 Cup melted butter (or non-dairy substitute)
2 tsp baking powder
1/2+ Cup milk or soy milk (add more to make thinner pancakes)
2 Cups shredded zucchini (~2 small zucchini or more to taste)
Combine dry ingredients (sift if you have the time), add eggs, oil, butter and milk and mix until the big lumps are broken up. Add more milk if you want thinner pancakes. Add shredded zucchini and mix in by hand with a spoon.
Cook pancakes as usual, but but be careful to not make them too thick so they don't cook all the way through.
Makes 4-6 large pan-sized pancakes.
Friday, March 19. 2010
Macbook Pro bluetooth stops showing "Turn Off" option
So recently my Macbook Pro (Intel) has been having some weird issues. Several times when I plug it into an external monitor the system hangs with a blue screen - I had to hard-power off. Then, I noticed that bluetooth was misbehaving - disconnecting, reconnecting, failing to reconnect, etc. I was resorting to removing and re-adding bluetooth keyboard and mouse to get them to work.
Finally, the bluetooth menu stopped showing "Turn Off" as an option! Since I wander around the house with my Macbook, this was really annoying - I was seeing disconnect and reconnect bluetooth notices constantly.
After Googling around a bit, I found this: http://support.apple.com/kb/HT3964
Resetting the SMC has fixed the bluetooth issue - the "Turn Off" (or "Turn On") has reappeared in the bluetooth menu - and I haven't had any display issues. If you have similar symptoms, give it a try.
Finally, the bluetooth menu stopped showing "Turn Off" as an option! Since I wander around the house with my Macbook, this was really annoying - I was seeing disconnect and reconnect bluetooth notices constantly.
After Googling around a bit, I found this: http://support.apple.com/kb/HT3964
Resetting the SMC has fixed the bluetooth issue - the "Turn Off" (or "Turn On") has reappeared in the bluetooth menu - and I haven't had any display issues. If you have similar symptoms, give it a try.
Wednesday, September 2. 2009
pidgin + openfire + kerberos on RHEL 5
For those who are struggling to get pidgin on RHEL 5 to work with kerberos auth to openfire IM server...
After some research I discovered that you have to install cyrus-sasl-gssapi and have a valid kerberos ticket before it will work. Pidgin will not require that package on install or upgrade (at this time), so you must install it and restart pidgin to load the library.
After some research I discovered that you have to install cyrus-sasl-gssapi and have a valid kerberos ticket before it will work. Pidgin will not require that package on install or upgrade (at this time), so you must install it and restart pidgin to load the library.
Friday, July 24. 2009
Filter stderr output in bash
I was searching around the other day for a way to filter stderr output from a init.d script. It was throwing useless errors and those were going to root mail since this was all being done via cron job on a few linux boxes.
After poking around a bit on the web, I found this wonderful little snippet for bash:
This particular solution only works in bash - it won't work for bash in sh mode. Some other shells have other (longer) solutions, but since I deal with bash 95% of the time, this is what I needed. I actually ignore stdout when I do a service restart, so it looks more like this:
It really works great and has reduced my needless cron mail!
After poking around a bit on the web, I found this wonderful little snippet for bash:
cmd 2> >(grep -v "filter Err Txt" >&2)
This particular solution only works in bash - it won't work for bash in sh mode. Some other shells have other (longer) solutions, but since I deal with bash 95% of the time, this is what I needed. I actually ignore stdout when I do a service restart, so it looks more like this:
/etc/init.d/something restart 2> >(grep -v "Pointless err" >&2) > /dev/null
It really works great and has reduced my needless cron mail!
Tuesday, June 23. 2009
iBank import from quicken creates categories with the same name as accounts
I recently switched from Quicken to iBank. The change wasn't without its hiccups though. When following the instructions from iBank to export and import from Quicken I discovered that the result was duplicate entries for every transfer transaction. I'm sure this is because iBank is importing the quicken export serially and doesn't know that the transactions are linked between accounts. To make things more difficult, some of the transfer entries were linked, probably due to the order in which they appeared in the file was after the creation of the account.
I found that I had to remove the duplicate transactions manually and change the non-duplicate transactions to link to the account, but that didn't fix the problem entirely. Turns out that iBank created categories with the same name as the account when it imported the quicken export. That meant that iBank would not let me change certain transactions to link (make them transfers between accounts). It would always revert to the category with that name instead of the account.
I ended up with the following solution. In the category view, rename each of the categories that matched the name of an account. Quit iBank and re-open it. Proceed with switching the unique transactions to link using the account, and then deleting the duplicate transactions that remained.
Fortunately it only took me about 20 minutes to finish cleaning up the transactions (I have data going back to '04). It wasn't much fun, but I'm happy to be off of quicken.
I found that I had to remove the duplicate transactions manually and change the non-duplicate transactions to link to the account, but that didn't fix the problem entirely. Turns out that iBank created categories with the same name as the account when it imported the quicken export. That meant that iBank would not let me change certain transactions to link (make them transfers between accounts). It would always revert to the category with that name instead of the account.
I ended up with the following solution. In the category view, rename each of the categories that matched the name of an account. Quit iBank and re-open it. Proceed with switching the unique transactions to link using the account, and then deleting the duplicate transactions that remained.
Fortunately it only took me about 20 minutes to finish cleaning up the transactions (I have data going back to '04). It wasn't much fun, but I'm happy to be off of quicken.
Friday, July 25. 2008
multi-threaded vmware esx evacuation perl script
The VMware perl SDK utilities have a script to evacuate an ESX server to another server, but it is painfully slow since it is done serially. I modified the script to use threads and queue up 6 moves (VMotions) at a time. The script also has an option to place the ESX server into maintenance mode after it is evacuated.
Since this script bypasses the DRS evacuation which is done from the GUI when you place a system into maintenance mode, it appears to be quite a bit faster (maybe 50% faster given my initial tests?). Feel free to post comments with your experience using the script. Obviously you'll need a working install of the VMware perl 1.5 perl modules (SDK) to use this script.
Right -click and select "Save..." to download perl source.
Since this script bypasses the DRS evacuation which is done from the GUI when you place a system into maintenance mode, it appears to be quite a bit faster (maybe 50% faster given my initial tests?). Feel free to post comments with your experience using the script. Obviously you'll need a working install of the VMware perl 1.5 perl modules (SDK) to use this script.
Right -click and select "Save..." to download perl source.
#!/usr/bin/perl -w
#
# This scripts allows users to move all running vm's from one host to another.
# Modified by Darren Patterson to be multithreaded and include an option to place the
# source ESX server into maintenance mode after the evac finishes.
use strict;
use warnings;
use threads;
use threads::shared;
use VMware::VIM25Runtime;
use VMware::VILib;
# MAX number of concurrently running evac processes.
my $MAXT = 6;
# seconds to sleep while checking for completed threads.
my $SLEEPSIZE = 8;
my %opts = (
src => {
type => "=s",
help => "Host to evacuate",
required => 1,
},
dst => {
type => "=s",
help => "Destination host for VMs",
required => 1,
},
maint => {
type => "",
help => "Place the source host that is evacuating into maintenance mode",
required => 0,
},
);
# read/validate options and connect to the server
Opts::add_options(%opts);
Opts::parse();
Opts::validate();
Util::connect();
# get source host view
my $src_host_name = Opts::get_option('src');
my $src_host_view = Vim::find_entity_view(view_type => 'HostSystem',
filter => { name => $src_host_name });
if (!$src_host_view) {
die "Source host '$src_host_name' not found\n";
}
# get destination host view
my $dst_host_name = Opts::get_option('dst');
# the destination host view must be a shared variable for threads to see
my $dst_host_view = Vim::find_entity_view(view_type => 'HostSystem',
filter => { name => $dst_host_name });
if (! $dst_host_view) {
die "Destiation host '$dst_host_name' not found\n";
}
# get all VM's under src host
my $vm_views = Vim::find_entity_views(view_type => 'VirtualMachine',
begin_entity => $src_host_view);
# migrate all vm's
#print "Starting threads...\n";
my @results : shared;
my $inc = 0;
foreach (@$vm_views) {
threads->new(\&evac, $dst_host_view, $_);
#print "Started thread: " . $t->tid . "\n";
$inc++;
while (($inc - ($#results+1) >= $MAXT) && (@$vm_views > $inc)) {
#print "wait thread(s) done: ".$inc." - ".($#results+1)." >= $MAXT\n";
sleep($SLEEPSIZE);
}
}
print "Waiting for all VMotion threads to finish...\n";
sleep ($SLEEPSIZE) while ($#results+1 < @$vm_views);
my $return;
foreach (@results) {
if (/returned 2$/) {
$return = 2;
print STDERR "An error was returned by a VMotion thread.\n";
}
}
# Note: Specifically don't join threads to avoid double free segfault.
# Let perl do the cleanup on exit.
#
# Loop through all the threads
# foreach my $thr (threads->list) {
# Don't join the main thread or ourselves
# if ($thr->tid && !threads::equal($thr, threads->self)) {
# $thr->join if (defined($thr) && print "joined thread: ".$thr->tid."\n");
# }
#}
# it may still be possible to enter maintenance mode even though an error
# may have happened earlier
if (Opts::get_option('maint')) {
print "Putting ".$src_host_name." into maintenance mode...\n";
$return = enter_maintenance($src_host_view);
}
print "done\n";
# disconnect from the server
Util::disconnect();
return $return;
sub enter_maintenance {
my $target_host = shift;
eval {
$target_host->EnterMaintenanceMode(timeout => 0);
print "\nHost '" . $target_host->name
. "' entered maintenance mode successfully\n";
return 0;
};
if ($@) {
if (ref($@) eq 'SoapFault') {
if (ref($@->detail) eq 'InvalidState') {
print "\nThe enter_maintenancemode operation".
" is not allowed in the current state";
}
elsif (ref($@->detail) eq 'Timedout') {
print "\nOperation timed out\n";
}
elsif (ref($@->detail) eq 'HostNotConnected') {
print "\nUnable to communicate with the"
. " remote host, since it is disconnected.\n";
}
else {
print "\nHost cannot be entered into maintenance mode \n" . $@. "";
}
}
else {
print "\nHost cannot be entered into maintenance mode \n" . $@. "";
}
return 2;
}
}
sub evac {
my $dst_host_view = shift;
my $vm = shift;
eval {
print "Starting VMotion for ".$vm->name."\n";
$vm->MigrateVM(host => $dst_host_view,
priority => VirtualMachineMovePriority->new('defaultPriority'),
state => VirtualMachinePowerState->new('poweredOn'));
print "VM " . $vm->name . " evacuated successfully.\n";
push (@results, (threads->self)->tid." returned 0");
return 0;
};
if ($@ && $vm->runtime->powerState->val eq 'poweredOn') {
# unexpected error
print "Unable to evacuate VM '" . $vm->name . "'\n";
print "Reason: " . $@ . "\n\n";
push (@results, (threads->self)->tid." returned 2");
return 2;
}
}
##############################################################################
# Documentation
##############################################################################
=head1 NAME
vmevac - evacuate an ESX server's VM guests to another ESX server
=head1 SYNOPSIS
BB<--src> I B<--dst> I [B<--maint>]
=head1 DESCRIPTION
Evacuate an ESX server's VM guests to another ESX server.
=head1 OPTIONS
=over 4
=item B<-h>, B<--help>
Print out help.
=item B<--dst> I
The destination ESX server to relocate VM guests to.
=item B<--maint>
Place the source ESX server into maintenance mode after evacuation.
=item B<--src> I
The souce ESX server to evacuate VM guests from.
=back
=head1 EXAMPLES
vmevac --src hal07.stanford.edu --dst hal08.stanford.edu
vmevac --src hal07.stanford.edu --dst hal08.stanford.edu --maint
Thursday, June 5. 2008
iTerm double click selects a word
Another one of my annoyances with using iTerm has been that it didn't select entire words sometimes. I finally found this article on how to make iTerm select words with non-alphanumeric characters.
Now it behaves very similarly to xterm or gnome-terminal in Linux, which makes me quite happy...
Now it behaves very similarly to xterm or gnome-terminal in Linux, which makes me quite happy...
Tuesday, June 3. 2008
command line newsgroup access
Since I've been working from my Macbook Pro quite a bit lately, I went in search for a good command line newsgroup reader (I use internal newsgroups for help ticket tracking and other tasks). My coworker pointed me at slrn since I'm VI kind of guy (I tried gnus once, but I hated it).
After a bit of reading and experimentation, I setup a nice scorefile, .slrnrc and was able to get through my daily newsgroup routine in less time than usual. Given that it can take me up to three hours to finish, I was stoked!
For those addicted to the command line and who don't do emacs, check out slrn.
After a bit of reading and experimentation, I setup a nice scorefile, .slrnrc and was able to get through my daily newsgroup routine in less time than usual. Given that it can take me up to three hours to finish, I was stoked!
For those addicted to the command line and who don't do emacs, check out slrn.
iTerm and the elusive ALT-. (for bash)
I've been using my Macbook Pro a lot lately and I seriously missed having ALT-. in iTerm for scrolling back through my bash last arg history. I finally was able to make it work, and here's how:
Go to the Bookmarks menu
Select "Manage Profiles"
Expand Keyboard Profiles and select the one you use - probably "xterm (OS X)" (Update: use the "Global" profile on the latest iTerm and Panther).
Click the "+" button to add a new key mapping.
For "Key" choose "Hex Code" and enter "0x2e"
Check the "Option" modifier.
Action should be "send escape sequence" and enter "." into the box.
You should now be able to press ALT-. and have it send the correct escape sequence through iTerm.
Go to the Bookmarks menu
Select "Manage Profiles"
Expand Keyboard Profiles and select the one you use - probably "xterm (OS X)" (Update: use the "Global" profile on the latest iTerm and Panther).
Click the "+" button to add a new key mapping.
For "Key" choose "Hex Code" and enter "0x2e"
Check the "Option" modifier.
Action should be "send escape sequence" and enter "." into the box.
You should now be able to press ALT-. and have it send the correct escape sequence through iTerm.
(Page 1 of 4, totaling 57 entries)
» next page
Navigation
Calendar
|
|
February '12 | |||||
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | ||||
Quicksearch
Categories
Blog Administration
Powered by serendipity, Design by Garvin Hicking. Smile, you're on the candid credit line!