Commit graph

352 commits

Author SHA1 Message Date
Scott Schneider
e0356968df (QENG-2995) Display associated VMs in GET /token/:token endpoint 2015-11-04 12:35:35 -08:00
Colin
7b9b178861 (MAINT) Remove Ping Check on Running VMs
Prior to this commit, a running VM could fail a ping check and be
destroyed. This causes issues when network hiccups occur or the machine
is performing a reboot.

A VM that is in a ready state will now be destroyed when handed back or
it hits the lifetime TTL.
2015-10-02 13:03:48 -07:00
Colin
b8bdfe1301 (maint) Move VM Only When SSH Check Succeeds
An SSH check was added before moving a VM from pending to ready.
However, the result of that check did not matter and move_pending would
still be called. This moves the move_pending call to within the begin
block that holds the SSH check. If the check fails, then only
fail_pending will be called.
2015-09-17 12:54:29 -07:00
Scott Schneider
5b6985c3a7 (QENG-2952) Check that SSH is available
SSH should be available before a VM is moved from the 'pending' queue to
'ready'.

`check_ssh` should probably be a function in the tradition of DRY; I'm
going to hopefully follow up this PR with a `Vmpooler::Utility` library.
2015-09-17 11:12:51 -07:00
Scott Schneider
906ae89987 Remove duplicate (nested) "ok" responses
As we approach an "official" v1.0.0 of the API I'd like to remove some old
nested "ok" responses.  These were left in as the Beaker vmpooler
hypervisor used them, but I long-ago patched that code and I think it's
time to deprecate these.
2015-08-21 13:58:07 -07:00
Scott Schneider
89ce70dba9 Track token use times
* rename the Redis token 'timestamp' var to 'created'
* update the Redis token 'last' var when token is successfully validataed
* expose the Redis token 'last' var in GET /token route
2015-08-20 19:54:59 -07:00
Scott Schneider
492cfb06a3 List tokens via GET /token 2015-08-20 18:50:51 -07:00
Colin
acb95d34c8 (MAINT) Reduce redis Calls in API
The return values from most redis calls inform the caller of whether a
key or hash value exists. Several exists() calls can be removed in
favor of this approach.

Updated spec tests to account for a removal of exists() and ismember()
calls in API tests.
2015-07-28 14:47:01 -07:00
Scott Schneider
add88c7bba (QENG-1304) vmpooler should require an auth key for VM destruction 2015-07-28 12:03:14 -07:00
Scott Schneider
85aad61192 Fix snapshort revert functionality 2015-07-16 11:41:00 -07:00
Scott Schneider
1689133b19 Require an auth token to use snapshots 2015-07-16 10:59:30 -07:00
Scott Schneider
fe65d5b11b Merge branch 'master' into host_snapshots 2015-07-16 10:42:16 -07:00
Scott Schneider
1c3045fd65 Host snapshot functionality 2015-07-16 10:29:49 -07:00
Scott Schneider
821ffd866a Log empty pools
Make a note in the logfile when a pool is detected to be empty.

Also:

- vmpooler__empty__<pool> Redis key to determine when to log
- lifetime/TTL checks moved to `_check_running_vm` method
  - no longer pay attention to VMware-based 'host.runtime.bootTime'

This PR implements a bunch of other stuff to account for rspec testing:

- Thread creation and looping in `check_pool`
- Everything else in `_check_pool`
2015-07-07 11:12:46 -07:00
Scott Schneider
c720f12c05 Move tag-filtering and exporting to API helper methods 2015-06-30 19:45:16 -07:00
Scott Schneider
6523062b62 Allow for only a [configurable] tag set 2015-06-30 12:54:46 -07:00
Scott Schneider
3aa8389749 Discard/skip empty tags 2015-06-30 11:20:13 -07:00
Colin
b6cb20ba9f Merge pull request #108 from sschneid/api_summary_reorg
API summary rework
2015-06-08 11:28:45 -07:00
Scott Schneider
d3f4f6fb77 Rerouting for new /summary routes 2015-06-04 14:55:26 -07:00
Scott Schneider
ce05c94677 Generate summaries from helpers; individual routes
- '/summary*' routes are now generated from helper methods
- many '/summary/...' combinations now possible
  - '/summary/tag'
  - '/summary/tag/beaker_version'
  - '/summary/boot'
  - '/summary/boot/duration'
  - '/summary/clone'
  - '/summary/clone/count?from=2015-06-01'
  - etc.
2015-06-04 14:55:19 -07:00
Scott Schneider
d938a50ee8 Add get_tag_summary and get_task_summary helpers 2015-06-04 10:39:07 -07:00
Scott Schneider
1f62379be8 Only filter regex matches
and a spec test for it.

Previously using the example shown in vmpooler.yaml.example was failing
to tag strings WITHOUT a '/' in them.
2015-06-02 19:12:30 -07:00
Scott Schneider
4bed6edde4 This implements regex-based tag filtering 2015-06-02 10:53:14 -07:00
Roger Ignazio
ae91077494 Merge pull request #104 from colinPL/qeng_2360
(QENG-2360) check_running_vm Spec Tests
2015-05-19 15:06:46 -07:00
Colin
dec95ba693 (QENG-2360) check_running_vm Spec Tests
Add spec tests for pool_manager#check_running_vm. In the process of
writing these tests, the method was broken in to smaller methods for
testability reasons.
2015-05-19 10:23:31 -07:00
Scott Schneider
4cfc078684 Create daily tag indexes, report in /summary
- Store daily tag roll-ups in vmpooler__tag__<date>
- GET /summary will display daily tag counts and roll-up
2015-05-07 15:24:08 -07:00
Colin
640b1ef4da Merge pull request #101 from sschneid/token_metadata_in_vm_obj
Store token metadata in vmpooler__vm__ Redis hash
2015-05-06 13:33:01 -07:00
Scott Schneider
64bbd7c973 Display VM state in GET /vm/:hostname route 2015-04-30 19:38:31 -07:00
Scott Schneider
7bddfdef1b Store token metadata in vmpooler__vm__ Redis hash 2015-04-30 19:29:18 -07:00
Scott Schneider
f3979de5ef Check for 'checkout' key if calculating 'running' time 2015-04-30 18:30:13 -07:00
Scott Schneider
13df748cc6 Add basic auth token functionality
...and rspec tests, hooray!
2015-04-28 10:47:57 -07:00
Scott Schneider
e447b754c3 Add basic HTTP authentication and /token routes
- the only initial backend option for auth is LDAP
2015-04-21 11:44:38 -07:00
Colin
ab990e2081 (QENG-2208) Move Sinatra Helpers to own file
This moves the inline Helpers contained in V1.rb to their own file:
helpers.rb. In making this change, any API.settings call was removed
from the helper method itself and passed through from V1.

This also adds tests for hostname shortener and validate date string.
2015-04-15 12:44:12 -07:00
Colin
10c5c6e287 Merge pull request #92 from sschneid/redirect_/_to_/dashboard
Redirect / to /dashboard
2015-04-10 10:16:16 -07:00
Scott Schneider
b6c53cd855 Redirect / to /dashboard 2015-04-10 09:38:55 -07:00
Colin
a2fbee55d9 Merge pull request #91 from sschneid/api_lifetime_force_int
Ensure 'lifetime' val returned by GET /vm/:hostname is an int
2015-04-09 16:27:10 -07:00
Scott Schneider
798aa3f9ff Ensure 'lifetime' val returned by GET /vm/:hostname is an int 2015-04-09 12:48:56 -07:00
Scott Schneider
818b92100b running-to-lifetime comparison should be 'greater than or equal to' 2015-04-09 12:35:13 -07:00
Scott Schneider
f9de28236b Auto-expire Redis metadata key via Redis EXPIRE
This commit also removed the unnecessary Vmpooler::Janitor lib
2015-04-07 11:01:37 -07:00
Scott Schneider
2b9f66b8d2 Merge pull request #86 from colinPL/qeng_1906_poolmanager
(QENG-1906) Break apart check_pending_vm and add spec tests
2015-04-06 16:24:03 -07:00
Colin
a5edb9bae2 (maint) Fix bad redis reference
This fixes a redis reference that was missed in a previous refactor.
2015-04-02 11:30:43 -07:00
Colin
e6ee6b1257 (QENG-1906) Break apart check_pending_vm and add spec tests
This commit breaks apart the method check_pending_vm in to three,
smaller methods that are easier to test. There are no functionality
changes or bug fixes.

This adds spec tests for the overall functionality that was
check_pending_vm.
2015-04-01 15:42:28 -07:00
Colin
d0275f5fba (QENG-1906) Add spec tests for Janitor
Add spec tests to verify Janitor deletes stale vms correctly. This
required a small refactor of Janitor to move the logic out of the for
loop.
2015-03-31 10:21:24 -07:00
Colin
1408f35867 (QENG-1906) Refactor initialize to allow config passing
Prior to this commit, several pieces of vmpooler performed configuration
and initialization steps within 'initialize'. This made it difficult to
pass in mock objects for testing purposes.

This commit performs a single configuration and passes the results to
the various pieces of vmpooler.
2015-03-30 14:23:06 -07:00
Scott Schneider
858d4c7541 Use 'checkout' time to calculate 'running' time 2015-03-25 13:41:26 -07:00
Colin
91563c0408 Merge pull request #71 from sschneid/historic_redis_vm_metadata
(QENG-2057) Historic Redis VM metadata
2015-03-25 12:48:56 -07:00
Scott Schneider
10db0c4c6a Catch improperly-formatted data payloads 2015-03-20 13:03:29 -07:00
Scott Schneider
d48d487de0 Validate data payload before operating on it 2015-03-20 12:52:17 -07:00
Scott Schneider
7b97e58e0f Clean up Redis VM objects after redis['data_ttl'] 2015-03-20 10:25:51 -07:00
Scott Schneider
48a9ef0dfd Store checkout and destroy timestamps 2015-03-20 09:57:47 -07:00