Commit Graph

59 Commits

Author SHA1 Message Date
Takashi Natsume 383e2a8bdc Remove six.text_type (1/2)
Replace six.text_type with str.
A subsequent patch will replace other six.text_type.

Change-Id: I23bb9e539d08f5c6202909054c2dd49b6c7a7a0e
Implements: blueprint six-removal
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
2020-12-13 11:25:31 +00:00
pandatt 2af89cfea0 Skip existing VMs when hosts apply force_config_drive
When hosts apply config `CONF.force_config_drive=True`, the existing
VMs shouldn't be enforced to must have config drive device. For they
may have been cloud-inited via metadata service, and may not need and
have any config drive device ever. In contrast, the newly being-built
ones should. Instance attr `launched_at` serves as an apparent flag
to distinguish the two kinds of VMs.

When hard reboots happend, existing VMs skip config drive enforcement,
and therefore avoid hitting 'No such file or directory (config drive
device)' error.

Change-Id: I0558ece92f8657c2f6294e07965c619eb7c8dfcf
Closes-Bug: #1827492
2019-05-22 21:02:16 +00:00
Michael Still 8ac2fe4b23 Convert configdrive to use processutils.
As per the other conversions, simply move over to calling
processutils directly instead of via our wrapper.

Change-Id: I61a9b249aae54999f460038e79db0f1f36237b13
blueprint: execs-ive-had-a-few
2018-05-02 21:42:05 +10:00
Michael Still fef1435167 Move makefs to privsep
Change-Id: I388d31d5e9c1cff10bc534ba69be899e67681ce6
blueprint: hurrah-for-privsep
2018-02-28 07:15:08 +11:00
Michael Still 7ad72b0922 Cleanup mount / umount and associated rmdir calls
Add a new filesytem mounting helper in privsep, and then start
moving things across to it. This currently implements mount and
unmount. We get to cleanup some rmdir calls while we're at it
which is nice as well.

I've added an upgrade note mentioning that we no longer ignore
the value of stderr from mount calls, as requesed in code review.

Change-Id: Ib5e585fa4bfb99617cd3ca983674114d323a3cce
blueprint: hurrah-for-privsep
2017-10-18 17:52:58 +11:00
Claudiu Belu 8e989bd9d5 Fixes python 3 unit tests
Fixes unit tests related to incomparable types.
Fixes unit tests related to writing / reading bytes in / from files
or response bodies.
Fixes console websocketproxy unit tests.
Fixes consoleauth unit tests.
Fixes db unit tests.
Fixes image unit tests.
Fixes virt/block_devices unit tests.
Fixes virt/configdrive unit tests.
Fixes virt_drivers unit tests.
Fixes xenapi agent, vmops and volume_utils unit tests.
Fixes wsgi unit tests.

Enables some python3 unit tests.

Partially Implements: blueprint goal-python35

Change-Id: Ie98e968740d1015eae3278edeb93d4ba08155169
2016-09-23 20:10:24 +00:00
Esra Celik eaeab5e935 Config options: centralize "configdrive" options
This change moves all of the configuration options previously defined in
nova/virt/configdrive.py to the new centralized nova/conf directory.

A subsequent patch will then improve the help texts.

Implements blueprint centralize-config-options-newton
Change-Id: Ic3a0f68cb1608ec9c379cf2b9419d5e681777d3f
2016-04-06 09:35:51 +03:00
Gary Kotton 9b28a8ee63 Config drive: convert to use instance.image_meta property
It is no longer neccessary to directly call the from_instance
class method on ImageMeta. Instead the instance.image_meta
property provides (read-only) access to image properties.

Change-Id: I3af39057127f58ad33ee70dff9ef37b7bf0e30a0
2016-01-17 02:01:23 -08:00
Zhihai Song f396c8e5fa Remove unused logging import and LOG global var
In some modules the global LOG is not used any more. And the import
of logging is not used. This patch removes the unused logging import
and LOG vars.

Change-Id: I28572c325f8c31ff38161010047bba00c5d5b833
2015-12-25 18:01:12 +08:00
Stephen Finucane 296479e1ab force_config_drive: StrOpt -> BoolOpt
The 'force_config_drive' option provides a way to force injection of
configuration drives on instances. Previously, this option supported
three values: 'always', 'True' and 'False'. However, the 'always'
value was deprecated in Liberty and can now be removed.

Remove this value and replace the existing 'StrOpt' with a 'BoolOpt'.
This also requires changing some unit tests to reflect the new value
for this parameter.

UpgradeImpact: This change removes support for the 'always' option.
    Configuration files providing this value will need to be updated
    accordingly.
DocImpact: This option is now a BoolOpt and documentation will need to
    be updated accordingly.
Change-Id: I0b4030ec1336fb1f2e721570c99a27a979e2847c
2015-11-11 19:59:22 +00:00
Gary Kotton 53c12143e9 Config drive: make use of an instance object
Use an instance object instead of a dictionary.

TrivialFix

Change-Id: I520a5f0607b0aad53db093a9ab5511520c06ac4c
2015-11-08 03:54:44 -08:00
Alessandro Pilotti 294e683b0e Revert "Fixes Python 3 str issue in ConfigDrive creation"
Reverting this patch due to issues with binary userdata.

This reverts commit 414243ace1.

Change-Id: Idf4048e064aa49423e45297f7a68168a2f5a7646
Closes-Bug: #1504235
2015-10-13 18:47:19 +03:00
Alessandro Pilotti 414243ace1 Fixes Python 3 str issue in ConfigDrive creation
ConfigDrive creation fails when writing metadata to file
due to a str to bytes conversion issue.

Change-Id: I4c086007543814a2f2ec3f7ccde9e8f9f2b5937f
Closes-Bug: #1502583
2015-10-04 14:28:05 +03:00
Daniel P. Berrange 3eea2a4492 objects: convert config drive to use ImageMeta object
The config drive code checks for a property 'img_config_drive'
in the instance system metadata. Add this property to the
ImageMetaProps object and convert the config drive code to
use the ImageMeta object for accessing it.

Change-Id: Id96af7e6f8429c58a8224c3d32c982a3af7d9cd7
2015-09-07 17:11:02 +01:00
Sergey Vilgelm 741f163fc5 Switch to the oslo_utils.fileutils
fileutils is graduated in the oslo.utils library.
Remove old implementation of the read_cached_file function
in the nova.utils and move from the fileutils the read_cached_file
and delete_cached_file functions to the nova.utils module and
the unit tests for these functions.

Implements: blueprint graduate-fileutils[1]
[1] https://blueprints.launchpad.net/oslo-incubator/+spec/graduate-fileutils

Depends-On: I51ba9076e1fbc16145ee2311f47b7768c16dcb20 (requirements)

Change-Id: I849f1c74ec811dbe82ba6270569a008a49eab465
2015-07-24 14:10:44 +03:00
Michael Still 47615815eb Revert "Add config drive support for Virtuozzo containers"
This reverts commit def785a23d.

As discussed at the nova liberty mid-cycle, we still have concerns about
how this was implemented. We've also talked through an alternative
implementation (generate the config drive to a directory and then just map
that directory into the container).

I will work on the changes needed on the config drive site to implement
that now, and will help the PCS guys integrate that with their code.

Change-Id: I7106e9bf367e0d392566cf5271ae52fc1595284e
2015-07-23 00:15:56 +10:00
Javeme 930da4406b Fix typos detected by toolkit misspellings.
* pip install misspellings
* git ls-files | grep -v locale | misspellings -f -

nova/tests/unit/objects/test_image_meta.py:98: existant -> "existent"
nova/virt/configdrive.py:161: similiar -> "similar"
nova/virt/configdrive.py:163: effeciency -> "efficiency"
nova/virt/libvirt/driver.py:567: targetted -> "targeted"

Change-Id: I611600b2000b2d26f6dcf61e0f1913b4ddfafaf7
2015-06-26 15:21:34 +08:00
Alexander Burluka def785a23d Add config drive support for Virtuozzo containers
With this change, we're defining new setup methodology
for container based virt (parallels now, and in future LXC too).
In such environments the *host* container technology will be
responsible for mounting the config drive image inside the guest
filesystem. So when the guest image boots, it will see the config
drive data immediately at the location defined by cloud-init.
The only demand for existing images is having cloud-init turned on.

To support config drive in Virtuozzo (former PCS) containers,
we use ploop block device. Actions with ploop device are performed
via ploop CLI tool and newly created device is mounted into
/var/lib/cloud/seed/config_drive on container's filesystem.
This destination recognised by cloud-init as a source of data.

(Ploop device description: https://openvz.org/Ploop)

Co-Authored-By: Maxim Nestratov <mnestratov@parallels.com>

Change-Id: Ib21ab954a08027fb1f2aec13c2d95b5f080eccce
Implements: blueprint config-drive-support-for-virtuozzo
2015-06-11 14:55:26 +03:00
Eric Brown ed9f1b8b43 Use oslo_config choices support
The oslo_config library supports the choices keyword argument. This commit
leverages the use of choices for StrOpts in Nova's configuration.

This change also adds 'ploop' as a valid value for the images_type option.
This was previously a valid value, but not documented.

Closes-Bug: #1423973

Change-Id: I4c0eb1366cc8a1b001fd403b67c3eec11f831541
2015-06-01 12:19:29 -07:00
Gary Kotton c7d77624b7 Compute: update config drive settings on instance
In the case the config drive setting are overridden by either
image properties or the configuration setting then these are updated
on the instance to actually reflect the running VM configuration.

The patch creates a common method for updating instance details
after spawn.

Change-Id: Ia5e36989a7b7543fa77c7c196919f8566e02d28a
Closes-bug: #1403889
2015-03-04 08:46:43 -08:00
Gary Kotton c12a78b35d Config driver: update help text for force_config_drive
The supported values are 'always', 'True' and 'False'. Update the
help text to support this.

DocImpact

UpgradeImpact

NOTE: the 'always' option will be deprecated in Liberty.

Change-Id: Ib3de8402addb4657f4f6ede35792aab0b1498ff8
Partial-bug: #1403889
2015-03-04 08:41:03 -08:00
Davanum Srinivas 97d63d8745 Use oslo.log
Convert the use of the incubated version of the log module
to the new oslo.log library.

Sync oslo-incubator modules to update their imports as well.

Co-Authored-By: Doug Hellmann <doug@doughellmann.com>
Change-Id: Ic4932e3f58191869c30bd07a010a6e9fdcb2a12c
2015-02-22 07:56:40 -05:00
Davanum Srinivas af2d6c9576 Switch to using oslo_* instead of oslo.*
The oslo team is recommending everyone to switch to the
non-namespaced versions of libraries. Updating the hacking
rule to include a check to prevent oslo.* import from
creeping back in.

This commit includes:
- using oslo_utils instead of oslo.utils
- using oslo_serialization instead of oslo.serialization
- using oslo_db instead of oslo.db
- using oslo_i18n instead of oslo.i18n
- using oslo_middleware instead of oslo.middleware
- using oslo_config instead of oslo.config
- using oslo_messaging instead of "from oslo import messaging"
- using oslo_vmware instead of oslo.vmware

Change-Id: I3e2eb147b321ce3e928817b62abcb7d023c5f13f
2015-02-06 06:03:10 -05:00
Mike Durnosvistov 76953c00c3 Replacement `_` on `_LW` in all LOG.warning part 4
oslo.i18n uses different marker functions to separate the
translatable messages into different catalogs, which the translation
teams can prioritize translating. For details, please refer to:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html#guidelines-for-use-in-openstack

There were not marker fuctions some places in directory network.
This commit makes changes:
* Add missing marker functions
* Use ',' instead of '%' while adding variables to log messages

Change-Id: I913077d3b0fdee78e423c35b3a48137a17946a7b
2014-12-04 13:43:38 +02:00
Gary Kotton 04b98c37cc Config drive: delete deprecated config var config_drive_tempdir
Commit 6e15d787ff removed the use
of this configuration variable.

Change-Id: Ifd5baa8b7d579b0959cdb57b1335380a4129d652
2014-11-09 07:05:19 -08:00
Davanum Srinivas 323fa6fef7 Use oslo.utils
oslo.utils library now provides the functionality previously in
oslo-incubator's excutils, importutils, network_utils, strutils
timeutils, units etc. Some modules already moved to oslo.utils
will still be around since other code in nova/openstack/common/
are using it and will be removed in a subsequent commit.

Change-Id: Idc716342535fdfa680963e0e073ddb46f5f1eb34
2014-10-06 21:41:17 -04:00
Yunhong Jiang 3cf563c3b2 Support image property for config drive
Currently Nova decides the config_drive based on user input and compute
node configuration. We should also consider the image requirement for
config drive.

Implements: blueprint config-drive-image-property

DocImpact:
    An new image metadata support added.

Change-Id: Ica32fb078d5440dbcf1251175585d34af9549815
2014-09-03 17:02:00 +00:00
Davanum Srinivas f3dc6eefe7 Fix and gate on H305 and H307
Both H305 and H307 are part of the OpenStack style guide.

Ensure that there are 3 groups of imports, stdlib,
third-party and project specific. Within each category
ensure that imports are in alphabetical order.

Change-Id: Id4994551c135c3c1a4982153f0c6cacba6176b95
2014-07-15 01:13:26 +00:00
Sean Dague 6e15d787ff ConfigDriveBuilder refactor for tempdir cleanliness
In looking to clean up excessive DEBUG logging, it became clear
that the logging in ConfigDriveBuilder was largely based on the
split logic that existed in doing fs opts in __init__ and then
also later in make_drive. This required a persistent tempdir, which
had to be manually cleaned up. It also meant a mandatory additional
config variable.

Refactor ConfigDriveBuilder to move all fs opts into make_drive,
deprecating the config variable in the process. In doing so, I don't
believe the previous debug logging is useful any more. However, in
case, add a __repr__ for ConfigDriveBuilder that will provide us with
a reasonable debug representation in case this becomes part of what
gets thrown.

Tests are now adjusted to not call private methods, but instead call
make_drive with config variable set.

Change-Id: I1aaf194fef00edd6eecf73b5bb9323e0e3a6f09f
2014-07-01 07:43:30 -04:00
Davanum Srinivas de92d65f29 Test force_config_drive as a boolean as last resort
The force_config_drive help clearly states that only possible option is
'always' but folks are setting it to 'True'/'False' etc and expecting
it to work. So let's enable that as well. In the worst case scenario
mentioned in the bug, it was set to 'False' and since the check for
force_config_drive took any string as true, we were enabling the flag
to true. With the change in this review, we force a conversion of the
string to true. Additional check for the flag to be set as 'always' is
treated as true as well. The test case checks for all the variations

Closes-Bug: #1319180
DocImpact

Change-Id: Ifa6348fa7dfd9de063eb13d30e3ddf94fa530b57
2014-06-17 07:52:28 +10:00
Gary Kotton cfd0846498 Don't translate debug level logs in nova.virt
Our translation policy
(https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls
for not translating debug level logs. This is to help prioritize log
translation. Furthermore translation has a performance overhead, even if
the log isn't used (since nova doesn't support lazy translation yet).

Change-Id: I524b48f530d8afd59a067074332e3964426e4d70
2014-06-08 00:36:49 -07:00
liu-sheng 74f953a1d7 Remove vi modelines
We don't need to have the vi modelines in each source file,
it can be set in a user's vimrc if required.

Also a check is added to hacking to detect if they are re-added.

Change-Id: I347307a5145b2760c69085b6ca850d6a9137ffc6
Closes-Bug: #1229324
2014-02-03 14:19:44 +00:00
Eric Guo 1a58ec19a3 Sync module units from oslo
Module units landed in Nova first, then was accepted by oslo with
minor changes. This patch removes nova specific unit module and
test, replaces with module units in oslo.

commit in Oslo:'Add unit constants' f9308560c36918cc

Change-Id: I6054c18a56f59d33a69f4714be19d34fbe9de335
Co-Authored-By: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@cloudwatt.com>
2014-01-21 23:55:55 +01:00
Alessandro Pilotti 1fc9eafab4 Fixes ConfigDrive bug on Windows
Files must be written specifying "wb" instead of "w"
to support binary files on both Windows and Linux.

Change-Id: I069845136df4a11b54c931a71575ca3efb9bc6d0
Closes-Bug: #1261585
2013-12-17 02:14:49 +02:00
Chang Bo Guo b823db7378 clean up numeric expressions with byte constants
Replace numeric expressions with constants in nova/virt
to make code more readable.

Implements: blueprint byte-unit-clean

Change-Id: I71aba00ac3c33931082cf0402e4b68764caa0212
2013-10-27 05:26:41 -07:00
Pádraig Brady 9304aabeb8 maint: remove redundant default=None for config options
These 73 instances were inconsistent and redundant.

Change-Id: I298f2406535d0805caebdca4f2729d720dd5222f
2013-08-09 02:05:04 +01:00
Alex Gaynor cd9d8e45c6 Remove the monkey patching of _ into the builtins
Previous _ was monkey patched into builtins whenever
certain modules were imported. This removes that and
simply imports it when it is needed.

Change-Id: I0af2c6d8a230e94440d655d13cab9107ac20d13c
2013-07-26 07:31:17 -07:00
Chris Behrens b013d80ff7 Remove broken config_drive image_href support.
image_href support has not been working since at least shortly before
Folsom release.  This is a good indication that this functionality is not
used.  As far as I can tell, the docs also do not match what was
supported.  An image ID was required, but docs show examples with full
hrefs.

DocImpact

http://docs.openstack.org/developer/nova/api_ext/ext_config_drive.html

References to supporting image_hrefs should be removed.

This patch also removes the hack that passed a config_drive_id via
the Instance dictionary when config_drive_id is not a valid Column for
Instance.

Fixes bug 1186401

Change-Id: Iced7bc8e278cb9f208183f1dbb7a293675a47eae
2013-06-26 21:04:07 +00:00
Zhongyue Luo ab1977af31 Replace functions in utils with oslo.fileutils
The following functions have moved to oslo.
remove_path_on_error
file_open
delete_if_exists

Replaced/removed overlapping functions with the ones in fileutils

Change-Id: I41a19d76a777b6f899843bb0cc0582630accbd5c
2013-06-11 13:28:29 +09:00
Dirk Mueller f3826902a0 Improve Python 3.x compatibility
A bit of mechanical translation to clean
out the deprecated except x,y: construct

Change-Id: I80883b6b0c014bdf4799e8b7b2c4a4a07d951a0b
2013-04-22 04:22:24 +02:00
Mark McLoughlin 706a137005 Use oslo-config-2013.1b4
The cfg API is now available via the oslo-config library, so switch to
it and remove the copied-and-pasted version.

Add the 2013.1b4 tarball to tools/pip-requires - this will be changed
to 'oslo-config>=2013.1' when oslo-config is published to pypi. This
will happen in time for grizzly final.

Add dependency_links to setup.py so that oslo-config can be installed
from the tarball URL specified in pip-requires.

Remove the 'deps = pep8==1.3.3' from tox.ini as it means all the other
deps get installed with easy_install which can't install oslo-config
from the URL.

Make tools/hacking.py include oslo in IMPORT_EXCEPTIONS like it already
does for paste. It turns out imp.find_module() doesn't correct handle
namespace packages.

Retain dummy cfg.py file until keystoneclient middleware has been
updated (I18c450174277c8e2d15ed93879da6cd92074c27a).

Change-Id: I4815aeb8a9341a31a250e920157f15ee15cfc5bc
2013-02-19 21:16:32 -08:00
Jenkins d0cfec26f4 Merge "Chown doesn't work on mounted vfat." 2013-01-14 22:28:01 +00:00
Michael Still 60b38f1c82 Chown doesn't work on mounted vfat.
As reported by a user. Resolves bug 1092560.

Change-Id: I44c847d5e7f3242ca46a7436bcbc6e519baa88fc
2013-01-13 17:40:20 +11:00
Michael Still 2f4616c2be Convert ConfigDriveHelper to being a context manager itself.
This is a little bit less awkward than the previous implementation,
and is based on a suggestion from Padraig Brady.

Change-Id: If8b09a41d21777a4bd56af16e1f7e02d61d1dd4e
2013-01-13 09:27:48 +11:00
Michael Still 39f80b8cc0 Adding configdrive to xenapi.
This version implements a configdrive v2 for xenapi as discussed
in the xenapi IRC meetings.

 - the config drive is now iso9660
 - the admin password is injected (if we know it)
 - vbd's are not reused
 - review comments have been addressed

Progresses blueprint xenapi-config-drive. DocImpact.

(Dear documentation people, if using config drive with xenapi,
the user should consider disabling the agent as well with
xenapi_disable_agent. This mostly depends on if they want to
support post-boot password updates still.)

Change-Id: Ib23d117ad4cd5dc92298a0812eb468f7d557417c
2013-01-11 17:43:56 +11:00
Michael Still 0edb7d4db9 Provide a configdrive helper which uses contextlib.
As suggested on review of Ib23d117ad4cd5dc92298a0812eb468f7d557417c.

Resolves bug 1092248.

Change-Id: I2829ac60732b86b9853983b03ef6f30f5c5a3283
2012-12-21 09:29:15 +11:00
Daniel P. Berrange 084ff0495d Make configdrive.py use version.product_string()
Instead of hardcoding 'OpenStack nova' for the publisher
when building ISO images, use version.product_string().
Also append the package version suffix, if any.

Change-Id: If3dfbf895ef7037e15dd3ff8da8f47daecb4d24a
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-12-19 18:54:33 +00:00
Michael Still e5b92d600c Catch ProcessExecutionError when building config drives.
There's not a lot we can do here, the instance is invalid. However,
the better log message will hopefully make this easier for operators
to diagnose.

Partially addresses bug 872489.

Change-Id: Ib650cb114e57956bfe911370dd52aa4fdd4adc78
2012-12-08 18:14:11 +11:00
Mark McLoughlin 94d87bce21 Remove nova.config.CONF
Modules import nova.config for two reasons right now - firstly, to
reference nova.config.CONF and, secondly, if they use one of the
options defined in nova.config.

Often modules import nova.openstack.common.cfg and nova.config
which is a bit pointless since they could just use cfg.CONF if
they just want to nova.config in order to reference CONF.

Let's just use cfg.CONF everywhere and we can explicitly state
where we actually require options defined in nova.config.

Change-Id: Ie4184a74e3e78c99658becb18dce1c2087e450bb
2012-11-20 00:00:21 +00:00
Mark McLoughlin 6e92a67fc3 Remove nova.flags
Now that options have all moved from nova.flags to nova.config, we can
safely remove the nova.flags imports and replace them with nova.config
imports.

Change-Id: Ic077a72dd6419bbf1e1babe71acfa43c4e8b55c8
2012-11-17 16:30:03 +00:00