Allow no_bridge option to be put in slapos.cfg

parent 429e937a
...@@ -1080,18 +1080,19 @@ class Config(object): ...@@ -1080,18 +1080,19 @@ class Config(object):
self.logger.addHandler(logging.StreamHandler()) self.logger.addHandler(logging.StreamHandler())
# Convert strings to booleans # Convert strings to booleans
root_needed = False for o in ['alter_network', 'alter_user', 'no_bridge']:
for o in ['alter_network', 'alter_user']: attr = getattr(self, o)
if getattr(self, o).lower() == 'true': if isinstance(attr, str):
root_needed = True if attr.lower() == 'true':
setattr(self, o, True) root_needed = True
elif getattr(self, o).lower() == 'false': setattr(self, o, True)
setattr(self, o, False) elif attr.lower() == 'false':
else: setattr(self, o, False)
message = 'Option %r needs to be "True" or "False", wrong value: ' \ else:
'%r' % (o, getattr(self, o)) message = 'Option %r needs to be "True" or "False", wrong value: ' \
self.logger.error(message) '%r' % (o, getattr(self, o))
raise UsageError(message) self.logger.error(message)
raise UsageError(message)
if not self.dry_run: if not self.dry_run:
if self.alter_user: if self.alter_user:
...@@ -1102,7 +1103,10 @@ class Config(object): ...@@ -1102,7 +1103,10 @@ class Config(object):
if self.alter_network: if self.alter_network:
self.checkRequiredBinary(['brctl']) self.checkRequiredBinary(['brctl'])
if self.dry_run: # Check if root is needed
if (self.alter_network or self.alter_user) and not self.dry_run:
root_needed = True
else:
root_needed = False root_needed = False
# check root # check root
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment