diff options
author | James Meyer <james.meyer@operamail.com> | 2012-01-19 17:07:06 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2012-01-19 17:07:06 (GMT) |
commit | 56826fc92b2709099307dcb18598d9d9ebae261b (patch) | |
tree | 5515a6c937e37e81cc2703634a53912f259f2225 /abs/core/LinHES-system/add_storage.py | |
parent | f73007ad230f904c5be6bd0ea38d86c0536b177a (diff) | |
download | linhes_pkgbuild-56826fc92b2709099307dcb18598d9d9ebae261b.zip linhes_pkgbuild-56826fc92b2709099307dcb18598d9d9ebae261b.tar.gz linhes_pkgbuild-56826fc92b2709099307dcb18598d9d9ebae261b.tar.bz2 |
LinHES-system: add_storage.py add the ability to only report on new disks, but take no action.
refs #796
Diffstat (limited to 'abs/core/LinHES-system/add_storage.py')
-rw-r--r-- | abs/core/LinHES-system/add_storage.py | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py index 9b20546..92a6120 100644 --- a/abs/core/LinHES-system/add_storage.py +++ b/abs/core/LinHES-system/add_storage.py @@ -362,7 +362,7 @@ def remove_pickle(): #-------------------------------------------- -def main(): +def main(scan_only): global bus bus = dbus.SystemBus() @@ -384,14 +384,27 @@ def main(): #print i.model continue else: - print "\n" - print "-------------------------------------------------------------" - print "Found new hard drive: %s location: %s size: %s \n" %(i.model,i.block_path,i.device_size) - if prompt_to_add(i) : - print "\nDisk will be added to the storage pool!" + if not scan_only: + print "\n" + print "-------------------------------------------------------------" + print "Found new hard drive: %s location: %s size: %s \n" %(i.model,i.block_path,i.device_size) + if prompt_to_add(i) : + print "\nDisk will be added to the storage pool!" + process_list.append(i) + else: process_list.append(i) + if scan_only: + if len(process_list) > 0: + f = open('/tmp/scan_report', 'w') + for i in process_list: + f.write("drive: %s , location: %s ,size: %s \n" %(i.model,i.block_path,i.device_size)) + print "drive: %s , location: %s ,size: %s \n" %(i.model,i.block_path,i.device_size) + f.close() + + sys.exit(0) + if len(process_list) > 0: DB = MythDB() host=gethostname() @@ -400,7 +413,7 @@ def main(): #BE = MythBE(db=DB) #save new list to disk_device - # write_known_drive_list(system_drive_list) + write_known_drive_list(system_drive_list) for i in process_list: i.partition_disk() @@ -414,12 +427,22 @@ def main(): if __name__ == "__main__": + scan_only = False + try: + os.remove("/tmp/scan_report") + except: + pass + if not os.geteuid()==0: sys.exit("\nRoot access is required to run this program\n") if "--new_init" in sys.argv : remove_pickle() - main() + + if "--report" in sys.argv : + scan_only = True + + main(scan_only) |