From 34f908229a491458a8d12f11c8afb4feffb74cad Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Thu, 30 Aug 2012 19:32:10 -0500
Subject: LinHES-system: add_Storage.py  split up storage groups into fe and be

---
 abs/core/LinHES-system/add_storage.py | 90 +++++++++++++++++++++++------------
 1 file changed, 60 insertions(+), 30 deletions(-)

diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py
index 367106e..3f02acd 100644
--- a/abs/core/LinHES-system/add_storage.py
+++ b/abs/core/LinHES-system/add_storage.py
@@ -20,20 +20,27 @@ storage_dir = "/etc/storage.d"
 pickle_file = "%s/storage.pkl" %storage_dir
 
 
+SG_MAP_BE={ 'Default'    :'tv',
+'LiveTV'     :'media/tv/live',
+'DB Backups' :'system_backups/mythtv_db/'}
 
-SG_MAP={ 'Default'    :'tv',
-  'LiveTV'     :'tv/live',
-  'Videos'     :'video',
-  'Trailers'   :'video_stuff/trailers',
-  'Coverart'   :'video_stuff/coverart',
-  'Fanart'     :'video_stuff/fanart',
-  'Banners'    :'video_stuff/banners',
-  'Screenshots':'video_stuff/screenshots',
-  'DB Backups' :'db_backups'}
-FS_LIST=[]
-for key in SG_MAP.keys():
-    FS_LIST.append(SG_MAP[key])
 
+SG_MAP_FE={
+  'Videos'     :'media/video',
+  'Trailers'   :'media/video_stuff/trailers',
+  'Coverart'   :'media/video_stuff/coverart',
+  'Fanart'     :'media/video_stuff/fanart',
+  'Banners'    :'media/video_stuff/banners',
+  'Screenshots':'media/video_stuff/screenshots',
+  }
+
+FS_LIST_BE=[]
+for key in SG_MAP_BE.keys():
+    FS_LIST_BE.append(SG_MAP_BE[key])
+
+FS_LIST_FE=[]
+for key in SG_MAP_FE.keys():
+    FS_LIST_FE.append(SG_MAP_FE[key])
 
 
 class disk_device:
@@ -453,7 +460,7 @@ def remove_pickle():
 
 #--------------------------------------------
 
-def main(scan_only, destruction, no_mount, install_call):
+def main(scan_only, destruction, no_mount, install_call , dir_fe_only):
     global bus
     bus = dbus.SystemBus()
 
@@ -516,23 +523,33 @@ def main(scan_only, destruction, no_mount, install_call):
     write_known_drive_list(system_drive_list)
     if len(process_list) > 0:
         print "\n    Adding storage: \n"
-    if prompt_to_continue() == True:
-        for i in process_list:
-            print "    Drive: %s" %(i.get_name())
-            if destruction == True:
-                i.partition_disk()
-                i.format_disk()
-            i.add_fstab()
-            i.mount_disk(no_mount)
-            if destruction == True:
-                i.mkdirs(FS_LIST)
-            i.write_config()
-            i.add_sg(DB,host,SG_MAP)
-            print "-----"
+        if prompt_to_continue() == True:
+            for i in process_list:
+                print "    Drive: %s" %(i.get_name())
+                if destruction == True:
+                    i.partition_disk()
+                    i.format_disk()
+                i.add_fstab()
+                i.mount_disk(no_mount)
+                if destruction == True:
+                    if dir_fe_only != True:
+                        i.mkdirs(FS_LIST_BE)
+                    i.mkdirs(FS_LIST_FE)
+                i.write_config()
+
+                #always create the FE groups(video)..do not need to create Be
+                if dir_fe_only != True:
+                    i.add_sg(DB,host,SG_MAP_BE)
+
+                i.add_sg(DB,host,SG_MAP_FE)
+
+
+
+                print "-----"
 
         #i.add_sg(DB,host,SG_MAP)
 
-def myth_main(no_mount,install_call):
+def myth_main(no_mount,install_call,dir_fe_only):
     global bus
     bus = dbus.SystemBus()
     #search for root
@@ -584,7 +601,12 @@ def myth_main(no_mount,install_call):
     #if not install_call:
     i.mount_disk(no_mount)
     i.write_config()
-    i.add_sg(DB,host,SG_MAP,'99',install_call)
+    #always create the FE groups(video)..do not need to create Be
+    if dir_fe_only != True:
+        i.add_sg(DB,host,SG_MAP_BE,'99',install_call)
+
+    i.add_sg(DB,host,SG_MAP_FE,'99',install_call)
+
     i.symlink()
 
 
@@ -607,6 +629,7 @@ def usage():
     --no_destruction:  Will not  partition or format the disk
     --new_init :  Erase the list of new disks and rescan.
     --report :  will scan the disks and print out if it found new storage.
+    --fe_only :  Will only create the storage group dir for videos..excludes tv
     '''
     print help
     sys.exit(0)
@@ -620,6 +643,8 @@ if __name__ == "__main__":
     no_mount = False
     destruction = True
     install_call = False
+    dir_fe_only = False
+
     try:
         os.remove("/tmp/scan_report")
     except:
@@ -646,10 +671,15 @@ if __name__ == "__main__":
     if "--report" in sys.argv :
         scan_only = True
 
+    if "--fe_only" in sys.argv:
+        dir_fe_only = True
+
+
+
     if "--double_myth" in sys.argv:
-        myth_main(no_mount,install_call)
+        myth_main(no_mount,install_call,dir_fe_only)
     else:
-        main(scan_only,destruction,no_mount, install_call)
+        main(scan_only,destruction,no_mount, install_call, dir_fe_only)
 
 
 
-- 
cgit v0.12