summaryrefslogtreecommitdiff
path: root/ironic/api/controllers/v1/portgroup.py
Commit message (Collapse)AuthorAgeFilesLines
* Use association_proxy for port groups node_uuidHarald Jensås2022-12-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | This change adds 'node_uuid' to: ironic.objects.portgroup.Portgroup 'node_uuid' is a relationship using association_proxy in models.Portgroup. Using the association_proxy removes the need to do the node lookup to populate node uuid for portgroups in the api controller. NOTE: On portgroup create a read is added to read the port from the database, this ensures node_uuid is loaded and solves the DetachedInstanceError which is otherwise raised. The test test_list_with_deleted_port_group was deleted, if the portgroup does not exist porgroup_uuid on the port will be None, no need for extra handling of that case. Bumps Portgroup object version to 1.5 Change-Id: I4317d034b6661da4248935cb0b9cb095982cc052
* Fix resource_url in the remaining resourcesDmitry Tantsur2022-01-241-6/+3
| | | | | | | | | Node history was particularly affected: limit was not converted from string to integer, so "next" link was never added. Add some safeguards to the generic API code. Change-Id: I1328e2f07621bf7e39b96eb4a7ddb66c9a2b65bb
* Set resource_url when getting all ports or portgroupsArne Wiebalck2022-01-171-0/+2
| | | | | | | Since the default value resource_url is None, make sure the parameter is set to 'ports' when getting all ports. Change-Id: Id603ae5a4a802dfc8f866b15c8d327d95eba9310
* Remove extra/vif_port_idJulia Kreger2021-03-221-11/+1
| | | | | | | | | | | | | | | | | 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
* Port/Portgroup project scoped accessJulia Kreger2021-03-021-26/+65
| | | | | | | | | | | | | | | | | | | | | This patch implements the project scoped rbac policies for a system and project scoped deployment of ironic. Because of the nature of Ports and Portgroups, along with the subcontroller resources, this change was a little more invasive than was originally anticipated. In that process, along with some discussion in the #openstack-ironic IRC channel, that it would be most security concious to respond only with 404s if the user simply does not have access to the underlying node object. In essence, their view of the universe has been restricted as they have less acess rights, and we appropriately enforce that. Not expecting that, or not conciously being aware of that, can quickly lead to confusion though. Possibly a day or more of Julia's life as well, but it comes down to perceptions and awareness. Change-Id: I68c5f2bae76ca313ba77285747dc6b1bc8b623b9
* Consistently use utils functions for policy authSteve Baker2020-12-171-13/+6
| | | | | | | | | | | The check_policy function exists in api utils, along with other more complex policy utility functions. This change replaces direct calls to authorize with calls to check_policy. Having authorize calls consolidated in api utils may help with the upcoming secure-rbac work. Change-Id: If4779b08b9f360f4c2f4675c605aa519f6ea4778
* Don't allow patching port internal_infoSteve Baker2020-11-191-1/+2
| | | | | | | | | | | Patching the port internal_info was allowed in error in the just landed JSON conversion change[1]. This is now fixed, and the comment has been updated to explain why internal_info needs to be part of patch schema. [1] https://review.opendev.org/750120 Change-Id: Ieab085cfd9731e180f741b17a27ea540dabbf62e
* Convert portgroups endpoint to plain JSONSteve Baker2020-11-161-266/+170
| | | | | | Change-Id: I3706051704c260e605c765e8a45e4d4f3ec0b977 Story: 1651346 Task: 10551
* Convert ports endpoint to plain JSONSteve Baker2020-11-161-2/+2
| | | | | | Change-Id: I0594e84905957873de17275ee396531b816cd468 Story: 1651346 Task: 10551
* Remove Link typeSteve Baker2020-07-201-11/+11
| | | | | | | | | | | | | | | | | | This type is only used for output response formatting, not for input validation, so it can be replaced with a basic dict equivalent without disruption. This results in fields in WSME types which shouldn't be handled by WSME because they are already in a dict format. This is handled by relaxing the validation in the (ex-WSME) types so that a None type means that WSME shouldn't serialize that attribute. This will allow old style type serialization to be mixed with plain dicts during the transition period. Story: 1651346 Task: 10551 Change-Id: Ifae9bd005fb7cf951b069ade0c92b8d61e095e0f
* Add validate decorator to exposeSteve Baker2020-06-021-2/+1
| | | | | | | | | | Unit test coverage is provided by the patch tests in ironic.tests.unit.api.controllers.v1.test_types Story: 1651346 Task: 10551 Change-Id: I11c0ef3f5b008fb55cf2470c5f78fa12a8ad6861
* Centralise imports of wsme typesSteve Baker2020-04-201-19/+19
| | | | | | | | | | Instead of importing wsme types directly from the wsme packages, import them from ironic.api.types. This reduces the number of wsme imports throughout the codebase, and confines much of the future code changes to the new types.py and a few other files. Change-Id: I231a1f82915ab9e07c00857aa6210c0764b8ce4b Story: 1651346
* Subclass wsme.exc.ClientSideErrorSteve Baker2020-01-221-4/+4
| | | | | | | | | | This change avoids importing a wsgi namespace exception class, and allows the future option of changing the parent class of exception.ClientSideError when wsme is no longer processing API requests. Change-Id: I8165e094fafb91ff94eaa1dd96baba7671487448 Story: 1651346
* Use str type instead of wsme.types.textSteve Baker2020-01-221-7/+7
| | | | | | | | | | wsme.type.text maps to six.text_type, which for py3 is str. Ironic is py3 only, and wsme is being removed, so this change replaces all wsme.types.text uses with str. Change-Id: Ie39f049840980d0595be3620f35f14eb4b0198af Story: 1651346
* Stop using six libraryRiccardo Pittau2019-12-231-1/+1
| | | | | | | | | | Since we've dropped support for Python 2.7, it's time to look at the bright future that Python 3.x will bring and stop forcing compatibility with older versions. This patch removes the six library from requirements, not looking back. Change-Id: Ib546f16965475c32b2f8caabd560e2c7d382ac5a
* Do not ignore 'fields' query parameter when building next urlArun S A G2019-10-181-1/+2
| | | | | | | | | | | | | | | | | | | | When an user calls the GET on an ironic resource it returns MAX_LIMIT number of resources at a time along with a next url. The default MAX_LIMIT is 1000. If the user requested specific set of fields from ironic API using the fields query parameter (eg: /v1/resource?fields=f1,f2,f3) The next url returned by the API ignores fields query parameter. This results in fields missing from the results after MAX_LIMIT is reached. This change fixes this problem by passing the fields as parameter to collections.get_next method and using the fields argument to build the query parameter. Change-Id: I62b59e8148171c72de0ccf63a1517e754b520c76 Story: 2006721 Task: 37093
* Abstract away pecan.request/responseDmitry Tantsur2019-07-161-21/+22
| | | | | | | This change changes direct usages of pecan context objects to wrapper in ironic.api, so that we can easier swap them with another implementation. Change-Id: Ia1e411e27001860b14f4f765e26ed9f5893233d3
* Deploy templates: conductor and API nitsMark Goddard2019-03-121-11/+8
| | | | | | | | | | Fixes nits from https://review.openstack.org/#/c/634732 and https://review.openstack.org/#/c/631845. Change-Id: I3da177cffca19c024850be675137cbeb4de31758 Story: 1722275 Task: 28675 Task: 28677
* Ensure pagination marker is always setWill Szumski2018-09-111-15/+37
| | | | | | | | | | | | | | | | | | | Previously the pagination marker was not being set for list queries where `uuid` was not in the list of requested fields. The affected endpoints were: port, portgroup, volume_target, volume_connector, node and chassis. The next marker contains the UUID of the last element that was returned to the client. This information was being removed from elements in the collection. This meant that we could no longer return a UUID for this marker. An extra parameter, `sanitize` was added to `convert_with_links`. This allows us to delay stripping this field from the elements until after the next marker has been set. Story: 2003192 Task: 23346 Change-Id: Ied45f698c3431c5113bae46c1a4f1de1cdaa2d74
* Add detail=[True, False] query string to API list endpointsSam Betts2018-06-181-7/+15
| | | | | | | | | | | | | | | We currently support /[nodes, ports, portgroups, chassis]/detail as an API endpoint for getting a detailed list of each object. This does not fit the RESTful and resourceful API design principles of <resource type>/<resource id> and makes it hard to consume the API from frameworks that expect that structure. We can't remove the old endpoint, so that is safeguarded by the restricted node names list. This patch adds a ?detail=[True, False] query string to the list API endpoints to allow those consuming the API to use the expected URL form. Change-Id: I694919b4a4eaa3419318bbee1cde79de15e19afa Story: #1662921 Task: #10176
* Fix W504 errorsJulia Kreger2018-05-091-12/+11
| | | | | | | | Also a few related errors based on some earlier investigation may have been pulled in along the lines of E305. Story: #2001985 Change-Id: Ifb2d3b481202fbd8cbb472e02de0f14f4d0809fd
* Implementation of inspect wait stateKaifeng Wang2018-04-101-0/+9
| | | | | | | | | | | | | | | | | | | This patch provides implementations to feature of adding inspect wait state. Changes covered in this patch: * Added state and transitions, state diagram regenerated. * inspector and oneview inspect interface now return INSPECTWAIT instead of INSPECTING. Move node to inspect wait if inspect interface returns INSPECTING or INSPECTWAIT. * Add a timeout option to conductor, and a periodic task to check timeout in the inspect wait state. Story: #1725211 Task: #10630 Partial-Bug: #1725211 Change-Id: Ie76bfdad5966014a4dae826919ff5705462c743b
* Copy port[group] VIF info from extra to internal_infoRuby Loo2018-04-021-4/+5
| | | | | | | | | | | | | | | | | | | | | | | 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
* Stop guessing mime types based on URLsDmitry Tantsur2018-02-071-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Currently we have a pecan feature enabled that strips extensions from the end of the URL and treat it like requested content type. E.g. /v1/nodes.json is treated as /v1/nodes with requested content type Application/Json. However, this prevents certain node names: e.g. /v1/nodes/small.1 is treated like /v1/nodes/small with content type of a man page. It does not make any sense for ironic API, as we only support Application/Json content type (and .json suffix). This change disabled this pecan feature. To keep backward compability a new middleware stips the .json prefix and saves a flag in the environment about its presence. API accepting names try to find their resource first without, then with .json suffix. The following endpoints are special-cased to support names with .json: * Node GET, PATCH and DELETE * Ramdisk heartbeat * Port group GET, PATCH and DELETE VIF API is not updated, so VIF IDs still cannot have .json suffix. Change-Id: I789ecfeac9b64a9c4105a20619f7bf5dfc133189 Closes-Bug: #1643995
* Check if sort key is allowed in API versionRuby Loo2017-05-161-0/+2
| | | | | | | | | | | | This checks the sort key, to make sure the specified field is allowed/available in the specified API microversion. If it is not allowed, a 406 HTTP status is returned. This affects requests to get lists of nodes, port groups, and ports. Change-Id: Id5fb44b8b7fe989514dbae4b60cef4a34d47e52b Closes-Bug: #1659419
* Merge "Fix usage of various deprecated methods"Jenkins2017-03-201-3/+5
|\
| * Fix usage of various deprecated methodsVladyslav Drok2017-03-171-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our unittest output complains about some of the codebase, described in more detail in the referred bug. This change fixes all of those places. static_root is now set only if debug=True is set in pecan configuration. Logging is now setup as part of the conf module import, so that unittests can use it. Closes-Bug: #1668240 Change-Id: I2536bd2b174e0d224ddf6806f1be37bd29017669
* | Add ironic port group CRUD notificationsYuriy Zveryanskyy2017-02-151-15/+45
|/ | | | | | | | | | | This patch adds notifications for create, update or delete port groups. Event types are: baremetal.portgroup.{create, update, delete}.{start,end,error}. Developer documentation updated. "portgroup_uuid" field added to port payload. Closes-Bug: #1660292 Change-Id: I9a8ce6c34e9c704b1aeeb526babcb20a5b1261db
* Allow to attach/detach VIF to portgroupVasyl Saienko2017-01-161-1/+7
| | | | | | | | | | | | | 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
* Forbid removing portgroup modeVladyslav Drok2016-12-201-0/+1
| | | | | | | | Mode can be left empty on creation, the value will be populated by the dbapi, but in case of updates, we should not allow removing it. Partial-Bug: #1618754 Change-Id: I917b23bc155972b777b143d16545a49039604910
* Merge "Fix policy dict checkers"Jenkins2016-12-191-6/+6
|\
| * Fix policy dict checkersVladyslav Drok2016-12-191-6/+6
| | | | | | | | | | | | | | | | | | | | After the ironic context refactor, the default policy values were changed to use project_domain_id and project_name, while not changing the checker methods in API to fetch the correct values from the context. This change fixes this issue. Closes-Bug: #1650203 Change-Id: If9bf67b9d7d6f66b12a99d1ee7826af9634415b5
* | Add portgroup configuration fieldsVladyslav Drok2016-12-151-2/+26
|/ | | | | | | | | | | This change adds mode and properties fields into portgroup object and adds a new API microversion to work with them. It also makes portgroups' address field optional for all API microversions. Partial-Bug: #1618754 Change-Id: Id8c62fa56908040b0df16cc54c122ce2473a4587
* Integrate portgroups with ports to support LAGMichael Turek2016-11-091-0/+42
| | | | | | | | | | | | | | | | | | | | | | | This patch adds portgroups subcontroller. The API version has been bumped to 1.24. New endpoints were added: * '/v1/nodes/<node>/portgroups' * '/v1/portgroups/<pg>/ports' Starting with this API version, ports have a new 'portgroup_uuid' field that contains UUID of a portgroup this port belongs to. Partial-bug: #1618754 DocImpact Co-Authored-By: Jenny Moorehead <jenny.moorehead@sap.com> Co-Authored-By: Will Stevenson <will.stevenson@sap.com> Co-Authored-By: Vasyl Saienko <vsaienko@mirantis.com> Co-Authored-By: Vladyslav Drok <vdrok@mirantis.com> Co-Authored-By: Zhenguo Niu <Niu.ZGlinux@gmail.com> Co-Authored-By: Michael Turek <mjturek@linux.vnet.ibm.com> Change-Id: I597ae1a3a969ee9fb4df57e444c606c77c5c093c
* Add PortGroups APIVladyslav Drok2016-11-031-0/+481
This patch adds the portgroups API object and REST controller to Ironic. Additionally this patch provides a PortgroupsCollection class and PortgroupsPatch class. API version has been bumped to 1.23. This commit includes changes to: - the API (addition of portgroup API) - the API tests Partial-bug: #1618754 Co-Authored-By: Jenny Moorehead <jenny.moorehead@sap.com> Co-Authored-By: Will Stevenson <will.stevenson@sap.com> Co-Authored-By: Vasyl Saienko <vsaienko@mirantis.com> Co-Authored-By: Vladyslav Drok <vdrok@mirantis.com> Co-Authored-By: Zhenguo Niu <Niu.ZGlinux@gmail.com> Co-Authored-By: Michael Turek<mjturek@linux.vnet.ibm.com> Change-Id: I03ab55c15c1ee2fdd4b2786e366f9502c1ad8972