mirror of
https://github.com/gryf/boxpy.git
synced 2025-12-18 13:00:17 +01:00
Better messagingn in conf/modules vbox issues
This commit is contained in:
15
box.py
15
box.py
@@ -267,6 +267,10 @@ class BoxVBoxFailure(BoxError):
|
||||
pass
|
||||
|
||||
|
||||
class BoxConfError(BoxError):
|
||||
pass
|
||||
|
||||
|
||||
class FakeLogger:
|
||||
"""
|
||||
print based "logger" class. I like to use 'end' parameter of print
|
||||
@@ -498,7 +502,7 @@ class Config:
|
||||
self.ssh_key_path = os.path.join(os.path.expanduser("~/.ssh"),
|
||||
self.ssh_key_path)
|
||||
if not os.path.exists(self.ssh_key_path):
|
||||
raise BoxNotFound(f'Cannot find ssh public key: {self.key}')
|
||||
raise BoxConfError(f'Cannot find ssh public key: {self.key}')
|
||||
|
||||
def _set_defaults(self):
|
||||
conf = yaml.safe_load(USER_DATA)
|
||||
@@ -720,6 +724,12 @@ class VBoxManage:
|
||||
LOG.fatal('Failed to create VM:\n%s', out.stderr)
|
||||
return None
|
||||
|
||||
if out.stdout.startswith('WARNING:'):
|
||||
LOG.fatal('Created crippled VM:\n%s\nFix the issue with '
|
||||
'VirtualBox, remove the dead VM and start over.',
|
||||
out.stdout)
|
||||
return None
|
||||
|
||||
for line in out.stdout.split('\n'):
|
||||
if line.startswith('UUID:'):
|
||||
self.uuid = line.split('UUID:')[1].strip()
|
||||
@@ -1137,7 +1147,8 @@ def vmcreate(args, conf=None):
|
||||
if not conf:
|
||||
try:
|
||||
conf = Config(args)
|
||||
except BoxNotFound:
|
||||
except BoxConfError as err:
|
||||
LOG.fatal(f'Configuration error: {err.args[0]}.')
|
||||
return 7
|
||||
except yaml.YAMLError:
|
||||
LOG.fatal(f'Cannot read or parse file `{args.config}` as YAML '
|
||||
|
||||
Reference in New Issue
Block a user