Commit graph

659 commits

Author SHA1 Message Date
kirby@puppetlabs.com
c750657c6f Update find_least_used_compatible_host to specify pool
This commit updates find_least_used_compatible_host method to specify
the pool name when evaluating a VM for migration. Without this change VM
migration fails with a wrong number of arguments error. Pool_manager
test references are updated to reflect the change.
2017-06-28 08:01:47 -07:00
Rob Braden
e5d2844fcc Merge pull request #223 from glennsarti/pooler-83-specify-datacenter
(POOLER-83) Add ability to specify a datacenter for vsphere
2017-06-27 15:16:27 -07:00
Samuel
5355d1cf03 Add find_folder method details
Specifically that the 3rd argument datacentername supports a 'nil' value, in which case the first datacenter is returned.
2017-06-20 15:48:30 -07:00
Glenn Sarti
7077eadc65 (POOLER-83) Add ability to specify a datacenter for vsphere
Previously the vsphere provider assumed that there was one and only one
datacenter (DC) in the vsphere instance.  However this is simply not true for
many vSphere installations.  This commit:
- Adds the ability to define a vSphere datacenter at the Pool or Provider level
  whereby the Pool setting takes precedence
- If no datacenter is specified the default behaviour of picking the first DC
  in the vSphere instance
- Updated all tests for the new setting
- Update the vmpooler configuration file example with relevant setting name
  and expected behaviour
- Fixed a bug in the rvmomi_helper whereby if no DC was found it would return
  all DCs.  This is opposite behaviour of the real RBVMOMI library as it returns
  nil
2017-06-20 15:48:30 -07:00
Rob Braden
58b580d3eb Merge pull request #225 from glennsarti/add-dev-doco
(maint) Update development documentation
2017-06-20 15:12:22 -07:00
Rob Braden
cfc1b61f0e Merge pull request #224 from glennsarti/gh-213-remove-underscore-connection
(GH-213) Remove use of private _connection method
2017-06-20 15:11:02 -07:00
Rob Braden
b54b248d75 Merge pull request #221 from puppetlabs/sam-suppert-multiple-providers
Adding support for multiple vsphere providers
2017-06-20 15:08:32 -07:00
Glenn Sarti
11dd15c7a8 (maint) Update development documentation
This commit adds documentation for how to setup a development environment for
VM Pooler.  This commit also moves the API under the new docs directory and
modifies the README appropriately.
2017-06-20 09:24:52 -07:00
Samuel
c0913ed7c7 Merge pull request #222 from puppetlabs/docker-in-vagrant
Added Vagrant setup and fixed the Dockerfile so it actually works
2017-06-20 14:45:16 +01:00
Glenn Sarti
3a4df791ff (GH-213) Remove use of private _connection method
Previosuly in find_vmdks in vsphere_helper it uses the call
vmdk_datastore._connection to get the underlying connection, however this is
already available as function parameter.  This commit removes this bad code and
the associated test fixtures.
2017-06-15 15:01:08 -07:00
Rob Braden
ee3f5e2215 Merge pull request #220 from puppetlabs/refactor-get_cluster_host_utilization
Refactor get_cluster_host_utilization method
2017-06-13 15:17:29 -07:00
a7274f3869
Updated README with Vagrant info 2017-06-12 15:21:16 -07:00
fdf5f5beb0
Added a Vagrant file that is caplable of running vmpooler in Docker or locally 2017-06-12 15:18:58 -07:00
fb1847f538
added sample usage of the dummy provider 2017-06-12 13:28:24 -07:00
dea5c4e962
Updated Dockerfile
Set to use a newer JRuby
Added an environment variable for the log file location
Changed entrypoint to cmd to add flexibility
Added missing trailing slash to copy command path
2017-06-12 13:27:36 -07:00
Samuel Beaulieu
d93ab332f7 Adding support for multiple vsphere providers
Refactoring the vmpooler.yaml format to support multiple providers.
The second level key under :providers: is a unique key name that
represents a provider that can be refered in the pool's parameter
called provider. The code is still backward compatible to support
the :vsphere: and :dummy: keys but in reality if you have more than
one vsphere configuration you would give them a different name. For
example :vsphere-pdx: and :vsphere-bfs: and the actual provider
class would be specified as a parameter called 'provider_class'.
See tests and examples for more information.
2017-06-09 21:44:03 +01:00
Samuel Beaulieu
87056a731c Fix test to raise expected error 2017-06-07 17:20:11 +01:00
Samuel Beaulieu
26d6cb28d9 Refactor the get_cluster_host_utilization method
The same method logic was being used in two places but only one was calling the method
get_cluster_host_utilization, so this refactors it to use the method for both.
The method could also return an empty array and the subsequent line would try
to .sort[0][1] which would return undefined method [] for nil:NilClass in that
case. The return value is now checked and an exception raised
2017-06-07 17:04:59 +01:00
mattkirby
1fcb19bd7b Merge pull request #216 from glennsarti/ticket/master/POOLER-70-add-providers
(POOLER-72)(POOLER-70)(POOLER-52) Move Pool Manager to use the VM Provider
2017-05-17 14:08:14 -07:00
Glenn Sarti
85b0f035aa (POOLER-52) Add recovery to vSphere connections
The generic connection pooler is only responsible for managing the connection
objects, however the providers themselves are responsible for ensuring that the
connection is alive/healthy etc.  Previously, the older vSphere helper would
reconnect however this was lost when the connection pooler was introduced.  This
commit adds a method that checks the connection before use, and then reconnects
if the connection is in a bad state.
2017-05-17 13:52:28 -07:00
Glenn Sarti
df783f0ed0 (POOLER-52) Use a Connection Pooler for vSphere connections
Previously the vSphere Provider would share a single vSphere connection for all
pools under management.  This would cause issues in large environments as this
would cause errors to be thrown or operations to slow down.  This commit
modifies the vSphere Provider to use a connection pool when communicating with
the vSphere API
- Uses the GenericConnectionPool object to manage the connection pool
- Uses a default connection pool size of:
	Whatever is biggest from:
	- How many pools this provider services
	- Maximum number of cloning tasks allowed
	- Need at least 2 connections so that a pool can have inventory functions
	  performed while cloning etc.
- A large connection_pool_timeout is used as a connection object is consumed
  during a VM clone, which can take up to 2 minutes
- Removes the `get_connection` method as that is now obsolete due to the
  connection pool
- Removes the `close` method as it is now obsolete
- Modified the spec tests slightly, to stop mocking get_connection as it no
  longer exists, and set a super low pool timeout so that if a test fails, it
  will fail quickly instead of taking the default time of 60+ seconds
2017-05-17 13:52:28 -07:00
Glenn Sarti
2f37c1e9b5 (POOLER-52) Modify dummy provider to use a connection pool
Previously a connection pooler class was added.  This commit modifies the Dummy
VM Provider to use a connection pooler.  While the Dummy provider strictly
speaking does not use connections, this allows testing to see what happens when
connection pools are stressed or exhausted.  This commit:
- Modifies functions to use a connection pool object for the public API
  functions
- Modifies the VMPooler YAML with new settings for connection pool size and
  timeout
2017-05-17 13:52:28 -07:00
Glenn Sarti
888ffc4afc (POOLER-52) Add a generic connection pool
Previously VMPooler had no concept of a connection pooler.  While there is an
up to date connection pooler Gem (connection_pool), that supports MRI and jRuby,
it lacked metrics which are useful to diagnose errors and judge pool size.
This commit:

- Brings in the connection_pool gem
- Creates a new class called generic_connection_pool which inherits from the
  ConnectionPool class in the connection_pool gem.
- Extends the connection pool object with a new function called `with_metrics`
  This copies the code from the original `with` method but emits metrics for
  how long it took to get an object from the pool, and then how many objects
  are left in the pool.  This is sent using VMPooler's metrics object.
  Extending the object was used instead of overriding as it was not possible to
  inject into the existing function and monkey patching did not seem the correct
  way.

  In order use the metics, the GenericConnectionPool object modifies the
  initialize method to use :metrics and :metrics_prefix options
- Also added tests for the GenericConnectionPool class to ensure the new
  functions are tested.  Note that the functionality that was not extended is
  not tested in VMPooler.
2017-05-17 13:52:28 -07:00
Glenn Sarti
0aa550f852 (POOLER-70) Remove vsphere_helper
In previous commits the code from vsphere_helper is now all moved to the vSphere
Provider.  This commit removes the vsphere_helper.rb file, spec tests and from
being loaded by vmpooler itself.
2017-05-17 13:52:28 -07:00
Glenn Sarti
ba686e3c0a (maint) Update VMPooler files with fixes for Rubocop violations
This commit updates vmpooler.rb, api.rb and providers.rb with style changes as
per rubocop style violations.

This commit also updates the rubocop configuration to always use LF line endings
even on Windows as rubocop was expecting CRLF even though git is configured
for LF.
2017-05-17 13:52:28 -07:00
Glenn Sarti
2e255a5a43 (POOLER-70) Move vSphere configuration into providers section
Previously the vSphere based configuration was in the root of the configuration
YAML.  As there is deprecation support to move the old configuration to the new
location, the vSphere provider can be updated.  This commit updates the vSphere
Provider and tests to use the new configuration location under:

:providers:
  :vsphere:
2017-05-17 13:52:28 -07:00
Glenn Sarti
57eba4a8e4 (POOLER-70) Update execute! for VM Provider
This commit modifies execute! to create the VM Providers on VMPooler startup
instead of check_pool creating a provider per pool.  This commit also adds
legacy support for old configuration files:
- Setting the default provider for pools to be vsphere
- Copying VSphere connection settings in the configuration file from the legacy
  location in the root, to under :providers/:vsphere which is new location for
  all provider configuration
2017-05-17 13:52:28 -07:00
Glenn Sarti
1a3ae86943 (POOLER-70) Add config for VM Provider
This commit adds a public function to access the internal variable holding the
VMPooler configuration.  This is required for later commits for the execute!
function testing.
2017-05-17 13:52:28 -07:00
Glenn Sarti
710b3808a5 (POOLER-70) Add create_provider_object for VM Provider
This commit adds a factory style function to create a VM provider object from
a provider name string.  This is used during VMPooler initialization to create
the various VM providers on startup.
2017-05-17 13:52:28 -07:00
Glenn Sarti
2ca1a39e8c (POOLER-70) Update _check_pool for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
- Removes the MockFindFolder class as it is no longer required
- Minor update for rubocop violations
2017-05-17 13:52:28 -07:00
Glenn Sarti
7c3ad716af (POOLER-70) Update check_pool for VM Provider
Previously the Pool Manager would use a single VM provider per Pool.  This
commit changes Pool Manager to use a single provider that services multiple
pools.
2017-05-17 13:52:28 -07:00
Glenn Sarti
3f6ead8134 (POOLER-70) Update migrate_vm_and_record_timing for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the migrate_vm_and_record_timing method to use VM and Pool names
  instead of VM and Pool objects.
2017-05-17 13:52:28 -07:00
Glenn Sarti
cf15829f05 (POOLER-70) Remove get_vm_host_info from pool_manager
Previously the Pool Manager would use vSphere objects directly.  This commit
removes get_vm_host_info as this functionality is now in the vSphere VM
Provider.
2017-05-17 13:52:28 -07:00
Glenn Sarti
2974eac371 (POOLER-70) Update migrate_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:28 -07:00
Glenn Sarti
acf32a3f7b (POOLER-70) Update check_snapshot_queue for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:28 -07:00
Glenn Sarti
41f9d7b3c4 (POOLER-70) Update check_disk_queue for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:28 -07:00
Glenn Sarti
e01b96c6d0 (POOLER-70) Add get_provider_for_pool for VM Provider
This commit adds a helper method which retrieves the associated Provider object
for a pool by name
2017-05-17 13:52:28 -07:00
Glenn Sarti
c09035cfcb (POOLER-70) Add get_pool_name_for_vm for VM Provider
Previously there was no simple way to calculate which pool a VM was a member of.
This commit adds a helper method which queries redis for the pool name for a
given VM.
2017-05-17 13:52:27 -07:00
Glenn Sarti
c7b37dec75 (POOLER-70) Update revert_vm_snapshot for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
a56d61c8bf (POOLER-70) Update create_vm_snapshot for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
fd54c4ca18 (POOLER-70) Update create_vm_disk for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
64bca33d45 (POOLER-70) Update destroy_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
- Splits the destroy_vm function into two.  One function spawns the thread
  while the other actually does the work.  This makes testing much easier.
2017-05-17 13:52:27 -07:00
Glenn Sarti
b21d78fa49 (POOLER-70) Update _clone_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
cc1910fd76 (POOLER-70) Update check_running_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
8c421aa3bd (POOLER-70) Update check_ready_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
- Splits the check_ready_vm function into two.  One function spawns the thread
  while the other actually does the work.  This makes testing much easier.
2017-05-17 13:52:27 -07:00
Glenn Sarti
760dc1c67e (POOLER-70) Update move_pending_vm_to_ready for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
2017-05-17 13:52:27 -07:00
Glenn Sarti
9f4fc903b9 (POOLER-70) Update fail_pending_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
- Modified to return true or false to indicate that the VM was failed
2017-05-17 13:52:27 -07:00
Glenn Sarti
199bf4a070 (POOLER-70) Update check_pending_vm for VM Provider
Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the pool_manager to use the VM provider methods instead
- Removes the open_socket method and tests as it is only required in the vSphere
  VM provider
2017-05-17 13:52:27 -07:00
Glenn Sarti
4bf32be87e (POOLER-70) Update base VM provider
Previously the base VM provider class was added however it was missing various
functions from its definition.  This commit:
- Modifies the VMPooler configuration to add an empty provider config. if the
  provider config is missing
- Helper method to return all of the pools this provider is responsible for
2017-05-17 13:52:27 -07:00
Glenn Sarti
5aa5019822 (POOLER-70) Add mock provider test fixture
This commit creates a VM Provider test fixture for spec tests that merely uses
the Base Provider class with a name of mock_provider.  This will then be used
by unit tests in further commits.
2017-05-17 13:52:27 -07:00