示例#1
0
 def _get_agent_by_type_and_host(self, context, agent_type, host):
     agent_objs = agent_obj.Agent.get_objects(context,
                                              agent_type=agent_type,
                                              host=host)
     if not agent_objs:
         raise ext_agent.AgentNotFoundByTypeHost(agent_type=agent_type,
                                                 host=host)
     if len(agent_objs) > 1:
         raise ext_agent.MultipleAgentFoundByTypeHost(agent_type=agent_type,
                                                      host=host)
     return agent_objs[0]
示例#2
0
 def _get_agent_by_type_and_host(self, context, agent_type, host):
     query = model_query.query_with_hooks(context, agent_model.Agent)
     try:
         agent_db = query.filter(agent_model.Agent.agent_type == agent_type,
                                 agent_model.Agent.host == host).one()
         return agent_db
     except exc.NoResultFound:
         raise ext_agent.AgentNotFoundByTypeHost(agent_type=agent_type,
                                                 host=host)
     except exc.MultipleResultsFound:
         raise ext_agent.MultipleAgentFoundByTypeHost(agent_type=agent_type,
                                                      host=host)
示例#3
0
 def _get_agent_by_type_and_host(self, context, agent_type, host):
     query = context.session.query(H3CAgent)
     try:
         agent_db = query.filter_by(agent_type=agent_type,
                                    host=host).one()
         return agent_db
     except exc.NoResultFound:
         raise ext_a.AgentNotFoundByTypeHost(agent_type=agent_type,
                                             host=host)
     except exc.MultipleResultsFound:
         raise ext_a.MultipleAgentFoundByTypeHost(agent_type=agent_type,
                                                  host=host)