Files
xen/tools/control/src/org/xenoserver/control/CommandVdDelete.java
T
rac61@labyrinth.cl.cam.ac.uk 005477225b bitkeeper revision 1.332 (3f0d4a71ScYIvhpYjrv_aLLacdn4Ig)
Remove on-disk storage of virtual block devices
Implement retrieving VBD info from /proc
remove VBD delete and flush commands as VBDs go away by themselves when their domains are destroyed
2003-07-10 11:13:53 +00:00

44 lines
1.2 KiB
Java

package org.xenoserver.control;
/**
* Delete virtual disk.
*/
public class CommandVdDelete extends Command {
/** Key of disk to delete. */
private String key;
/** Force deletion? */
private boolean force;
/**
* Constructor for CommandVdDelete.
* @param key The key of the disk to delete.
*/
public CommandVdDelete(String key,boolean force) {
this.key = key;
this.force = force;
}
/**
* @see org.xenoserver.control.Command#execute()
*/
public String execute() throws CommandFailedException {
if (VirtualDiskManager.IT.getVirtualDisk(key) == null) {
throw new CommandFailedException(
"Virtual disk " + key + " does not exist");
}
if ( !force ) {
CommandVbdList list = new CommandVbdList();
list.execute();
VirtualBlockDevice[] vbds = list.vbds();
for (int i=0;i<vbds.length;i++) {
if (vbds[i].getVirtualDisk().getKey().equals(key)) {
throw new CommandFailedException("Virtual disk " + key + " is in use.");
}
}
}
VirtualDiskManager.IT.deleteVirtualDisk(key);
return "Deleted virtual disk " + key;
}
}