Unable to delete Xenserver VDI – This operation cannot be performed because this VDI is in use by some other operation

After having problems with one of my Xenservers in my lab, I decided to build a SAN to store my VMs. After building the SAN, I created an iSCSI target and added it to the Xenserver pool. Next, I started moving a Windows 7 VM to the new SR, but changed my mind while it was copying. After I got the copy to cancel, I still had the virtual disk showing in the repository, and it was eating up space. When I went to delete it, the delete button was greyed out. I tried restarting the toolstack, but no luck.

So I guess it’s time to go to the command line. First thing I do is get the UUID of the VDI using the “xe vdi-list sr-uuid=611441f9-20c7-6775-716a-37c78b6d672e”. I get a list of VDIs and quickly find the uuid of the disk I want to delete.

uuid ( RO) : 203137f6-d98b-4e8e-8940-263e26360559
name-label ( RW): Win7-Image 0
name-description ( RW): DELETE
sr-uuid ( RO): 611441f9-20c7-6775-716a-37c78b6d672e
virtual-size ( RO): 25769803776
sharable ( RO): false
read-only ( RO): false

Now let’s try deleting with “xe vdi-destory uuid=611441f9-20c7-6775-716a-37c78b6d672e”. Result: The uuid you supplied was invalid. Whoops. Entered the SR uuid. Ok, let’s try this again. “xe vdi-destory uuid=203137f6-d98b-4e8e-8940-263e26360559

This operation cannot be performed because this VDI is in use by some other operation
vdi: 203137f6-d98b-4e8e-8940-263e26360559 (Win7-Image 0)
operation: destroy

Eh boy. OK, so what is using it? When I’m looking at Xencenter, it shows the Virtual machine it is attached to is “Control domain on host xen1”, which is my first xenserver.

Next we need to look at the the virtual block devices that might be tying up this VDI by entering “xe vbd-list vdi-uuid=203137f6-d98b-4e8e-8940-263e26360559”. This should give you the result back similar to the following.

uuid ( RO) : fb58a7e8-6ad3-ed6b-05bb-817d6ff1e4f0
vm-uuid ( RO): 233c0fd0-1a4d-4746-8ae6-8d0bd642a145
vm-name-label ( RO): Control domain on host: xen1
vdi-uuid ( RO): 203137f6-d98b-4e8e-8940-263e26360559
empty ( RO): false
device ( RO): sm/backend/611441f9-20c7-6775-716a-37c78b6d672e/203137f6-d98b-4e8e-8940-263e26360559

Now, let’s delete that vbd so it releases the vdi by entering “xe vbd-unplug uuid=fb58a7e8-6ad3-ed6b-05bb-817d6ff1e4f0” followed by “xe vbd-destroy uuid=fb58a7e8-6ad3-ed6b-05bb-817d6ff1e4f0″.

You should now be able to delete the drive from Xencenter for from the command line.

WordPress 404 error on preview.. aka this is embarrassing error

I was having no luck finding a solution for this issue, so I figured I’d blog about it for posterity (so I can find it next time when I forget what I did). I recently setup a new blog about business continuity. I set everything up like this blog and my python blog, and everything seemed to work fine. I put my intro post out without a problem.

The next time I go to post, I put my first draft in and go to preview the post. This time, I get a message telling me the site is so embarrassed this happened but the page cannot be found. While this 404 error is kinda funny, I had no idea why I was getting it. Also, I could still post without issue. It was preview only that wasn’t working.

I must have played with the permalinks a hundred times including editing the .htaccess file directly. I searched on WordPress’s site and constantly came across the resolution of it’s your web browser. Clear your cache. Not so in my case. I tried it from several computers.

After this, I disabled all plugins, which didn’t help either. I changed the theme. No go. Finally, a week after this started, I just so happened to be looking at my settings and noticed I didn’t have the same URL in the site address and the WordPress address. One had http://www.playingwithdisaster.com and the other had http://playingwithdisaster.com. Unfortunately, I can’t remember which was which now, but that did the trick.

Wordpress and site URL

Fortinet Fortigate won’t save changes – CFG_CMDBAPI_ERR

It seems like every time I have to make a change to one of our Fortigate firewalls, the changes won’t be accepted, and I get the error “CFG_CMDBAPI_ERR“. That might be even worse than a Microsoft error.

If you do some googling for the error, you will find most people tell you to restart the ipsmonitor process. This is done with the “diag test application ipsmonitor 99” command. This typically does the trick, but today it was not working for me.

To see what was using up resources, I entered the “diag sys top 1” command. The last field shows the memory used. In my case, the problem was forticron.

Now, you can’t restart forticron the same way you restart ipsmonitor. You have to kill forticron, and to do that, you first have to get the pid (process ID). At the “diag sys top 1” command screen, the pid is the number right after the process name, which is the second column. Next, hit the Q key to exit the process screen. Now enter “diag sys kill 11 <pid>” where <pid> is replaced with the pid you just got from the previous screen. That should kill the process. It did for me, and I was able to make the changes that I needed.

Hope this helps someone out there. I know it was a pain trying to find the fix when I needed it.

WordPress emails not working

This wasn’t intended to be my first post, but I just finished getting email working for this blog, so I figured why not post how I got it work. We can always do an intro later.

For this blog and another blog I just started, www.playingwithpython.com, I setup a Linux server to host the sites using Apache. After getting the sites setup, I went to setup a couple security plugins that send email alerts. Unfortunately, emails were not working.

Being a fairly recent adopter of Linux, these type of issue are never light bulb moments for me. It takes hitting up Google for the answers. Typically, I scour the web for a couple hours trying pull enough pieces together to get the puzzle put together. This was no different.

In order to save you the time that I wasted, let me just post the steps I did to get this working.

First, I immediately figured I didn’t load sendmail, since I loaded a barebones linux install for this server. So, first step is to load Sendmail.

Install Sendmail:

  1. Since I’m running CentOS, I installed sendmail with “yum install sendmail”.
  2. Next, I set the service to start automatically with the “chkconfig sendmail on” command.
  3. Lastly, start the service with “service sendmail start”.

Alright, send mail is loaded and allows local host by default. Let’s go test these emails again….. nope. Still not working. I was getting the error “Could not instantiate mail function”.

I went to check the logs in the file /var/log/maillog and found the error…

NOQUEUE: SYSERR(apache): can not chdir(/var/spool/clientmqueue/): Permission denied

The problem now is SELinux. You can test and resolve this issue via the following commands:

  1. Check to see if httpd can sendmail by running “getsebool -a | grep mail”
  2. See if “httpd_can_sendmail –> on” shows. If it says off, SELinux is blocking httpd from initiating sendmail.
  3. Run “setsebool -P httpd_can_sendmail on” to fix SELinux.

You should now be able to send emails via WordPress’s, well really PHP’s mail() function.