1054 Commits

Author SHA1 Message Date
Michael Still
c1eb6f0e50 Move ploop commands to privsep.
The same pattern as the others, but with an added security concern.

Co-Authored-By: Evgeny Antyshev <eantyshev@virtuozzo.com>

Closes-Bug: #1717533

Change-Id: I1ac3a0ea4756ec68884866435c3da69171bbeb13
blueprint: hurrah-for-privsep
2017-09-28 07:29:51 +10:00
Michael Still
90e91ca052 Squash dacnet_admin privsep context.
As discussed at the PTG, we're going to use one big context for
ease of management.

Change-Id: I951abd402736735730e0868f31b85b1817055b2f
blueprint: hurrah-for-privsep
2017-09-18 23:17:35 +10:00
Michael Still
e00d8eb759 Squash dac_admin privsep context.
As discussed at the PTG, squash the dac_admin privsep context into
the sysadmin context.

Change-Id: I10142be4baa404835fabebd50f7f976ca6ec402e
blueprint: hurrah-for-privsep
2017-09-18 23:15:10 +10:00
Michael Still
0952f80d01 Move execs of tee to privsep.
Instead of calling tee to write to files as root, we should just
write to files as root.

Change-Id: Ic48087fdf283b3ba503294a944be91be0c338132
2017-09-12 05:38:26 +10:00
Jenkins
4a8020c2e6 Merge "Move execs of touch to privsep." 2017-09-08 18:21:28 +00:00
Jenkins
def81cace8 Merge "Move libvirt usages of chown to privsep." 2017-09-08 18:16:34 +00:00
Michael Still
8325d41d4e Move execs of touch to privsep.
Instead of starting a process to update the mtime of a file, just
use privsep.

Change-Id: I2f3cfdf157e0c8bfb699ef2b29c18e9359ddd63f
2017-09-08 03:08:41 +10:00
Michael Still
0908d338c4 Move libvirt usages of chown to privsep.
A nice simple example of how to move things to privsep (and the new set
of helpers). In a few of these cases I think a more complicated re-write
is actually required, but I've put TODOs there are will do those in a
followup patch.

Change-Id: Ibb6ef001e3f2add459b0e37dfbd9f51c9eff2eb7
2017-09-08 03:07:57 +10:00
Andreas Jaeger
4e6eec5c9b Fix broken URLs
Fix broken nova URLs that linked to the old developer/nova places and
use the new link instead.

Change-Id: Ideb50626e140201dded19fc82584440f1a407e47
2017-09-07 15:42:31 +02:00
Michael Still
f535e8bb99 First attempt at adding a privsep user to nova itself.
I don't particularly care about this use case (although the localfs
code should perhaps go away), but it was a nice contained example
of a privsep user which wasn't just calling a command line.

This patch also starts to layout what an API to the privsep'd code
might look like. For now its modelled on python's os module, because
that's where all the operations we perform are coming from.

The rootwrap configuration is cleaned up as we remove users.

Co-Authored-By: Tony Breeds <tony@bakeyournoodle.com>
Change-Id: I911cc51a226d6af29d63a7a2c69253de870073e9
2017-09-07 03:01:01 +10:00
Tony Breeds
fa2e975e7d rootwrap.d cleanup mislabeled files
The form for rootwrap.d files is to include a comment before the filter
with the filename (and preferably) the command the filter matches.

This change ensures that these file comments refer to a valid file in the
tree.  They can be checked with something like:
  for i in `awk '/^#.*py *:/ {print $2}' etc/nova/rootwrap.d/compute.filters \
                 | sort -u` ; do
      ls ${i/:}
  done

* I13c701c390784fa1f7809705741abb46e40973be renamed
   .../libvirt/connection.py to .../libvirt/drver.py
* I400db60fcc29c2d5e2d3b9dabc055649138468eb switched to os-brick and
   removed nova/storage/linuxscsi.py
* I5fc2425d2c25076ea87686b2e41be35f66ebb923 moved .../libvirt/volume.py
   into .../libvirt/volume/
* Update one comment to make the awk script above work.
* Add comments as 'chown' and 'tee' are used in nova/virt/libvirt/

Change-Id: I3d89830e4770a7cf88389fac5a2a684554a29bc5
2017-08-01 16:09:18 +10:00
Sean Dague
aa45a6f3ab request_log addition for running under uwsgi
If someone chooses to run under uwsgi/apache instead of eventlet, the
basic logging of requests goes away (as that was an eventlet.wsgi
function). This is a critical piece of information for understanding
how services are working, and we need to retain it under uwsgi/apache.

This creates a new request_log middleware, inspired by the one in
placement, to provide that functionality. This includes all the same
information as before: http method, uri, status, content length, time
for the request. It also includes the microversion the request was
processed as, "-" if no microversion.

The middleware does not emit anything if it detects that it's running
under eventlet, to prevent duplicate log messages.

Release notes provided as this will be a manual transition for folks
as it's an api-paste.ini change.

Change-Id: I3a597b06d3501c765e2d7805c6c1375d6f4e40db
2017-07-24 14:23:38 -04:00
Matt Riedemann
9e5b915687 libvirt: remove scality volume driver
The Scality volume driver was removed from Cinder in Ocata:

a931f9db79554630d8d71fcff1334bb4e37cb398

It's unmaintained and therefore no longer supported, and won't
even work with recent Cinder, so let's remove it.

Change-Id: I0cfa0c4b3d7138f989225a44bdedfa716a035a14
2017-05-19 14:51:37 -04:00
Jackie Truong
a963aecb4c Add missing rootwrap filter for cryptsetup
This change restores the rootwrap filter for cryptsetup that was
recently removed by I37ffc90c0bd57029fced251b5cfd7cd4318a0292 from
compute.filters, as it is still needed by dmcrypt.  Without the rootwrap
filter, `cryptsetup` is not authorized to run with root permissions.

Change-Id: I5fe3e5d5e5a9694d0dbe5b59248e5eaf89858c62
Closes-Bug: #1688166
2017-05-08 10:05:48 +08:00
Lee Yarwood
9c23cdc247 encryptors: Switch to os-brick encryptor classes
This change drops the encryptor classes and supporting code from the
codebase in favor of the classes provided by os-brick. This is made
possible by the following os-brick change that introduced new encryption
provider constants during Ocata :

Ic155bd29d46059832cce970bf60375e7e472eca6

Thanks to the following bugfix also released as part of 1.11.0 for Ocata
the constants present in os-brick also support the use of the deprecated
legacy class paths from Nova, for example
nova.volume.encryptors.luks.LuksEncryptor, while using the os-brick
provided classes :

I3ec6e3fe919bc03d158da04a18fb8b651002ed52

Implements: blueprint switch-to-os-brick-encryptor-classes
Change-Id: I37ffc90c0bd57029fced251b5cfd7cd4318a0292
Depends-On: Iae12605dc7d0607e78020a24b5b8801606c2f169
2017-04-25 13:51:41 +00:00
Takashi NATSUME
1585ca189e Fix doc generation warnings
Fix the following warnings.

- A warning in config sample generation
- Warnings about nova-status.rst

Change-Id: Ifcc3b4a89eeea9d0dd62e2a8b560c5e6a9ff3d1a
Closes-Bug: #1659485
2017-02-24 17:43:08 +00:00
Jenkins
727375d5d4 Merge "Trivial-fix: replace "json" with "yaml" in policy README" 2017-01-31 19:10:46 +00:00
Mikhail Feoktistov
b1d575f2ad libvirt: ephemeral disk support for virtuozzo containers
For virtuozzo containers we create ephemeral disk based on ploop format.
After we create ploop disk, we should add 'read 'permission for all users.
It's necessary because openstack user query info of this disk by qemu-img.

Change-Id: I2d6dd043340322d4c4ac1efd38f993f08932a483
Implements: blueprint ephemeral-disk-ploop
2017-01-26 14:19:08 +03:00
liusheng
747bc611e3 Trivial-fix: replace "json" with "yaml" in policy README
Change-Id: I555eb6b68b27fe99a837e2297fa1aa681ae61ead
2017-01-25 11:25:53 +08:00
Dina Belova
ecc8de8d6c Integrate OSProfiler and Nova
* Add osprofiler wsgi middleware. This middleware is used for 2 things:
  1) It checks that person who want to trace is trusted and knows
     secret HMAC key.
  2) It starts tracing in case of proper trace headers
     and adds the first wsgi trace point with info about the HTTP request

* Add initialization of osprofiler on start of a service
  Currently that includes oslo.messaging notifier instance creation
  to send Ceilometer backend notifications.

oslo-spec: https://review.openstack.org/#/c/103825/
python-novaclient change: https://review.openstack.org/#/c/254699/
based on: https://review.openstack.org/#/c/105096/

Co-Authored-By: Boris Pavlovic <boris@pavlovic.me>
Co-Authored-By: Munoz, Obed N <obed.n.munoz@intel.com>
Co-Authored-By: Roman Podoliaka <rpodolyaka@mirantis.com>
Co-Authored-By: Tovin Seven <vinhnt@vn.fujitsu.com>

Implements: blueprint osprofiler-support-in-nova
Change-Id: I82d2badc8c1fcec27c3fce7c3c20e0f3b76414f1
2017-01-18 15:00:14 +07:00
Corentin Ardeois
706f104e33 Add CORS filter to versions pipeline
This patch exposes the root (version) resource to CORS-enabled
browser clients that wish to perform API version discovery.

This feature is required for js-openstack-lib, and its devstack
tests. https://review.openstack.org/#/c/370389/

Change-Id: I4052186bffa3bddb4d28e378e6a135694a71e05b
Needed-By: Ia19afa530ae8c2df60db740cec9267fe240978c0
2016-12-02 11:44:09 -05:00
Andrew Laski
d17a20d3d7 Remove the sample policy file
The sample file has been empty for a little while now since default
policies are registered in code. Shipping an empty file may be
confusing, so let's remove it. A README has been added explaining how to
generate an actual sample policy file.

Change-Id: I23c934d2b610a451d6ebbd4276721c455365cedc
Depends-On: I85a251376dfe38caa4b100861bf764014a98bc37
2016-09-29 14:41:39 -04:00
Brent Eagles
58de26288c Add bigswitch command to compute rootwrap filters
'ivs-ctl' is called from the libvirt vif driver. While the filter exists
in network.filters, as the command is still used by nova compute it is
consistent to include it in compute.filters.

Change-Id: Icf61dba632fee26461ac18246ecf6a93f6bde346
2016-09-02 14:01:38 -02:30
Matt Riedemann
a2219b8335 Remove nova.network namespace from nova-config-generator.conf
The nova.network options are all under nova/conf/* modules now.

Change-Id: I0e4aa64d0db9a12322bcd768b141ff3249bc3b4f
2016-07-28 18:14:12 -04:00
ChangBo Guo(gcb)
6af8d2c8e9 Remove deprecated config option volume_api_class
UpgradeImpact: Config option volume_api_class was deprecated in 13.0.0,
We can remove it in 14.0.0.

This commit also removes namespace 'nova' in file
nova-config-generator.conf.

Change-Id: I7841b016703a9cb5c0e783fe81a5cdcd7f4af9c5
2016-07-21 23:08:08 +08:00
Jenkins
aa1e6715db Merge "Add namespace oslo.db.concurrency in nova-config-generator.conf" 2016-07-13 04:27:42 +00:00
Jenkins
5a7e273901 Merge "Fix multipath iSCSI encrypted volume attach failure" 2016-07-05 22:37:06 +00:00
Claudiu Belu
7d01bceaa0 policy: clean-up
Registers in-code the last remaining policy rules.
Adds missing 'discoverable' rules. Without them,
the extension_info API can fail, as it tries to check the
os_compute_api:os_server_tags:discoverable rule. As it wasn't
previously registered, when listing the available extensions,
an exception of type PolicyNotRegistered is encountered.
In order to validate this, functional/api_sample_tests/test_extension_info.py
now runs without mocking policy.authorize.

Switches extension_info to context.can.
Switches nova.cells.filters to context.can.
Switches network.neutronv2.api to context.can.

Removes the rest of the entries in etc/policy.json.
Removes DefaultPolicyTestCase, as it tests the default
policy rule, which is not registered.
Removes rules from fake_policy.py that brings no value,
that are the same as the default values.
Removes extensions authorizer factories.
Removes nova.policy.enforce.

Change-Id: Ie7771768f4f3efe0edc787c12f297aa93d533d7e
Partially-Implements: bp policy-in-code
2016-06-30 19:56:14 +00:00
Jenkins
317f7d758c Merge "Add policy sample generation" 2016-06-29 14:32:04 +00:00
ChangBo Guo(gcb)
cf83eccec2 Add namespace oslo.db.concurrency in nova-config-generator.conf
Nova uses oslo_db.concurrency.TpoolDbapiWrapper in [1], and config
option use_tpool decides to use of thread pooling for all DB API
calls[2]. We should provide this config opitons to users.

[1]https://github.com/openstack/nova/blob/master/nova/db/api.py#L43
[2]https://github.com/openstack/oslo.db/blob/master/oslo_db/concurrency.py#L28

Change-Id: Ic596a4db39224b5bb676765b6bcb7ac09d3aaaf4
2016-06-29 17:16:31 +08:00
Andrew Laski
5e38fa3cb5 Add policy sample generation
This adds the entry point and config file necessary for using the
oslo.policy sample generation script. It also adds a tox target to
simplify the usage of it.

The command is also run in the docs tox target since the sample file
can be considered documentation.

Change-Id: I18a1fa567fc04b0e0a37c02f20024b2ce483f060
Partially-Implements: bp policy-in-code
2016-06-28 20:52:44 +00:00
Mikhail Feoktistov
d4aa455d53 libvirt: virtuozzo instance resize support
Adapt "nova resize" code to support Virtuozzo ploop disks.
As far as ploop disks are in fact directories we add '-r' argument
to all utilities that deal with instance' disks such as cp, rsync and scp.
Thus we copy disks universally whether they are folders or files.

Also using "prl_disk_tool" instead of "qemu-img" is better for ploop images
because it resizes guest filesystem as well.

We can't resize disks from guest OS in containers,
because they are not allowed to write directly to block device.
ploop tool can resize partition table and internal filesystem,
but only for container's disks. Such disks must have only one partition
with ext filesystem.

prl_disk_tool can resize disks with internal filesystems
and doesn't require any special layout so it can resize disks
for virtual machines.  So it's better to use this tool instead of ploop.

Also we make compute.filters more strict
We call "ploop" only with "restore-descriptor" argument
And we set disk size in megabytes for prl_disk_tool

Co-Authored-By: Dmitry Guryanov <dguryanov@parallels.com>
Depends-On: I04c4379459c2fc1fd4801ec2aad53d0f6053b6d6
Change-Id: I38dbf73beb01fe1939ddca63fbfedbec1dc3c826
Implements: blueprint virtuozzo-instance-resize-support
2016-06-28 22:13:49 +03:00
Jenkins
5f75130c94 Merge "libvirt: add nova volume driver for vzstorage" 2016-06-28 10:23:37 +00:00
Dmitry Guryanov
b71a594db6 libvirt: add nova volume driver for vzstorage
Driver for vzstorage cinder volumes. The driver mounts
vzstorage cluster and uses images, located on this mount
as volumes.

Snapshots of "in-use" volumes support:
https://review.openstack.org/#/c/276465/

Cinder part has been merged, here are the bluprint and review:
https://blueprints.launchpad.net/cinder/+spec/virtuozzo-cloud-storage-support
https://review.openstack.org/#/c/188869/

Blueprint: libvirt-vzstorage-volume-support

Change-Id: I6732fff3a5c40859781a017ef05046513685167f
Co-Authored-By: Evgeny Antyshev <eantyshev@virtuozzo.com>
2016-06-27 17:43:16 +00:00
Claudiu Belu
89a3cd86cc policy: Add defaults in code (part 6)
Partially-Implements: bp policy-in-code

Change-Id: I7c2dca52f5970ad9421bf5175fcbd963deac408f
2016-06-24 06:18:37 -04:00
Claudiu Belu
f6e81bf7ee policy: Add defaults in code (part 5)
Partially-Implements: bp policy-in-code

Change-Id: I3c400b774ce7fb5a59e6523cfbc9e3ba4d4730c1
2016-06-23 19:25:29 +00:00
Claudiu Belu
f13a933300 policy: Add defaults in code (part 4)
Partially-Implements: bp policy-in-code

Change-Id: I8ae24035ec6aee8fa93f3f55cbafc843d0e9d5ae
2016-06-23 19:25:06 +00:00
Claudiu Belu
ba242101e3 policy: Add defaults in code (part 3)
Partially-Implements: bp policy-in-code

Change-Id: I19e4d312b5c475b4b42d7f734cb6876c16378d28
2016-06-23 19:22:53 +00:00
Claudiu Belu
51b3fefaac policy: Add defaults in code (part 2)
Partially-Implements: bp policy-in-code

Change-Id: I09ba2381a9f365a163012f6bae495838ff11acbe
2016-06-23 12:10:03 -07:00
Claudiu Belu
eacdbc3d8e policy: Add defaults in code (part 1)
Adds default values for policy rules in code and removes
them from etc/policy.json file. The change is validated
by the nova.tests.unit.test_policy unit tests.

Adds default policy rules in policy_fixture. The policy_fixture
is currently loading an incomplete set of policy rules (from
policy.json or fake_policy), resulting in unit tests running
with an incomplete set of policy rules.

Co-Authored-By: Andrew Laski <andrew@lascii.com>

Partially-Implements: bp policy-in-code

Change-Id: I7a7dc2a111d536380a763169320a0820b0715a11
2016-06-23 19:53:29 +03:00
Sean Dague
525285eb1c remove os-disk-config part 4
There are no test changes as all new code is tested by the
extension_info functional tests, and should we want to eliminate the
extension_info portion of our API later, new tests would just make
this much harder to tear down.

This modifies default policy to drop os-disk-config as well as
modifying extension tests to pass even though we're injecting
additional hardcoded items into the list for compatibility.

Part of bp:api-no-more-extensions

Change-Id: I0192ccef7e858fd0ff15c339f683abaabbdc09b7
2016-06-22 07:36:33 -04:00
Andrew Laski
19f9a4bbd4 Policy-in-code servers rules
This adds the basic framework for registering and using default policy
rules. Rules should be defined and returned from a module in
nova/policies/, and then added to the list in nova/policies/__init__.py.

A new context.can() method has been added for policy enforcement of
registered rules. It has the same parameters as the enforce() method
currently being used.

To establish the full pattern for usage the policy checks in the servers
API module have been registered and converted to the new usage.

Now that some policy checks are registered they're being used properly
by tests. Some tests have been updated so that the instance project_id
matches the context project_id in order to pass the 'admin_or_owner'
check.

Change-Id: I71b3d1233255125cb280a000b990329f5b03fdfd
Partially-Implements: bp policy-in-code
2016-06-15 16:55:45 -04:00
Jenkins
c43e3f2454 Merge "Remove legacy v2 policy rules" 2016-06-09 10:32:04 +00:00
He Jie Xu
1fba0bc166 Remove legacy v2 policy rules
The legacy v2 API code was removed. The policy rules which are used by legacy
v2 API code are useless anymore. This patch cleanup them.

Partially implements blueprint remove-legacy-v2-api-code

Change-Id: I64648bf97ec483981426086b81b2056928fa1b3e
2016-06-08 17:57:29 -04:00
Sean Dague
11ed7bd39b set wrap_width for config generator to 80
pep8 is testing for 80 character lines. By force wrapping at 79 we get
weird edge conditions in our detailed help blocks of very odd wraps
with 80 character lines.

pep8 and conf generator should agree on this value.

Change-Id: I003964dfc46673bed3717862043d76bfb59ce217
Closes-Bug: #1587821
2016-06-02 10:42:32 -04:00
Tomoki Sekiyama
89a61ab8f4 Fix multipath iSCSI encrypted volume attach failure
Currently iSCSI volume attachment fails if iscsi_use_multipath is
set to True. This is because the encryptor requests cryptsetup
to create the symlink to the LUKS device with the same name of
the device-mapper multipath device. To avoid the name collision,
this patch adds the 'crypt-' prefix to the symlink.

Change-Id: I01a3104025a9c479e40933ca24024355df9dfb8b
Closes-Bug: #1439869
2016-06-02 17:53:47 +09:00
Juan Antonio Osorio Robles
6051f30a7e Add proxy middleware to application pipeline
Recently the http_proxy_to_wsgi middleware was added before the
versions resource; This correctly sets the URL scheme for keystone
version discovery, however, this is missing the URL schemes for
pagination URLs. So for this to work, the middleware needs to be
added to the application pipelines. Note that a similar commit
was done in cinder [1].

[1] If5aab9cc25a2e7c66a0bb13b5f7488a667b30309

Change-Id: I808469f24066d382decf55b9dad5312d6e068da7
Closes-Bug: #1573766
2016-05-30 08:12:20 +03:00
Ken'ichi Ohmichi
120d77e076 Remove APIRouter of legacy v2 API code
This patch removes the APIRouter because there is not any code
which uses the APIRouter. In addition, this patch update the
corresponding reno for explaining actual way for api-paste.ini.

Partially implements blueprint remove-legacy-v2-api-code

Change-Id: I136eb6ce7478f9ff692ebcbe1b14aa76222826bf
2016-05-25 14:33:50 +09:00
Juan Antonio Osorio Robles
b609a3b32e Add http_proxy_to_wsgi to api-paste
This sets up the HTTPProxyToWSGI middleware in front of Nova-API. The
purpose of thise middleware is to set up the request URL correctly in
case there is a proxy (For instance, a loadbalancer such as HAProxy)
in front of Nova.

So, for instance, when TLS connections are being terminated in the
proxy, and one tries to get the versions from the / resource of
Nova, one will notice that the protocol is incorrect; It will show
'http' instead of 'https'. So this middleware handles such cases.
Thus helping Keystone discovery work correctly.

The HTTPProxyToWSGI is off by default and needs to be enabled via a
configuration value.

Change-Id: Ia78f73e96585ab33a379a0b0be6d9682f7fbd810
Closes-Bug: #1573766
2016-05-23 08:08:14 +03:00
Jenkins
a1f74c7dba Merge "Config options: centralize cache options" 2016-05-17 20:00:58 +00:00