Best Python code snippet using tempest_python
test_agents_rbac.py
Source:test_agents_rbac.py  
...167            self.agent['id'])168    @decorators.idempotent_id('14e014ac-f355-46d3-b6d8-98f2c9ec1610')169    @rbac_rule_validation.action(service="neutron",170                                 rule="create_dhcp-network")171    def test_add_dhcp_agent_to_network(self):172        """Add DHCP agent to network test.173        RBAC test for the neutron create_dhcp-network policy174        """175        network_id = self._create_and_prepare_network_for_agent(176            self.agent['id'])177        self.rbac_utils.switch_role(self, toggle_rbac_role=True)178        self.agents_client.add_dhcp_agent_to_network(179            self.agent['id'], network_id=network_id)180        # Clean up is not necessary and might result in 409 being raised.181    @decorators.idempotent_id('937a4302-4b49-407d-9980-5843d7badc38')182    @rbac_rule_validation.action(service="neutron",183                                 rule="delete_dhcp-network")184    def test_delete_network_from_dhcp_agent(self):185        """Delete DHCP agent from network test.186        RBAC test for the neutron delete_dhcp-network policy187        """188        network_id = self._create_and_prepare_network_for_agent(189            self.agent['id'])190        self.agents_client.add_dhcp_agent_to_network(191            self.agent['id'], network_id=network_id)192        # Clean up is not necessary and might result in 409 being raised.193        self.rbac_utils.switch_role(self, toggle_rbac_role=True)194        self.agents_client.delete_network_from_dhcp_agent(...agents_client.py
Source:agents_client.py  
...46    def remove_network_from_dhcp_agent(self, agent_id, network_id):47        uri = '/agents/%s/dhcp-networks/%s' % (agent_id,48                                               network_id)49        return self.delete_resource(uri)50    def add_dhcp_agent_to_network(self, agent_id, **kwargs):51        # TODO(piyush): Current api-site doesn't contain this API description.52        # After fixing the api-site, we need to fix here also for putting the53        # link to api-site.54        # LP: https://bugs.launchpad.net/openstack-api-site/+bug/152621255        uri = '/agents/%s/dhcp-networks' % agent_id...neutron-check-dhcp-agents.py
Source:neutron-check-dhcp-agents.py  
...26            print("Network %s has only %d agents assigned" % (network.name, length))27            # FIXME(berendt): make the number of assigned DHCP agents configurable28            # FIXME(berendt): randomly select the assigned DHCP agents29            for agent in conn.network.agents(binary="neutron-dhcp-agent"):...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
