Reassign MAC address for vm  when resize_revert

In the case of a resize or migrate on the same host, we need to assign
a temp mac address to the source LPAR so we don't have a conflict when
another LPAR is booted with the same mac address as the original LPAR.
We need reassign the original mac address, replacing the temp mac on
the old instance during revert resize. The new instance has been
destroyed before this method, so remove the precondition to make sure
original mac address be set.

Fixes bug #1196404

Change-Id: I709292a7725f0a21f04f1c3c79f2fafc4437e402
Fix power_state lookup in confirm_resize

Previously the compute manager's confirm_resize method was trying to get
the current power_state of the resized/migrated instance from the
hypervisor layer to account for a case where the user migrated from a
stopped instance and then powered it on via the hypervisor (below
openstack) to test it before confirming the migration.  This doesn't
work in the migrate case because the confirm_resize request is serviced
on the source compute node, and the instance no longer lives there so
_get_power_state results in an InstanceNotFound.  The vm_state would
then be set to ACTIVE even though the instance's power_state is still
SHUTDOWN.

This patch fixes this problem by just getting the instance power_state
from the database since the scenario of powering on the migrated
instance outside of openstack is not supported.

Fixes bug 1197514

Change-Id: If2ea83cd317aa8897b7b6bd6b43a2067e1074e33
Fix debug message for GroupAntiAffinityFilter

Fix bug 1198109

The log message in not accurate for GroupAntiAffinityFilter, it
should be fixed as "Group anti affinity"

Change-Id: Ib58c2934626c28349dd49bafd1b3e781fcbe9cb9
Replace get_instance_metadata call in api.ec2.cloud._format_instances

The _format_instances method in api.ec2.cloud populates an instance
dictionary from the sqlalchemy instance model objects, and populates the
metadata by calling compute.api.get_instance_metadata.

This is unnecessary, since the instance objects already have metadata
attached. The helper class is needed until the migration to nova objects
is complete.

Partially fixes bug #1192715

Change-Id: Ib5a593bd36c8d6a531b9494b9861cca9a40ed08a
Validate volume_size in block_device_mapping

Reject invalid values for volume_size upfront.
For compatibility with old python-novaclient, an
empty volume_size is ignored.

Create a common _validate_int_value() function for
validating that a parameter is an integer in a given
range. Use it also for min_count/max_count to share code.

Fixes LP Bug#1199539

Change-Id: I18ac285d5b3c8200d7706c7d577809b15d6ab9e8
Fix duplicate fping_path config option

This is causing an error in the config file tool generator. Just use
the config option in the original copy of this code.

Change-Id: I5e7c3069913eea11633f35273183c3c3b46f4969
xenapi: Stub out _add_torrent_url for Vhd tests

This will make the FetchVhdImageTestCasetest case play nicer when
a BitTorrent url plugin is installed and the tests are running with
no virtual environment.

Change-Id: I204f14246938981633989654bd3446ca3230c222
Sort output for unit tests in test_describe_tags before compare

There's no guarantees on what order the output from describe_tags
comes back in, so it needs to be sorted.

Partially fixes bug #1192715

Change-Id: Ibb2619e8077ea8b8bd4796f9ffe89c2376d047f6
Fix issue with pip installing oslo.config-1.2.0

Fixes bug #1194807

Firstly, we update the oslo.config dep to 1.2.0a3 because of the issue
with namespace packages (bug #1194742).

But the main issue here is that when we previously depended on 1.2.0a3
we found that if you did:

  $> pip install -r nova/requirements.txt

then you end up with the oslo.config 1.1.1 code installed. This is
because oslo.config>=1.1.0 gets pulled in as a transitive dep and pip
gets confused.

See I977700d73342e81ee962019b76238d2cb2b1fff4

You can reproduce with e.g.

  $> pip install \
       http://.../oslo.config-1.2.0a3.tar.gz#egg=oslo.config-1.2.0a3 \
       python-keystoneclient
  $> pip freeze | grep oslo.config
  oslo.config-1.2.0a3
  $> python -c 'from oslo.config.cfg import DeprecatedOpt'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  ImportError: cannot import name DeprecatedOpt

This is because of a bug with pip where it sees oslo.config-1.2.0a3 and
oslo.config as two unrelated things. It should strip the version part of
the egg= fragment before using it as a package name, but it doesn't.

However, we can simply use the -f/--find-links pip option in our
requirements.txt to add the tarball URL to the list of URLs considered
and also add the oslo.config>=1.2.0a3 dependency:

  $> pip install \
       -f http://.../oslo.config-1.2.0a3.tar.gz#egg=oslo.config-1.2.0a3 \
       'oslo.config>=1.2.0a3' \
       python-keystoneclient
  $> pip freeze | grep oslo.config
  oslo.config-1.2.0a3
  $> python -c 'from oslo.config.cfg import DeprecatedOpt'

This is actually exactly the semantics we want and we go to great
lengths in pbr to get these semantics while using a single tarball URL.
The only downside to this --find-links strategy is that we gain an extra
line in our requirements.txt ... but it does work around the pip bug.

Change-Id: I6f3eb5fd2c75615d9a1cae172aed859b36b27d4c
Allow ::/0 for IPv6 security group rules

Nova fails to create a security group rule if ::/0 is used as
value for the cidr field

Fixes: LP bug #1199943

Change-Id: Ifce53dbc9f0740337921491aa752900892f47052
Signed-off-by: Rosario Di Somma <rosario.disomma@dreamhost.com>
xenapi: enable attach volumes to non-running VM

Similar to when detaching a volume, ensure we only attempt to
plug a VBD when the server is running, otherwise it will fail.
This also fixes up the existing unit test that was not working.

Fixes bug 1199477
Change-Id: I32d85ca09849b63b815cc3daba3bb02c31d92e8d
xenapi: Add disk config value to xenstore.

To be able to access the value of disk_config from inside the VM,
added the value to xenstore.

Implements blueprint add-disk-config-to-xenstore
Change-Id: I21170252400ffc73f386dbd19aaa9f7a7613bd56
Fix extensions os-remote-consoles to follow API v3 rules

* Add extensions.expected_errors decorator
* Correct the action naming style
* Catch exception ConsoleTypeInvalid explicit

Partially implements bp v3-api-extension-versioning

Change-Id: Ie07751b2db72c43af23936e2e8c00ee3c861428a
Passing volume ID as id to InvalidBDMVolume exception

Passing volume ID as positional argument causes error
 when formatting exception message.

Fixes bug 1200584

Change-Id: Iac49c8b5c13d3807e8bb744151300418b121bd5c
Fix aggregate update.

Bug description: when update 'availability_zone'
value existing aggregate metadata cleared.

Method aggregate_update() in sqlalchemy api updated.

Fix bug 1200369.

Change-Id: Ie1dffa90b1e339b81883dc14037f7817f1cec15d
Remove unused recreate-db options from run_test.sh

run_tests.sh had an option to delete tests.sqlite, but that file is not
used anymore so the run_test options don't do anything.

Change-Id: I1abb257579da34c9dd7698543d8297268276bbc5
Unify duplicate code for powering on an instance

Moves duplicate code to a common method

Change-Id: I9809e654df8602c00a18cbb7be3a4cf4498b274b
Makes _PATH_CELL_SEP a public global variable

_PATH_CELL_SEP is used outside of cells.utils so it should be not be private

Change-Id: I0b06a223b50f7d90007bb44ec7897174ed836ad4
xenapi:populating hypervisor version in host state

This will be used in the scheduler to compare it to the image
properties.
Pulled out conversion of version string into integer to utils.
Partially implements blueprint xen-support-for-hypervisor-versions

Change-Id: Ib2eb91f6f18af6d39f9381daeff7ba9a24b4785a
Add missing tests for db.api.instance_* methods

Add missing and fixed existing tests.

Mostly replaced assertEqual(2, len(result)) by _assertEqualListOfInstances
and some other minor nits.

blueprint db-api-tests

Change-Id: Ia81dc1d75cbceb3ab882a02a66b3d9ce292816c1