Improved handling of unknown OS, Distribution

Introduce UnknownSystemExcpetion to indicate that the system is
is unknonwn. Catch said exception in cloud-setup-management,
print an error and exit.

CLOUDSTACK-966: Improve error reporting when running on unknown OS / version

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
Noa Resare 2013-01-12 19:07:32 +00:00 committed by Prasanna Santhanam
parent 5442df2b5e
commit 127867cc99
2 changed files with 13 additions and 3 deletions

View File

@ -16,8 +16,9 @@
# specific language governing permissions and limitations
# under the License.
import sys
from cloudutils.syscfg import sysConfigFactory
from cloudutils.utilities import initLoging
from cloudutils.utilities import initLoging, UnknownSystemException
from cloudutils.cloudException import CloudRuntimeException, CloudInternalException
from cloudutils.globalEnv import globalEnv
from cloudutils.serviceConfigServer import cloudManagementConfig
@ -35,7 +36,12 @@ if __name__ == '__main__':
glbEnv.mode = "Server"
print "Starting to configure CloudStack Management Server:"
syscfg = sysConfigFactory.getSysConfigFactory(glbEnv)
try:
syscfg = sysConfigFactory.getSysConfigFactory(glbEnv)
except UnknownSystemException:
print >>sys.stderr, ("Error: CloudStack failed to detect your "
"operating system. Exiting.")
sys.exit(1)
try:
syscfg.registerService(cloudManagementConfig)
syscfg.config()

View File

@ -96,6 +96,10 @@ def writeProgressBar(msg, result):
output = "[%-6s]\n"%"Failed"
sys.stdout.write(output)
sys.stdout.flush()
class UnknownSystemException(Exception):
"This Excption is raised if the current operating enviornment is unknown"
pass
class Distribution:
def __init__(self):
@ -120,7 +124,7 @@ class Distribution:
self.arch = bash("uname -m").getStdout()
else:
self.distro = "Unknown"
raise UnknownSystemException
def getVersion(self):
return self.distro