30 March 2014

Updating Citrix XenServer 6.2

Intro
XenServer is a great Enterprise class virtual host which I have been recommending to people after trialling it myself. It has the advantage of being a light bare bones Linux install. It is administered via SSH or a Windows GUI (XenCenter). Citrix have said they will not release a non-windows admin tool which is a shame.

Since version 6.20 have seen fit to change their model for updates. They can no longer be installed via the GUI for the free version, but it is possible via CLI. In XenCenter (the Windows admin tool). In my opinion there are a couple of problems with this:
  1. Many online sources and even their own free license email point to installing free licenses via Tools/License Manager. However you can no longer add the free license: the button is greyed out or disappears depending on if the server is selected or not. The GUI doesn't explain this which makes for a frustrating experience unless you've read all the release notes (we all do that right?).
  2. The Tools/Update Manager presents a list of servers to apply updates to, but unlicensed servers are simply presented as grey, with no explanation of why they are unavailable.
If the focus is for Windows based users, then I feel they need to address this lack of feedback. Personally I also feel the product ought to just work out of the box for a limited period.

How am I supposed to persuade a Windows virtual host administrator to switch to a Linux based VH with patchy GUI coverage? It just ain't gunna happen.

Attempting to Apply Updates to XenServer v6.2

This is now the path to updates to XenServer free since version 6.2:
  1. On a Windows machine, browse to XenServer IP address and install XenCenter (it only runs on Windows)
  2. See the update alerts top right.
  3. Click on the web address and download the update(s).
  4. Extract them (or this can be done later on the Linux CLI via unzip)
  5. Try to install the updates via the GUI:
    1. Go to Tools/Install Update, select the update and find you're unable to select the select server (no explanation as to why). 
    2. Assume you're doing something wrong, get frustrated and Google it.
    3. Realise you haven't installed a license (as per previous versions) and request one.
  6. Attempt to install a free license, following the instructions in the email that gets sent to you:
    1. "Select the desired XenServer host and press the Activate Free XenServer button selecting Apply Activation Key"
    2. Notice the button greyed out or disappear as you select your server.
    3. Get annoyed

Updates to XenServer v6.2 free are now only possible via CLI

  1. Download Putty or another ssh client and log into the server.
  2. Copy the already downloaded updates to the server e.g.
    scp /Users/<username>/Downloads/XS62E001/XS62E001.xsupdate root@<XenServer hostname or IP>:/tmp/
  3. Follow the instructions to install it on the server:
    xe patch-upload -s <XenServer IP> -u root -pw <password> file-name=/tmp/XS62E001.xsupdate
  4. Note the GUID e.g.
    dedcc0dd-d8f3-4f76-78qk-92697c7a44f0
  5. Apply the hotfix to the server e.g.
    xe -s <hostname> -u root -pw <password> patch-pool-apply uuid=dedcc0dd-d8f3-4f76-78qk-92697c7a44f0
  6. Ensure it was applied:
    xe patch-list -s <XenServer IP> -u root -pw <password> name-label=XS62ESP1
    or in the GUI via XenCenter, select server, General tab and Updates section.
I understand they need to get people to buy licenses, I really do... but I don't believe making patchy GUIs with partial functionality is the best way to go about it.

UPDATE

Thanks to diogo miranda for this script that will handle it automatically:
  1. Change to the folder where you want to install it e.g.
    mkdir xeer1update
    cd xeer1update
  2. Run the following on the server to install it:
    wget https://raw.githubusercontent.com/Coultard/XenServer-Patcher-bash/master/xeer1update.sh --no-check-certificate
    chmod +x xeer1update.sh
    bash xeer1update.sh
You could add this to Crontab to semi-automate it... you'll need to checkin and ensure what the output is.
  1. crontab -e
  2. paste i n:
    00 00,18 * * * ./root/xeer1update/xeer1update.sh
  3. Restart cron:
    /sbin/service crond restart
xe-toolstack-restart will restart the toolstack on all hosts.

You may run out of disk space so see my separate post on that.

Export from Parallells to VMDK fo use on VirtualBox or Similar


Exporting from Parallels to VirtualBox

I've used Parallels 9 for about six months now to run a Windows 8 machine I use for development on my Mac (Macbook pro late 2011 OSX 10.9.2) and I love it. Previously I had been using VMWare Fusion 6 and I found the latter locked up all too often. Anyway I found myself wanting to export a machine I had created in Parallels to use it on another virtual host e.g. VirtualBox or XenServer. If you're not familiar with XenServer I heartily recommend it: bare bones Linux based virtual hosting.

  1. Remove Parallels Tools from the virtual
  2. Copy the Parallels virtual file to a new location and rename it (e.g. appending date) by way of a backup.
  3. Right click the .pvm file and "Show Package Contents"
  4. Right click the .hdd file and "Show Package Contents"
  5. Copy the .hds file to another location.
  6. Rename the .hds file to .hdd
  7. Open VirtualBox and create a new VM, selecting "using existing hdd".
Note you can also use:

Disk Formats

I prefer the VMDK format for it's portability but also for the ability to split the file into smaller 2GB chunks. I find this works better with backup systems and also when moving the files around.

19 March 2014

Visual Studio Web.config Transforms on build

Web.config Transforms

Requires Visual Studio Pro or better.

Normally web.config transforms only happen on Publish, not build. To do config transforms on build:


  1. In configuration manager add a build for the project for each config e.g. Release, Debug, Debug.[developer initials]
  2. Copy web.config to web.Base.config (this will become the basis for the transform)
  3. Unload WebProject (right click) and edit project file: 
  4. Edit web.config includers for each file like:<Content Include="Web.config" />
    <Content Include="Web.Base.Debug.config">
    <DependentUpon>Web.Base.config</DependentUpon></Content>[other configs here] 
  5. Above <Target Name="BeforeBuild"> add:<UsingTask taskname="TransformXml" assemblyfile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />or<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />Depending on your install location
  6. Add lines to edit file properties and carry out transform:<Target Name="BeforeBuild"><Exec Command="ATTRIB -R "$(SolutionDir)$(SolutionName).Website\web.config"" /><TransformXml Source="Web.Base.config" Transform="Web.Base.$(Configuration).config" Destination="Web.config" StackTrace="true" /></Target>
An alternative approach is to use the web.config as the 'base' BUT you will need to be sure to amend/remove the results of other transforms e.g. changing a debug transform result back to a release setting: the web.config may get transformed as debug then checked in as is. The advantage to using the web.config as the 'base' is that both VS, other developers and Nuget expect to use that and will modify it e.g. when un/installing packages.

15 March 2014

How to: Share Files From Finder on a Mac

The Problem

Select a file in Finder and 'send via email' is an option I use on Windows a great deal. On my Mac OS (v10.9.2) it isn't there.

The Solution

This option should be available via the 'share' context menu but if you have set your default mail app to a mail program which is not Apple Mac Mail then it won't show up. I have set mine to Thunderbird. To reset it open Mail and go to Preferences and General, then select the mail app as the default.

How To: Set hidden preferences on a Mac

The Problem

On a Mac many of the settings are hidden e.g. setting inline mail attachments.

The Solution

There are many solutions you can achieve via Terminal and command line arguments but there is also an app that exposes them for you:
http://secrets.blacktree.com/ 

04 March 2014

Android Development: Browsing Android Source in Eclipse

The Problem

I got bored of seeing messages like:
"the jar of this class file belongs to container android private libraries..."

The Solution

You need to tell Eclipse how to resolve the source files so it knows where to find them.
NB:
  • It requires ADT in version 20 or later.
  • You must first download the sources using the SDK Manager
Steps:
  1. In the libs directory of your project you will find the android-support-v4.jar library. In that directory create a text file with the same name as the JAR, but with a .properties suffix  i.e.
    android-support-v4.jar.properties.
  2. Open the created properties file and set the value of a property named src to the location where sources for that library can be found e.g.
    src=/Users/[username]/Development/adt-bundle-mac-x86_64-20131030/sdk/extras/android/support/v4/src
    Where: [username] is the username of your account
  3. Save the file.
  4. Close and re-open your android project.
  5. Try browsing to one of the definitions of a standard Android method (i.e. in the support classes).