def main(ctx, config_file, sync): """Calm CLI \b Commonly used commands: calm get apps -> Get list of apps calm get bps -> Get list of blueprints calm launch bp --app_name Fancy-App-1 MyFancyBlueprint -> Launch a new app from an existing blueprint calm create bp -f sample_bp.py --name Sample-App-3 -> Upload a new blueprint from a python DSL file calm describe app Fancy-App-1 -> Describe an existing app calm app Fancy-App-1 -w my_action -> Run an action on an app calm get runbooks -> Get list of runbooks calm describe runbook MyFancyRunbook -> Describe an existing runbook calm create runbook -f sample_rb.py --name Sample-RB -> Upload a new runbook from a python DSL file calm run runbook MyFancyRunbook -> Runs the existing runbook MyFancyRunbook calm run runbook -f sample_rb.py -> Runs the runbook from a python DSL file calm get execution_history -> Get list of runbook executions calm get endpoints -> Get list of endpoints calm create endpoint -f sample_ep.py --name Sample-Endpoint -> Upload a new endpoint from a python DSL file """ ctx.ensure_object(dict) ctx.obj["verbose"] = True try: validate_version() except Exception: LOG.debug("Could not validate version") pass if config_file: update_config_file_location(config_file=config_file) if sync: Cache.sync()
def update_cache(): """Update the data for dynamic entities stored in the cache""" Cache.sync() Cache.show_data() LOG.info( highlight_text("Cache updated at {}".format(datetime.datetime.now())))
def compile_blueprint(bp_file, no_sync=False): # Sync only if no_sync flag is not set if not no_sync: LOG.info("Syncing cache") Cache.sync() user_bp_module = get_blueprint_module_from_file(bp_file) UserBlueprint = get_blueprint_class_from_module(user_bp_module) if UserBlueprint is None: return None bp_payload = None if isinstance(UserBlueprint, type(SimpleBlueprint)): bp_payload = UserBlueprint.make_bp_dict() else: UserBlueprintPayload, _ = create_blueprint_payload(UserBlueprint) bp_payload = UserBlueprintPayload.get_dict() # Note - Install/Uninstall runbooks are not actions in Packages. # Remove package actions after compiling. cdict = bp_payload["spec"]["resources"] for package in cdict["package_definition_list"]: if "action_list" in package: del package["action_list"] return bp_payload
def update_cache(obj, entity_type): """Update the data for dynamic entities stored in the cache""" click.echo(highlight_text("Updating cache ...")) Cache.sync(entity_type) show_cache(obj) click.echo( highlight_text("Cache updated at {}".format(datetime.datetime.now())))
def update_cache(obj, entity_type): """Update the data for dynamic entities stored in the cache""" LOG.debug("Updating cache") Cache.sync(entity_type) LOG.debug("Success") show_cache(obj) LOG.info(highlight_text("Cache updated at {}".format(datetime.datetime.now())))
def update_cache(entity_type): """Update the data for dynamic entities stored in the cache""" LOG.debug("Updating cache") # Update api cache Cache.sync(entity_type) # Update version cache Version.sync() LOG.debug("Success") show_cache() LOG.info(highlight_text("Cache updated at {}".format(datetime.datetime.now())))
def compile_blueprint(bp_file, no_sync=False): # Sync only if no_sync flag is not set if not no_sync: Cache.sync() user_bp_module = get_blueprint_module_from_file(bp_file) UserBlueprint = get_blueprint_class_from_module(user_bp_module) if UserBlueprint is None: return None bp_payload = None if isinstance(UserBlueprint, type(SimpleBlueprint)): bp_payload = UserBlueprint.make_bp_dict() else: UserBlueprintPayload, _ = create_blueprint_payload(UserBlueprint) bp_payload = UserBlueprintPayload.get_dict() return bp_payload
def init_bp(bp_name, dir_name, provider_type): bp_name = bp_name.strip().split()[0].title() bp_dir, local_dir, key_dir, script_dir = make_bp_dirs(dir_name, bp_name) # sync cache LOG.info("Syncing cache") Cache.sync() LOG.info("Success") # Creating keys LOG.info("Generating keys for credentials") create_cred_keys(key_dir) LOG.info("Success") # create scripts create_scripts(script_dir) create_bp_file(bp_dir, bp_name, provider_type)
def init_bp(service_name, dir_name, provider_type): bp_name = "{}Blueprint".format(service_name, ) bp_dir, local_dir, key_dir, script_dir = make_bp_dirs(dir_name, bp_name) # sync cache LOG.info("Syncing cache") Cache.sync() LOG.info("Success") # Creating keys LOG.info("Generating keys for credentials") create_cred_keys(key_dir) LOG.info("Success") # create scripts create_scripts(script_dir) create_bp_file(bp_dir, service_name, provider_type)
def main(ctx, config_file, sync): """Calm CLI \b Commonly used commands: calm get apps -> Get list of apps calm get bps -> Get list of blueprints calm launch bp --app_name Fancy-App-1 MyFancyBlueprint -> Launch a new app from an existing blueprint calm create bp -f sample_bp.py --name Sample-App-3 -> Upload a new blueprint from a python DSL file calm describe app Fancy-App-1 -> Describe an existing app calm app Fancy-App-1 -w my_action -> Run an action on an app """ ctx.ensure_object(dict) ctx.obj["verbose"] = True try: validate_version() except Exception: LOG.debug("Could not validate version") pass if config_file: get_config(config_file=config_file) if sync: Cache.sync()
def init_bp(service_name, dir_name, provider_type): bp_name = "{}Blueprint".format(service_name, ) bp_dir, local_dir, key_dir, script_dir = make_bp_dirs(dir_name, bp_name) # sync cache Cache.sync() # Getting the subnet registered to the project client = get_api_client() config = get_config() project_name = config["PROJECT"].get("name", "default") project_uuid = Cache.get_entity_uuid("PROJECT", project_name) res, err = client.project.read(project_uuid) if err: raise Exception("[{}] - {}".format(err["code"], err["error"])) res = res.json() subnets = res["status"]["project_status"]["resources"].get( "subnet_reference_list", []) if not subnets: raise Exception("no subnets registered !!!") default_subnet = subnets[0]["name"] create_bp_file(bp_dir, service_name, default_subnet, provider_type) # Creating keys create_cred_keys(key_dir) # create scripts create_scripts(script_dir)
def sync_cache(): Cache.sync()
def sync_cache(): click.echo("Updating Cache ... ", nl=False) Cache.sync() click.echo("[Success]")
def sync_cache(): LOG.info("Updating Cache") Cache.sync() LOG.info("Success")