def start(): # Here we check existance of given credentials and create services if needed print "Creating ENV" exit = 0 if not user: log.error('No username provided. Set QUBELL_USER env') exit = 1 if not password: log.error('No password provided. Set QUBELL_PASSWORD env') exit = 1 if not api: log.error('No api url provided. Set QUBELL_API env') exit = 1 if exit: sys.exit(1) # Setup access context = Context(user=user, password=password, api=api) # Initialize platform and check access platform = QubellPlatform(context=context) assert platform.authenticate() print "Authorization passed" # Initialize organization organization = platform.organization(name=org) print "Using orgainzation %s" % org if zone: # Need to run tests against zones. Create env for each z = [x for x in organization.list_zones() if x['name'] == zone] if len(z): print "Using zone %s" % zone create_env(organization, z[0]['id']) create_env(organization) create_launcher_apps(organization) print "ENV created"
def start(): # Here we check existance of given credentials and create services if needed print "Creating ENV" exit = 0 if not user: log.error('No username provided. Set QUBELL_USER env') exit = 1 if not password: log.error('No password provided. Set QUBELL_PASSWORD env') exit = 1 if not tenant: log.error('No api url provided. Set QUBELL_TENANT env') exit = 1 if exit: sys.exit(1) # Setup access auth = Auth(user=user, password=password, tenant=tenant) # Initialize platform and check access platform = QubellPlatform(auth=auth) assert platform.authenticate() print "Authorization passed" # Initialize organization organization = platform.organization(name=org) print "Using orgainzation %s" % org if zone: # Need to run tests against zones. Create env for each z = [x for x in organization.list_zones() if x['name'] == zone] if len(z): print "Using zone %s" % zone create_env(organization, z[0]['id']) create_env(organization) create_launcher_apps(organization) print "ENV created"
# Define manifest. We take example from documentation. # TODO: make manifests accessible from docs.qubell.com app_manifest = Manifest(url="https://raw.github.com/qubell/contrib-python-qubell-client/master/qm/hierarchical-main.yml") db_manifest = Manifest(url="https://raw.github.com/qubell/contrib-python-qubell-client/master/qm/hierarchical-db.yml") # Initialize our qubell platform platform = QubellPlatform(context=context) # Try to login assert platform.authenticate() print "Authenticate passed" # Create new organization org = platform.organization(name="python-qubellclient") # Use existing organization # org = platform.organization(id="524f3028e4b0b12cd4de2759") # Init environment (find by name "default") env = org.environment(name='default') # If env is not set up yet, do it. (dirty check) if not env.json()['areProvidersAvailable']: prepare_env(org) print "Prepearing environment" print "Environment initialized" """ We need to create child application that runs database, using db_manifest. After, wee need to create parent application that will use our DB application as a child"""
def main(): # Parse arguments global qubell qubell = cls() parser = argparse.ArgumentParser(description='Tool for launching manifests and checking returnvalues') parser.add_argument('-c', '--config', help='Use provided configuration file') parser.add_argument('-u', '--user', help='User email to access qubell platform') parser.add_argument('-p', '--password', help='User password to access qubell platform') parser.add_argument('-t', '--tenant', help='Link to qubell api') parser.add_argument('-g', '--organization', help='Qubell organization') parser.add_argument('-i', '--appid', help='Application ID launch manifest in') parser.add_argument('-n', '--appname', help='Application name launch manifest in') parser.add_argument('-m', '--manifest', help='Launch single manifest and check it launched') parser.add_argument('-o', '--output', help='Write JUnit report to specified file') parser.add_argument('-v', '--verbose', help='increase output verbosity', action="store_true") parser.add_argument('--debug', action="store_true", help='Show debug info') parser.parse_args(namespace=qubell) # todo improve cfg loading if not qubell.config: qubell.config = 'launcher.cfg' try: cfile = open(qubell.config, 'r') config = yaml.load(cfile, OrderedDictYAMLLoader) log('Config: %s' % config,'debug') except: if qubell.manifest: config = OrderedDict({'cli-manifest': { 'source': qubell.manifest, 'launch': { 'parameters':{}, 'expected':{}, }}}) else: error('No configuration file or manifest provided') if 'qubell' in config.keys(): cfg = config.pop('qubell') if not qubell.user: qubell.user = cfg['user'] if not qubell.password: qubell.password = cfg['password'] if not qubell.tenant: qubell.tenant = cfg['tenant'] if not qubell.appid or qubell.appname: if cfg.has_key('appid'): qubell.appid = cfg['appid'] elif cfg.has_key('appname'): qubell.appname = cfg['appname'] if qubell.verbose: verbosity.append('info') if qubell.debug: verbosity.append('debug') verbosity.append('info') #TODO: get qubell organization be app ID # Inintialize platform platform = QubellPlatform() assert platform.connect(tenant=qubell.tenant, user=qubell.user, password=qubell.password) qubell.organization = platform.organization(name=qubell.organization) process(config) exit_code = 0 for case in test_cases: if case.is_error() or case.is_failure(): exit_code = 1 if qubell.output: publish_result(qubell.output) exit(0) else: publish_result() exit(exit_code)