Commit 9ebe136f authored by Marco Mariani's avatar Marco Mariani

extracted write_computer_definition()

parent c8c8f1b2
......@@ -1039,28 +1039,13 @@ def parse_computer_xml(config, xml_path):
return computer
def run(config):
if config.input_definition_file:
computer = parse_computer_definition(config, config.input_definition_file)
else:
# no definition file, figure out computer
computer = parse_computer_xml(config, config.computer_xml)
computer.instance_root = config.instance_root
computer.software_root = config.software_root
config.logger.info('Updating computer')
address = computer.getAddress(config.create_tap)
computer.address = address['addr']
computer.netmask = address['netmask']
if config.output_definition_file:
def write_computer_definition(config, computer):
computer_definition = ConfigParser.RawConfigParser()
computer_definition.add_section('computer')
if computer.address is not None and computer.netmask is not None:
computer_definition.set('computer', 'address', '/'.join(
[computer.address, computer.netmask]))
partition_number = 0
for partition in computer.partition_list:
for partition_number, partition in enumerate(computer.partition_list):
section = 'partition_%s' % partition_number
computer_definition.add_section(section)
address_list = []
......@@ -1071,10 +1056,27 @@ def run(config):
computer_definition.set(section, 'user', partition.user.name)
computer_definition.set(section, 'network_interface', partition.tap.name)
computer_definition.set(section, 'pathname', partition.reference)
partition_number += 1
computer_definition.write(open(config.output_definition_file, 'w'))
config.logger.info('Stored computer definition in %r' % config.output_definition_file)
def run(config):
if config.input_definition_file:
computer = parse_computer_definition(config, config.input_definition_file)
else:
# no definition file, figure out computer
computer = parse_computer_xml(config, config.computer_xml)
computer.instance_root = config.instance_root
computer.software_root = config.software_root
config.logger.info('Updating computer')
address = computer.getAddress(config.create_tap)
computer.address = address['addr']
computer.netmask = address['netmask']
if config.output_definition_file:
write_computer_definition(config, computer)
computer.construct(alter_user=config.alter_user,
alter_network=config.alter_network, create_tap=config.create_tap)
......
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