8649 Commits

Author SHA1 Message Date
Chris Dent
6a265bcac6 [placement] increase gabbi coverage of handlers.inventory
Test for correctly formed but invalid data when creating an Inventory.
This increases the coverage of the inventory handler from gabbi.

Race condition and ConcurrentUpdateDetected scenarios are not
covered as those are hard to cause from a gabbi test.

Change-Id: I603558c08d540aa53918252a0a9a050701456f5a
2016-11-22 15:34:51 +00:00
Chris Dent
1e6c13f2ec [placement] increase gabbi coverage of handlers.allocation
A case where a non-existent resource provider in an allocation PUT
request could raise a 400 was not covered. Now it is.

This still leave a ConcurrentUpdateDetected exception (which can
lead to 409) not covered. There's no simple way to cause such a
thing from a gabbi test.

Change-Id: I98243b679ba8101663d459cb9a76f7015078aff7
2016-11-22 15:34:51 +00:00
Jenkins
47ea0cdee8 Merge "Typo error allocations.yaml" 2016-11-22 07:47:09 +00:00
Prashanth kumar reddy
62a30fa363 Separate CRUD policy for server_groups
The same policy rule (os_compute_api:os-server-groups) is being used
for all actions (show, index, delete, create) for server_groups REST
APIs. It is thus impossible to provide different RBAC for specific
actions based on roles. To address this changes are made to have
separate policy rules for each of action.

It has been argued that index and show may not need separate policy
rules, but most other places in nova (and OpenStack in general) do
have separate policy rules for each action. This affords the ultimate
flexibility to deployers, who can obviously use the same rule if
that is what they want. One example where show and index may be
different is that if show is restricted based on some criteria, such
that a user is able to see some resources within the tenant but not
others, then list would need to be disallowed to prevent the user
from using list to see resources they cannot show.

Change-Id: Ica9e07f6e80257902b4a0cc44b65fd6bad008bba
Closes-Bug: #1636157
2016-11-21 11:43:13 -05:00
Jenkins
332deaf48a Merge "Database poison note" 2016-11-19 01:46:33 +00:00
melanie witt
40ad8a2199 Use pick_context_manager throughout DB APIs
The pick_context_manager method will use a connection to a cell
database if one is present in the RequestContext, else it falls
back on the global main_context_manager in the DB API.

Currently, there are several places in our DB API code where
pick_context_manager isn't used because in a real scenario, each
cell is in a separate process where main_context_manager points
to its local database. This causes problems for testing though,
because we are unable to patch the DB API to simulate switching
between multiple 'main' databases in our functional tests because
of the global nature of main_context_manager.

This replaces all uses of main_context_manager with
pick_context_manager to:

  1. Make switching between multiple databases able to work in
     functional tests
  2. Fix any possible cases where pick_context_manager is not
     used for a DB API method that could be called from the
     API using target_cell

Change-Id: I31e3170e0953cefbf49bfc84b29edab514c90cb5
2016-11-18 17:15:51 +00:00
Diana Clarke
07fbac6db7 Database poison note
Add a few tips for folks that encounter database poison exceptions.

Change-Id: Ic54d9d2fdd100e20e020fb7944f1f7f16be82db0
Related-Bug: #1568414
2016-11-18 11:09:53 -05:00
Chris Dent
4a1e85595f Implement get and set aggregates in the placement API
/resource_providers/{uuid}/aggregates
GET for a list of aggregate uuids associated with this resource
    provider
PUT to set the list of aggregate uuids associated with this this
    provider

The API requests map directly to set_ and get_ aggregates on the
ResourceProvider object.

This is implemented as placement API microversion 1.1. To make that
easier a raise_404_if_not_version helper method is added to the
microversion module.

The new rest_api_version_history doc is updated to reflect this
new version.

Change-Id: I514c15c7d387cf25bf7986d07baccf0e7a785f46
Partially-Implements: blueprint generic-resource-pools-ocata
2016-11-17 17:32:13 +00:00
Jenkins
bf7d70793f Merge "conf: Remove extraneous whitespace" 2016-11-17 14:03:55 +00:00
Jenkins
498f2868a0 Merge "Updated from global requirements" 2016-11-17 13:59:33 +00:00
OpenStack Proposal Bot
a9d0f19942 Updated from global requirements
Change-Id: I56f82972fe87410d5d4e2d222fdeaec632fbbea1
2016-11-16 21:59:09 +00:00
Jenkins
f5a220ec3d Merge "Add the initial documentation for the placement API" 2016-11-16 12:11:58 +00:00
Jenkins
02b3c7421a Merge "[placement] Enforce min_unit, max_unit and step_size" 2016-11-16 11:42:07 +00:00
Jenkins
dd0cd8bd6a Merge "Placement api: 404 response do not indicate what was not found" 2016-11-16 11:41:06 +00:00
pangliye
7eb0987d6c Typo error allocations.yaml
Change-Id: Id3ce395785963bf9ff015a629f61a296fa343fcd
2016-11-16 18:59:46 +08:00
Jenkins
26ad102b9b Merge "Replace admin check with policy check in placement API" 2016-11-15 17:53:52 +00:00
Chris Dent
291e85a326 [placement] Enforce min_unit, max_unit and step_size
Add support for checking min_unit, max_unit and step_size when
making allocations to the placement API. When the constraints are
violated a new exception InvalidAllocationConstraintsViolated is
raised.

Change-Id: I18596a3c0f2b0049aaccd0f3e73aef90b684c4a8
Closes-Bug: #1623545
2016-11-14 20:04:02 +00:00
Matt Riedemann
bc29704f87 Add the initial documentation for the placement API
This is the initial set of docs for the placement API
service introduced in the Newton release.

We still have to flesh out the API reference in detail
but this gets us started.

The deployment steps are taken from how devstack does
this today.

Change-Id: Ic2436d92a7cefaeb1ae67ed878da968444f2f18d
2016-11-11 17:21:50 -05:00
Jenkins
dc1101c750 Merge "[placement] add a placement_aggregates table to api_db" 2016-11-11 21:39:18 +00:00
Maciej Szankin
7b5ea2c508 conf: fix formatting in wsgi
* Removed leading space before asterisks in listings
  which causes list to be wrapped in blockquote tag [0]
* Removed redundant empty lines in code

[0] http://docs.openstack.org/newton/config-reference/compute/config-options.html

Change-Id: I4c26650b08e1f89cd8a0ffa3a35c87e66873f0f5
Implements: blueprint centralize-config-options-ocata
2016-11-11 16:05:58 +00:00
Jenkins
2d2744339d Merge "Updated from global requirements" 2016-11-10 18:17:17 +00:00
Jenkins
e7df53a867 Merge "EventReporterStub" 2016-11-10 15:54:38 +00:00
Jenkins
2ff3157d56 Merge "Change database poison warning to an exception" 2016-11-10 15:24:05 +00:00
Jenkins
c6450c74cd Merge "encryptors: Workaround mangled passphrases" 2016-11-10 15:21:43 +00:00
Diana Clarke
88cfde277e Change database poison warning to an exception
The following warning appears in the unit test logs a number of times.

    "UserWarning: This test uses methods that set internal oslo_db
state, but it does not claim to use the database. This will conflict
with the setup of tests that do use the database and cause failures
later."

Note that this warning is only emitted once per unit test worker, so new
offenders will show up in the logs each time you fix a test until they
are all gone.

This patch is intended to be merged after all the existing warnings are
addressed by other patches in this series:

  https://review.openstack.org/#/q/topic:bug/1568414

Change-Id: I91909a356187bac70fa2fa920cebf3888410ae01
Closes-Bug: #1568414
2016-11-10 14:02:10 +00:00
OpenStack Proposal Bot
d2c6330435 Updated from global requirements
Change-Id: I04217182c7d8216120e254de3bace8a639973f9c
2016-11-10 10:19:39 +00:00
Jenkins
48e54c9d0f Merge "Add explicit dependency on testscenarios" 2016-11-09 22:52:33 +00:00
Pushkar Umaranikar
7c0bdd52a3 Placement api: 404 response do not indicate what was not found
Add informative messages to the 404 error response from
nova/objects/resource_provider.py

For the method _update_inventory_in_db() from resource_provider.py,
gabbi test validation is not added since it is not being used and
from the placement API you create an inventory but then call
set_inventory or add_inventory on a resource_provider.

Similar change, i.e. adding informative messages to 404 error can be
done for api tests from inventory.yaml and usage.yaml

It includes adding informative logging in code for 404 exceptions and
adding gabbi tests for those.
This can be done in follow up patch.

Change-Id: If53f84ac5f7521e9926b97bdcce3cf77ec5b4ffd
Closes-Bug: #1634115
2016-11-09 21:11:07 +00:00
Jenkins
af8704cb16 Merge "Updated from global requirements" 2016-11-09 19:17:57 +00:00
OpenStack Proposal Bot
1f0bcfd981 Updated from global requirements
Change-Id: Id48bb947ae71b8ca9058cc1035b72f04e76ba127
2016-11-09 04:20:44 +00:00
Jenkins
41447556e4 Merge "[placement] Add support for a version_handler decorator" 2016-11-09 03:18:16 +00:00
Chris Dent
320f60f28b [placement] add a placement_aggregates table to api_db
In order to facilitate a future extraction of the placement service
we want to record the association between a resource provider and an
arbitrary aggregate uuid in its own table.

A PlacementAggregate model is joined from ResourceProvider via
ResourceProviderAggregate. Note that this structure is used so we can
join on ids instead of strings (the uuids). A direct mapping between
ResourceProvider uuid and Aggregate uuid was mooted earlier in the year
but was determined to be suboptimal.

The name 'placement_aggregates' is used as the least problematic of
several choices after discussion amongst several parties.

The data will be used by the forthcoming get_ and set_aggregates
methods on the ResourceProvider object.

Change-Id: Id0355cb022f68e962af306ff04cf724d22b68d19
Partially-Implements: blueprint generic-resource-pools-ocata
2016-11-08 16:09:56 +00:00
OpenStack Proposal Bot
5401735ee8 Updated from global requirements
Change-Id: I5657f22c2e9db9d6ff1d9bef9ed6b9c3f4afde72
2016-11-07 18:56:32 +00:00
Dirk Mueller
6000822eba Add explicit dependency on testscenarios
With the update to oslotest 2.11.0, we're missing testscenarios
now in the unit test environment[1], so depend on it.

1: https://review.openstack.org/#/c/385274/

Change-Id: I57da89ade9eb3fcf920ec6d333db7577ee3ef138
2016-11-06 16:03:07 +01:00
OpenStack Proposal Bot
e2f12e01f1 Updated from global requirements
Change-Id: Id4ed29504256fbf879a51481c6e2a3b44d8fe62d
2016-11-06 02:03:47 +00:00
Jenkins
d1c5065493 Merge "placement: raise exc when resource class not found" 2016-11-04 22:00:40 +00:00
Stephen Finucane
85e7d91e08 conf: Remove extraneous whitespace
Per the conventions seen in other files.

Change-Id: I84b15f0eeddfd4d654aea9b5386ae3d90faafabf
Implements: bp centralize-config-options-ocata
2016-11-04 10:40:20 +00:00
Diana Clarke
53fe742087 EventReporterStub
A number of tests in test_compute_mgr.py patch the event reporter to
prevent database poison warnings but otherwise don't assert on the event
reporter behaviour. Replace those individual mocks with a fixture that
stubs out the event reporter in the test setUp.

Change-Id: I57233259065d887b38a79850a05177fcbbdfb8c3
Related-Bug: #1568414
2016-11-03 22:17:52 -04:00
Jenkins
05381ec9a1 Merge "Fix import statement order" 2016-11-03 17:19:17 +00:00
Jay Pipes
bc39bcda4c placement: raise exc when resource class not found
The ResourceProvider.set_inventory() method was not raising NotFound
when an Inventory object in the supplied InventoryList object was using
a resource class that did not exist in the resource class cache. This
patch fixes that by having the string_from_id() and id_from_string()
methods of the resource class cache raise ResourceClassNotFound instead
of returning None. We raise specific ResourceClassNotFound and
InventoryWithResourceClassNotFound exception subclasses to differentiate
in the inventory API handler between an unknown resource class and a
known resource class that doesn't exist in a given resource provider's
inventory.

We return a 400 Not Found when InventoryWithResourceClassNotFound is
raised on updating a single inventory, but return a 409 Conflict when
InventoryWithResourceClassNotFound is raised on updating a set of
inventory records since in the latter scenario, it represents a race
condition that frankly should not occur.

Change-Id: I350b02dcdbaa9d30d885cd085f60daa6b53a7745
2016-11-03 11:48:53 -04:00
Lee Yarwood
5a3ef8b40f encryptors: Workaround mangled passphrases
Prior to Ib563b0ea the passphrase used by CryptsetupEncryptor and
LuksEncryptor had any leading zeros per hexadecimal digit removed, for
example 0x04 or 04 would turn into 0x4 or 4. As a result any volume
encrypted prior to the release of Newton used a modified passphrase that
was different to that stored by the key manager being used in the
environment.

To correct this for LuksEncryptor volumes permission denied errors are
now caught when attempting to open a volume. A second attempt to open
the volume is then made using a mangled passphrase. If successful the
correct passphrase is then added to the volume before the mangled
passphrase is finally removed. This workaround can be removed in a
future release once it is safe to assume that all LuksEncryptor volumes
have had any mangled passphrases replaced in this way.

This isn't possible for CryptsetupEncryptor volumes as the plain mode
used by cryptsetup does not provide a way for adding and removing keys.
As such on a permission denied error a second attempt is made to open
the volume using a mangled passphrase. Unlike the above workaround this
cannot be removed in a future release.

Change-Id: I7096463c5eba951dd6322ee6965435e877ca0371
Partial-bug: #1633518
2016-11-02 20:03:41 +00:00
OpenStack Proposal Bot
ce425540d5 Updated from global requirements
Change-Id: I0704601ca7ba9a84ffbb9d25ae0b0c7a51032d35
2016-11-02 15:36:54 +00:00
Andrew Laski
7777ec9a14 Replace admin check with policy check in placement API
This sets up a basic framework for policy checking in the placement API
and replaces the current admin check.

There are some limitations here based on oslo.policy limitations. It
turns out that policy rule defaults can only be registered if a policy
file is also used. Since we don't have immediate plans for a placement
policy file the issue is avoided by loading the necessary rule when
policy.Enforcer is initialized. There is also no support for generating
policy files using the oslopolicy CLI scripts. This can all be addressed
later when we determine a path for separating placement policy from Nova
or merging it together.

Although there is an existing nova.policy the changes for placement
policy are implemented in nova.api.openstack.placement.policy to
ease any later extraction that may happen. This is straightforward
because the placement policy code doesn't use any code from
nova.policy.

Co-Authored-By: Chris Dent <cdent@anticdent.org>
Change-Id: Ia62158e0eed50a34114718ee724b038f577c7e87
Partially-Implements: bp placement-api-policy-authz
2016-10-31 12:46:39 +00:00
Takashi NATSUME
f653f8b52e Fix import statement order
Fix import statement order to comply with
OpenStack Style Guidelines(*1).

*1: http://docs.openstack.org/developer/hacking/#import-order-template

TrivialFix
Change-Id: I8ded09c14396a46f9d0f8f565d1294b179ce09bc
2016-10-31 21:42:42 +09:00
Jenkins
b83e47c756 Merge "Removal of tests with different result depending on testing env" 2016-10-28 09:06:00 +00:00
OpenStack Proposal Bot
4f7147c4f5 Updated from global requirements
Change-Id: I9d99b300afe6c501c03e69de70870fda07cc0796
2016-10-27 12:19:17 +00:00
Jenkins
fc65e1bc56 Merge "Make build_requests.instance MediumText" 2016-10-27 12:04:07 +00:00
Jenkins
f1c61d20a4 Merge "Updated from global requirements" 2016-10-26 19:48:09 +00:00
Matt Riedemann
8efb8ca4be Make build_requests.instance MediumText
The build_requests.instance column is a serialized
instance object, and the instances.user_data column
is MediumText, so the build_requests.instance column
itself needs to be at least MediumText in size for MySQL.

Change-Id: I7d65df37c02750593037744543ad15e5bc64e913
Closes-Bug: #1635446
2016-10-26 06:27:07 -04:00
OpenStack Proposal Bot
b11774cd47 Updated from global requirements
Change-Id: I0c74d6fb97ca8b887a2eaba5eed8398c9b135e1d
2016-10-22 01:24:04 +00:00