Sample Resource Driver (Python) #1496
Quali-Community
started this conversation in
Integrations
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Sample Resource Driver (Python)
Originally by Meni B
This sample includes a resource driver that is written in Python which demonstrates the most common elements of integration with CloudShell.
Prerequisites:
• CloudShell 7.0
• Python 2.7 installed on the development machine
• For simple development and debugging process, install PyCharms IDE and the CloudShell plugin for PyCharms - [General] CloudShell Python Driver Development and Deployment with PyCharm Plugin
• Python drivers are associated with models, create a new resource model and resource before you start, so that you can test this sample easily
Downloading the sample:
• Download the attached zip file to your local computer
• Extract the zip file and browse the content: • The driver files are stored under the root folder: drivercontext, drivermetadata, requirements & the main code file: SampleResourceDriver
• In addition, since this driver was developed in PyCharm using the CloudShell PyCharms Plugin, it includes:
• A deployment.xml file that configures the plugin
• A deployment folder that contains the packaged driver which is ready to be uploaded to CloudShell.
Uploading the driver to CloudShell and testing it for the first time:



• Login to CloudShell with an administrator’s account and navigate to the Manage -> Drivers -> Resource page
• Click ‘Add new Driver’ and select the packaged zip file: deployment\PythonDriverSample.zip
• Edit the driver properties
• Associate the driver with the model you created, this will allow resources from that model to use the driver
• If you already have a resource to test the driver, you can use the ‘Set as active’ option to automatically update the resource with the new driver (it will only work if the resource doesn’t have a different driver), You can always create additional resources from the Resource Manager desktop application and then associate them with the driver.
• Now that you have a resource that is using this driver, you can test it by creating an empty reservation, adding the resource and opening the commands side pane.
Running the driver commands:
This driver covers the basic integration with CloudShell:
Hello World command writes output to the output console and demonstrates how to add ‘user friendly’ names and descriptions to the python function
Hello With Params command demonstrates the use of user parameters in CloudShell
CloudShell Context command demonstrates the use of the context parameter which provides information on the resource and reservation during function run-time.
Using CloudShell API command demonstrates how to connect to open a secure session and integrate with the CloudShell API
Stop Enabled command demonstrates how to specifically declare and implement commands that can be stopped by non admin users
More information about these capabilities can be found in the help: http://help.qualisystems.com/Online Help/7.0.0.0/Portal/Content/API/Pyth-API-Intg-Drv.htm
Write / Modify the Python code using the PyCharms with the CloudShell PyCharms Plugin:

• Create a new project in PyCharms, the source folder for the project should be the extracted zip root folder: Resource Driver
• Configure the deployment.xml file to point to your QualiServer
• Open the driver code: SampleResourceDriver.py
• Notice the implementation of the different functions
• Change the code or add your own functions as you wish
• To upload a new version to CloudShell you can simply use PyCharms Plugin: Click Run -> Publish Python Driver on CloudShell
Repository
Name
CloudShell-Community
Owner
QualiSystems
Type
Category
Min. Compatible CloudShell Version
* Please allow 30-60 seconds for manual update changes to take effect.
Quali 06/20/2016 00:29 AM
· 194 ·
Beta Was this translation helpful? Give feedback.
All reactions