incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core] Mock: Moved the default directory from /var/tmp to /var/lib (BZ: #750880)
Date Mon, 07 Nov 2011 10:47:10 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/Rakefile                                   |   13 +++++++++----
 server/lib/deltacloud/drivers/mock/mock_driver.rb |    2 +-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/server/Rakefile b/server/Rakefile
index f07a6ce..e8b2f03 100644
--- a/server/Rakefile
+++ b/server/Rakefile
@@ -129,13 +129,18 @@ namespace :mock do
       if ENV["DELTACLOUD_MOCK_STORAGE"]
         storage_root = ENV["DELTACLOUD_MOCK_STORAGE"]
       elsif ENV["USER"]
-        storage_root = File::join("/var/tmp", "deltacloud-mock-#{ENV["USER"]}")
+        storage_root = File::join("/var/lib/deltacloud", "deltacloud-mock-#{ENV["USER"]}")
       else
         raise "Please set either the DELTACLOUD_MOCK_STORAGE or USER environment variable"
       end
       data = Dir::glob(File::join(File::dirname(__FILE__), "lib", "deltacloud", "drivers",
"mock", "data", "*"))
-      FileUtils::mkdir_p(storage_root, :verbose => true)
-      FileUtils::cp_r(data, storage_root, :verbose => true)
+      begin
+        FileUtils::mkdir_p(storage_root, :verbose => true)
+        FileUtils::cp_r(data, storage_root, :verbose => true)
+      rescue Errno::EACCES
+        puts "\nERROR: Please create the '/var/lib/deltacloud' directory manually and ensure
that the current user has write permissions on it.\n"
+        puts "TIP: You can set the DELTACLOUD_MOCK_STORAGE environment variable to overide
the default location.\n\n"
+      end
     end
 
     desc "Remove Mock driver fixtures"
@@ -143,7 +148,7 @@ namespace :mock do
       if ENV["DELTACLOUD_MOCK_STORAGE"]
         storage_root = ENV["DELTACLOUD_MOCK_STORAGE"]
       elsif ENV["USER"]
-        storage_root = File::join("/var/tmp", "deltacloud-mock-#{ENV["USER"]}")
+        storage_root = File::join("/var/lib/deltacloud", "deltacloud-mock-#{ENV["USER"]}")
       else
         raise "Please set either the DELTACLOUD_MOCK_STORAGE or USER environment variable"
       end
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index 29d18ef..a5f6ff1 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -91,7 +91,7 @@ module Deltacloud::Drivers::Mock
       if ENV["DELTACLOUD_MOCK_STORAGE"]
         storage_root = ENV["DELTACLOUD_MOCK_STORAGE"]
       elsif ENV["USER"]
-        storage_root = File::join("/var/tmp", "deltacloud-mock-#{ENV["USER"]}")
+        storage_root = File::join("/var/lib/deltacloud", "deltacloud-mock-#{ENV["USER"]}")
       else
         raise "Please set either the DELTACLOUD_MOCK_STORAGE or USER environment variable"
       end
-- 
1.7.4.4


Mime
View raw message