mirror of
https://github.com/gryf/boxpy.git
synced 2025-12-19 05:30:18 +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
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BoxConfError(BoxError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FakeLogger:
|
class FakeLogger:
|
||||||
"""
|
"""
|
||||||
print based "logger" class. I like to use 'end' parameter of print
|
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 = os.path.join(os.path.expanduser("~/.ssh"),
|
||||||
self.ssh_key_path)
|
self.ssh_key_path)
|
||||||
if not os.path.exists(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):
|
def _set_defaults(self):
|
||||||
conf = yaml.safe_load(USER_DATA)
|
conf = yaml.safe_load(USER_DATA)
|
||||||
@@ -720,6 +724,12 @@ class VBoxManage:
|
|||||||
LOG.fatal('Failed to create VM:\n%s', out.stderr)
|
LOG.fatal('Failed to create VM:\n%s', out.stderr)
|
||||||
return None
|
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'):
|
for line in out.stdout.split('\n'):
|
||||||
if line.startswith('UUID:'):
|
if line.startswith('UUID:'):
|
||||||
self.uuid = line.split('UUID:')[1].strip()
|
self.uuid = line.split('UUID:')[1].strip()
|
||||||
@@ -1137,7 +1147,8 @@ def vmcreate(args, conf=None):
|
|||||||
if not conf:
|
if not conf:
|
||||||
try:
|
try:
|
||||||
conf = Config(args)
|
conf = Config(args)
|
||||||
except BoxNotFound:
|
except BoxConfError as err:
|
||||||
|
LOG.fatal(f'Configuration error: {err.args[0]}.')
|
||||||
return 7
|
return 7
|
||||||
except yaml.YAMLError:
|
except yaml.YAMLError:
|
||||||
LOG.fatal(f'Cannot read or parse file `{args.config}` as YAML '
|
LOG.fatal(f'Cannot read or parse file `{args.config}` as YAML '
|
||||||
|
|||||||
Reference in New Issue
Block a user