summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/drivers/modules/network/test_common.py
Commit message (Collapse)AuthorAgeFilesLines
* CI: Fix another network testJulia Kreger2023-05-081-0/+4
| | | | | | | | Turns out more than one test was relying upon the object change determination test. Modifies this test to use the same pattern of behavior so we are avoiding racing. Change-Id: I29ee6cab7320d13fcc2eeda27dae08aeb2d98b00
* CI: Modify dhcp client ID failJulia Kreger2023-05-081-2/+4
| | | | | | | | | | | | | | | | The test, periodically under certian CI race conditions, may be handled as if there was not a change, which breaks the test as it does not save a modified port, it uses the in-flight list of changes to determine the correct path. The challenge is, the list of changes may not reconize there has been a change with the underlying object/db layer. So instead of re-test the library code, we just force the behavior by replacing the method on the object in the test, as the undrelying method being tested is tested as part of the oslo versioned objects code base. Change-Id: Ic8f9b2384ab2f8f76299afce9806fbe93e350f0e
* CI: Fix race prone unit test in networkingJulia Kreger2023-01-181-1/+3
| | | | | | | | | | | | | In the networking code stack, one of the methods looks to identify if a change has occured, except some of the other tests utilize the same value that was previously asserted for the same base object. Becaues of this, just use a unique value so we don't risk the possibility of the test failing erroneously. Change-Id: Ide2b205ade67a4090a0b9bfe1282d01f7605ceb9
* Remove extra/vif_port_idJulia Kreger2021-03-221-93/+57
| | | | | | | | | | | | | | | | | Removes API translation layer into port/portgroup internal_info Removes internal logic to support use of VIFs stored in the extra field, which effectively means all vif binding must now utilize vif attachment and detachment. This is a change that we likely should have pushed forward a couple years back, but I didn't want to break compatability with very old of ironic or standalone users which were deploying instances using very old instructions. That being said, it is necessary to remove the legacy vif support so new access controls can properly wrap vif API endpoints. Depends-On: https://review.opendev.org/c/openstack/ironic-tempest-plugin/+/769204 Change-Id: I588b3a64475656542389ff83786189e2dc16d35c
* Fix DHCP-less operations with the noop network interfaceDmitry Tantsur2020-11-101-8/+0
| | | | | | | | The base implementation of get_node_network_data returns {} and is not overridden in the noop network. Update the base implementation to use task.node.network_data and remove the excessive logging. Change-Id: Ie50dcd1c2a151f5dd09794467792527032249809
* Use assertCountEqual instead of assertItemsEqual, part 2Riccardo Pittau2020-07-071-4/+4
| | | | | | | | | | | | | | | | Follow up of https://review.opendev.org/735127 The assertItemsEqual method has been removed in Python 3.3 [1] but it was kept alive by unittest2, imported by testtools. To prevent mayhem and despair caused by testtools removing unittest2 from its requirements in the near future, we switch to assertCountEqual. For an unknown reason, some asserts were forgotten, this patch fixes them all, for real, I swear. [1] https://bugs.python.org/issue17866 Change-Id: I51a31204ddef83fe36a55631f1a81bff346d176b
* Enforce autospec in test_commonRiccardo Pittau2020-06-241-40/+67
| | | | | | And remove the corresponding H210 filter. Change-Id: I1d6e130cded0322ec08a3c1166744b802661c5ee
* Merge "Allow node vif attach to specify port_uuid or portgroup_uuid"Zuul2020-06-231-6/+65
|\
| * Allow node vif attach to specify port_uuid or portgroup_uuidTzu-Mainn Chen2020-06-151-6/+65
| | | | | | | | | | | | | | | | | | | | | | Update the function that checks for free ports/portgroups to accept a port_like_obj_id parameter to match. This parameter comes from the vif_info dictionary. Story: 2007723 Task: 39872 Change-Id: I82efa90994325aa37cca865920d656f510a691b2
* | Use assertCountEqual instead of assertItemsEqualRiccardo Pittau2020-06-111-12/+12
| | | | | | | | | | | | | | | | | | | | | | The assertItemsEqual method has been removed in Python 3.3 [1] but it was kept alive by unittest2, imported by testtools. To prevent mayhem and despair caused by testtools removing unittest2 from its requirements in the near future, we switch to assertCountEqual. [1] https://bugs.python.org/issue17866 Change-Id: I614bcedc9981370fb54cfe3da997a3d52484c07f
* | Add `get_node_network_data` to non-Neutron NetworkInterfaceIlya Etingof2020-05-251-0/+14
|/ | | | | | | | | | Implements `get_node_network_data` network interface method for non-Neutron networks providing network configuration for the node taken from the `network_data` field of the ironic node object. Change-Id: I4c5722b5e515f6edfa6a1bac0a443c71312c34d8 Story: 2006691 Task: 37070
* Switch to unittest mockIury Gregory Melo Ferreira2020-04-301-1/+2
| | | | | | | Python3 have a standard library for mock in the unittest module, let's drop the mock requirement and switch tests to unittest mock. Change-Id: I4f1b3e25c8adbc24cdda51c73da3b66967f7ef23
* Use auth values from neutron conf when managing Neutron portsTzu-Mainn Chen2020-04-031-3/+9
| | | | | | | | | | Using the auth values from the neutron section of the Ironic configuration prevents issues where a non-admin user is not allowed to manage Neutron ports. Change-Id: I66cf1acba10a7b7b82f5a2a55453c3d5a29a086e Story: #2006506 Task: #38789
* Add support for Smart NICsHamdy Khader2019-02-071-0/+20
| | | | | | | | | | | | | | | | Extend Ironic to enable use of Smart NICs to implement generic networking services for baremetal servers. Extending the ramdisk, direct, iscsi and ansible deployment Interfaces to support the Smart NIC use-cases. For Smart NIC use-case the baremetal node must be powered on and booted into bios then wait for agent that runs on the Smart NIC to be alive then do the network changes required. Task: #26932 Story: #2003346 Change-Id: I00d6f13dd991074e4f45ada4d7cf4ccc0edbc7e1
* Completely stop using the "fake" classic driver in unit testsDmitry Tantsur2018-06-061-3/+0
| | | | | | | | | | | This change makes "fake-hardware" the default driver for test nodes and makes enabled_drivers empty in the base test class. Note that some unit test coverage for classic drivers is lost because of this change. It is fine, because the classic drivers themselves are deprecated and will be removed soon. Change-Id: I06acb5aed24ef952db3f9e6987e5a90c81e96401
* Remove excessive usage of mock_the_extension_manager in unit tests - part 1Dmitry Tantsur2018-05-151-4/+0
| | | | | | | | | | | This function does not work properly with hardware types, and is not needed in the most cases where it is used. The enabled_drivers option is changed instead where needed. This change covers only a (randomly selected) part of files. Other files will be updated separately. Change-Id: Iae40ed6c5d37bb2d2af3219d2f94922a2b32d78d
* Merge "Remove vifs upon teardown"Zuul2018-04-171-0/+14
|\
| * Remove vifs upon teardownJulia Kreger2018-04-121-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we removed the ability for nova to cleanly remove the vif during teardown because that created a race condition, the removal of all vif attachment records only seems to be the right thing to do since we can't realistically change nova try harder, and functionally we are otherwise looking at massive locking changes. Removing vif records is the lesser evil until we can reach consensus on completely revamping locking to allow for greater concurrency. Change-Id: I8d683d2d506c97535b5a8f9a5de4c070c7e887df Story: #1743652 Task: #9275
* | Copy port[group] VIF info from extra to internal_infoRuby Loo2018-04-021-79/+3
|/ | | | | | | | | | | | | | | | | | | | | | | For API versions >= 1.28, Port & portgroup's .extra['vif_port_id'] was deprecated in Ocata. Before we can remove support for this, we need to copy that information to the object's internal_info['tenant_vif_port_id']. This copy/migration is done at the API layer when the user specifies the .extra[] value, as well as when the 'ironic db-sync online_data-migrations' is run. In order to know whether the ports and port groups have been migrated, their IronicObject versions are incremented. This also fixes it so that for API versions < 1.28, the deprecation warning is not shown, since we still need to support extra['vif_port_id'] in this case. When a port or portgroup's .extra['vif_port_id'] is removed via a PATCH API request, that VIF is removed from that object's internal_info. Change-Id: I69468c935e68dd9d37a474c318c3ceb9cdfc5868 Partial-Bug: 1722850
* Revert "Don't try to lock for vif detach"Dmitry Tantsur2018-02-211-17/+1
| | | | | | | | | | | | | This is causing more serious issues, as there is a race between tenant VIF removal and cleaning VIF adding. This reverts commit 4f79cb3932f2518ab3f06b86ceea065cbb399e8c. The release note is not deleted from it, because the change has already been released. A new one is added instead. Change-Id: I922f24293645ff6bb79ad753f49dc9548b9f2485 Closes-Bug: #1750785
* Don't try to lock for vif detachJulia Kreger2018-02-071-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Historically, we did not have a prohibition upon removing a VIF entry stored in the extra field, however the VIF attachment/detachment feature resulted in a task being created which by default attempts to pull a reservation lock unless explicitly shared. This is problematic as part of the process of undeploying a node as exclusive locks are generated. Presently, if any of those locked tasks run long, such as a new image being required or for some crazy reason, the BMC power request hangs for a few minutes, the VIF record may be orphaned and never removed, as the expectation is that nova deletes the VIF record from ironic. This allows the VIF record to be removed when a node is no longer in active use and possibly subject to a lock being held for a long period of time, such as when setting up for CLEANING. Additionally, this patch moves the actual VIF record deletion until after the detachment action in the event that it fails. This allows for the state in ironic to be consistent instead of the record being removed before the detachment occurs. Change-Id: Ib7544e43a2b26441d4f562b584bbc7fee6a11fea Closes-Bug: #1743652
* Add rescue related methods to network interfaceShivanand Tendulker2018-01-221-1/+10
| | | | | | | | | | | | | | | | | Adds methods `add_rescuing_network` and `remove_rescuing_network` to add/remove rescuing network to `network` interface. These methods are not added to `flat` network interface. The 'flat' network uses same network for tenant and provisioning. It makes sense to use the same for rescuing as well; as opposed to a separate network like we have for cleaning. Change-Id: I8f4123bfe7d293e8ff6f3bfc2f25445a39c94c73 Related-bug: #1526449 Co-Authored-By: Jay Faulkner <jay@jvf.cc> Co-Authored-By: Mario Villaplana <mario.villaplana@gmail.com> Co-Authored-By: Jesse J. Cook <jesse.j.cook@member.fsf.org> Co-Authored-By: Aparna <aparnavtce@gmail.com> Co-Authored-By: Shivanand Tendulker <stendulker@gmail.com>
* Use adapters for neutronclientPavlo Shchelokovskyy2017-12-141-19/+30
| | | | | | | | | | | | | | | | | | | | deprecates the following options in [neutron] section: - url - url_timeout - auth_strategy Changes some internal networking-related functions/methods to accept a request context as optional keyword argument (defaults to None). This allows to pass a global request id to neutron client and in future will simplify creating a user auth plugin from request context. For backward compatibility, when calling those functions/methods without a request context, a dummy request context will be generated automatically. Change-Id: Ib327c7a141cfbca63b870027ad8e901c0f48bb2d Partial-Bug: #1699547
* Change pxe dhcp options name to codes.Vasyl Saienko2017-10-131-1/+1
| | | | | | | | | | | | | | | | | | | There is difference between dhcp option names in different backends. This patch changes options name to code according to [0]. [0] https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml Closes-Bug: 1717236 This is an updated version of c377f5cbbd034e16b68a3fc30e138b03badc9c94 which problems with PXE and dnsmasq due to buggy dnsmasq code which uses siaddr field to specify tftp server. They are addressed now by always sending server-ip-address to make sure that dnsmasq works. More information about siaddr and option 150,66 can be found in informational RFC https://tools.ietf.org/html/rfc5859 Change-Id: I55487d867979bf6bb4cf228fcf6408beae955d2b
* Update vif_attach from NeutronVIFPortIDMixinVasyl Saienko2017-09-081-38/+0
| | | | | | | | | | | This patch updates vif_attach from NeutronVIFPortIDMixin to rely on presence of Neutron. Drop incorrect logic that skips mac_address update when show_port() to neutron failed as NeutronVIFPortIDMixin is used only in flat and neutron network interfaces which require neutron presence. Update api tests to use real neutron port. Change-Id: Iffaf3569aa296b4466729cf7f62c92995b6b3723
* Refactor VIFPortIDMixin: factor out common methodsMark Goddard2017-07-271-188/+362
| | | | | | | | | | | | | | | | | | | | | | | | This change is part of a series of changes which aim to refactor the VIFPortIDMixin mixin class. The refactor aims to reduce code duplication, and separate the neutron interactions from the more general VIF attach/detach behaviour. The neutron separation will be made possible by introducing an inheritence hierarchy to the mixin class. VIFPortIDMixin will become a general VIF attach/detach class, with no neutron interaction. NeutronVIFPortIDMixin will inherit from VIFPortIDMixin and override the subclass behaviour to interact with neutron where appropriate. Once this refactor is complete, a new fake network interface will be added with similar VIF attach/detach behaviour to the flat and neutron network interfaces, but without any interaction with neutron. This interface will be useful in testing environments. This change refactors the NeutronVIFPortIDMixin class by factoring out some common methods into a parent class, VIFPortIDMixin. This will help to avoid code duplication between the classes. Change-Id: I69a104ec967572f65566b0e0d67145d135be3ac9
* Refactor VIFPortIDMixin: renameMark Goddard2017-07-211-3/+3
| | | | | | | | This prepares the ground for addition of a VIF mixin without support for interacting with neutron, by explicitly showing that the current VIF mixin class is for neutron network interfaces. Change-Id: Ic0707c310c736c78f6f4fa0345311e99f7203a58
* Physical network aware VIF attachmentMark Goddard2017-07-061-36/+324
| | | | | | | | | | | | | | | | | | | | | | | | | | | When attaching virtual interfaces to ironic ports and portgroups, we need to take account of the physical network assigned to those ports and portgroups. A neutron virtual interface has a set of physical networks on which it can be attached which is governed by the segments of its network (of which there may be more than one). This change makes the ironic VIF attach API physical network-aware using the physical network information added to the port object. When selecting a port or portgroup to attach a virtual interface to, the following ordered criteria are applied: * Require ports or portgroups to have a physical network that is None or one of the VIF's allowed physical networks. * Prefer ports or portgroups with a physical network field which is not None. * Prefer portgroups to ports. * Prefer ports with PXE enabled. The change is backwards compatible, as the old behaviour is maintained when ports have a physical_network field which is None. Change-Id: I3d13bfacfb5578f570791e3c06e769a9a0140a4c Partial-Bug: #1666009
* Replace deprecated .assertRaisesRegexp()Ruby Loo2017-05-181-2/+2
| | | | | | | | This replaces the deprecated (in python 3.2) unittest.TestCase method assertRaisesRegexp() with assertRaisesRegex(). Change-Id: Iec0f38102a76f4830ba1a96ed06743072048285f Related-Bug: 1673768
* Merge "Allow to attach/detach VIFs to active ironic nodes"Jenkins2017-03-291-2/+50
|\
| * Allow to attach/detach VIFs to active ironic nodesVasyl Saienko2017-03-021-2/+50
| | | | | | | | | | | | | | | | | | | | This patch enhances attach/detach logic and allows to work with active ironic nodes. Starting with this change when VIF is attach/detach neutron port is updated appropriately to reflect changes on hardware (ie: plug port to specific network) Change-Id: Idc9dc37b11950e3aa2864a0a90d6ec2e307926a3 Related-Bug: #1659282
* | Walk over all objects when doing VIF detachVasyl Saienko2017-02-131-0/+16
|/ | | | | | | | | | | | We apply specific rules when doing VIF attach, do not duplicate them in vif_detach just walk over all port and portgroup objects. This also fixes an issue when VIF was attached to port manually (set vif_port_id key in port.extra) and it is impossible to detach such VIF via v1/nodes/<node_ident>/vifs API. Closes-Bug: #1663660 Change-Id: I70fe87bb4ae15a506fec705d10beaed572c0b45e
* Merge "Validate port info before assume we may use it"Jenkins2017-02-031-10/+62
|\
| * Validate port info before assume we may use itVasyl Saienko2017-01-271-10/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Ironic 'neutron' network driver requires local_link_connection to be present on ironic port to be able to work with it (plug to specific network). This patch ignores ironic ports without local_link_connection when attaching VIF to node with 'neutron' network driver. Also make sure that we do not pick such port for provisioning and cleaning. Closes-Bug: #1653249 Change-Id: Icb8298b9be0d8ba62192580263feafa0e1708129
* | Do not use user token in neutron clientVasyl Saienko2017-01-191-11/+7
|/ | | | | | | | | | | | | | | | Ironic requires admin rights in Neutron to perform certain operations like (create provisioning/cleaning ports, unbind port, update mac_address). Previously only admins were able to use ironic, with keystone policy implementation it is possible that baremetal admin doesn't have enough rights (admin rights) in Neutron with leads to neutron operations failures. This patch ensures that we do not pass user token to neutron client, and always pick admin session. Closes-Bug: #1657675 Change-Id: If17d5501062075fb8d6ca0eb4f2f38c87e2c2cc3
* Allow to attach/detach VIF to portgroupVasyl Saienko2017-01-161-42/+290
| | | | | | | | | | | | | With this patch port groups are activated in Ironic. When attaching a VIF to a node, it is attached to the first free port group. If there are no free port groups, the first available port (pxe_enabled has higher priority) is used instead. Related-Bug: #1618754 Related-Bug: #1582188 Co-Authored-By: Vladyslav Drok <vdrok@mirantis.com> Change-Id: I0dca2c2d98184e370c08c3e05aa3edadead869af
* Fix assertEqual parmeters position in unittestsVasyl Saienko2017-01-121-5/+5
| | | | | | | This patch updates drivers/modules/network/common tests to use assertEqual(expected, actual). Fix docstring formatting. Change-Id: Ia9b75f4db07c1ac264255dddd2371a4353407ae1
* Add Virtual Network Interface REST APIsSam Betts2017-01-111-2/+36
| | | | | | | | | | | | | | | | | | | This patch adds the REST APIs for the virtual network interface API in order to abstract the task of assigning logical network interfaces to physical network interfaces. Since Newton Ironic provides an interface for pluggable network implementations. Different network implementations may want to handle how logical to physical network interface assignment happens. To do this the new API calls into new functions on the network implementation loaded for the specified node. This is part 3 of 3, and adds the node vif subcontroller to expose the /nodes/<ident>/vifs REST API endpoint. API version is bumped to 1.28. Co-Authored-By: Vasyl Saienko (vsaienko@mirantis.com) Change-Id: I70f1166a15a26f392734e21d6bc30a03da4e5486 Partial-Bug: #1582188
* Add Virtual Network Interface Driver APIsSam Betts2016-12-231-0/+555
This patch adds the driver API interfaces for the virtual network interface API in order to abstract the task of assigning logical network interfaces to physical network interfaces. Since the OpenStack Newton release, Ironic provides an interface for pluggable network implementations. Different network implementations may want to handle how logical to physical network interface assignment happens. To do this the new API calls into new functions on the network implementation loaded for the specified node. This is part 1 of 3, and adds four new functions vif_attach, vif_detach, vif_list, port_changed, portgroup_changed, get_current_vif to the base network interface class, which should be overridden by network interface implementations. DHCP provider update_mac_address method was deprecated, network interface port_changed() and portgroup_changed() should be used instead. Co-Authored-By: Vasyl Saienko (vsaienko@mirantis.com) Change-Id: I0b84cfd85557d18254697f2e539c583ea0f8e88c Partial-Bug: #1582188 Closes-Bug: #1158684