Package: qubell-api-python-client
Version 2.0, January 2004http://www.apache.org/licenses/TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION1. Definitions."License" shall mean the terms and conditions for use, reproduction, anddistribution as defined by Sections 1 through 9 of this document."Licensor" shall mean the copyright owner or entity authorized by the copyrightowner that is granting the License."Legal Entity" shall mean the union of the acting entity and all other entitiesthat control, are controlled by, or are under common control with that entity.For the purposes of this definition, "control" means (i) the power, direct orindirect, to cause the direction or management of such entity, whether bycontract or otherwise, or (ii) ownership of fifty percent (50%) or more of theoutstanding shares, or (iii) beneficial ownership of such entity."You" (or "Your") shall mean an individual or Legal Entity exercisingpermissions granted by this License."Source" form shall mean the preferred form for making modifications, includingbut not limited to software source code, documentation source, and configurationfiles."Object" form shall mean any form resulting from mechanical transformation ortranslation of a Source form, including but not limited to compiled object code,generated documentation, and conversions to other media types."Work" shall mean the work of authorship, whether in Source or Object form, madeavailable under the License, as indicated by a copyright notice that is includedin or attached to the work (an example is provided in the Appendix below)."Derivative Works" shall mean any work, whether in Source or Object form, thatis based on (or derived from) the Work and for which the editorial revisions,annotations, elaborations, or other modifications represent, as a whole, anoriginal work of authorship. For the purposes of this License, Derivative Worksshall not include works that remain separable from, or merely link (or bind byname) to the interfaces of, the Work and Derivative Works thereof."Contribution" shall mean any work of authorship, including the original versionof the Work and any modifications or additions to that Work or Derivative Worksthereof, that is intentionally submitted to Licensor for inclusion in the Workby the copyright owner or by an individual or Legal Entity authorized to submiton behalf of the copyright owner. For the purposes of this definition,"submitted" means any form of electronic, verbal, or written communication sentto the Licensor or its representatives, including but not limited tocommunication on electronic mailing lists, source code control systems, andissue tracking systems that are managed by, or on behalf of, the Licensor forthe purpose of discussing and improving the Work, but excluding communicationthat is conspicuously marked or otherwise designated in writing by the copyrightowner as "Not a Contribution.""Contributor" shall mean Licensor and any individual or Legal Entity on behalfof whom a Contribution has been received by Licensor and subsequentlyincorporated within the Work.2. Grant of Copyright License.Subject to the terms and conditions of this License, each Contributor herebygrants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,irrevocable copyright license to reproduce, prepare Derivative Works of,publicly display, publicly perform, sublicense, and distribute the Work and suchDerivative Works in Source or Object form.3. Grant of Patent License.Subject to the terms and conditions of this License, each Contributor herebygrants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,irrevocable (except as stated in this section) patent license to make, havemade, use, offer to sell, sell, import, and otherwise transfer the Work, wheresuch license applies only to those patent claims licensable by such Contributorthat are necessarily infringed by their Contribution(s) alone or by combinationof their Contribution(s) with the Work to which such Contribution(s) wassubmitted. If You institute patent litigation against any entity (including across-claim or counterclaim in a lawsuit) alleging that the Work or aContribution incorporated within the Work constitutes direct or contributorypatent infringement, then any patent licenses granted to You under this Licensefor that Work shall terminate as of the date such litigation is filed.4. Redistribution.You may reproduce and distribute copies of the Work or Derivative Works thereofin any medium, with or without modifications, and in Source or Object form,provided that You meet the following conditions:You must give any other recipients of the Work or Derivative Works a copy ofthis License; andYou must cause any modified files to carry prominent notices stating that Youchanged the files; andYou must retain, in the Source form of any Derivative Works that You distribute,all copyright, patent, trademark, and attribution notices from the Source formof the Work, excluding those notices that do not pertain to any part of theDerivative Works; andIf the Work includes a "NOTICE" text file as part of its distribution, then anyDerivative Works that You distribute must include a readable copy of theattribution notices contained within such NOTICE file, excluding those noticesthat do not pertain to any part of the Derivative Works, in at least one of thefollowing places: within a NOTICE text file distributed as part of theDerivative Works; within the Source form or documentation, if provided alongwith the Derivative Works; or, within a display generated by the DerivativeWorks, if and wherever such third-party notices normally appear. The contents ofthe NOTICE file are for informational purposes only and do not modify theLicense. You may add Your own attribution notices within Derivative Works thatYou distribute, alongside or as an addendum to the NOTICE text from the Work,provided that such additional attribution notices cannot be construed asmodifying the License.You may add Your own copyright statement to Your modifications and may provideadditional or different license terms and conditions for use, reproduction, ordistribution of Your modifications, or for any such Derivative Works as a whole,provided Your use, reproduction, and distribution of the Work otherwise complieswith the conditions stated in this License.5. Submission of Contributions.Unless You explicitly state otherwise, any Contribution intentionally submittedfor inclusion in the Work by You to the Licensor shall be under the terms andconditions of this License, without any additional terms or conditions.Notwithstanding the above, nothing herein shall supersede or modify the terms ofany separate license agreement you may have executed with Licensor regardingsuch Contributions.6. Trademarks.This License does not grant permission to use the trade names, trademarks,service marks, or product names of the Licensor, except as required forreasonable and customary use in describing the origin of the Work andreproducing the content of the NOTICE file.7. Disclaimer of Warranty.Unless required by applicable law or agreed to in writing, Licensor provides theWork (and each Contributor provides its Contributions) on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,including, without limitation, any warranties or conditions of TITLE,NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You aresolely responsible for determining the appropriateness of using orredistributing the Work and assume any risks associated with Your exercise ofpermissions under this License.8. Limitation of Liability.In no event and under no legal theory, whether in tort (including negligence),contract, or otherwise, unless required by applicable law (such as deliberateand grossly negligent acts) or agreed to in writing, shall any Contributor beliable to You for damages, including any direct, indirect, special, incidental,or consequential damages of any character arising as a result of this License orout of the use or inability to use the Work (including but not limited todamages for loss of goodwill, work stoppage, computer failure or malfunction, orany and all other commercial damages or losses), even if such Contributor hasbeen advised of the possibility of such damages.9. Accepting Warranty or Additional Liability.While redistributing the Work or Derivative Works thereof, You may choose tooffer, and charge a fee for, acceptance of support, warranty, indemnity, orother liability obligations and/or rights consistent with this License. However,in accepting such obligations, You may act only on Your own behalf and on Yoursole responsibility, not on behalf of any other Contributor, and only if Youagree to indemnify, defend, and hold each Contributor harmless for any liabilityincurred by, or claims asserted against, such Contributor by reason of youraccepting any such warranty or additional liability.END OF TERMS AND CONDITIONSAPPENDIX: How to apply the Apache License to your workTo apply the Apache License to your work, attach the following boilerplatenotice, with the fields enclosed by brackets "[]" replaced with your ownidentifying information. (Don't include the brackets!) The text should beenclosed in the appropriate comment syntax for the file format. We alsorecommend that a file or class name and description of purpose be included onthe same "printed page" as the copyright notice for easier identification withinthird-party archives.Copyright [yyyy] [name of copyright owner]Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.Description: python-qubell-client====================Installation============pip install qubell-api-python-clientConfiguration=============To configure tests, set up environment variables:QUBELL_USER, QUBELL_PASSWORD - user to access qubellQUBELL_TENANT - url to qubell platform (https://express.qubell.com)QUBELL_ORGANIZATION - name of organization to use. Will be created if not exists.If you attend to create environment, you will also need:PROVIDER_TYPE, PROVIDER_REGION, PROVIDER_IDENTITY, PROVIDER_CREDENTIAL - credentials for amazon ec2. (to create provider)By default Amazon ec2 used (in us-east zone)Example:export QUBELL_TENANT="https://express.qubell.com"export QUBELL_USER="user@gmail.com"export QUBELL_PASSWORD="password"export QUBELL_ORGANIZATION="my-org"# Additional parametersexport PROVIDER_TYPE="aws-ec2"export PROVIDER_REGION="us-east-1"export PROVIDER_IDENTITY="FFFFFFFFF"export PROVIDER_CREDENTIAL="FFFFFFFFFF"CLI Tool========Many operations are available direcly through CLI interface, like creating orgs,initializing cloud accounts, and importing/exporting applications.$ nomiUsage: nomi [OPTIONS] COMMAND [ARGS]...CLI for tonomi.com using contrib-python-qubell-clientTo enable completion:eval "$(_NOMI_COMPLETE=source nomi)"Options:--tenant TEXT         Tenant url to use, QUBELL_TENANT by default--user TEXT           User to use, QUBELL_USER by default--password TEXT       Password to use, QUBELL_PASSWORD by default--organization TEXT   Organization to use, QUBELL_ORGANIZATION by default--debug               Debug mode, also QUBELL_LOG_LEVEL can be used.--help                Show this message and exit.Commands:instanceapplicationenvironmentorganizationplatformzonemanifestCommands are documented via help:$ nomi instance --helpUsage: nomi instance [OPTIONS] COMMAND [ARGS]......Features:instancedescribe     Show details about instancedestroy      Destroy instancelaunch       Launch instance in applicationlist         List instances in current organization or applicationlogs         Get activity logsparameters   Get default launch parameters for applicationremove       Force remove instancewait-status  Wait until instance status becomes 'Status' or timeout reachedapplicationdelete  Delete applicationexport  Save manifest of applications to filesimport  Upload manifest to application.list    List applications in organizationenvironmentclear         Clean environment.clone         Copy environmentcreate        Create environmentdelete        Delete environmentdescribe      Show services, markers and properties of environmentexport        Save environment to fileget-keypair   Download keypairimport        Import environment from fileinit          Add basic services to environment (WF, CA, KS services)list          List environmentsmake-defaultorganizationcreate      Create organizationimport-kit  Import starter kitinit        Initialize cloud account servicelist        List organizationsrestore     Restore configuration from ENV fileplatformshow-account  Exports current account configuration inshell-friendly form. Takes intoaccount explicit top-level flags like --organizationzonelist          List available zonesmanifestvalidate      Validate manifestRunning tests=============Run single test:nosetests -s -v stories.instance.test_actions:BasicInstanceActionsTest.test_workflow_launchRun all tests in folder:nosetests -s -v testsorcd testsnosetestsUsing client============Building sandboxes------------------Sandboxes in qubell platform could be created on different levels. Maximum isolated sandbox could be achieved by separate organization (with it's own environments, users and application).Simple way to create sandbox (see ./contrib-python-qubell-client/sandbox/):Create file containing organization structure, for example:organizations:- name: DEFAULT_ORGapplications:- name: super_parentfile: ./super_parent.yml- name: middle_childfile: ./middle_child.yml- name: childfile: ./child.ymlenvironments:- name: defaultservices:- name: Default credentials service- name: Default workflow service- name: child-serviceservices:- name: Default workflow servicetype: builtin:workflow_service- name: Default credentials servicetype: builtin:cobalt_secure_store- name: child-serviceapplication: childinstances:- name: test-instanceapplication: super_parentNow you can create organization, running:./restore_env.py default.envAfter, you will have fully configured organization, even with running instances. This example shows how to describe 3-level hearchical application, where child instance launched as service.Coding your own scripts-----------------------First way of creating sandbox, using restore method:config = {'organizations': [{'name': 'DEFAULT_ORG','applications': [{'file': './super_parent.yml','name': 'super_parent'},{'file': './middle_child.yml','name': 'middle_child'},{'file': './child.yml','name': 'child'}],'environments': [{'name': 'default','services': [{'name': 'Default credentials service'},{'name': 'Default workflow service'},{'name': 'child-service'}]}],'instances': [{'application': 'super_parent','name': 'test-instance'}],'providers': [{'ec2SecurityGroup': 'default','jcloudsCredential': 'AAAAAAAAA','jcloudsIdentity': 'BBBBBBBBBBB','jcloudsRegions': 'us-east-1','name': 'generated-provider-for-tests','provider': 'aws-ec2','providerCopy': 'aws-ec2'}],'services': [{'name': 'Default workflow service','type': 'builtin:workflow_service'},{'name': 'Default credentials service','type': 'builtin:cobalt_secure_store'},{'application': 'child','name': 'child-service'}]}]}from qubell.api.private.platform import QubellPlatformfrom qubell.api.globals import QUBELLplatform = QubellPlatform.connect(user=QUBELL['user'], password=QUBELL['password'], tenant=QUBELL['tenant'])platform.restore(config)# Let's check what we've gotprint platform.organizations['DEFAULT_ORG'].namefor ins in platform.organizations['DEFAULT_ORG'].instances:print ins.nameSecond way, using get/create methods:from qubell.api.private.platform import QubellPlatformfrom qubell.api.private.manifest import Manifestfrom qubell.api.globals import QUBELL, PROVIDER_CONFIG, DEFAULT_WORKFLOW_SERVICE, DEFAULT_CREDENTIAL_SERVICE, DEFAULT_CLOUD_ACCOUNT_SERVICEfrom qubell.api.private.service import CLOUD_ACCOUNT_TYPE, WORKFLOW_SERVICE_TYPE, COBALT_SECURE_STORE_TYPE# Connect to platformplatform = QubellPlatform.connect(user=QUBELL['user'], password=QUBELL['password'], tenant=QUBELL['tenant'])##### Organizationorg = platform.organization(name='DEFAULT_ORG')# After executing this code, organization "DEFAULT_ORG" would be created (if not exists) or initialized (if exists)##### Environment# Usually environment consists of cloud account, keystore service and workflow service. So, we need to add these services to our organization, then add them to our environment:def prepare_env(org):# Add services to organizationkey_service = org.service(type=COBALT_SECURE_STORE_TYPE, name=DEFAULT_CREDENTIAL_SERVICE())wf_service = org.service(type=WORKFLOW_SERVICE_TYPE, name=DEFAULT_WORKFLOW_SERVICE())cloud_account = org.service(type=CLOUD_ACCOUNT_TYPE, name=DEFAULT_CLOUD_ACCOUNT_SERVICE(), parameters=PROVIDER_CONFIG)# Add services to environmentenv = org.environment(name='new-environment')env.clean()env.add_service(key_service)env.add_service(wf_service)env.add_service(cloud_account)# Here we regenerate keypairenv.add_policy({"action": "provisionVms","parameter": "publicKeyId","value": key_service.regenerate()['id']})return envenvironment = prepare_env(org)# Now, platform ready to be used. We need only application with valid manifest.##### Application# We need manifest to create application::manifest = Manifest(url='https://raw.githubusercontent.com/qubell/contrib-python-qubell-client/master/sandbox/child.yml')# Creating applicationapp = org.application(manifest=manifest, name='first_app')# Application will be created.# Let's start instance using in env1 :instance = org.create_instance(application=app, environment=environment)# This way we wait instance to came up in 15 minutes or break.assert instance.ready(15)print instance.return_values['child_out.child_output']Platform: UNKNOWN