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