Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _mock_manager_setup(self, *args, **kwargs):
if kwargs:
device_params = kwargs['device_params']
device_handler = make_device_handler(device_params)
session = SSHSession(device_handler)
return Manager(session, device_handler)
def _mock_manager(self, *args, **kwargs):
if kwargs and 'normalize' not in kwargs:
device_params = kwargs['device_params']
device_handler = make_device_handler(device_params)
session = SSHSession(device_handler)
return Manager(session, device_handler)
elif args:
if args[0].tag == 'command':
if args[0].text == 'show cli directory':
return self._read_file('show-cli-directory.xml')
if args[0].text == 'show interface terse':
return self._read_file('show-interface-terse.json')
elif args[0].text == 'show configuration':
return self._read_file('show-configuration.xml')
elif args[0].text == 'show system alarms':
return self._read_file('show-system-alarms.xml')
elif args[0].text == 'show system uptime| display xml rpc':
return self._read_file('show-system-uptime-rpc.xml')
elif args[0].text == 'show configuration interfaces':
return self._read_file('show-configuration-interfaces.xml')
elif args[0].text == 'show interfaces terse asdf':
return self._read_file('show-interfaces-terse-asdf.xml')
def _mock_manager_setup(self, *args, **kwargs):
if kwargs:
device_params = kwargs['device_params']
device_handler = make_device_handler(device_params)
session = SSHSession(device_handler)
return Manager(session, device_handler)
def _mock_manager_setup(self, *args, **kwargs):
if kwargs:
device_params = kwargs['device_params']
device_handler = make_device_handler(device_params)
session = SSHSession(device_handler)
return Manager(session, device_handler)
def _mock_manager(self, *args, **kwargs):
if kwargs and 'normalize' not in kwargs:
device_params = kwargs['device_params']
device_handler = make_device_handler(device_params)
session = SSHSession(device_handler)
return Manager(session, device_handler)
if args:
if args[0].tag == 'request-pfe-execute':
file_name = (args[0].findtext('command')).replace(' ', '_')
return self._read_file(file_name + '.xml')
elif args[0].tag == 'command':
file_name = (args[0].text).replace(' ', '_')
return self._read_file(file_name + '.xml')
def _mock_manager(self, *args, **kwargs):
if kwargs:
if 'normalize' in kwargs and args:
return self._read_file(args[0].tag + '.xml')
device_params = kwargs['device_params']
device_handler = make_device_handler(device_params)
session = SSHSession(device_handler)
return Manager(session, device_handler)
if args:
return self._read_file(args[0].tag + '.xml')
def _mock_manager_setup(self, *args, **kwargs):
if kwargs:
device_params = kwargs['device_params']
device_handler = make_device_handler(device_params)
session = SSHSession(device_handler)
return Manager(session, device_handler)
def mock_manager(*args, **kwargs):
if 'device_params' in kwargs:
# open connection
device_params = kwargs['device_params']
device_handler = make_device_handler(device_params)
session = SSHSession(device_handler)
return Manager(session, device_handler)
elif args:
# rpc request
rpc_request = args[0].tag
rpc_command = str(args[0].text)
rpc_command = rpc_command.strip()
rpc_command = rpc_command.replace(" ", "_")
if rpc_request in rpc_reply_dict:
xml = rpc_reply_dict[rpc_request]
elif 'dir' in rpc_reply_dict:
fname = os.path.join(rpc_reply_dict['dir'], 'rpc-reply', rpc_command, rpc_request + '.xml')
with open(fname, 'r') as f:
xml = f.read()
else:
_rpc_reply_dict['dir']
fname = os.path.join(os.path.dirname(__file__), 'rpc-reply', rpc_command, rpc_request + '.xml')
with open(fname, 'r') as f:
def _mock_manager(self, *args, **kwargs):
if kwargs:
device_params = kwargs['device_params']
device_handler = make_device_handler(device_params)
session = SSHSession(device_handler)
return Manager(session, device_handler)
if args:
if args[0].xpath('//configuration/system/login/user'):
return self._read_file('get-configuration-user.xml')
else:
return self._read_file(args[0].tag + '.xml')
def _mock_manager(self, *args, **kwargs):
if kwargs:
device_params = kwargs['device_params']
device_handler = make_device_handler(device_params)
session = SSHSession(device_handler)
return Manager(session, device_handler)
if args:
if 'version_RE0-RE0' in self.facts:
return self._read_file(args[0].tag + '_RE0-RE0.xml')
return self._read_file(args[0].tag + '.xml')