Commit b4de4ad1 authored by Tomáš Peterka's avatar Tomáš Peterka

Replace plurals

parent 69e53d9e
...@@ -66,7 +66,7 @@ logger = logging.getLogger("slapos.format") ...@@ -66,7 +66,7 @@ logger = logging.getLogger("slapos.format")
# dict[str: ManagerClass] used in configuration and XML dump of computer # dict[str: ManagerClass] used in configuration and XML dump of computer
# this dictionary is intended to be filled after each definition of a Manager # this dictionary is intended to be filled after each definition of a Manager
available_managers = {} available_manager_list = {}
def prettify_xml(xml): def prettify_xml(xml):
...@@ -427,7 +427,7 @@ class CGroupManager(Manager): ...@@ -427,7 +427,7 @@ class CGroupManager(Manager):
return folder return folder
# mark manager available # mark manager available
available_managers[CGroupManager.short_name] = CGroupManager available_manager_list[CGroupManager.short_name] = CGroupManager
class Computer(object): class Computer(object):
...@@ -437,7 +437,7 @@ class Computer(object): ...@@ -437,7 +437,7 @@ class Computer(object):
ipv6_interface=None, software_user='slapsoft', ipv6_interface=None, software_user='slapsoft',
tap_gateway_interface=None, tap_gateway_interface=None,
instance_root=None, software_root=None, instance_storage_home=None, instance_root=None, software_root=None, instance_storage_home=None,
partition_list=None, managers=None): partition_list=None, manager_list=None):
""" """
Attributes: Attributes:
reference: str, the reference of the computer. reference: str, the reference of the computer.
...@@ -466,11 +466,11 @@ class Computer(object): ...@@ -466,11 +466,11 @@ class Computer(object):
self.slapos_version = None self.slapos_version = None
# HASA relation to managers (could turn into plugins with `format` and `update` methods) # HASA relation to managers (could turn into plugins with `format` and `update` methods)
self.managers = managers # for serialization self.manager_list = manager_list # for serialization
# hide list[Manager] from serializer by prepending "_" # hide list[Manager] from serializer by prepending "_"
self._manager_list = tuple(filter(lambda manager: manager.is_allowed(), self._manager_list = tuple(filter(lambda manager: manager.is_allowed(),
(available_managers[manager_str](self) for manager_str in managers))) \ (available_manager_list[manager_str](self) for manager_str in manager_list))) \
if managers else tuple() if manager_list else tuple()
def __getinitargs__(self): def __getinitargs__(self):
return (self.reference, self.interface) return (self.reference, self.interface)
...@@ -600,7 +600,7 @@ class Computer(object): ...@@ -600,7 +600,7 @@ class Computer(object):
@classmethod @classmethod
def load(cls, path_to_xml, reference, ipv6_interface, tap_gateway_interface, def load(cls, path_to_xml, reference, ipv6_interface, tap_gateway_interface,
instance_root=None, software_root=None, managers=None): instance_root=None, software_root=None, manager_list=None):
""" """
Create a computer object from a valid xml file. Create a computer object from a valid xml file.
...@@ -624,10 +624,10 @@ class Computer(object): ...@@ -624,10 +624,10 @@ class Computer(object):
tap_gateway_interface=tap_gateway_interface, tap_gateway_interface=tap_gateway_interface,
software_root=dumped_dict.get('software_root', software_root), software_root=dumped_dict.get('software_root', software_root),
instance_root=dumped_dict.get('instance_root', instance_root), instance_root=dumped_dict.get('instance_root', instance_root),
managers=dumped_dict.get('managers', managers), manager_list=dumped_dict.get('manager_list', manager_list),
) )
for i, partition_dict in enumerate(dumped_dict['partition_list']): for partition_index, partition_dict in enumerate(dumped_dict['partition_list']):
if partition_dict['user']: if partition_dict['user']:
user = User(partition_dict['user']['name']) user = User(partition_dict['user']['name'])
...@@ -645,10 +645,10 @@ class Computer(object): ...@@ -645,10 +645,10 @@ class Computer(object):
tap = Tap(partition_dict['reference']) tap = Tap(partition_dict['reference'])
if partition_dict.get('tun') is not None and partition_dict['tun'].get('ipv4_addr') is not None: if partition_dict.get('tun') is not None and partition_dict['tun'].get('ipv4_addr') is not None:
tun = Tun(partition_dict['tun']['name'], i, len(dumped_dict['partition_list'])) tun = Tun(partition_dict['tun']['name'], partition_index, len(dumped_dict['partition_list']))
tun.ipv4_addr = partition_dict['tun']['ipv4_addr'] tun.ipv4_addr = partition_dict['tun']['ipv4_addr']
else: else:
tun = Tun("slaptun" + str(i), i, len(dumped_dict['partition_list'])) tun = Tun("slaptun" + str(partition_index), partition_index, len(dumped_dict['partition_list']))
address_list = partition_dict['address_list'] address_list = partition_dict['address_list']
external_storage_list = partition_dict.get('external_storage_list', []) external_storage_list = partition_dict.get('external_storage_list', [])
...@@ -1509,7 +1509,7 @@ def parse_computer_xml(conf, xml_path): ...@@ -1509,7 +1509,7 @@ def parse_computer_xml(conf, xml_path):
tap_gateway_interface=conf.tap_gateway_interface, tap_gateway_interface=conf.tap_gateway_interface,
software_root=conf.software_root, software_root=conf.software_root,
instance_root=conf.instance_root, instance_root=conf.instance_root,
managers=conf.managers) manager_list=conf.manager_list)
# Connect to the interface defined by the configuration # Connect to the interface defined by the configuration
computer.interface = interface computer.interface = interface
else: else:
...@@ -1525,7 +1525,7 @@ def parse_computer_xml(conf, xml_path): ...@@ -1525,7 +1525,7 @@ def parse_computer_xml(conf, xml_path):
ipv6_interface=conf.ipv6_interface, ipv6_interface=conf.ipv6_interface,
software_user=conf.software_user, software_user=conf.software_user,
tap_gateway_interface=conf.tap_gateway_interface, tap_gateway_interface=conf.tap_gateway_interface,
managers=conf.managers, manager_list=conf.manager_list,
) )
partition_amount = int(conf.partition_amount) partition_amount = int(conf.partition_amount)
...@@ -1640,7 +1640,7 @@ class FormatConfig(object): ...@@ -1640,7 +1640,7 @@ class FormatConfig(object):
tap_gateway_interface = None tap_gateway_interface = None
use_unique_local_address_block = None use_unique_local_address_block = None
instance_storage_home = None instance_storage_home = None
managers = None manager_list = None
def __init__(self, logger): def __init__(self, logger):
self.logger = logger self.logger = logger
...@@ -1730,13 +1730,13 @@ class FormatConfig(object): ...@@ -1730,13 +1730,13 @@ class FormatConfig(object):
# Split str into list[str] and check availability of every manager # Split str into list[str] and check availability of every manager
# Config value is expected to be strings separated by spaces or commas # Config value is expected to be strings separated by spaces or commas
managers = [] manager_list = []
for manager in self.managers.replace(",", " ").split(): for manager in self.manager_list.replace(",", " ").split():
if manager not in available_managers: if manager not in available_manager_list:
raise ValueError("Unknown manager \"{}\"! Known are: {!s}".format( raise ValueError("Unknown manager \"{}\"! Known are: {!s}".format(
manager, list(available_managers.keys()))) manager, list(available_manager_list.keys())))
managers.append(manager) manager_list.append(manager)
self.managers = managers # replace original str with list[str] of known managers self.manager_list = manager_list # replace original str with list[str] of known managers
if not self.dry_run: if not self.dry_run:
if self.alter_user: if self.alter_user:
......
...@@ -195,7 +195,7 @@ class CGroupManagerMock(slapos.format.CGroupManager): ...@@ -195,7 +195,7 @@ class CGroupManagerMock(slapos.format.CGroupManager):
return True return True
# update available managers with our partially-mocked version # update available managers with our partially-mocked version
slapos.format.available_managers[CGroupManagerMock.short_name] = CGroupManagerMock slapos.format.available_manager_list[CGroupManagerMock.short_name] = CGroupManagerMock
class SlapformatMixin(unittest.TestCase): class SlapformatMixin(unittest.TestCase):
...@@ -705,7 +705,7 @@ class TestComputerWithCGroup(SlapformatMixin): ...@@ -705,7 +705,7 @@ class TestComputerWithCGroup(SlapformatMixin):
slapos.format.Partition( slapos.format.Partition(
'partition', '/tmp/slapgrid/instance_root/part1', slapos.format.User('testuser'), [], tap=None), 'partition', '/tmp/slapgrid/instance_root/part1', slapos.format.User('testuser'), [], tap=None),
], ],
managers=(CGroupManagerMock.short_name, ) manager_list=(CGroupManagerMock.short_name, )
) )
# self.patchOs(self.logger) # self.patchOs(self.logger)
......
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