Skip to content

Commit

Permalink
Merge pull request #50 from QualiSystems/refactoring_session_usage
Browse files Browse the repository at this point in the history
Refactoring session usage
  • Loading branch information
Yaroslav Nikonorov committed Jan 6, 2017
2 parents 4ed05eb + 7af3d46 commit 36a3696
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cloudshell/cli/command_template/command_template_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class CommandTemplateExecutor(object):
Execute command template using cli service
"""

def __init__(self, cli_service, command_template, action_map=OrderedDict(), error_map=OrderedDict()):
def __init__(self, cli_service, command_template, action_map=OrderedDict(), error_map=OrderedDict(),
**optional_kwargs):
"""
:param cli_service:
:type cli_service: CliService
Expand All @@ -19,6 +20,7 @@ def __init__(self, cli_service, command_template, action_map=OrderedDict(), erro
self._command_template = command_template
self._action_map = action_map
self._error_map = error_map
self._optional_kwargs = optional_kwargs

@property
def action_map(self):
Expand All @@ -31,12 +33,20 @@ def action_map(self):
def error_map(self):
return OrderedDict(self._command_template.error_map.items() + self._error_map.items())

@property
def optional_kwargs(self):
return self._optional_kwargs

def execute_command(self, **command_kwargs):
command = self._command_template.prepare_command(**command_kwargs)
return self._cli_service.send_command(command, action_map=self.action_map, error_map=self.error_map)
return self._cli_service.send_command(command, action_map=self.action_map, error_map=self.error_map,
**self.optional_kwargs)

def update_action_map(self, action_map):
self._action_map.update(action_map)

def update_error_map(self, error_map):
self._error_map.update(error_map)

def update_optional_kwargs(self, **optional_kwargs):
self.optional_kwargs.update(optional_kwargs)

0 comments on commit 36a3696

Please sign in to comment.