Commit graph

203 commits

Author SHA1 Message Date
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
Glenn Sarti
77afc86aeb (POOLER-72) Add Dummy Provider
Previously the only VM Provider was vSphere however this made testing and making
changes difficult as it required a functioning vSphere instance.  This commit
adds a Dummy Provider which presents a VM provider to Pool Manager but manages
provisioned "VM"s in a hashtable.  The Dummy Provider can also be configured to
randomly fail operations and take random amounts of time to perform operations,
 such as cloning a VM, which is useful to see how the Pool Manager copes with
these events.

This commit also updates the configuration YAML documentation and adds
appropriate unit tests.
2017-05-17 13:52:27 -07:00
Glenn Sarti
a155dca081 (POOLER-70) Add Pool Manager based functions to vSphere Provider
Previously the vSphere provider did not implement any of the required methods
from the base class.  This commit modifies the vSphere provider so that in
can properly implement the following methods:

- name
- vms_in_pool
- get_vm_host
- find_least_used_compatible_host
- migrate_vm_to_host
- get_vm
- create_vm
- destroy_vm
- vm_ready?
- vm_exists?
- create_disk
- create_snapshot
- revert_snapshot

This commit also includes changes to syntax for rubocop violations.
2017-04-03 11:30:02 -07:00
Glenn Sarti
821dcf45c2 (POOLER-70) Update the provider base class
Previously it was expected that the timeout setting should be passed when
determining whether a VM was ready.  However this should be in the pool
configuration and is not required to be a method parameter.

Previously many of the methods did not have a pool name passed as a parameter.
While this may be ok for the vSphere provider, it may not for other providers.
This commit changes the base provider to consistently use (pool,vm,other..) as
method parameters.  This commit also updates the base spec tests as well.

Additionally:
- Updated documentation around expected error states
- Updated documentation to be more consistent in format
- Added snapshot and disk manager functions and unit tests
- Update the initialization method to take in a more formal defintion with
  required global objects for metrics, logging and configuration
- Added helper functions
  - logger : Allows providers to log information as per Pool Manager
  - metrics : Allows providers to submit metrics as per Pool Manager
  - provider_options : Allows providers to access initialization options for a
    provider
  - pool_config : Get the configuration for a specific pool
  - provider_config : Get the configuration of this specific provider
  - global_config: Get the VMPooler global configuration
2017-04-02 21:23:09 -07:00
Glenn Sarti
901ddde7c3 (POOLER-52) Prepare the vSphere Provider for a connection pooler
Previously, all calls to the vSphere API assumed an instance variable called
`@connection`.  This commit prepares the provider for a connection pooler:

- Removes all references to `@connection` where needed and funnels all calls to
  get a vSphere connection through the newly renamed method `get_connection`.
  For the moment, this still uses `@connection` behind the scenes but will make
  it easier in the future to migrate to a connection pooler
- Removes all references and tests for the ensure_connected method as it's no
  longer required
- All methods that explicitly need a connection object will have this as part of
  the method parameters
- The connect_to_vsphere method has been changed so that instead of setting the
  instance level `@connection` object it just returns the newly created connection.
  This can then be easily consumed by a connection pooler later.
2017-03-22 10:23:43 -07:00
Glenn Sarti
e5db02b44f (POOLER-70) Rename conflicting method in vSphere Provider
Previously, the vSphere Provider had two methods called
`find_least_used_compatible_host`: one in the base class and one in the vSphere
helper methods.  This commit renames the vSphere helper methods and tests to
`find_least_used_vsphere_compatible_host` to stop the conflict.
2017-03-22 10:10:51 -07:00
Glenn Sarti
8cf3d043bf (POOLER-70) Copy vSphere helper into the vSphere Provider
This commit copies the code and tests from the vSphere Helper into the vSphere
Provider and modifies the test initialisation for the new class name.
2017-03-22 08:58:35 -07:00
Morgan Rhodes
d4a50e5e56 Merge pull request #208 from glennsarti/maint-rubocop
(maint) Fix rubocop violations
2017-03-21 15:21:20 -07:00
Glenn Sarti
bcaad0a15b (POOLER-73) Add spec tests for vsphere_helper
Previously there were no spec tests to document the behaviour of the
vsphere_helper.  This commit adds the behavioural spec tests in prepration of
the refactoring work as part of POOLER-70, the connection pooling work in
POOLER-52 and various bugs found in vsphere_helper while these spec tests were
being created.
2017-03-20 17:31:59 -07:00
Glenn Sarti
06100ddea6 (maint) Fix rubocop violations
This commit fixes minor rubocopy violations in eleven source files.  Minor
violations are those that include formatting, single quotes, and recently added
classes.
2017-03-16 15:39:15 -07:00
Glenn Sarti
c724d90d90 (POOLER-70) Add initial VSphere VM Provider
This commit adds a skeleton VM Provider for VSphere based VM operations.
2017-03-08 17:14:52 -08:00
Glenn Sarti
ac8a34de86 (POOLER-70) Rename the use of vsphere to provider
VM provisioning will be handled by VM Providers.  This commit renames the use of
vsphere to provider where appropriate and changes the per-pool helper from
vsphere to providers to more accurately represent it's intended use.
2017-03-08 17:14:52 -08:00
Glenn Sarti
c502f92cd3 (POOLER-70) Add initial VM Provider service
Previously all of the VM provisioning code was intertwined with the VM lifecycle
code e.g. The VSphere specific code is mixed with Redis code.  This makes it
impossible to add aditional providers or disable VSphere integration.  This
commit begins the process to refactor the VSphere code out of the lifecycle code
by introducing the concept of VM Providers.  A Provider will contain the logic/
code to manage VMs i.e. create/destroy/inquire.  Therefore the Pool Manager can
query a strict interface into one or more Providers.  Initially only a VSphere
provider will be available.

This commit adds the base class for all providers and describes the API or
contract that the Pool Manager will use to manage VMs.
2017-03-08 17:14:12 -08:00
Morgan Rhodes
850919f5db Merge pull request #189 from glennsarti/ticket/maint/rename-moves-and-clonevm
(POOLER-70) Refactor clone_vm to take pool configuration object
2017-03-02 11:39:29 -08:00
Glenn Sarti
ac7d7009d2 (POOLER-70) Refactor clone_vm to take pool configuration object
Previously, the clone_vm method took various VSphere specific parameters e.g.
template folder.  However in order make VMPooler less VSphere specific this
method should just take the pool configuration and then it can determine the
appropriate settings itself.  This commit also moves the threading to a clone_vm
while the actual method which does the work is now _clone_vm as per all other
multithread worker methods in pool_manager.  This commit also updates the spec
tests appropriately.
2017-03-01 21:53:42 -08:00
Glenn Sarti
f433056734 (GH-185) Remove unnecessary checks in check_ready_vm
Previously in check_ready_vm, if the VM is powered off, the VM is moved in
redis however the function doesn't return there, and instead then checks if the
hostname is the same, and then if TCP socket 22 is open. This is unnecessary as
we already know the VM is turned off so of course the hostname is wrong and TCP
22 is unavailable. The same applies for the VM hostname.

This commit instead returns after it is found a VM is no longer ready.  This
commit also amends the spec tests for the correct behaviour.
2017-03-01 20:28:36 -08:00
Glenn Sarti
e783e93784 (POOLER-73) Modify spec tests for _migrate_vm
Modify spec tests for _migrate_vm
2017-02-17 15:51:05 -08:00
Glenn Sarti
c69d61107f (POOLER-73) Modify spec tests for _revert_vm_snapshot
Modify spec tests for _revert_vm_snapshot
2017-02-17 15:51:05 -08:00
Glenn Sarti
b63822fa9f (POOLER-73) Modify spec tests for _create_vm_snapshot
Modify spec tests for _create_vm_snapshot
2017-02-17 15:51:05 -08:00
Glenn Sarti
0a6dffbd05 (POOLER-73) Add spec tests for _create_vm_disk
Add spec tests for _create_vm_disk
2017-02-17 15:51:05 -08:00
Glenn Sarti
3083186241 (POOLER-73) Add spec tests for _check_disk_queue
Add spec tests for _check_disk_queue
2017-02-17 15:51:05 -08:00
Glenn Sarti
25ad5d58f7 (POOLER-73) Add spec tests for _check_snapshot_queue
Add spec tests for _check_snapshot_queue
2017-02-17 15:51:05 -08:00
Glenn Sarti
6f127d32bc (POOLER-73) Add spec tests for check_snapshot_queue
Add spec tests for check_snapshot_queue

Previously the check_snapshot_queue method would execute the loop indefinitely
as it did not have a terminating condition.  This made it impossible to test.
This commit modifies the check_snapshot_queue method so that it can take a
maxloop and delay parameter so that it can be tested.
2017-02-17 15:51:05 -08:00
Glenn Sarti
4dd0c96a78 (POOLER-73) Add spec tests for check_disk_queue
Add spec tests for check_disk_queue

Previously the check_disk_queue method would execute the loop indefinitely as it
did not have a terminating condition.  This made it impossible to test.  This
commit modifies the check_disk_queue method so that it can take a maxloop and
delay parameter so that it can be tested.
2017-02-17 15:51:04 -08:00
Glenn Sarti
47d597f68a (POOLER-73) Add spec tests for migrate_vm_and_record_timing
Add spec tests for migrate_vm_and_record_timing
2017-02-17 15:51:04 -08:00
Glenn Sarti
fb6be8e079 (POOLER-73) Add spec tests for remove_vmpooler_migration_vm
Add spec tests for remove_vmpooler_migration_vm
2017-02-17 15:51:04 -08:00
Glenn Sarti
a4c55d5bf4 (POOLER-73) Add spec tests for migration_limit
Add spec tests for migration_limit
2017-02-17 15:51:04 -08:00
Glenn Sarti
925071be79 (POOLER-73) Add spec tests for migrate_vm
Add spect tests for migrate_vm
2017-02-17 15:51:04 -08:00
Glenn Sarti
713e202d68 (POOLER-73) Add spec tests for revert_vm_snapshot
Add spec tests for revert_vm_snapshot
2017-02-17 15:51:04 -08:00
Glenn Sarti
e6be5bfb75 (POOLER-73) Add spec tests for create_vm_snapshot
Add spec tests for create_vm_snapshot
2017-02-17 15:51:04 -08:00
Glenn Sarti
6f79c438c7 (POOLER-73) Add spec tests for create_vm_disk
Add spec tests for create_vm_disk
2017-02-17 15:51:04 -08:00
Glenn Sarti
943d3025d1 (POOLER-73) Remove #_stats_running_ready tests
This commit removes the #_stats_running_ready tests as they are covered in the
_check_pool tests.
2017-02-17 15:51:04 -08:00
Glenn Sarti
15d4dfa64a (POOLER-73) Add spec tests for _check_pool
Add spec tests for _check_pool
2017-02-17 15:51:04 -08:00
Glenn Sarti
64d2d95ab3 (POOLER-73) Remove #move_running_to_completed tests
The tests for #move_running_to_completed are already tested in the
2017-02-17 15:51:03 -08:00
Glenn Sarti
daad5c7086 (POOLER-73) Add spec tests for check_pool
Add spec tests for check_pool

Previously the check_pool method would execute the loop indefinitely as it did not
have a terminating condition.  This made it impossible to test.  This commit
modifies the check_pool method so that it can take a maxloop and delay parameter
so that it can be tested.
2017-02-17 15:51:03 -08:00
Glenn Sarti
5e46ace584 (POOLER-73) Add spec tests for execute!
Add spec tests for execute!

Previously the execute! method would execute the loop indefinitely as it did not
have a terminating condition.  This made it impossible to test.  This commit
modifies the execute! method so that it can take a maxloop and delay parameter
so that it can be tested.
2017-02-17 15:51:03 -08:00
Glenn Sarti
e342cfe56a (POOLER-73) Add spec tests for get_vm_host_info
Add spec tests for get_vm_host_info
2017-02-17 15:51:03 -08:00
Glenn Sarti
14c091383c (POOLER-73) Add spec tests for destroy_vm
Add spec tests for destroy_vm
2017-02-17 15:51:03 -08:00
Glenn Sarti
434ab546a2 (POOLER-73) Add spec tests for clone_vm
Add spec tests for clone_vm
2017-02-17 15:51:03 -08:00
Glenn Sarti
9d8b792c4a (POOLER-73) Add spec tests for move_vm_queue
Add spec tests for move_vm_queue
2017-02-17 15:51:03 -08:00
Glenn Sarti
cb4e1400aa (POOLER-73) Modify spec tests for _check_running_vm
Modify spec tests for _check_running_vm
2017-02-17 15:51:03 -08:00
Glenn Sarti
58175dec47 (POOLER-73) Add spec tests for check_running_vm
Add spec tests for check_running_vm
2017-02-17 15:51:03 -08:00
Glenn Sarti
2475f55103 (POOLER-73) Add spec tests for check_ready_vm
Add spec tests for check_ready_vm
2017-02-17 15:51:03 -08:00
Glenn Sarti
8ae6b29be3 (POOLER-73) Modify spec tests for move_pending_vm_to_ready
Modify spec tests for move_pending_vm_to_ready
2017-02-17 15:51:02 -08:00
Glenn Sarti
4b2ca49e02 (POOLER-73) Modify spec tests for fail_pending_vm
Modify spec tests for fail_pending_vm
2017-02-17 15:51:02 -08:00
Glenn Sarti
b5ec74bae9 (POOLER-73) Add spec tests for remove_nonexistent_vm
Add spec tests for remove_nonexistent_vm
2017-02-17 15:51:02 -08:00
Glenn Sarti
9fdb51eb00 (POOLER-73) Modify spec tests for _check_pending_vm
(POOLER-73) Modify spec tests for _check_pending_vm
2017-02-17 15:51:02 -08:00
Glenn Sarti
b72275b552 (POOLER-73) Add spec tests for open_socket
Add spec tests for open_socket
2017-02-17 15:51:02 -08:00