translates empty remote_ip_prefix to valid cidr for nova

Quantum allows empty remote_ip_prefix to mean "any host"
but Nova uses a CIDR as part of each rule.

Fixes bug 1180828

Change-Id: I4983515ccd0cc621491d63e59d6ab6ac4dd74b6a
Fix _drop_unique_constraint_in_sqlite() function.

We got incorrect unique constrains in function
_drop_unique_constraint_in_sqlite().
New function `_get_unique_constraints_in_sqlite()` was added to fix it.

Change-Id: Iebb4c0e6c3e6a069ba5cde2fdb2a2ff1200b826f
Fixes: bug 1184526
Removed session from reservation_create()

Removed session objects from public reservation_create() function
in nova/db/sqlalchemy/api module. Minor code refactoring.

blueprint db-session-cleanup

Change-Id: Ib87dd407328b0208a92a7e50bf4117e85fc512fb
Fix VMwareVCdriver reporting incorrect stats

fix bug #1180779

VMware nova compute drivers VMwareESXDriver and VMwareVCDriver
currently report stats for the column local_gb in MB instead of in GB
The fix would be to modify vmwareapi/host.py to ensure the values
reported for disk space are calculated in GB instead of MB.
Fix is done by further dividing the existing MB value by 1024 to
convert to GB.
The unit tests to check for capacity and freespace have been modified
to check for GB.

Change-Id: I0610047ee2bddefe0ccb46568c0f48de4c0941af
hardcode pbr and d2to1 versions

Hard code pbr to d2to1 to >=0.2.10,<0.3 and
pbr to >=0.5,<0.6 for consistency across projects.

Change-Id: I7163bef37934856e5f80df336044f8ebcb690797
Signed-off-by: Chuck Short <chuck.short@canonical.com>
Refactor libvirt driver exception handling

Centralize exception handling for id based instance lookups in new
method _lookup_by_id().

Change-Id: If8d215b85fabf235afcf78a9203378fbb26e68db
Fix quota checks while resizing up by admin

Fixes LP 1184594

Fixing a bug when admin issues a resize up for a user, it checks for
admin's quota instead of user's quota.

Change-Id: Ida5db9039396df0a08c699711b72882e2ef136f8
Don't snat all traffic when force_snat_range set

When using /proc/sys/net/bridge/bridge-nf-call-iptables=1, bridged
traffic gets snatted even though it is being bridged out to an
external gateway. This can lead to asymmetric routes where traffic
goes out the fixed network and comes back on the float network
and can lead to packets being blocked by firewalls. Work around
this problem by only fallback snatting when the traffic is
going to one of the force_snat_ranges. If force_snat_range is not
set it defaults to the existing behavior of snatting all traffic
that doesn't hit an earlier rule.

Fixes bug 1182143

Change-Id: If496dad2308a68a6a4a9fd43d695943bc5034ac4
Some libvirt driver lookups lacks proper exception handling

Add error handling to list_instance_uuids() and get_memory_mb_used().
While fixing list_instance_uuids, this change also removes an
unnecessary extra lookup for every running instance.

Improve test coverage for list_instances() and list_instance_uuids().

Change-Id: I0cabe5f38d19143a3eb7b2ebce1ea6ea63f36929
Register libvirt driver with closed connection callback

libvirt v1.0.1 and later support a callback to alert clients
when the connection is lost.  The libvirt driver will now
register for this callback when available so that the driver
can properly reconnect.

Fixes: bug #1154635
Change-Id: Ie5f1b69cf6f0655022148386cd2be9955d37b467
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
Fix to disallow server name with all blank spaces

* Nova CLI allows server name to be created with all blank characters.
  This fix will disallow a server name with all blank spaces during
  server/instance creation as well as while updating/renaming a server
* Adding unit tests to test the above scenarios (create & rename
  server with blank spaces)

Fixes bug 1175956

Change-Id: I58af207c4a6b8579bb172d4bb612e0aa2aa6b498
Remove redundant architecture property update in powervm snapshot

During an instance snapshot if the architecture property is defined
in the image it is updated twice in the snapshot image.
The snapshot is created with the metadata values from the
"instance_system_metadata" table and then, if defined, the architecture
property is updated from the value in the base image in that moment.

There is no reason to treat this property differently from others.
Also, it didn't respect the "non_inheritable_image_properties" option.

This change removes the special behavior for the architecture property
in the powervm driver during a snapshot.

Fixes bug 1189969

Change-Id: I05ebcaef7b75387827917b5b223868794d98e0aa
Remove explicit distribute depend.

Causes issues with the recent re-merge with setuptools. Advice from
upstream is to stop doing explicit depends.

Change-Id: Ib2c68618368c766e7444e45074bddb01b29752d3
Remove unused db api call.

There is unused db api call in NetworkManager
setup_networks_on_host() method, results from
this call not used, no specific exception raised,
this patch just remove it.

Change-Id: Icf898dcdda635a3a78c92e76ec0e19c6ab075ce1
update_dns() method optimization.

update_dns() method in NetworkManager rewrited,
in new version used only one db api call.

Change-Id: Ib56c642d53e7a80439875bc304c4874d6ef4dcca
Quantum API _get_floating_ip_by_address mismatch with Nova-Net

_get_floating_ip_by_address() has a unspecified behavior when
IP address is empty and only one floating IP is allocated in
the pool. It should return a 404 Not found like Nova-Net does
but instead returns the only IP in the pool.

Fix bug #1190242

Change-Id: Id4843edda8e66ccabab5e9d053c595a1cd247770
Naming instance directory by uuid in VMware Hyper.

Like Libvirt Hyper, Using EC2 template for naming instance
directory may cause conflict. we follow what Libvirt does to use
instance uuid instead of EC2 template naming. To keep backwards
compability, when fails to find a instance by uuid, fall back to use
EC2 name.

Fix bug #1186944

Change-Id: Iaba099225a9b3b0390cae4c5fbd82d7e6c11f0e0
Allow confirm_resize if instance is in 'deleting' status

Deleting an instance puts it into 'deleting' task_state.
If the instance is in 'resized' vm_status, this tries a
confirm_resize on the instance. confirm_resize currently expects
the task_state to be None. It should instead expect
None/deleting task_state.

Fixes bug: 1189391

Change-Id: I6a3f82eab9ed2242bfd38bc1ac760dbb4b3d8c4a
Fix VMware Hyper can't honor hw_vif_model image property.

Support setting instance vif model through image property,
change default vif model to e1000. Available vif model options
for VMware Hyperv is "VirtualE1000, VirtualPCNet32, VirtualVmxnet".

DocImpact
Fix bug #1183192

Change-Id: I3a98bc26df7e2252bf043a71acbba2a158e213b8