Guest User

Untitled

a guest
Apr 23rd, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. I spent the better part of a day trying to find out why I was able to remove a single router from an l3 agent, but when I tried the same in a loop over the generator that returns all agents hosting a router it wouldn't work. It would have been smart to check the type earlier, but long story short, I didn't :)
  2.  
  3. In [124]: agent1 = next(conn.network.agents(agent_type='L3 Agent', host='networker1'
  4.      ...: ))
  5.  
  6. In [125]: agent1_from_network = next(conn.network.routers_hosting_l3_agents(router))
  7.  
  8. In [126]: conn.network.remove_router_from_agent(agent1_from_network, router) # This doesn't work. It returns quickly without output.
  9.  
  10. In [127]: conn.network.remove_router_from_agent(agent1, router) # But this does work!
  11.  
  12. ## At that point I tried to see what could possible be the difference between objects that look to be the same.
  13.  
  14. In [128]: type(agent1)
  15. Out[128]: openstack.network.v2.agent.Agent
  16.  
  17. In [129]: type(agent1_from_network)
  18. Out[129]: openstack.network.v2.agent.RouterL3Agent
  19.  
  20.  
  21. So after finding out that the problem is probably the fact that I'm passing a different type, I tried referencing the agent by ID and that does work.
  22. ---
  23.  
  24. In [131]: conn.network.add_router_to_agent(agent1.id, router)
  25.  
  26. In [132]: conn.network.remove_router_from_agent(agent1_from_network.id, router)
Add Comment
Please, Sign In to add comment