diff --git a/db_server/delete.provision.inc b/db_server/delete.provision.inc
index 67e2cf8..4f08888 100644
--- a/db_server/delete.provision.inc
+++ b/db_server/delete.provision.inc
@@ -2,7 +2,9 @@
 
 
 function drush_provision_mysql_provision_delete_validate() {
-  provision_db_connect();
+  if (PROVISION_CONTEXT_SITE) {
+    provision_db_connect();
+  }
 }
 
 /**
@@ -11,6 +13,7 @@ function drush_provision_mysql_provision_delete_validate() {
  * This will drop the database, revoke the privileges and flush the privileges.
  */
 function drush_provision_mysql_provision_delete($url = NULL) {
-  return  _provision_mysql_destroy_site_db(drush_get_option('db_name'), drush_get_option('db_user'), drush_get_option('db_passwd'));
+  if (PROVISION_CONTEXT_SITE) {
+    return  _provision_mysql_destroy_site_db(drush_get_option('db_name'), drush_get_option('db_user'), drush_get_option('db_passwd'));
+  }
 }
-
diff --git a/platform/delete.provision.inc b/platform/delete.provision.inc
index fd676aa..5d3e2fa 100644
--- a/platform/delete.provision.inc
+++ b/platform/delete.provision.inc
@@ -2,27 +2,39 @@
 
 
 function drush_provision_drupal_provision_delete_validate($url = NULL, $backup_file = NULL) {
-  _provision_drupal_valid_site();
+  if (PROVISION_CONTEXT_SITE) {
+    _provision_drupal_valid_site();
+  }
 }
 
-
 /**
  * Before starting to delete the site, make a backup
  */
-function drush_provision_drupal_pre_provision_delete($url, $backup_file = NULL) {
-  drush_set_option('force', true, 'process');
-  drush_invoke("provision backup", $url, $backup_file);
-  drush_unset_option('force', 'process');
+function drush_provision_drupal_pre_provision_delete($url = NULL, $backup_file = NULL) {
+  if (PROVISION_CONTEXT_SITE) {
+    drush_set_option('force', true, 'process');
+    drush_invoke("provision backup", $url, $backup_file);
+    drush_unset_option('force', 'process');
+  }
 }
 
 /**
- * Remove any directories for the site in sites
+ * If we're deleting a site, remove any directories for the site in sites folder
+ * If we're deleting a platform, remove the whole platform
  * This can't be rolled back. so won't even try.
  */
-function drush_provision_drupal_provision_delete($url) {
-  _provision_recursive_delete(drush_get_option('sites_path') . "/$url");
-  _provision_drupal_delete_aliases(drush_get_option('aliases', array()));
-  drush_set_option('installed', FALSE, 'site');
+function drush_provision_drupal_provision_delete($url = NULL) {
+  if (PROVISION_CONTEXT_SITE) {
+    _provision_recursive_delete(drush_get_option('sites_path') . "/$url");
+    _provision_drupal_delete_aliases(drush_get_option('aliases', array()));
+    drush_set_option('installed', FALSE, 'site');
+  }
+  if (PROVISION_CONTEXT_PLATFORM) {
+    if(!provision_drupal_find_any_sites()) {
+      $drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT');
+      _provision_recursive_delete($drupal_root);
+    }
+  }
 }
 
 
diff --git a/platform/lock.provision.inc b/platform/lock.provision.inc
new file mode 100644
index 0000000..899bd50
--- /dev/null
+++ b/platform/lock.provision.inc
@@ -0,0 +1,17 @@
+<?php
+
+// $Id$ 
+
+/**
+ * Provision lock command
+ *
+ * Disable an enabled platform from having any more sites provisioned on it
+ */
+
+/**
+ * Set the enabled property of the platform to false
+ */
+function drush_provision_drupal_provision_lock() {
+  drush_set_option('enabled', FALSE, 'platform');
+}
+
diff --git a/platform/provision_drupal.drush.inc b/platform/provision_drupal.drush.inc
index 5f6a9a4..3c5a3eb 100644
--- a/platform/provision_drupal.drush.inc
+++ b/platform/provision_drupal.drush.inc
@@ -86,7 +86,9 @@ function provision_drupal_drush_exit($url = NULL) {
       }
     }
     else {
-      _provision_generate_config();
+      if ($command[1] !== 'delete') {
+        _provision_generate_config();
+      }
     }
   }
 }
@@ -332,6 +334,27 @@ function provision_drupal_find_sites() {
   return $sites;
 }
 
+// Simple function to return true if *any* sites are found
+function provision_drupal_find_any_sites() {
+  if ($dir = opendir("./sites")) {
+    while (FALSE !== ($subdir = readdir($dir))) {
+      // skip internal directory pointers
+      if ($subdir != '.' && $subdir != '..') {
+        $file = "./sites/$subdir/settings.php";
+        if (file_exists("$file") && ($subdir != 'default') && !is_link("./sites/$subdir")) {
+          $sites[$subdir] = $file;
+          drush_set_error(dt("Existing sites were found on this platform. Platform cannot be deleted until sites are removed or migrated off this platform."));
+          $sites = TRUE;
+        }
+      }
+    }
+    closedir($dir);
+  } else {
+    drush_log(dt("Found no existing sites, so will proceed with platform deletion"));
+    $sites = FALSE;
+  }
+  return $sites;
+}
 function _provision_drupal_get_cvs_versions($files) {
   foreach ($files as $modulename => $file) {
       $project = array();
diff --git a/platform/unlock.provision.inc b/platform/unlock.provision.inc
new file mode 100644
index 0000000..938e7c9
--- /dev/null
+++ b/platform/unlock.provision.inc
@@ -0,0 +1,17 @@
+<?php
+
+// $Id$ 
+
+/**
+ * Provision unlock command
+ *
+ * Enable a previously locked platform so that sites can be provisioned on it
+ */
+
+/**
+ * Set the enabled property of the platform to true
+ */
+function drush_provision_drupal_provision_unlock() {
+  drush_set_option('enabled', TRUE, 'platform');
+}
+
diff --git a/provision.drush.inc b/provision.drush.inc
index 18e8522..3bf05d3 100644
--- a/provision.drush.inc
+++ b/provision.drush.inc
@@ -22,13 +22,18 @@
  *             or used for an upgrade.
  *   disable - Disable an installed Drupal site. Changes the virtual host config file so that it redirects to provision_disabled_site_redirect_url
  *   enable  - Re-enable a site that has already been disabled. Recreates the virtual host file.
- *   delete  - Generates a back up of the site, and then removes all references to it.
+ *   delete  - In a site context: generates a back up of the site, and then removes all references to it.
+ *             In a platform context: removes the platform and its vhost config from the server if no sites are currently running on it
  *   restore - Revert to a previous backup of the site.
  *
  *   deploy  - Accepts a site package (backup) as argument, and redeploys it, running the upgrade processes on it.
  *             Uses hook_provision_pre_upgrade(), hook_provision_upgrade() and hook_provision_post_upgrade() hooks,
  *             and allows clean roll back if any errors occur. Will include stringent checking of module versions,
  *             and allow unit tests to be run.
+ *   lock    - Lock a platform so that sites cannot be provisioned on it. This does not disable or delete the platform
+ *             nor any sites currently provisioned on it.
+ *   unlock  - Unlock a platform so that sites can be provisioned on it.
+ *
  * Not implemented yet :
  *   rename  - Change the url of a site. This requires moving of files, and numerous other issues.
  */
@@ -75,12 +80,23 @@ function provision_drush_command() {
     'description' => 'Enable a disabled site.',
     'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
   );
+
   $items['provision disable'] = array(
     'arguments' => array('domain.com' => dt('The domain of the site to disable (only if disabled).')),    
     'description' => 'Disable a site.',
     'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
   );
 
+  $items['provision lock'] = array(
+    'description' => 'Lock a platform from having any other sites provisioned on it.',
+    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
+  );
+
+  $items['provision unlock'] = array(
+    'description' => 'Unlock a platform so that sites can be provisioned on it.',
+    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
+  );
+
   $items['provision verify'] = array(
     'arguments' => array('domain.com' => dt('The domain of the site to verify).')),    
     'description' => 'Verify that the provisioning framework is correctly installed.',
diff --git a/web_server/delete.provision.inc b/web_server/delete.provision.inc
index 8dca268..8770153 100644
--- a/web_server/delete.provision.inc
+++ b/web_server/delete.provision.inc
@@ -1,7 +1,15 @@
 <?php
 
 function drush_provision_apache_provision_delete($url = NULL) {
-  _provision_apache_delete_vhost_config($url);
+  if (PROVISION_CONTEXT_SITE) {
+    _provision_apache_delete_vhost_config($url);
+  }
+  if (PROVISION_CONTEXT_PLATFORM) {
+    $options = drush_get_merged_options();
+    if(!provision_drupal_find_any_sites()) {
+      _provision_apache_delete_config('platform_' . $options['platform'] . '.conf');
+    }
+  }
   return _provision_apache_restart_apache();  
 }
 
diff --git a/web_server/provision_apache.drush.inc b/web_server/provision_apache.drush.inc
index d0cfb85..9a3f90d 100644
--- a/web_server/provision_apache.drush.inc
+++ b/web_server/provision_apache.drush.inc
@@ -216,6 +216,12 @@ function _provision_apache_create_config($file, $data, $template) {
   }
 }
 
+function _provision_apache_delete_config($file) {
+  provision_path("unlink", drush_get_option('vhost_path') ."/" . $file, TRUE, dt("Removed apache platform vhost configuration"));
+}
+
+
+
 /**
  * Restart Apache
  */
