302 Commits

Author SHA1 Message Date
lzyeval
13d6345c4f PEP8 type comparison cleanup
Fixes bug #910295

The None, True, and False values are singletons.

All variable *comparisons* to singletons should use 'is' or 'is not'.
All variable *evaluations* to boolean should use 'if' or 'if not'.

"== None", "== True", "== False", and "!= None" comparisons in sqlalchemy's
where(), or_(), filter(), and_(), and select() functions should not be changed.

Incorrect comparisons or evaluations in comments were not changed.

Change-Id: I087f0883bf115b5fe714ccfda86a794b9b2a87f7
2012-01-04 07:32:13 +08:00
Jenkins
9b272c22dd Merge "Adds running_deleted_instance_reaper task." 2012-01-03 19:00:14 +00:00
Rick Harris
9849ae53ef Adds running_deleted_instance_reaper task.
This adds a periodic task to cleanup erroneously running instances. The
impetus of the patch was a XenServer specific issue bug #911366, where deleted
instances would remain running on the host machine.

The patch however is hypervisor agnostic and is generally useful as a
housekeeping task to make sure these 'zombied' instances are detected.

Change-Id: Iddc6a88920a537a3a115f8b9bc0039ec0e24a194
2012-01-03 11:51:22 -06:00
lzyeval
66c9a8b02b PEP8 remove direct type comparisons
Fixes bug #910763

According to PEP8,
- Object type comparisons should always use isinstance() instead
      of comparing types directly.

        Yes: if isinstance(obj, int):

        No: if type(obj) is type(1):

      When checking if an object is a string, keep in mind that it might be a
      unicode string too! In Python 2.3, str and unicode have a common base
      class, basestring, so you can do:

        if isinstance(obj, basestring):

Change-Id: I7c0fdecf99872f5b8f72b2c2ed4f5c539c33def1
2012-01-03 11:12:42 +08:00
Jenkins
641f29d139 Merge "Ensure generated passwords meet minimum complexity" 2011-12-30 14:54:42 +00:00
Brian Waldon
8d08308478 Clean up pylint errors in top-level files
Change-Id: Ida7cf1ff0cbf94ad82c7a75708c79ad7bb27f7fd
2011-12-29 14:49:00 -05:00
Johannes Erdfelt
fb482b037f Ensure generated passwords meet minimum complexity
Windows has a complexity requirement of at least three of these
criteria:
- one or more upper case characters
- one or more lower case characters
- one or more numbers
- one or more special characters

In some cases, the passwords generated didn't meet three of these four
critera. This change enforces that three of these criteria will be
met in the generated passwords.

Change-Id: Ibe0055b8830b426aee1c9b722cc2fae2f5db4c5c
2011-12-29 19:38:24 +00:00
Joe Gordon
e5764f74c3 'except:' to 'except Exception:' as per HACKING
Change-Id: I6e372152946dc7b51a4d84d6f4b893774e7d1a1d
2011-12-27 12:07:06 -08:00
Pádraig Brady
0b8344f09f Bug#898257 abstract out disk image access methods
Rather than providing two mutually exlusive image
access methods (loop and qemu-nbd), try each in turn.
This is to prepare for a follow up patch which will
add libguestfs as a method to try.

* nova/virt/mount.py: A new Mount class to abstract the
devce allocation, partition mapping and file sys mounting,
for each access type.
* nova/virt/disk/loop.py: A specialization of the base Mount class
to provide loop back mounting support.
* nova/virt/disk/nbd.py: A specialization of the base Mount class
to provide qemu-nbd mounting support.
* nova/virt/disk/api.py: A new file containing the nova.virt.disk
module interface.
(img_handlers): A new list of access methods to try,
with the order being honored.
(_DiskImage): An internal helper class that uses the plugin classes
above, to provide the operations available on a disk image file.
When mounting, iterate over each access method until one succeeds.
If a hint is provided about a CoW format image, the list of
methods to try will be reduced accordingly.
Note expected errors are no longer raised as exceptions during mounting.
Instead, on failure to mount an image, errors are collated and raised.
Interveining errors are logged in debug mode for successful mounts.
* nova/virt/libvirt/connection.py: Adjust the function parameter
names to be more general, rather than referencing specific
implementations like 'nbd' and 'tune2fs'.
Simplify the destroy_container() by storing and passing
back a reference to the _DiskImage object, which has the
necessary state to unmount.
* nova/utils.py (trycmd): A helper function to both deal with,
commands that issue ignorable warnings to stderr,
and commands that EXIT_SUCCESS while issuing errors to stderr.
nova/virt/xenapi/vm_utils.py: Adjust for the moved virt.disk package

Change-Id: If3a4b1c8f4e2f2e7300a21071340dcc839cb36d7
2011-12-22 11:50:52 +00:00
Russell Bryant
ca9169a3d3 Make UUID format checking more correct.
This patch uses the same logic from glance to verify if a UUID is
properly formed.  It just tries to build a uuid.UUID from the string.
A test case has been added which previously would have failed, but now
passes.

A second test case has been added that verifies that the result of the
gen_uuid() function is considered valid, as well.

Change-Id: I33fe37b23ef03eda0f0e9d69afb601ca260aabde
2011-12-20 10:24:05 -05:00
Russell Bryant
534fdc3c53 Document return type from utils.execute().
Change-Id: Id0bc0dff09a809fe3999c4ec5014ac40ccfd8d6d
2011-12-19 14:37:46 -05:00
Alvaro Lopez Garcia
0e17b30765 Fixes bug 723235
The XML templates have been converted into properties, thus we can
compare the mtime of the XML templates (libvirt and cpuinfo) each
time they are needed, checking if they have been modified and
reloading them. Added a function to read cached files.

Change-Id: I6cf0229c6435300e73f9d9a6b10b0bf9bf144a55
2011-12-15 18:09:21 +01:00
Dan Prince
cc0a78d0f8 Update utils.execute so that check_exit_code handles booleans.
Fixes LP bug #904560.

Change-Id: I5d09b65dade166763981dc6b248034d86ba217f1
2011-12-15 08:08:42 -05:00
Dean Troyer
363b61098d Fixes bug 887402
Change utils.execute to accept a list or a single integer in
check_exit_code.

In libvirt.disconnect_volume() return codes 0 and 255 are both valid
for logout/delete, where 255 is returned if the volume is already
disconnected.

Change-Id: Icffeb0fe8269a02d95ac6ed180ba0bb9f458a6ed
2011-12-14 18:46:24 -06:00
Vishvananda Ishaya
a5b3c3fc79 Moves find config to utils because it is useful
This is to prepare for a future patch will will use find
config to load other config files.

Change-Id: Ic9bd9027baf518734c3f51f516651b80d1e752f2
2011-12-10 14:01:17 -08:00
Soren Hansen
5f7b125d8b Log it when we get a lock
Currently, we log it when we attempt to acquire a log, but we don't
mention it when we succesfully do acquire it. This makes people think
it's stuck.

This patch logs the succesful acquiry of locks.

Change-Id: I3b49ff331641ceafa46c93d8f5233c85fe45e5e2
2011-12-09 14:57:47 +01:00
Joe Gordon
bab97677e4 remove duplicate netaddr in nova/utils
Change-Id: Ib9b7ddc619ce62010b5661579fe32cc55b68f7e6
2011-12-05 17:10:08 -08:00
Brian Lamar
c9ac362488 Follow hostname RFCs
Updated hostname sanitization method to more closely follow RFC-952
and RFC-1123. Also moved it to nova.utils, where it seems to fit
better.

Fixes bug 885374

(Patch Set 1) Updated hostname sanitization with more efficient and
              [opinion] more readable implementation.

Change-Id: I60d7ee89867c05950bec1fd53b072a1c6247ebea
2011-11-15 17:36:02 -05:00
Josh Kearney
557354a465 Log the URL to an image_ref and not just the ID.
Change-Id: Iaae6b969d9ef3cd0f50dd3297d4b0bb51f61f5c9
2011-11-14 15:30:23 -06:00
Ahmad Hassan
360d424194 Verify security group parameters
Introduced various sanity checks before adding security group rule
into the database. The checks have been implemented both in EC2 and
openstack extension code.
Implemented the suggestions made in first patch by Brian
Fixed the unit tests in security groups
Fixed pep8 issues in security group unit tests

Fixes bug 869979.

Change-Id: I2ac28666e90e7bdeacb7b1c2676c0719cfb9e441
2011-11-11 09:46:15 +00:00
Joe Gordon
b3536ff8d7 More spelling fixes inside of nova
Change-Id: I79daf7519c99cc363ac7175c85912298f273da8a
2011-11-09 19:57:44 -08:00
Aaron Lee
085ea1bcac Refactor logging_error into utils
update: pep8, and fixing log output.
update2: more pep8, I'm looking at you vim
update3: more formating
update4: mailmap
update5: more pep8

Change-Id: I38617e14260e65ed5cb81b3554479d3720850aae
2011-11-09 11:49:52 -06:00
Jenkins
26f8c83113 Merge "Log original dropped exception when a new exception occurs" 2011-11-03 17:28:43 +00:00
Matt Dietz
2774d7f252 Fixes lp883279
Nova sending instance_id in notifications instead of uuids

Change-Id: I411ea1a9aee53af4ee8cb4b1118dc41549c80227
2011-10-31 11:44:04 -05:00
Johannes Erdfelt
0ec6377092 Log original dropped exception when a new exception occurs
If a exception is caught while processing a previous exception, make sure
to log it so it doesn't silently get discarded

Change-Id: Ic887db9c2592229970737daf5dd9732b2258877b
2011-10-31 16:42:47 +00:00
David Subiros
a09755f599 Improve the liveness checking for services
With this modification both nova-manage and scheduler use the flag
service_down_time and check positive and negative values in a
correct way.
Fixes bug: 867674.

Change-Id: I15c48d80cafa2089cd228c09c61b0a1e513730e8
2011-10-21 13:32:01 +01:00
Rick Harris
d554f915f3 Repartition and resize disk when marked as managed.
Implements part of the instance-disk-management blueprint.

Change-Id: I16d0f816cdf82ee1e19a323cb9976477924e4c5c
2011-10-19 11:45:42 -05:00
Jenkins
471b7d8e8b Merge "Xenapi driver can now generate swap from instance_type" 2011-10-14 18:54:09 +00:00
Rick Harris
1115ecacee Xenapi driver can now generate swap from instance_type
Change-Id: I50268a85ccd62b019436a207c2b52b1901597564
2011-10-13 18:46:38 -05:00
Monsyne Dragon
831a60e88b Adds more usage data to Nova's usage notifications.
Adds in bandwidth, state and IP data on standard notifications,
and new notifications on add/remove IP.

These were missing before, and are needed to meet spec.
This fixes bug 849117

Change-Id: Ie586ff3a91a56e5f5eff8abc6905ba6a0b624451
2011-10-12 19:11:14 +00:00
Julien Danjou
e632f76e96 Include original exception in ClassNotFound exception
By doing this, we allow the error messages to be more useful. When an import
of a class fails because of a missing module dependency, it would have fail
that way for example:

$ nova-manage
Traceback (most recent call last):
  File "./bin/nova-manage", line 84, in <module>
    from nova import image
  File "/home/jd/Work/src/nova/nova/image/__init__.py", line 22, in <module>
    from nova.image import glance
  File "/home/jd/Work/src/nova/nova/image/glance.py", line 42, in <module>
    GlanceClient = utils.import_class('glance.client.Client')
  File "/home/jd/Work/src/nova/nova/utils.py", line 66, in import_class
    raise exception.ClassNotFound(class_name=class_str)
nova.exception.ClassNotFound: Class Client could not be found

This does not help the user, since it indicates the class Client cannot be
found, even if it is actually found but fail to import.

With this commit, the error message is better:
nova-manage
Traceback (most recent call last):
  File "./bin/nova-manage", line 84, in <module>
    from nova import image
  File "/home/jd/Work/src/nova/nova/image/__init__.py", line 22, in <module>
    from nova.image import glance
  File "/home/jd/Work/src/nova/nova/image/glance.py", line 42, in <module>
    GlanceClient = utils.import_class('glance.client.Client')
  File "/home/jd/Work/src/nova/nova/utils.py", line 66, in import_class
    raise exception.ClassNotFound(class_name=class_str, exception=exc)
nova.exception.ClassNotFound: Class Client could not be found: No module named kombu.connection

This helps to know that in this kombu is missing.

It would probably even better to rename ClassNotFound to
ClassCannotBeImported or something like that too.

Change-Id: I4100d931a0a825fa0729d5467d2f9268fdd2a261
Signed-off-by: Julien Danjou <julien.danjou@enovance.com>
2011-10-10 09:55:37 +02:00
Rick Harris
7f33611c19 Fixing tests 2011-09-21 15:59:40 -05:00
Josh Kearney
466c5ad651 Fixed unit tests with some minor refactoring. 2011-09-20 15:21:06 -05:00
Rick Harris
49c012d233 Adding progress 2011-09-14 23:11:03 +00:00
Tushar Patil
b2b69a423b Fixed review comments 2011-09-02 11:00:33 -07:00
Tushar Patil
8409af0f95 Fix for LP Bug #838251 2011-08-31 17:06:15 -07:00
Nachi Ueno
71e19faa0c Removed blank line 2011-08-23 08:51:44 -07:00
Nachi Ueno
0ea7bdf78b Merged with trunk 2011-08-23 08:46:55 -07:00
Nachi Ueno
6a7075b6d8 Fixed typo and docstring and example class name 2011-08-23 08:07:25 -07:00
Tushar Patil
ea0635f407 Merged from trunk,resolved conflicts and fixed broken unit tests due to changes in the extensions which now include ProjectMapper 2011-08-22 16:35:09 -07:00
Nachi Ueno
6d2f8203bf Fixed conflict with branch 2011-08-22 14:45:18 -07:00
Nachi Ueno
808ed1e6ed Added Test Code, doc string, and fixed pip-requiresw 2011-08-22 14:24:37 -07:00
William Wolf
3ea4a282d4 merge with trunk 2011-08-22 08:28:12 -04:00
Nachi Ueno
43d47f5a9f Fixed typo 2011-08-19 14:22:53 -07:00
Nachi Ueno
ac59605d2e Merged with trunkw 2011-08-19 13:25:49 -07:00
Nachi Ueno
82a1346485 Added monkey patching notification code function
w
2011-08-19 12:30:55 -07:00
Tushar Patil
e2a242fd55 Merged from trunk 2011-08-19 10:08:46 -07:00
Sandy Walsh
3c959d8890 Fixes primitive with builtins, modules, etc 2011-08-19 10:01:25 -07:00
William Wolf
2ea0693903 merge with trunk 2011-08-19 09:54:05 -04:00
Vishvananda Ishaya
f3af277911 Make all services use the same launching strategy 2011-08-17 16:25:53 -07:00