[WIP] remove givencfgs from result

This commit is contained in:
zolliker 2023-10-17 13:06:40 +02:00
parent 7e34c6f6cd
commit ac4e6f851a
2 changed files with 10 additions and 18 deletions

View File

@ -178,12 +178,11 @@ def summarize_server_state(givencfgs, ourcfgs, sealist, sea_info, strict=False):
:param sealist: list of running sea configuration :param sealist: list of running sea configuration
:param sea_info: dict <frappycfg> of <seacfg> with info about sea configs :param sea_info: dict <frappycfg> of <seacfg> with info about sea configs
:param strict: when True return empty cfg result on error :param strict: when True return empty cfg result on error
:return: tuple (<error>, <proposed>, (<frappyitems>, <seaitems>), (<givenitems>, <remarks>) where: :return: tuple (<error>, <proposed>, (<frappyitems>, <seaitems>), <remarks> where:
<error>: proposed config not sure <error>: proposed config not sure
<proposed>: dict <service> of proposed cfg <proposed>: dict <service> of proposed cfg
<frappyitems>: dict of items runnning in frappy servers (addons are separated) <frappyitems>: dict of items runnning in frappy servers (addons are separated)
<seaitems>: dict of items running on the sea server <seaitems>: dict of items running on the sea server
<givenitems>: dict of given items (addons are separated)
<remarks>: dict of actions / remarks <remarks>: dict of actions / remarks
""" """
givencfgs = dict(givencfgs) givencfgs = dict(givencfgs)
@ -274,7 +273,7 @@ def summarize_server_state(givencfgs, ourcfgs, sealist, sea_info, strict=False):
prop = result.get(service, '') prop = result.get(service, '')
if prop == cfg and service not in restart: if prop == cfg and service not in restart:
result[service] = True result[service] = True
return error, result, (ourcfgs, seacfgs), (givencfgs, remarks) return error, result, (ourcfgs, seacfgs), remarks
class FrappyManager(ServiceManager): class FrappyManager(ServiceManager):
@ -545,13 +544,12 @@ class FrappyManager(ServiceManager):
:param ins: the instance to be checked for :param ins: the instance to be checked for
:param givencfgs: a dict <service> of cfg given by the ECS :param givencfgs: a dict <service> of cfg given by the ECS
:return: tuple (<error>, <proposed>, (<frappyitems>, <seaitems>), (<givenitems>, <remarks>) where: :return: tuple (<error>, <proposed>, (<frappyitems>, <seaitems>), <remarks> where:
<error>: proposed config not sure <error>: proposed config not sure
<proposed>: dict <service> of proposed cfg <proposed>: dict <service> of proposed cfg
<frappyitems>: dict of items runnning in frappy servers (addons are separated) <frappyitems>: dict of items runnning in frappy servers (addons are separated)
<seaitems>: dict of items running on the sea server <seaitems>: dict of items running on the sea server
<givenitems>: dict of given items (addons are separated) <remarks>: dict of actions to do / remarks
<remarks>: dict of actions / remarks
""" """
ourcfgs = self.get_cfg(ins, None) ourcfgs = self.get_cfg(ins, None)
sea = SeaManager() sea = SeaManager()

View File

@ -1,5 +1,5 @@
import pytest import pytest
from servicemanager.frappyman import make_proposed from servicemanager.frappyman import summarize_server_state
sea_info = { sea_info = {
'ma10': 'ma10.config', 'ma10': 'ma10.config',
@ -15,19 +15,13 @@ given = dict(main='ma10', stick='ma10stick')
cfgs = dict(given) cfgs = dict(given)
seacfg = ['ma10', 'ma10'] seacfg = ['ma10', 'ma10']
@pytest.mark.parametrize('given, current, seacfg, output, proposed, proposedstrict', [ @pytest.mark.parametrize('given, current, seacfg, state, proposed', [
]) ])
def test_proposed(given, current, seacfg, output, proposed, proposedstrict): def test_proposed(given, current, seacfg, result):
prop, overview = make_proposed(given, current, seacfg, sea_info) assert result == summarize_server_state(given, current, seacfg, sea_info)
assert overview == output
assert prop == proposed
props, overview = make_proposed(given, current, seacfg, sea_info, True)
assert overview == output
assert props == proposedstrict
def do(): def do():
prop, tab = make_proposed(given, cfgs, seacfg, sea_info) result = summarize_server_state(given, cfgs, seacfg, sea_info)
print(prop) print(result)
print('\n'.join(tab))