These forums are a place for learning, helping and sharing experiences with others about any of our products. Feel free to ask a question and get answers from our community and our most advanced users.
Note that these are public forums - anyone can view the discussions here.
VISIT OUR DIFFERENT FORUMS:
Announcements > | |
CloudShell > | TestShell > |
Developers > | BI (Business Inteligence) > |
This is where you can suggest your ideas to help and improve the product for everyone.
Please make sure to read the following article before posting a new idea, to get more information about the required information and ideas lifecycle.
Feel free to vote and comment on other ideas to promote them.
Thanks for everyone who suggested the ideas and voted for them.
Find, download and share integrations that can extend and enhance the CloudShell experience.
Integrations have several levels:
Certified - Officially tested and supported by Quali.
Preview - Provides a sneak peek to what the Quali team is developing. Officially supported by Quali. Feel free to experiment and comment, but please take into consideration that it is not yet tested and released.
Community - Integrations shared by community users. Feel free to look into what other users have contributed, please take into consideration that these integrations are not tested by Quali.
To learn more about creating Shells and integrating with CloudShell, use the following links:
CloudShell's Dev Guide > | Configuration Management > |
Getting started with Shells > | Extending CloudShell with Cloud Providers > |
Getting started with Orchestration > | API Guide > |
To share your integration, follow the instructions in this guide >.
How do we implement a timeout?
You know how in the old authoring client, each step could have a timeout?
In Python, how would we do that? Specifically, 2 cases:
1. If we do an “ExecuteCommand” from the SETUP or TEARDOWN script to a driver command – how do we set a timeout where if it doesn’t return after a set amount of time, it terminates it and then raises an exception?
2. In a driver itself, if for example, we try to call a function and we want to set a timeout for the function to return?
Answer by Yaniv Kalsky · Jan 19, 2018 at 11:05 PM
Hi @mchua,
First, make sure that your driver commands support cancellation (as much as you can), so that in a case of getting stopped (either from the portal or with the API), the driver will be able to stop at the right time or roll back parts of what it did if it's required. You can learn more about cancellation and termination support in the dev guide.
You should also check in the driver itself, why a command should take so long, sometimes, you can set the timeout when you call the internal modules (like setting a timeout on a telnet/ssh/rest calls).
Next, if you have a function that you can poll and check the progress/result and decide if you'd like to stop after a certain timeout, then you can do a while loop that validates that:
def _run_something_with_timeout(arg1, arg2, timeout=10, cancellation_context) start_time = time.time() data = self._get_data(arg1, arg2) while not data: if time.time() - start_time >= timeout: raise TimeoutError('Timeout: Waiting for data') # check if CloudShell sent a cancel update if cancellation_context.is_cancelled: raise CommandCancelledException("Command was Cancelled") time.sleep(5) data = self._get_data(arg1, arg2) return data def my_driver_command(self, context, cancellation_context): try: data = _run_something_with_timeout('a', 'b', timeout=30, cancellation_context) except TimeoutError as te: print 'timeout' return '' except CommandCancelledException as cce: return 'command cancelled'
If you'd like to do something similar from the orchestration script, that will execute the command and will poll for its status, you'll need to use the Sandbox API, which allows you to start a command, get an execution id, poll the status, and if needed, call the stop execution (with the cloudshell-automation-api, you can either ExecuteCommand or EnqueueCommand (without knowing its status)). There is a python sandbox api wrapper that can get you started (it's not covering executing/stopping commands yet, but should be hard to add them).
Yaniv
These forums are a place for learning, helping and sharing experiences with others about any of our products. Feel free to ask a question and get answers from our community and our most advanced users.
Note that these are public forums - anyone can view the discussions here.
Announcements | |
CloudShell | TestShell |
Developers | BI (Business Inteligence) |
This is where you can suggest your ideas to help and improve the product for everyone.
Please make sure to read the following article before posting a new idea, to get more information about the required information and ideas lifecycle.
Feel free to vote and comment on other ideas to promote them.
Thanks for everyone who suggested the ideas and voted for them.
Find, download and share integrations that can extend and enhance the CloudShell experience.
Integrations have several levels:
Certified - Officially tested and supported by Quali.
Preview - Provides a sneak peek to what the Quali team is developing. Officially supported by Quali. Feel free to experiment and comment, but please take into consideration that it is not yet tested and released.
Community - Integrations shared by community users. Feel free to look into what other users have contributed, please take into consideration that these integrations are not tested by Quali.
To learn more about creating Shells and integrating with CloudShell, use the following links:
CloudShell's Dev Guide | Configuration Management |
Getting started with Shells | Extending CloudShell with Cloud Providers |
Getting started with Orchestration | API Guide |
To share your integration, follow the instructions in this guide.
Is there a way for a driver to obtain a blueprint's "Estimated setup duration" value? 4 Answers
How do I add new Python startup/teardown functionality to a blueprint? 4 Answers
Upload resource driver - error message: 'Object reference not set to an instance of an object' 1 Answer
Has someone experience with Python vs cx_Oracle library integration? 3 Answers
Failed to install shell? 1 Answer