Saturday, April 30, 2011

Removing "Update Failed" VMs from the VMM Administrator Console

Recently getting annoyed by the increasing number of VMs with status "Update
Failed". The last thing I remember that this happened after the one of my
Hyper-V host crashed, and ended up 2 identical VMs appear after the quick
migration took place.

Found this blog
http://blogs.technet.com/m2/archive/2010/04/16/removing-missing-vms-from-the-vmm-administrator-console.aspx
and below are my summary of the steps :

1. Close VMM Administrator Console
2. Stop "Virtual Machine Manager" service.
3. Backup the VMM database (optional)
4. Download and install "Microsoft SQL Server Management Studio Express"
from
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c243a5ae-4bd1-4e3d-94b8-5a0f62bf7796.
5. Launch "Microsoft SQL Server Management Studio Express", select VMM
database and execute script below.
6. Start the "Virtual Machine Manager" service.
7. The VMs with "Update Failed" should have gone by now.

===========Start Script========
BEGIN TRANSACTION T1

DECLARE custom_cursor CURSOR FOR
SELECT ObjectId from
dbo.tbl_WLC_VObject WHERE [ObjectState] = 220

DECLARE @ObjectId uniqueidentifier
OPEN custom_cursor
FETCH NEXT FROM custom_cursor INTO @ObjectId

WHILE(@@fetch_status = 0)
BEGIN

DECLARE vdrive_cursor CURSOR FOR
SELECT VDriveId, VHDId, ISOId from
dbo.tbl_WLC_VDrive WHERE ParentId = @ObjectId

DECLARE @VDriveId uniqueidentifier
DECLARE @VHDId uniqueidentifier
DECLARE @ISOId uniqueidentifier


OPEN vdrive_cursor
FETCH NEXT FROM vdrive_cursor INTO @VDriveId, @VHDId, @ISOId
WHILE(@@fetch_status = 0)
BEGIN
DELETE FROM dbo.tbl_WLC_VDrive
WHERE VDriveId = @VDriveId
if(@VHDId is NOT NULL)
BEGIN

DELETE FROM dbo.tbl_WLC_VHD
WHERE VHDId = @VHDId
DELETE FROM dbo.tbl_WLC_PhysicalObject
WHERE PhysicalObjectId = @VHDId
END
if(@ISOId is NOT NULL)
BEGIN

DELETE FROM dbo.tbl_WLC_ISO
WHERE ISOId = @ISOId
DELETE FROM dbo.tbl_WLC_PhysicalObject
WHERE PhysicalObjectId = @ISOId
END

FETCH NEXT FROM vdrive_cursor INTO @VDriveId, @VHDId, @ISOId
END
CLOSE vdrive_cursor
DEALLOCATE vdrive_cursor

-----------------
DECLARE floppy_cursor CURSOR FOR
SELECT VFDId, vFloppyId from
dbo.tbl_WLC_VFloppy WHERE HWProfileId = @ObjectId

DECLARE @vFloppyId uniqueidentifier
DECLARE @vfdId uniqueidentifier

OPEN floppy_cursor
FETCH NEXT FROM floppy_cursor INTO @vfdId, @vFloppyId
WHILE(@@fetch_status = 0)
BEGIN
DELETE FROM dbo.tbl_WLC_VFloppy
WHERE VFloppyId = @vFloppyId

if(@vfdid is NOT NULL)
BEGIN
DELETE FROM dbo.tbl_WLC_VFD
WHERE VFDId = @vfdId
DELETE FROM dbo.tbl_WLC_PhysicalObject
WHERE PhysicalObjectId = @vfdId

END
FETCH NEXT FROM floppy_cursor INTO @vfdId, @vFloppyId
END
CLOSE floppy_cursor
DEALLOCATE floppy_cursor

----------------
DECLARE checkpoint_cursor CURSOR FOR
SELECT VMCheckpointId from
dbo.tbl_WLC_VMCheckpoint WHERE VMId = @ObjectId

DECLARE @vmCheckpointId uniqueidentifier
OPEN checkpoint_cursor
FETCH NEXT FROM checkpoint_cursor INTO @vmCheckpointId
WHILE(@@fetch_status = 0)
BEGIN
DELETE FROM dbo.tbl_WLC_VMCheckpointRelation
WHERE VMCheckpointId = @vmCheckpointId


FETCH NEXT FROM checkpoint_cursor INTO @vmCheckpointId
END
CLOSE checkpoint_cursor
DEALLOCATE checkpoint_cursor

-------------------------
---------Clean checkpoint

DELETE FROM dbo.tbl_WLC_VMCheckpoint
WHERE VMId = @ObjectID


exec [dbo].[prc_VMMigration_Delete_VMInfoAndLUNMappings] @ObjectId

DECLARE @RefreshId uniqueidentifier
exec [dbo].[prc_RR_Refresher_Delete] @ObjectId, @RefreshId


DELETE FROM dbo.tbl_WLC_VAdapter
WHERE HWProfileId = @ObjectId


DELETE FROM dbo.tbl_WLC_VNetworkAdapter
WHERE HWProfileId = @ObjectId


DELETE FROM dbo.tbl_WLC_VCOMPort
WHERE HWProfileId = @ObjectId

DELETE FROM dbo.tbl_WLC_HWProfile
WHERE HWProfileId = @ObjectId

DELETE FROM dbo.tbl_WLC_VMInstance
WHERE VMInstanceId = @ObjectId

DELETE FROM dbo.tbl_WLC_VObject
WHERE ObjectId = @ObjectId

FETCH NEXT FROM custom_cursor INTO @ObjectId
END
CLOSE custom_cursor
DEALLOCATE custom_cursor

COMMIT TRANSACTION T1
===========End Script===========

The above method does not work for me all time. In case you have the same
issue after the steps above are performed, you may try to remove host
cluster from the VMM.


This is my last resource and it always works for me ☺

Sunday, November 15, 2009

How To: Free iSCSI storage with Fedora 10

This how-to guide explains how did I set up an iSCSI target using Fedora 10 and iSCSI initiator on Windows Vista. I was always wondering to setup a free iSCSI storage at home to enable me further run testing with SCVMM (System Center Virtual Machine Manager) R2 with CSV (Cluster Share Volume) as it is hard to get a copy of Windows iSCSI Target Software, unless you have a very good relations with OEM partners.
As hardware remain my main obstacle, I actually setup the iSCSI Target server on Virtual PC


To find out how Fedora 10 can be setup on Virtual PC, see my blog on How-To: Fedora 10 Installtion on Virtual PC here.

Setting up the iSCSI Target (Fedora 10)


  1. Get a copy of iSCSI Enterprise Target (IET) at RPM Fusion
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm


  1. Install the iSCSI target packages:
yum install iscsitarget kmod-iscsitarget

  1. Restart the server.

  1. Get a copy of RPM package of Webmin at www.webmin.com and install in on the server.
    wget http://prdownloads.sourceforge.net/webadmin/webmin-1.490-1.noarch.rpm
    rpm -U webmin-1.490-1.noarch.rpm


    1. Get a copy of iSCSI Target module from http://www.webmin.com/cgi-bin/search_third.cgi?recent=1.
      wget http://update.intellique.com/pub/iscsitarget-0.9.3.wbm

    1. Access to Webmin using you favorite internet browser. Select Hardware and then iSCSI target management.



    1. Click on Create a new target



    1. Type in your prefer target name and alias



    1. Click on Add a Logical Unit


    1. In my case, I have select to use Local file. If you want to use block device, refer to the Use Block IO bottom of this post.


    1. When completed the LUN is ready


    1. You are now require to restart the iscsi-target service

    Setting up the iSCSI Initiator (Windows Vista)

    1. Go to Discovery tab. Add a Target portals.



    1. Go to Targets tab.



    1. Select the target and click Log on. Click OK.



    1. The status now will turn to connected.


    1. Right-click My Computer and select Manage.
    2. Go to Disk Management and then Storage. The new disk now is visible.


    Use Block IO
    It required you to allocate a new hard drive, or storage media for you to use BlockIO in IET. In my case, i am attaching a new hard drive and detect as /dev/sdb.


    1. Check the drive detail
      fdisk -l /dev/sdb

    2. Create new partition
      fdisk /dev/sdb
      Command (m for help): n
      accept default value to allocate all capacity

    3. Create filesystem. In my case, i am attaching the LUN to my Windows server, therefore i used NTFS
      mkntfs -f -L LUN1 -v /dev/sdb1

    4. Edit the ietd.conf
      Target iqn.2009-11:com.cotonso.storage2.lun1
              Alias com.cotonso.storage2.lun1
              Lun 0 Type=blockio,Path=/dev/sdb1,IOMode=wthru

    5. Restart IET service

    References

    Thursday, November 12, 2009

    How To: Fedora 10 Installation on Virtual PC

    1. Get Fedora 10 Distribution from http://fedoraproject.org/get-fedora.html .
    2. Create a virtual machine as ussual. Capture the Fedora 10 ISO image or use your CD\DVD drive if you have burn a copy to a disc.
    3. Boot up the virtual machine an you will find yourself at the boot screen.
    4. Hit e to edit the boot parameters.


    5. Add noreplace-paravirt singles as shown.




    6. Hit b to continue the boot process.



    7. Choose the packages according to your prefer preferences


    8. Installation in progress


    9. Click Finish to reboot the machine and complete the installation.

    10. For the first boot up, quickly hit F10 just after the BIOS screen to display the GRUB boot opyions.
    11. Type in the boot parameters as shown in step 5 and continue the boot process.
    12. Login to the system and ammend the /boot/grub/grub.conf file as shown below.




    13. Save and exit the editor. Run terminal# grub.
           Grub#> grub-install --no-floppy /dev/sda

    14. You will be able to load up to the login screen the next time you boot up.