mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Add initial FSChan object
This object will allow us to replace a channel in the file client with a local channel that just uses the file server class
This commit is contained in:
parent
4f3a2489cc
commit
12ac5b9c5b
@ -532,3 +532,26 @@ class Fileserver(object):
|
||||
(x, y) for x, y in ret.items() if x.startswith(prefix)
|
||||
])
|
||||
return ret
|
||||
|
||||
|
||||
class FSChan(object):
|
||||
'''
|
||||
A class that mimics the transport channels allowing for local access to
|
||||
to the fileserver class class structure
|
||||
'''
|
||||
def __init__(self, opts, **kwargs):
|
||||
self.opts = opts
|
||||
self.kwargs = kwargs
|
||||
self.fs = Fileserver(self.opts)
|
||||
|
||||
def send(self, load, tries=None, timeout=None):
|
||||
'''
|
||||
Emulate the channel send method, the tries and timeout are not used
|
||||
'''
|
||||
if 'cmd' not in load:
|
||||
log.error('Malformed request: {0}'.format(load))
|
||||
return {}
|
||||
if not hasattr(self.fs, load['cmd']):
|
||||
log.error('Malformed request: {0}'.format(load))
|
||||
return {}
|
||||
return getattr(self.fs, load['cmd'])(load)
|
||||
|
Loading…
Reference in New Issue
Block a user