Skip to content

Commit

Permalink
cvlib: Remove runDeviceCommands reliance on deprecated fields
Browse files Browse the repository at this point in the history
Ctx.changecontrol is a deprecated field and should not be relied
upon for checking if the function is callable. Action (its replacement)
should be used instead.

Furthermore, studio autofill actions are not change controls, but may
require to run device commands to fetch such information as the
hostname.
Allow commands to be run in such contexts

Change-Id: I0dc93e50056c81f22fd2407dfd59f8eacb1fa005
  • Loading branch information
cianmcgrath committed Oct 13, 2022
1 parent 84c294c commit af2c68e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cloudvision/cvlib/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Context:
- user: Info on the user executing this script
- device: Info on the device the script is operating on, if applicable
- action: Info on the action associated with the current context, if applicable
- changeControl: Common change-control script parameters
- changeControl: Common change-control script parameters (Deprecated, use action)
- studio: Common studio parameters
- execution: Info on the standalone execution context
- connections: Object storing connection info used by the context, e.g. apiserver address
Expand Down Expand Up @@ -230,9 +230,9 @@ def runDeviceCmds(self, commandsList: List[str], device: Optional[Device] = None
DeviceCommandsFailed if validating command responses and the contents
contain an error code/message (can occur if request is a 200)
'''
if not self or not self.changeControl:
if not self or not self.action:
raise InvalidContextException(
"runDeviceCmds is only available during change controls")
"runDeviceCmds is only available in action contexts")

if device is None:
if self.device is None:
Expand Down

0 comments on commit af2c68e

Please sign in to comment.