Commit 6522e6f7 authored by Cédric de Saint Martin's avatar Cédric de Saint Martin

Merge branch 'no_bridge'

Conflicts:
	slapos/grid/SlapObject.py
parents d41f6522 0c37c785
......@@ -4,7 +4,9 @@ Changes
0.26 (Unreleased)
-----------------
* No change yet.
* slapformat: no_bridge option becomes 'not create_tap'.
create_tap is true by default. So a bridge is used and tap will be created by
default. [Cedric de Saint Martin]
0.25 (2012-05-16)
-----------------
......
......@@ -179,7 +179,7 @@ class Computer(object):
def __getinitargs__(self):
return (self.reference, self.interface)
def getAddress(self):
def getAddress(self, allow_tap=False):
"""
Return a list of the interface address not attributed to any partition, (which
are therefore free for the computer itself).
......@@ -201,12 +201,16 @@ class Computer(object):
if address_dict['addr'] not in computer_partition_address_list:
return address_dict
if allow_tap:
# all addresses on interface are for partition, so lets add new one
computer_tap = Tap('compdummy')
computer_tap.createWithOwner(User('root'), attach_to_tap=True)
self.interface.addTap(computer_tap)
return self.interface.addAddr()
# Can't find address
return False
def send(self, config):
"""
Send a marshalled dictionary of the computer object serialized via_getDict.
......@@ -851,10 +855,6 @@ class Parser(OptionParser):
help="Don't actually do anything.",
default=False,
action="store_true"),
Option("-b", "--no_bridge",
help="Don't use bridge but use real interface like eth0.",
default=False,
action="store_true"),
Option("-v", "--verbose",
default=False,
action="store_true",
......@@ -979,7 +979,7 @@ def run(config):
computer.instance_root = config.instance_root
computer.software_root = config.software_root
config.logger.info('Updating computer')
address = computer.getAddress()
address = computer.getAddress(config.create_tap)
computer.address = address['addr']
computer.netmask = address['netmask']
......@@ -1006,7 +1006,7 @@ def run(config):
computer_definition.write(open(filepath, 'w'))
config.logger.info('Stored computer definition in %r' % filepath)
computer.construct(alter_user=config.alter_user,
alter_network=config.alter_network, create_tap=not config.no_bridge)
alter_network=config.alter_network, create_tap=config.create_tap)
# Dumping and sending to the erp5 the current configuration
if not config.dry_run:
......@@ -1020,6 +1020,7 @@ class Config(object):
cert_file = None
alter_network = None
alter_user = None
create_tap = None
computer_xml = None
logger = None
log_file = None
......@@ -1080,6 +1081,8 @@ class Config(object):
self.alter_user = 'True'
if self.software_user is None:
self.software_user = 'slapsoft'
if self.create_tap is None:
self.create_tap = True
# set up logging
self.logger = logging.getLogger("slapformat")
......@@ -1088,7 +1091,7 @@ class Config(object):
self.logger.addHandler(logging.StreamHandler())
# Convert strings to booleans
for o in ['alter_network', 'alter_user', 'no_bridge']:
for o in ['alter_network', 'alter_user', 'create_tap']:
attr = getattr(self, o)
if isinstance(attr, str):
if attr.lower() == 'true':
......@@ -1105,12 +1108,12 @@ class Config(object):
if not self.dry_run:
if self.alter_user:
self.checkRequiredBinary(['groupadd', 'useradd', 'usermod'])
if not self.no_bridge:
if self.create_tap:
self.checkRequiredBinary(['tunctl'])
if self.alter_network:
self.checkRequiredBinary(['ip'])
# Required, even for dry run
if self.alter_network and not self.no_bridge:
if self.alter_network and self.create_tap:
self.checkRequiredBinary(['brctl'])
# Check if root is needed
......@@ -1149,8 +1152,8 @@ class Config(object):
self.logger.debug("Verbose mode enabled.")
if self.dry_run:
self.logger.info("Dry-run mode enabled.")
if self.no_bridge:
self.logger.info("No-bridge mode enabled.")
if self.create_tap:
self.logger.info("Tap mode enabled.")
# Calculate path once
self.computer_xml = os.path.abspath(self.computer_xml)
......
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