Python munch.Munch() Examples
The following are 30
code examples of munch.Munch().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
munch
, or try the search function
.
Example #1
Source File: test_os_vif_util.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_neutron_to_osvif_subnet(self, m_conv_routes): gateway = '1.1.1.1' cidr = '1.1.1.1/8' dns = ['2.2.2.2', '3.3.3.3'] host_routes = mock.sentinel.host_routes route_list = osv_route.RouteList(objects=[ osv_route.Route(cidr='4.4.4.4/8', gateway='5.5.5.5')]) m_conv_routes.return_value = route_list neutron_subnet = munch.Munch({ 'cidr': cidr, 'dns_nameservers': dns, 'host_routes': host_routes, 'gateway_ip': gateway, }) subnet = ovu.neutron_to_osvif_subnet(neutron_subnet) self.assertEqual(cidr, str(subnet.cidr)) self.assertEqual(route_list, subnet.routes) self.assertEqual(set(dns), set([str(addr) for addr in subnet.dns])) self.assertEqual(gateway, str(subnet.gateway)) m_conv_routes.assert_called_once_with(host_routes)
Example #2
Source File: test_lb_public_ip.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_acquire_service_pub_ip_info_alloc_from_pool(self, m_cfg): cls = d_lb_public_ip.FloatingIpServicePubIPDriver m_driver = mock.Mock(spec=cls) m_driver._drv_pub_ip = public_ip.FipPubIpDriver() os_net = self.useFixture(k_fix.MockNetworkClient()).client m_cfg.neutron_defaults.external_svc_subnet = (mock.sentinel .external_svc_subnet) os_net.get_subnet.return_value = munch.Munch( {'network_id': 'ec29d641-fec4-4f67-928a-124a76b3a8e6'}) fip = munch.Munch({'floating_ip_address': '1.2.3.5', 'id': 'ec29d641-fec4-4f67-928a-124a76b3a888'}) os_net.create_ip.return_value = fip project_id = mock.sentinel.project_id spec_type = 'LoadBalancer' spec_lb_ip = None expected_resp = obj_lbaas.LBaaSPubIp(ip_id=fip.id, ip_addr=fip.floating_ip_address, alloc_method='pool') result = cls.acquire_service_pub_ip_info(m_driver, spec_type, spec_lb_ip, project_id) self.assertEqual(result, expected_resp)
Example #3
Source File: test_lb_public_ip.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_acquire_service_pub_ip_info_user_specified_occupied_fip(self): cls = d_lb_public_ip.FloatingIpServicePubIPDriver m_driver = mock.Mock(spec=cls) m_driver._drv_pub_ip = public_ip.FipPubIpDriver() os_net = self.useFixture(k_fix.MockNetworkClient()).client fip = munch.Munch({'floating_ip_address': '1.2.3.4', 'port_id': 'ec29d641-fec4-4f67-928a-124a76b3a8e6'}) os_net.ips.return_value = (ip for ip in [fip]) project_id = mock.sentinel.project_id spec_type = 'LoadBalancer' spec_lb_ip = '1.2.3.4' result = cls.acquire_service_pub_ip_info(m_driver, spec_type, spec_lb_ip, project_id) self.assertIsNone(result)
Example #4
Source File: test_namespace_subnet.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_create_network(self): cls = subnet_drv.NamespacePodSubnetDriver m_driver = mock.MagicMock(spec=cls) namespace = 'test' project_id = mock.sentinel.project_id os_net = self.useFixture(k_fix.MockNetworkClient()).client os_net.networks.return_value = iter([]) net = munch.Munch({'id': mock.sentinel.net}) os_net.create_network.return_value = net net_id_resp = cls.create_network(m_driver, namespace, project_id) self.assertEqual(net_id_resp, net['id']) os_net.create_network.assert_called_once() os_net.networks.assert_called_once()
Example #5
Source File: test_lb_public_ip.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_acquire_service_pub_ip_info_usr_specified_ip(self): cls = d_lb_public_ip.FloatingIpServicePubIPDriver m_driver = mock.Mock(spec=cls) m_driver._drv_pub_ip = public_ip.FipPubIpDriver() os_net = self.useFixture(k_fix.MockNetworkClient()).client fip = munch.Munch({'floating_ip_address': '1.2.3.4', 'port_id': None, 'id': 'a2a62ea7-e3bf-40df-8c09-aa0c29876a6b'}) os_net.ips.return_value = (ip for ip in [fip]) project_id = mock.sentinel.project_id spec_type = 'LoadBalancer' spec_lb_ip = '1.2.3.4' expected_resp = (obj_lbaas .LBaaSPubIp(ip_id=fip.id, ip_addr=fip.floating_ip_address, alloc_method='user')) result = cls.acquire_service_pub_ip_info(m_driver, spec_type, spec_lb_ip, project_id) self.assertEqual(result, expected_resp)
Example #6
Source File: test_lb_public_ip.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_associate_lb_fip_id_not_exist(self): cls = d_lb_public_ip.FloatingIpServicePubIPDriver m_driver = mock.Mock(spec=cls) os_net = self.useFixture(k_fix.MockNetworkClient()).client os_net.update_floatingip.return_value = None m_driver._drv_pub_ip = public_ip.FipPubIpDriver() fip = munch.Munch({'floating_ip_address': '1.2.3.5', 'id': 'ec29d641-fec4-4f67-928a-124a76b3a888'}) service_pub_ip_info = (obj_lbaas .LBaaSPubIp(ip_id=0, ip_addr=fip.floating_ip_address, alloc_method='pool')) vip_port_id = 'ec29d641-fec4-4f67-928a-124a76b3a777' result = cls.associate_pub_ip(m_driver, service_pub_ip_info, vip_port_id) self.assertIsNone(result)
Example #7
Source File: test_lb_public_ip.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_associate_lb_fip_id_not_exist_neutron_exception(self): cls = d_lb_public_ip.FloatingIpServicePubIPDriver m_driver = mock.Mock(spec=cls) m_driver._drv_pub_ip = public_ip.FipPubIpDriver() os_net = self.useFixture(k_fix.MockNetworkClient()).client os_net.update_ip.side_effect = os_exc.SDKException fip = munch.Munch({'floating_ip_address': '1.2.3.5', 'id': 'ec29d641-fec4-4f67-928a-124a76b3a888'}) service_pub_ip_info = (obj_lbaas .LBaaSPubIp(ip_id=fip.id, ip_addr=fip.floating_ip_address, alloc_method='pool')) vip_port_id = 'ec29d641-fec4-4f67-928a-124a76b3a777' self.assertRaises(os_exc.SDKException, cls.associate_pub_ip, m_driver, service_pub_ip_info, vip_port_id)
Example #8
Source File: test_lb_public_ip.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_disassociate_pub_ip_fip_id_not_exist(self): cls = d_lb_public_ip.FloatingIpServicePubIPDriver m_driver = mock.Mock(spec=cls) m_driver._drv_pub_ip = public_ip.FipPubIpDriver() os_net = self.useFixture(k_fix.MockNetworkClient()).client os_net.update_floatingip.return_value = None fip = munch.Munch({'floating_ip_address': '1.2.3.5', 'id': 'ec29d641-fec4-4f67-928a-124a76b3a888'}) service_pub_ip_info = (obj_lbaas .LBaaSPubIp(ip_id=0, ip_addr=fip.floating_ip_address, alloc_method='pool')) result = cls.disassociate_pub_ip(m_driver, service_pub_ip_info) self.assertIsNone(result)
Example #9
Source File: test_lbaasv2.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_create_loadbalancer_provider_mismatch(self): cls = d_lbaasv2.LBaaSv2Driver m_driver = mock.Mock(spec=d_lbaasv2.LBaaSv2Driver) lbaas = self.useFixture(k_fix.MockLBaaSClient()).client loadbalancer = obj_lbaas.LBaaSLoadBalancer( name='TEST_NAME', project_id='TEST_PROJECT', ip='1.2.3.4', subnet_id='D3FA400A-F543-4B91-9CD3-047AF0CE42D1', security_groups=[], provider='amphora') loadbalancer_id = '00EE9E11-91C2-41CF-8FD4-7970579E5C4C' req = { 'name': loadbalancer.name, 'project_id': loadbalancer.project_id, 'vip_address': str(loadbalancer.ip), 'vip_subnet_id': loadbalancer.subnet_id, 'provider': loadbalancer.provider, } resp = o_lb.LoadBalancer(id=loadbalancer_id, provider='haproxy') lbaas.create_load_balancer.return_value = resp m_driver._get_vip_port.return_value = munch.Munch( {'id': mock.sentinel.port_id}) ret = cls._create_loadbalancer(m_driver, loadbalancer) lbaas.create_load_balancer.assert_called_once_with(**req) self.assertIsNone(ret)
Example #10
Source File: test_namespace_subnet.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_create_subnet_existing(self): cls = subnet_drv.NamespacePodSubnetDriver m_driver = mock.MagicMock(spec=cls) namespace = 'test' project_id = mock.sentinel.project_id net_id = mock.sentinel.net_id subnet = munch.Munch({'id': mock.sentinel.subnet, 'cidr': mock.sentinel.cidr}) os_net = self.useFixture(k_fix.MockNetworkClient()).client os_net.subnets.return_value = iter([subnet]) subnet_id, subnet_cidr = cls.create_subnet(m_driver, namespace, project_id, net_id) self.assertEqual(subnet_id, subnet['id']) self.assertEqual(subnet_cidr, subnet['cidr']) os_net.create_subnet.assert_not_called() os_net.subnets.assert_called_once()
Example #11
Source File: test_network_policy.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_create_security_group_rules_from_network_policy(self, m_utils, m_parse, m_add_crd, m_get_crd, m_add_default): self._driver.os_net.create_security_group.return_value = ( munch.Munch({'id': mock.sentinel.id, 'security_group_rules': []})) m_utils.get_subnet_cidr.return_value = mock.sentinel.cidr m_parse.return_value = (self._i_rules, self._e_rules) self._driver.os_net.create_security_group_rule.return_value = ( munch.Munch({'id': mock.sentinel.id})) self._driver.create_security_group_rules_from_network_policy( self._policy, self._project_id) m_get_crd.assert_called_once() m_add_crd.assert_called_once() m_add_default.assert_called_once()
Example #12
Source File: test_lbaasv2.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_release_listener(self): os_net = self.useFixture(k_fix.MockNetworkClient()).client lbaas = self.useFixture(k_fix.MockLBaaSClient()).client os_net.security_group_rules.return_value = (x for x in []) cls = d_lbaasv2.LBaaSv2Driver m_driver = mock.Mock(spec=d_lbaasv2.LBaaSv2Driver) m_driver._get_vip_port.return_value = munch.Munch({ 'security_group_ids': [mock.sentinel.sg_id]}) loadbalancer = mock.Mock() listener = mock.Mock() cls.release_listener(m_driver, loadbalancer, listener) m_driver._release.assert_called_once_with(loadbalancer, listener, lbaas.delete_listener, listener.id)
Example #13
Source File: test_os_vif_util.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_neutron_to_osvif_network(self): network_id = str(uuid.uuid4()) network_name = 'test-net' network_mtu = 1500 neutron_network = munch.Munch({ 'id': network_id, 'name': network_name, 'mtu': network_mtu, 'provider_network_type': None }) network = ovu.neutron_to_osvif_network(neutron_network) self.assertEqual(network_id, network.id) self.assertEqual(network_name, network.label) self.assertEqual(network_mtu, network.mtu)
Example #14
Source File: test_network_policy.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_create_security_group_rules_with_k8s_exc(self, m_utils, m_parse, m_add_crd, m_get_crd, m_add_default): self._driver.os_net.create_security_group.return_value = ( munch.Munch({'id': mock.sentinel.id, 'security_group_rules': []})) m_utils.get_subnet_cidr.return_value = mock.sentinel.cidr m_parse.return_value = (self._i_rules, self._e_rules) m_get_crd.side_effect = exceptions.K8sClientException self._driver.os_net.create_security_group_rule.return_value = ( munch.Munch({'id': mock.sentinel.id})) self.assertRaises( exceptions.K8sClientException, self._driver.create_security_group_rules_from_network_policy, self._policy, self._project_id) m_add_crd.assert_called_once() m_add_default.assert_called_once()
Example #15
Source File: test_network_policy.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_create_security_group_rules_error_add_crd(self, m_utils, m_parse, m_add_crd, m_get_crd, m_add_default): self._driver.os_net.create_security_group.return_value = ( munch.Munch({'id': mock.sentinel.id, 'security_group_rules': []})) m_utils.get_subnet_cidr.return_value = mock.sentinel.cidr m_parse.return_value = (self._i_rules, self._e_rules) m_add_crd.side_effect = exceptions.K8sClientException self._driver.os_net.create_security_group_rule.return_value = ( munch.Munch({'id': mock.sentinel.id})) self.assertRaises( exceptions.K8sClientException, self._driver.create_security_group_rules_from_network_policy, self._policy, self._project_id) m_get_crd.assert_not_called() m_add_default.assert_called_once()
Example #16
Source File: test_pagure_flask.py From pagure with GNU General Public License v2.0 | 6 votes |
def test_is_repo_committer_external_committer_restricting_another_one( self, ): """ Test is_repo_committer in pagure with EXTERNAL_COMMITTER configured to give access the provenpackager just for one repo not this one """ repo = pagure.lib.query._get_project(self.session, "test2") g = munch.Munch() g.fas_user = tests.FakeUser(username="foo") g.authenticated = True g.fas_user.groups.append("provenpackager") g.session = self.session with mock.patch("flask.g", g): output = pagure.utils.is_repo_committer(repo) self.assertFalse(output)
Example #17
Source File: test_utils.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_get_subnet(self, m_osv_subnet, m_osv_network): os_net = self.useFixture(k_fix.MockNetworkClient()).client subnet = mock.MagicMock() network = mock.MagicMock() subnet_id = mock.sentinel.subnet_id network_id = mock.sentinel.network_id neutron_subnet = munch.Munch({'network_id': network_id}) neutron_network = mock.sentinel.neutron_network os_net.get_subnet.return_value = neutron_subnet os_net.get_network.return_value = neutron_network m_osv_subnet.return_value = subnet m_osv_network.return_value = network ret = utils.get_subnet(subnet_id) self.assertEqual(network, ret) os_net.get_subnet.assert_called_once_with(subnet_id) os_net.get_network.assert_called_once_with(network_id) m_osv_subnet.assert_called_once_with(neutron_subnet) m_osv_network.assert_called_once_with(neutron_network) network.subnets.objects.append.assert_called_once_with(subnet)
Example #18
Source File: test_vif_pool.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_release_vif(self): cls = vif_pool.BaseVIFPool m_driver = mock.MagicMock(spec=cls) m_driver._recyclable_ports = {} m_driver._existing_vifs = {} pod = get_pod_obj() project_id = mock.sentinel.project_id security_groups = [mock.sentinel.security_groups] net_id = str(uuid.uuid4()) _net = munch.Munch({'id': net_id, 'name': None, 'mtu': None, 'provider_network_type': None}) network = ovu.neutron_to_osvif_network(_net) vif = osv_vif.VIFOpenVSwitch(id='0fa0e837-d34e-4580-a6c4-04f5f607d93e', network=network) m_driver._return_ports_to_pool.return_value = None cls.release_vif(m_driver, pod, vif, project_id, security_groups) m_driver._return_ports_to_pool.assert_not_called()
Example #19
Source File: test_vif_pool.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_cleanup_leftover_ports(self): cls = vif_pool.BaseVIFPool m_driver = mock.MagicMock(spec=cls) os_net = self.useFixture(k_fix.MockNetworkClient()).client port_id = str(uuid.uuid4()) port = fake.get_port_obj(port_id=port_id) net_id = port.network_id tags = 'clusterTest' port.tags = [tags] os_net.ports.return_value = [port] oslo_cfg.CONF.set_override('resource_tags', tags, group='neutron_defaults') self.addCleanup(oslo_cfg.CONF.clear_override, 'resource_tags', group='neutron_defaults') os_net.networks.return_value = [munch.Munch({'id': net_id})] cls._cleanup_leftover_ports(m_driver) os_net.networks.assert_called() os_net.delete_port.assert_not_called()
Example #20
Source File: test_vif_pool.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_cleanup_leftover_ports_no_binding(self): cls = vif_pool.BaseVIFPool m_driver = mock.MagicMock(spec=cls) os_net = self.useFixture(k_fix.MockNetworkClient()).client port_id = str(uuid.uuid4()) port = fake.get_port_obj(port_id=port_id) net_id = port.network_id tags = 'clusterTest' port.tags = [tags] port.binding_host_id = None os_net.ports.return_value = [port] oslo_cfg.CONF.set_override('resource_tags', tags, group='neutron_defaults') self.addCleanup(oslo_cfg.CONF.clear_override, 'resource_tags', group='neutron_defaults') os_net.networks.return_value = [munch.Munch({'id': net_id})] cls._cleanup_leftover_ports(m_driver) os_net.networks.assert_called() os_net.delete_port.assert_called_once_with(port.id)
Example #21
Source File: test_vif_pool.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test_cleanup_leftover_ports_no_tags(self): cls = vif_pool.BaseVIFPool m_driver = mock.MagicMock(spec=cls) os_net = self.useFixture(k_fix.MockNetworkClient()).client port_id = str(uuid.uuid4()) port = fake.get_port_obj(port_id=port_id) net_id = port.network_id tags = 'clusterTest' os_net.ports.return_value = [port] oslo_cfg.CONF.set_override('resource_tags', tags, group='neutron_defaults') self.addCleanup(oslo_cfg.CONF.clear_override, 'resource_tags', group='neutron_defaults') os_net.networks.return_value = [munch.Munch({'id': net_id})] cls._cleanup_leftover_ports(m_driver) os_net.networks.assert_called() os_net.delete_port.assert_called_once_with(port.id)
Example #22
Source File: mirrored_entities.py From pyxcli with Apache License 2.0 | 6 votes |
def get_mirror_resources_by_name_map(self, scope=None): """ returns a map volume_name -> volume, cg_name->cg scope is either None or CG or Volume """ volumes_mirrors_by_name = dict() cgs_mirrors_by_name = dict() if ((scope is None) or (scope.lower() == 'volume')): mirror_list = self.xcli_client.cmd.mirror_list(scope='Volume') for xcli_mirror in mirror_list: name = MirroredEntities.get_mirrored_object_name(xcli_mirror) volumes_mirrors_by_name[name] = xcli_mirror if ((scope is None) or (scope.lower() == CG)): for xcli_mirror in self.xcli_client.cmd.mirror_list(scope='CG'): name = MirroredEntities.get_mirrored_object_name(xcli_mirror) cgs_mirrors_by_name[name] = xcli_mirror res = Munch(volumes=volumes_mirrors_by_name, cgs=cgs_mirrors_by_name) return res
Example #23
Source File: response.py From pyxcli with Apache License 2.0 | 6 votes |
def _populate_bunch_with_element(element): """ Helper function to recursively populates a Bunch from an XML tree. Returns leaf XML elements as a simple value, branch elements are returned as Bunches containing their subelements as value or recursively generated Bunch members. """ if 'value' in element.attrib: return element.get('value') current_bunch = Munch() if element.get('id'): current_bunch['nextra_element_id'] = element.get('id') for subelement in element.getchildren(): current_bunch[subelement.tag] = _populate_bunch_with_element( subelement) return current_bunch
Example #24
Source File: test_vif_pool.py From kuryr-kubernetes with Apache License 2.0 | 6 votes |
def test__trigger_return_to_pool_delete_key_error(self): cls = vif_pool.NeutronVIFPool m_driver = mock.MagicMock(spec=cls) os_net = self.useFixture(k_fix.MockNetworkClient()).client pool_key = ('node_ip', 'project_id') port_id = str(uuid.uuid4()) pool_length = 10 m_driver._recyclable_ports = {port_id: pool_key} m_driver._available_ports_pools = {} m_driver._existing_vifs = {} oslo_cfg.CONF.set_override('ports_pool_max', 5, group='vif_pool') os_net.ports.return_value = [ munch.Munch({'id': port_id, 'security_group_ids': ['security_group_modified']})] m_driver._get_pool_size.return_value = pool_length cls._trigger_return_to_pool(m_driver) os_net.update_port.assert_not_called() os_net.delete_port.assert_not_called()
Example #25
Source File: copr_helper.py From packit with MIT License | 5 votes |
def copr_web_build_url(self, build: Munch) -> str: """ Construct web frontend url because build.repo_url is not much user-friendly.""" copr_url = self.copr_client.config.get("copr_url") return f"{copr_url}/coprs/build/{build.id}/"
Example #26
Source File: main.py From squash-generation with MIT License | 5 votes |
def main(): args = parser.parse_args() modify_arguments(args) # setting random seeds torch.cuda.manual_seed(args.seed) np.random.seed(args.seed) random.seed(args.seed) with open(args.config_file, 'r') as stream: config = yaml.load(stream) args.config = Munch(modify_config(args, config)) logger.info(args) if args.mode == 'train': train.train(args, device) elif args.mode == 'test': pass elif args.mode == 'analysis': analysis.analyze(args, device) elif args.mode == 'generate': pass elif args.mode == 'classify': analysis.classify(args, device) elif args.mode == 'classify_coqa': analysis.classify_coqa(args, device) elif args.mode == 'classify_final': analysis.classify_final(args, device)
Example #27
Source File: test_vif_pool.py From kuryr-kubernetes with Apache License 2.0 | 5 votes |
def test__trigger_return_to_pool_delete_exception(self): cls = vif_pool.NeutronVIFPool m_driver = mock.MagicMock(spec=cls) os_net = self.useFixture(k_fix.MockNetworkClient()).client pool_key = ('node_ip', 'project_id') port_id = str(uuid.uuid4()) pool_length = 10 vif = mock.sentinel.vif m_driver._recyclable_ports = {port_id: pool_key} m_driver._available_ports_pools = {} m_driver._existing_vifs = {port_id: vif} oslo_cfg.CONF.set_override('ports_pool_max', 5, group='vif_pool') os_net.ports.return_value = [ munch.Munch({'id': port_id, 'security_group_ids': ['security_group_modified']})] m_driver._get_pool_size.return_value = pool_length cls._trigger_return_to_pool(m_driver) os_net.update_port.assert_not_called() os_net.delete_port.assert_called_once_with(port_id)
Example #28
Source File: test_utils.py From kuryr-kubernetes with Apache License 2.0 | 5 votes |
def test_get_subnet_cidr(self): os_net = self.useFixture(k_fix.MockNetworkClient()).client subnet_id = mock.sentinel.subnet_id subnet = munch.Munch(cidr='10.0.0.0/24') os_net.get_subnet.return_value = subnet result = utils.get_subnet_cidr(subnet_id) os_net.get_subnet.assert_called_once_with(subnet_id) self.assertEqual(result, '10.0.0.0/24')
Example #29
Source File: test_vif_pool.py From kuryr-kubernetes with Apache License 2.0 | 5 votes |
def test__trigger_return_to_pool(self, max_pool): cls = vif_pool.NestedVIFPool m_driver = mock.MagicMock(spec=cls) os_net = self.useFixture(k_fix.MockNetworkClient()).client pool_key = ('node_ip', 'project_id') port_id = str(uuid.uuid4()) pool_length = 5 m_driver._recyclable_ports = {port_id: pool_key} m_driver._available_ports_pools = {} oslo_cfg.CONF.set_override('ports_pool_max', max_pool, group='vif_pool') oslo_cfg.CONF.set_override('port_debug', True, group='kubernetes') os_net.ports.return_value = [ munch.Munch({'id': port_id, 'security_group_ids': ['security_group_modified']})] m_driver._get_pool_size.return_value = pool_length cls._trigger_return_to_pool(m_driver) (os_net.update_port .assert_called_once_with(port_id, name=constants.KURYR_PORT_NAME)) os_net.delete_port.assert_not_called()
Example #30
Source File: test_vif_pool.py From kuryr-kubernetes with Apache License 2.0 | 5 votes |
def test__trigger_return_to_pool(self, max_pool): cls = vif_pool.NeutronVIFPool m_driver = mock.MagicMock(spec=cls) os_net = self.useFixture(k_fix.MockNetworkClient()).client pool_key = ('node_ip', 'project_id') port_id = str(uuid.uuid4()) pool_length = 5 m_driver._recyclable_ports = {port_id: pool_key} m_driver._available_ports_pools = {} oslo_cfg.CONF.set_override('ports_pool_max', max_pool, group='vif_pool') oslo_cfg.CONF.set_override('port_debug', True, group='kubernetes') os_net.ports.return_value = [ munch.Munch({'id': port_id, 'security_group_ids': ['security_group_modified']})] m_driver._get_pool_size.return_value = pool_length cls._trigger_return_to_pool(m_driver) os_net.update_port.assert_called_once_with( port_id, name=constants.KURYR_PORT_NAME, device_id='') os_net.delete_port.assert_not_called()