#!/usr/bin/env python
#
# Copyright 2006-2016 Hunan Kylin, Inc.  All Rights Reserved.
# 
# NOTICE: ALL INFORMATION CONTAINED HEREIN IS, AND REMAINS THE PROPERTY OF
# HUNAN KYLIN, INC. AND ITS SUPPLIERS, IF ANY. THE INTELLECTUAL AND
# TECHNICAL CONCEPTS CONTAINED HEREIN ARE PROPRIETARY TO HUNAN KYLIN, INC.
# AND ITS SUPPLIERS AND MAY BE COVERED BY U.S. AND FOREIGN PATENTS, PATENTS IN
# PROCESS, AND ARE PROTECTED BY TRADE SECRET OR COPYRIGHT LAW. DISSEMINATION
# OF THIS INFORMATION OR REPRODUCTION OF THIS MATERIAL IS STRICTLY FORBIDDEN
# UNLESS PRIOR WRITTEN PERMISSION IS OBTAINED FROM HUNAN KYLIN, INC.
#
# -*- coding: utf-8 -*-

#
# Main source file for the "ksvd-dump-storage-config" executable.
# Prints the storage configuration either from file, or from the
# hardware configuration
#

import sys
import errno
from os.path import join, dirname, abspath

# Find our python libraries
sys.path.append(join(dirname(dirname(abspath(sys.argv[0]))), 'etc/python'))

from KsvdUtil import xl_
import KsvdApp
import KsvdNetConfig
import KsvdScreen



class KsvdDumpStorageConfigApp(KsvdApp.KsvdApp):
	#
	# Initialize the application framework
	#
	def __init__(self, appArgs):
		KsvdApp.KsvdApp.__init__(
			self,
			appArgs,
			forceInteractive = True)

	#
	# Construct the storage configuration dump
	#
	def InvokeApp(self):
		# Gather the network configuration
		currNetCfg = KsvdNetConfig.GatherNetworkConfiguration()
		if not currNetCfg or not len(currNetCfg):
			KsvdScreen.PrintError(xl_(
				'No network configuration exists. This utility'
				'\nmust be run on a configured network.'))
			return errno.ENOENT

		# Gather the storage configuration
		storageConfigStr = currNetCfg.ListExternalStorageInfo()

		# Print it out
		KsvdScreen.PrintMessage(storageConfigStr)
		return 0

# Run this program, that's all.
KsvdDumpStorageConfigApp(appArgs = sys.argv).RunApp()

