Skip to content

Commit 127867c

Browse files
Noa ResarePrasanna Santhanam
authored andcommitted
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>
1 parent 5442df2 commit 127867c

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

client/bindir/cloud-setup-management.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818

19+
import sys
1920
from cloudutils.syscfg import sysConfigFactory
20-
from cloudutils.utilities import initLoging
21+
from cloudutils.utilities import initLoging, UnknownSystemException
2122
from cloudutils.cloudException import CloudRuntimeException, CloudInternalException
2223
from cloudutils.globalEnv import globalEnv
2324
from cloudutils.serviceConfigServer import cloudManagementConfig
@@ -35,7 +36,12 @@ if __name__ == '__main__':
3536
glbEnv.mode = "Server"
3637

3738
print "Starting to configure CloudStack Management Server:"
38-
syscfg = sysConfigFactory.getSysConfigFactory(glbEnv)
39+
try:
40+
syscfg = sysConfigFactory.getSysConfigFactory(glbEnv)
41+
except UnknownSystemException:
42+
print >>sys.stderr, ("Error: CloudStack failed to detect your "
43+
"operating system. Exiting.")
44+
sys.exit(1)
3945
try:
4046
syscfg.registerService(cloudManagementConfig)
4147
syscfg.config()

python/lib/cloudutils/utilities.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ def writeProgressBar(msg, result):
9696
output = "[%-6s]\n"%"Failed"
9797
sys.stdout.write(output)
9898
sys.stdout.flush()
99+
100+
class UnknownSystemException(Exception):
101+
"This Excption is raised if the current operating enviornment is unknown"
102+
pass
99103

100104
class Distribution:
101105
def __init__(self):
@@ -120,7 +124,7 @@ def __init__(self):
120124
self.arch = bash("uname -m").getStdout()
121125

122126
else:
123-
self.distro = "Unknown"
127+
raise UnknownSystemException
124128

125129
def getVersion(self):
126130
return self.distro

0 commit comments

Comments
 (0)