mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 21:38:41 -05:00
(#34) Raise TokenError on operations that require tokens
Prior to this commit, the Pooler class would raise an exception if the token provided was nil and it attempted to make a request with Faraday. This fixes that by catching when nil tokens are provided and instead raising a TokenError to be caught by the consumer.
This commit is contained in:
parent
08760d8c0b
commit
b51a549fe5
3 changed files with 71 additions and 5 deletions
|
|
@ -55,6 +55,10 @@ class Pooler
|
|||
end
|
||||
|
||||
def self.modify(verbose, url, hostname, token, lifetime, tags)
|
||||
if token.nil?
|
||||
raise TokenError, "Token provided was nil. Request cannot be made to modify vm"
|
||||
end
|
||||
|
||||
modify_body = {}
|
||||
if lifetime
|
||||
modify_body['lifetime'] = lifetime
|
||||
|
|
@ -76,6 +80,10 @@ class Pooler
|
|||
end
|
||||
|
||||
def self.disk(verbose, url, hostname, token, disk)
|
||||
if token.nil?
|
||||
raise TokenError, "Token provided was nil. Request cannot be made to modify vm"
|
||||
end
|
||||
|
||||
conn = Http.get_conn(verbose, url)
|
||||
conn.headers['X-AUTH-TOKEN'] = token
|
||||
|
||||
|
|
@ -129,6 +137,10 @@ class Pooler
|
|||
end
|
||||
|
||||
def self.snapshot(verbose, url, hostname, token)
|
||||
if token.nil?
|
||||
raise TokenError, "Token provided was nil. Request cannot be made to snapshot vm"
|
||||
end
|
||||
|
||||
conn = Http.get_conn(verbose, url)
|
||||
conn.headers['X-AUTH-TOKEN'] = token
|
||||
|
||||
|
|
@ -138,6 +150,10 @@ class Pooler
|
|||
end
|
||||
|
||||
def self.revert(verbose, url, hostname, token, snapshot_sha)
|
||||
if token.nil?
|
||||
raise TokenError, "Token provided was nil. Request cannot be made to revert vm"
|
||||
end
|
||||
|
||||
conn = Http.get_conn(verbose, url)
|
||||
conn.headers['X-AUTH-TOKEN'] = token
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue