Fix upper bound checking for flavor create parameters

Fix flavor-create upper bound checking so it uses platform-independent
32-bit max signed integer value instead of sys.maxint, which causes
problems on 64-bit platforms.  The DB int type is a 32-bit signed
integer, regardless of platform.

Change-Id: I82624121a45f6385d3ea9ae9c032109834584fac
Closes-bug: 1278939
Ensure parent dir exists while injecting files

Currently, if we inject a file to a not existing path,
the injecting will be failed with error 'No such file
or directory'.
Nova will firstly execute `mkdir -p` in folsom before injecting,
but this operation is lost from commit
72918415f2b6a241d6097a563aba55a849936591

This patch fix this bug by adding the `mkdir -p` operation as folsom.

Closes-bug: #1272829

Change-Id: If33a79c538e07cb25300db64ac7a9dee3d3b19c2
Removing redundant validation for rebuild request.

Any method decorated with wsgi.action will need to have
the said key, in this case 'rebuild', before it
reaches the relevant code block. If not, a key
error is raised when the wsgi.action code kicks in. This
code is at openstack/wsgi.py in the  _process_stack
method and subsequently the self.get_method method.
A KeyError is raised and caught. Removing the redundant
check for rebuild api.

Change-Id: I4baf920c7e1b3d51a91323f12d0802cedec77fe2
Remove and recreate interface if already exists

If a nova-compute machine restarts when openvswitch comes up it logs the
following warning messages for all tap interfaces that do not exist:

bridge|WARN|could not open network device tap2cf7dbad-9d (No such device)

Once the compute-node starts it recreates the interfaces and re-adds them
to the ovs-bridge. Unfortunately, ovs does not reinitialize the interfaces
as they are already in ovsdb and does not assign them a ofport number.

This situation corrects itself though the next time a port is added to the
ovs-bridge which is why no one has probably noticed this issue till now.

In order to correct this we should first remove interface that exist and
then readd them.

Change-Id: I1dc01604c5857941d9f35eb1e0c4d5103a56d57b
Closes-bug: #1270973
Related-bug: #1268762
xenapi: make session calls more discoverable

Its currently hard to discover what existing calls there are to
XenAPI, and the *_utils.py are getting very large.

Also, with the move to mock, it is becoming hard work testing multiple
calls to call_xenapi within a single method. Moving to this more object
oriented way of calling XenAPI should make writing tests with mock much
easier, and give us an obvious place to move some of simpler helper
methods in vm_utils and volume_utils.

This is the very first step in this direction. Dependent patches will
show how this can be used.

Part of blueprint xenapi-driver-refactor
Change-Id: I021fbedf2e84d58f24a3d9cb8fab0b906125f7c1
Refactor pool.py to remove calls to call_xenapi

In addition adding the Pool XenAPI object that is needed by pool.py

Change-Id: I1b417c469bbb2542a3fde40064142bde2b4dd400
When a claim is rejected, explain why

Previously, the Claim class offered #test which would return a Boolean
based on availability of memory, disk, CPU and PCI devices.

Now these tests are performed from the constructor and if any test
fails, an exception is thrown. All failure reasons are described in the
exception message. EG:

  "Insufficient compute resources: Free memory 8192.00 MB <
  requested 16384 MB; Free disk 45.00 GB < requested 50 GB; Free CPUs
  16.00 VCPUs < requested 17 VCPUs."

Change-Id: I5bf9c81bba747a6c164144e60a92dc6da2f98f4c
Closes-Bug: #1212768
Merge "Remove and recreate interface if already exists"
Merge "Fix upper bound checking for flavor create parameters"
Merge "Ensure parent dir exists while injecting files"
Merge "Removing redundant validation for rebuild request."
Merge "xenapi: make session calls more discoverable"
Merge "Refactor pool.py to remove calls to call_xenapi"
Merge "When a claim is rejected, explain why"