def file_update_all(backend, message, dryrun): """ Update all of the changed files for this Recipe """ kitchen = DKCloudCommandRunner.which_kitchen_name() if kitchen is None: raise click.ClickException('You must be in a Kitchen') recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder') recipe = DKRecipeDisk.find_recipe_name() if dryrun: click.secho( '%s - Display all changed files in Recipe (%s) in Kitchen(%s) with message (%s)' % (get_datetime(), recipe, kitchen, message), fg='green') else: click.secho( '%s - Updating all changed files in Recipe (%s) in Kitchen(%s) with message (%s)' % (get_datetime(), recipe, kitchen, message), fg='green') check_and_print( DKCloudCommandRunner.update_all_files(backend.dki, kitchen, recipe, recipe_dir, message, dryrun))
def recipe_status(backend): """ Compare local recipe to remote recipe for the current recipe. """ kitchen = DKCloudCommandRunner.which_kitchen_name() if kitchen is None: raise click.ClickException('You are not in a Kitchen') recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder') recipe_name = DKRecipeDisk.find_recipe_name() click.secho("%s - Getting the status of Recipe '%s' in Kitchen '%s'\n\tversus directory '%s'" % ( get_datetime(), recipe_name, kitchen, recipe_dir), fg='green') check_and_print(DKCloudCommandRunner.recipe_status(backend.dki, kitchen, recipe_name, recipe_dir))
def order_delete(backend, kitchen, order_id): """ Delete one order or all orders in a kitchen """ use_kitchen = Backend.get_kitchen_name_soft(kitchen) print use_kitchen if use_kitchen is None and order_id is None: raise click.ClickException('You must specify either a kitchen or an order_id or be in a kitchen directory') if order_id is not None: click.secho('%s - Delete an Order using id %s' % (get_datetime(), order_id), fg='green') check_and_print(DKCloudCommandRunner.delete_one_order(backend.dki, order_id)) else: click.secho('%s - Delete all orders in Kitchen %s' % (get_datetime(), use_kitchen), fg='green') check_and_print(DKCloudCommandRunner.delete_all_order(backend.dki, use_kitchen))
def secret_list(backend,path): """ List all Secrets """ click.echo(click.style('%s - Getting the list of secrets' % get_datetime(), fg='green')) check_and_print( DKCloudCommandRunner.secret_list(backend.dki,path))
def recipe_get(backend, recipe): """ Get the latest files for this recipe. """ recipe_root_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_root_dir is None: if recipe is None: raise click.ClickException("\nPlease change to a recipe folder or provide a recipe name arguement") # raise click.ClickException('You must be in a Recipe folder') kitchen_root_dir = DKKitchenDisk.is_kitchen_root_dir() if not kitchen_root_dir: raise click.ClickException("\nPlease change to a recipe folder or a kitchen root dir.") recipe_name = recipe start_dir = DKKitchenDisk.find_kitchen_root_dir() else: recipe_name = DKRecipeDisk.find_recipe_name() if recipe is not None: if recipe_name != recipe: raise click.ClickException("\nThe recipe name argument '%s' is inconsistent with the current directory '%s'" % (recipe, recipe_root_dir)) start_dir = recipe_root_dir kitchen_name = Backend.get_kitchen_name_soft() click.secho("%s - Getting the latest version of Recipe '%s' in Kitchen '%s'" % (get_datetime(), recipe_name, kitchen_name), fg='green') check_and_print(DKCloudCommandRunner.get_recipe(backend.dki, kitchen_name, recipe_name, start_dir))
def secret_delete(backend,path): """ Delete a secret """ click.echo(click.style('%s - Deleting secret' % get_datetime(), fg='green')) check_and_print( DKCloudCommandRunner.secret_delete(backend.dki,path))
def secret_delete(backend,path): """ Checks if a secret exists """ click.echo(click.style('%s Checking secret' % get_datetime(), fg='green')) check_and_print( DKCloudCommandRunner.secret_exists(backend.dki,path))
def secret_delete(backend, path): """ Delete a secret """ click.echo(click.style('%s - Deleting secret' % get_datetime(), fg='green')) check_and_print(DKCloudCommandRunner.secret_delete(backend.dki, path))
def recipe_get(backend, recipe): """ Get the latest files for this recipe. """ recipe_root_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_root_dir is None: if recipe is None: raise click.ClickException( "\nPlease change to a recipe folder or provide a recipe name arguement" ) # raise click.ClickException('You must be in a Recipe folder') kitchen_root_dir = DKKitchenDisk.is_kitchen_root_dir() if not kitchen_root_dir: raise click.ClickException( "\nPlease change to a recipe folder or a kitchen root dir.") recipe_name = recipe start_dir = DKKitchenDisk.find_kitchen_root_dir() else: recipe_name = DKRecipeDisk.find_recipe_name() if recipe is not None: if recipe_name != recipe: raise click.ClickException( "\nThe recipe name argument '%s' is inconsistent with the current directory '%s'" % (recipe, recipe_root_dir)) start_dir = recipe_root_dir kitchen_name = Backend.get_kitchen_name_soft() click.secho( "%s - Getting the latest version of Recipe '%s' in Kitchen '%s'" % (get_datetime(), recipe_name, kitchen_name), fg='green') check_and_print( DKCloudCommandRunner.get_recipe(backend.dki, kitchen_name, recipe_name, start_dir))
def kitchen_config(backend, kitchen, add, get, unset, listall): """ Get and Set Kitchen variable overrides """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) check_and_print(DKCloudCommandRunner.config_kitchen(backend.dki, use_kitchen, add, get, unset, listall))
def delete_orderrun(backend, orderrun_id): """ Delete the orderrun specified by the argument. """ click.secho('%s - Deleting orderrun %s' % (get_datetime(), orderrun_id), fg='green') check_and_print( DKCloudCommandRunner.delete_orderrun(backend.dki, orderrun_id.strip()))
def secret_list(backend, path): """ List all Secrets """ click.echo( click.style('%s - Getting the list of secrets' % get_datetime(), fg='green')) check_and_print(DKCloudCommandRunner.secret_list(backend.dki, path))
def order_resume(backend, orderrun_id): """ Resumes a failed order run """ click.secho('%s - Resuming orderrun %s' % (get_datetime(), orderrun_id), fg='green') check_and_print( DKCloudCommandRunner.order_resume(backend.dki, orderrun_id.strip()))
def order_stop(backend, order_id): """ Stop an order - Turn off the serving generation ability of an order. Stop any running jobs. Keep all state around. """ if order_id is None: raise click.ClickException('invalid order id %s' % order_id) click.secho('%s - Stop order id %s' % (get_datetime(), order_id), fg='green') check_and_print(DKCloudCommandRunner.stop_order(backend.dki, order_id))
def kitchen_list(backend): """ List all Kitchens """ click.echo( click.style('%s - Getting the list of kitchens' % get_datetime(), fg='green')) check_and_print(DKCloudCommandRunner.list_kitchen(backend.dki))
def recipe_list(backend, kitchen): """ List the Recipes in a Kitchen """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) click.secho("%s - Getting the list of Recipes for Kitchen '%s'" % (get_datetime(), use_kitchen), fg='green') check_and_print(DKCloudCommandRunner.list_recipe(backend.dki, use_kitchen))
def order_stop(backend, order_run_id): """ Stop the run of an order - Stop the running order and keep all state around. """ if order_run_id is None: raise click.ClickException('invalid order id %s' % order_run_id) click.secho('%s - Stop order id %s' % (get_datetime(), order_run_id), fg='green') check_and_print(DKCloudCommandRunner.stop_orderrun(backend.dki, order_run_id.strip()))
def recipe_status(backend): """ Compare local recipe to remote recipe for the current recipe. """ kitchen = DKCloudCommandRunner.which_kitchen_name() if kitchen is None: raise click.ClickException('You are not in a Kitchen') recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder') recipe_name = DKRecipeDisk.find_recipe_name() click.secho( "%s - Getting the status of Recipe '%s' in Kitchen '%s'\n\tversus directory '%s'" % (get_datetime(), recipe_name, kitchen, recipe_dir), fg='green') check_and_print( DKCloudCommandRunner.recipe_status(backend.dki, kitchen, recipe_name, recipe_dir))
def recipe_create(backend, kitchen, name): """ Create a new Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) click.secho("%s - Creating Recipe %s for Kitchen '%s'" % (get_datetime(), name, use_kitchen), fg='green') check_and_print(DKCloudCommandRunner.recipe_create(backend.dki, use_kitchen,name))
def check_in_kitchen_root_folder_and_get_name(): """ Ensures that the caller is in a kitchen folder. :return: kitchen name or None """ in_kitchen = DKCloudCommandRunner.which_kitchen_name() if in_kitchen is None: raise click.ClickException("Please change directory to a kitchen folder.") else: return in_kitchen
def active_serving_watcher(backend, kitchen, period): """ Watches all cooking Recipes in a Kitchen Provide the kitchen name as an argument or be in a Kitchen folder. """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) click.secho('%s - Watching Active OrderRun Changes in Kitchen %s' % (get_datetime(), use_kitchen), fg='green') DKCloudCommandRunner.watch_active_servings(backend.dki, use_kitchen, period) while True: try: DKCloudCommandRunner.join_active_serving_watcher_thread_join() if not DKCloudCommandRunner.watcher_running(): break except KeyboardInterrupt: print 'KeyboardInterrupt' exit_gracefully(None, None) exit(0)
def kitchen_delete(backend, kitchen): """ Provide the name of the kitchen to delete """ click.secho('%s - Deleting kitchen %s' % (get_datetime(), kitchen), fg='green') master = 'master' if kitchen.lower() != master.lower(): check_and_print(DKCloudCommandRunner.delete_kitchen(backend.dki, kitchen)) else: raise click.ClickException('Cannot delete the kitchen called %s' % master)
def get_kitchen_name_soft(given_kitchen=None): """ Get the kitchen name if it is available. :return: kitchen name or None """ if given_kitchen is not None: return given_kitchen else: in_kitchen = DKCloudCommandRunner.which_kitchen_name() return in_kitchen
def kitchen_create(backend, parent, kitchen): """ Create a new kitchen """ click.secho('%s - Creating kitchen %s from parent kitchen %s' % (get_datetime(), kitchen, parent), fg='green') master = 'master' if kitchen.lower() != master.lower(): check_and_print(DKCloudCommandRunner.create_kitchen(backend.dki, parent, kitchen)) else: raise click.ClickException('Cannot create a kitchen called %s' % master)
def file_update_all(backend, message, dryrun): """ Update all of the changed files for this Recipe """ kitchen = DKCloudCommandRunner.which_kitchen_name() if kitchen is None: raise click.ClickException('You must be in a Kitchen') recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder') recipe = DKRecipeDisk.find_recipe_name() if dryrun: click.secho('%s - Display all changed files in Recipe (%s) in Kitchen(%s) with message (%s)' % (get_datetime(), recipe, kitchen, message), fg='green') else: click.secho('%s - Updating all changed files in Recipe (%s) in Kitchen(%s) with message (%s)' % (get_datetime(), recipe, kitchen, message), fg='green') check_and_print(DKCloudCommandRunner.update_all_files(backend.dki, kitchen, recipe, recipe_dir, message, dryrun))
def kitchen_config(backend, kitchen, add, get, unset, listall): """ Get and Set Kitchen variable overrides """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) check_and_print( DKCloudCommandRunner.config_kitchen(backend.dki, use_kitchen, add, get, unset, listall))
def order_stop(backend, order_run_id): """ Stop the run of an order - Stop the running order and keep all state around. """ if order_run_id is None: raise click.ClickException('invalid order id %s' % order_run_id) click.secho('%s - Stop order id %s' % (get_datetime(), order_run_id), fg='green') check_and_print( DKCloudCommandRunner.stop_orderrun(backend.dki, order_run_id.strip()))
def recipe_conflicts(backend): """ See if there are any unresolved conflicts for this recipe. """ recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder.') click.secho("%s - Checking for conflicts on Recipe '%s'" % ( get_datetime(),recipe_name)) recipe_name = DKRecipeDisk.find_recipe_name() check_and_print(DKCloudCommandRunner.get_unresolved_conflicts(recipe_name, recipe_dir))
def kitchen_merge(backend, source_kitchen, target_kitchen): """ Merge two Kitchens """ click.secho('%s - Merging Kitchen %s into Kitchen %s' % (get_datetime(), source_kitchen, target_kitchen), fg='green') check_and_print( DKCloudCommandRunner.merge_kitchens_improved(backend.dki, source_kitchen, target_kitchen))
def check_in_kitchen_root_folder_and_get_name(): """ Ensures that the caller is in a kitchen folder. :return: kitchen name or None """ in_kitchen = DKCloudCommandRunner.which_kitchen_name() if in_kitchen is None: raise click.ClickException( "Please change directory to a kitchen folder.") else: return in_kitchen
def exit_gracefully(signum, frame): # print 'exit_gracefully' # restore the original signal handler as otherwise evil things will happen # in raw_input when CTRL+C is pressed, and our signal handler is not re-entrant DKCloudCommandRunner.stop_watcher() # print 'exit_gracefully stopped watcher' signal(SIGINT, original_sigint) question = False if question is True: try: if raw_input("\nReally quit? (y/n)> ").lower().startswith('y'): exit(1) except (KeyboardInterrupt, SystemExit): print("Ok ok, quitting") exit(1) else: print("Ok ok, quitting now") DKCloudCommandRunner.join_active_serving_watcher_thread_join() exit(1) # restore the exit gracefully handler here signal(SIGINT, exit_gracefully)
def recipe_create(backend, kitchen, name): """ Create a new Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) click.secho("%s - Creating Recipe %s for Kitchen '%s'" % (get_datetime(), name, use_kitchen), fg='green') check_and_print( DKCloudCommandRunner.recipe_create(backend.dki, use_kitchen, name))
def exit_gracefully(signum, frame): # print 'exit_gracefully' # restore the original signal handler as otherwise evil things will happen # in raw_input when CTRL+C is pressed, and our signal handler is not re-entrant DKCloudCommandRunner.stop_watcher() # print 'exit_gracefully stopped watcher' signal(SIGINT, original_sigint) question = False if question is True: try: if input("\nReally quit? (y/n)> ").lower().startswith('y'): exit(1) except (KeyboardInterrupt, SystemExit): print("Ok ok, quitting") exit(1) else: print("Ok ok, quitting now") DKCloudCommandRunner.join_active_serving_watcher_thread_join() exit(1) # restore the exit gracefully handler here signal(SIGINT, exit_gracefully)
def recipe_conflicts(backend): """ See if there are any unresolved conflicts for this recipe. """ recipe_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_dir is None: raise click.ClickException('You must be in a Recipe folder.') recipe_name = DKRecipeDisk.find_recipe_name() click.secho("%s - Checking for conflicts on Recipe '%s'" % (get_datetime(), recipe_name)) recipe_name = DKRecipeDisk.find_recipe_name() check_and_print( DKCloudCommandRunner.get_unresolved_conflicts(recipe_name, recipe_dir))
def secret_write(backend,entry): """ Write a secret """ path,value=entry.split('=') if value.startswith('@'): with open(value[1:]) as vfile: value = vfile.read() click.echo(click.style('%s - Writing secret' % get_datetime(), fg='green')) check_and_print( DKCloudCommandRunner.secret_write(backend.dki,path,value))
def order_list(backend, kitchen): """ Apply variables to a Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) click.secho('%s - Get Order information for Kitchen %s' % (get_datetime(), use_kitchen), fg='green') check_and_print( DKCloudCommandRunner.list_order(backend.dki, use_kitchen))
def get_kitchen_from_user(kitchen=None): in_kitchen = DKCloudCommandRunner.which_kitchen_name() if kitchen is None and in_kitchen is None: raise click.ClickException("You must provide a kitchen name or be in a kitchen folder.") elif kitchen is not None and in_kitchen is not None: raise click.ClickException( "Please provide a kitchen parameter or change directory to a kitchen folder, not both.\nYou are in Kitchen '%s'" % in_kitchen) if in_kitchen is not None: use_kitchen = in_kitchen else: use_kitchen = kitchen return "ok", use_kitchen
def active_serving_watcher(backend, kitchen, period): """ Watches all cooking Recipes in a Kitchen Provide the kitchen name as an argument or be in a Kitchen folder. """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) click.secho('%s - Watching Active OrderRun Changes in Kitchen %s' % (get_datetime(), use_kitchen), fg='green') DKCloudCommandRunner.watch_active_servings(backend.dki, use_kitchen, period) while True: try: DKCloudCommandRunner.join_active_serving_watcher_thread_join() if not DKCloudCommandRunner.watcher_running(): break except KeyboardInterrupt: print('KeyboardInterrupt') exit_gracefully(None, None) exit(0)
def order_list(backend, kitchen): """ Apply variables to a Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) click.secho('%s - Get Order information for Kitchen %s' % (get_datetime(), use_kitchen), fg='green') check_and_print(DKCloudCommandRunner.list_order(backend.dki, use_kitchen))
def kitchen_delete(backend, kitchen): """ Provide the name of the kitchen to delete """ click.secho('%s - Deleting kitchen %s' % (get_datetime(), kitchen), fg='green') master = 'master' if kitchen.lower() != master.lower(): check_and_print( DKCloudCommandRunner.delete_kitchen(backend.dki, kitchen)) else: raise click.ClickException('Cannot delete the kitchen called %s' % master)
def secret_write(backend, entry): """ Write a secret """ path, value = entry.split('=') if value.startswith('@'): with open(value[1:]) as vfile: value = vfile.read() click.echo(click.style('%s - Writing secret' % get_datetime(), fg='green')) check_and_print(DKCloudCommandRunner.secret_write(backend.dki, path, value))
def file_resolve(backend, filepath): """ Mark a conflicted file as resolved, so that a merge can be completed """ recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException('You must be in a recipe folder.') click.secho("%s - Resolving conflicts" % get_datetime()) for file_to_resolve in filepath: if not os.path.exists(file_to_resolve): raise click.ClickException('%s does not exist' % file_to_resolve) check_and_print(DKCloudCommandRunner.resolve_conflict(file_to_resolve))
def kitchen_get(backend, kitchen_name, recipe): """ Get an existing Kitchen """ found_kitchen = DKKitchenDisk.find_kitchen_name() if found_kitchen is not None and len(found_kitchen) > 0: raise click.ClickException("You cannot get a kitchen into an existing kitchen directory structure.") if len(recipe) > 0: click.secho("%s - Getting kitchen '%s' and the recipes %s" % (get_datetime(), kitchen_name, str(recipe)), fg='green') else: click.secho("%s - Getting kitchen '%s'" % (get_datetime(), kitchen_name), fg='green') check_and_print(DKCloudCommandRunner.get_kitchen(backend.dki, kitchen_name, os.getcwd(), recipe))
def order_delete(backend, kitchen, order_id): """ Delete one order or all orders in a kitchen """ use_kitchen = Backend.get_kitchen_name_soft(kitchen) print(use_kitchen) if use_kitchen is None and order_id is None: raise click.ClickException( 'You must specify either a kitchen or an order_id or be in a kitchen directory' ) if order_id is not None: click.secho('%s - Delete an Order using id %s' % (get_datetime(), order_id), fg='green') check_and_print( DKCloudCommandRunner.delete_one_order(backend.dki, order_id)) else: click.secho('%s - Delete all orders in Kitchen %s' % (get_datetime(), use_kitchen), fg='green') check_and_print( DKCloudCommandRunner.delete_all_order(backend.dki, use_kitchen))
def kitchen_create(backend, parent, kitchen): """ Create a new kitchen """ click.secho('%s - Creating kitchen %s from parent kitchen %s' % (get_datetime(), kitchen, parent), fg='green') master = 'master' if kitchen.lower() != master.lower(): check_and_print( DKCloudCommandRunner.create_kitchen(backend.dki, parent, kitchen)) else: raise click.ClickException('Cannot create a kitchen called %s' % master)
def file_delete(backend, kitchen, recipe, message, filepath): """ Delete a Recipe file. Provide the file name and path to the file name, relative to the recipe root """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException('You must be in a recipe folder, or provide a recipe name.') click.secho('%s - Deleting (%s) in Recipe (%s) in kitchen(%s) with message (%s)' % (get_datetime(), filepath, recipe, use_kitchen, message), fg='green') check_and_print(DKCloudCommandRunner.delete_file(backend.dki, use_kitchen, recipe, message, filepath))
def get_kitchen_from_user(kitchen=None): in_kitchen = DKCloudCommandRunner.which_kitchen_name() if kitchen is None and in_kitchen is None: raise click.ClickException( "You must provide a kitchen name or be in a kitchen folder.") elif kitchen is not None and in_kitchen is not None: raise click.ClickException( "Please provide a kitchen parameter or change directory to a kitchen folder, not both.\nYou are in Kitchen '%s'" % in_kitchen) if in_kitchen is not None: use_kitchen = in_kitchen else: use_kitchen = kitchen return "ok", use_kitchen
def file_add(backend, kitchen, recipe, message, filepath): """ Add a newly created file to a Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException('You must be in a recipe folder, or provide a recipe name.') click.secho('%s - Adding File (%s) to Recipe (%s) in kitchen(%s) with message (%s)' % (get_datetime(), filepath, recipe, use_kitchen, message), fg='green') check_and_print(DKCloudCommandRunner.add_file(backend.dki, use_kitchen, recipe, message, filepath))
def recipe_compile(backend, kitchen, recipe, variation): """ Apply variables to a Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException('You must be in a recipe folder, or provide a recipe name.') click.secho('%s - Get the Compiled OrderRun of Recipe %s.%s in Kitchen %s' % (get_datetime(), recipe, variation, use_kitchen), fg='green') check_and_print(DKCloudCommandRunner.get_compiled_serving(backend.dki, use_kitchen, recipe, variation))
def order_run(backend, kitchen, recipe, variation, node): """ Run an order: cook a recipe variation """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException('You must be in a recipe folder, or provide a recipe name.') msg = '%s - Create an Order:\n\tKitchen: %s\n\tRecipe: %s\n\tVariation: %s\n' % (get_datetime(), use_kitchen, recipe, variation) if node is not None: msg += '\tNode: %s\n' % node click.secho(msg, fg='green') check_and_print(DKCloudCommandRunner.create_order(backend.dki, use_kitchen, recipe, variation, node))
def file_add(backend, kitchen, recipe, message, filepath): """ Add a newly created file to a Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException( 'You must be in a recipe folder, or provide a recipe name.') click.secho( '%s - Adding File (%s) to Recipe (%s) in kitchen(%s) with message (%s)' % (get_datetime(), filepath, recipe, use_kitchen, message), fg='green') check_and_print( DKCloudCommandRunner.add_file(backend.dki, use_kitchen, recipe, message, filepath))
def file_delete(backend, kitchen, recipe, message, filepath): """ Delete a Recipe file. Provide the file name and path to the file name, relative to the recipe root """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException( 'You must be in a recipe folder, or provide a recipe name.') click.secho( '%s - Deleting (%s) in Recipe (%s) in kitchen(%s) with message (%s)' % (get_datetime(), filepath, recipe, use_kitchen, message), fg='green') check_and_print( DKCloudCommandRunner.delete_file(backend.dki, use_kitchen, recipe, message, filepath))
def recipe_compile(backend, kitchen, recipe, variation): """ Apply variables to a Recipe """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException( 'You must be in a recipe folder, or provide a recipe name.') click.secho( '%s - Get the Compiled OrderRun of Recipe %s.%s in Kitchen %s' % (get_datetime(), recipe, variation, use_kitchen), fg='green') check_and_print( DKCloudCommandRunner.get_compiled_serving(backend.dki, use_kitchen, recipe, variation))
def order_run(backend, kitchen, recipe, variation, node): """ Run an order: cook a recipe variation """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) if recipe is None: recipe = DKRecipeDisk.find_recipe_name() if recipe is None: raise click.ClickException( 'You must be in a recipe folder, or provide a recipe name.') msg = '%s - Create an Order:\n\tKitchen: %s\n\tRecipe: %s\n\tVariation: %s\n' % ( get_datetime(), use_kitchen, recipe, variation) if node is not None: msg += '\tNode: %s\n' % node click.secho(msg, fg='green') check_and_print( DKCloudCommandRunner.create_order(backend.dki, use_kitchen, recipe, variation, node))
def orderrun_detail(backend, kitchen, summary, nodestatus, runstatus, log, timing, test, all_things, order_id, order_run_id, disp_order_id, disp_order_run_id): """ Display information about an Order-Run """ err_str, use_kitchen = Backend.get_kitchen_from_user(kitchen) if use_kitchen is None: raise click.ClickException(err_str) # if recipe is None: # recipe = DKRecipeDisk.find_reciper_name() # if recipe is None: # raise click.ClickException('You must be in a recipe folder, or provide a recipe name.') pd = dict() if all_things: pd['summary'] = True pd['logs'] = True pd['timingresults'] = True pd['testresults'] = True # pd['state'] = True pd['status'] = True if summary: pd['summary'] = True if log: pd['logs'] = True if timing: pd['timingresults'] = True if test: pd['testresults'] = True if nodestatus: pd['status'] = True if runstatus: pd['runstatus'] = True if disp_order_id: pd['disp_order_id'] = True if disp_order_run_id: pd['disp_order_run_id'] = True # if the user does not specify anything to display, show the summary information if not runstatus and \ not all_things and \ not test and \ not timing and \ not log and \ not nodestatus and \ not summary and \ not disp_order_id and \ not disp_order_run_id: pd['summary'] = True if order_id is not None and order_run_id is not None: raise click.ClickException("Cannot specify both the Order Id and the OrderRun Id") if order_id is not None: pd[DKCloudCommandRunner.ORDER_ID] = order_id.strip() elif order_run_id is not None: pd[DKCloudCommandRunner.ORDER_RUN_ID] = order_run_id.strip() # don't print the green thing if it is just runstatus if not runstatus and not disp_order_id and not disp_order_run_id: click.secho('%s - Display Order-Run details from kitchen %s' % (get_datetime(), use_kitchen), fg='green') check_and_print(DKCloudCommandRunner.orderrun_detail(backend.dki, use_kitchen, pd))
def delete_orderrun(backend, orderrun_id): """ Delete the orderrun specified by the argument. """ click.secho('%s - Deleting orderrun %s' % (get_datetime(), orderrun_id), fg='green') check_and_print(DKCloudCommandRunner.delete_orderrun(backend.dki, orderrun_id.strip()))