async def populate_apps(agent: MesosAgent): try: agent.applications = await agent.apps() agent.total_apps = len(agent.applications) except Exception as e: agent.add_error(field_name="total_apps", error_msg="INDISPONIVEL") log.logger.exception({ "event": "Erro buscando agent applications", "agent": agent.id, "hostname": agent.hostname, })
async def test_mesos_agent_calculate_stats(self): """ Each agent should be capable of calculating its ocupancy """ agent_info = get_fixture( "agents/ead07ffb-5a61-42c9-9386-21b680597e6c-S10/info.json") agent = MesosAgent(**agent_info) self.assertEqual({}, agent.stats) await agent.calculate_stats() self.assertEqual({"cpu_pct": "16.00", "ram_pct": "22.50"}, agent.stats)
def to_asgard_model(other: MesosClientAgent) -> MesosAgent: return MesosAgent( id=other.id, hostname=other.hostname, port=other.port, attributes=MesosAttrbutesSpecConverter.to_asgard_model( other.attributes), version=other.version, active=other.active, used_resources=MesosUsedResourcesSpecConverter.to_asgard_model( other.used_resources), resources=MesosResourcesSpecConverter.to_asgard_model( other.resources), )
def test_it_instantiates_a_agentsresource_using_agents_instances(self): agents = [ MesosAgent(**dict( id="id", hostname="hostname", active="active", version="version", port=8080, used_resources={"bla": "used_resources"}, attributes={"data": "attributes"}, resources={"data": "resources"}, )) ] resource = AgentsResource(agents=agents) self.assertIsInstance(resource, AgentsResource) for agent in resource.agents: self.assertIsInstance(agent, MesosAgent)
async def setUp(self): self.agent_id = "ead07ffb-5a61-42c9-9386-21b680597e6c-S0" agent_info = get_fixture(f"agents/{self.agent_id}/info.json") self.agent = MesosAgent(**agent_info)