class DTK::Client::Workspace

Public Class Methods

all_children() click to toggle source

this includes children of children

# File lib/commands/thor/workspace.rb, line 120
def self.all_children()
  # [:node, :component, :attribute]
  [:node]
end
extended_context() click to toggle source

using extended_context when we want to use autocomplete from other context e.g. we are in assembly/apache context and want to create-component we will use extended context to add component-templates to autocomplete

# File lib/commands/thor/workspace.rb, line 65
def self.extended_context()
  {
    :context => {
      :add_component => "component_template",
      :create_node => "node_template",
      :create_node_group => "node_template",
      :add_component_dependency => "component_template",
      :set_target => 'target'
    },
    :command => {
      :edit_component_module => {
        :endpoint => "assembly",
        :url => "assembly/info_about",
        :opts => {:subtype=>"instance", :about=>"modules"}
      },
      :push_component_module_updates => {
        :endpoint => "assembly",
        :url => "assembly/info_about",
        :opts => {:subtype=>"instance", :about=>"modules"}
      },
      :delete_node => {
        :endpoint => "assembly",
        :url => "assembly/get_nodes_without_node_groups"
      },
      :delete_node_group => {
        :endpoint => "assembly",
        :url => "assembly/get_node_groups"
      },
      :pull_base_component_module => {
        :endpoint => "assembly",
        :url => "assembly/info_about",
        :opts => {:subtype=>"instance", :about=>"modules"}
      },
      :action_info => {
        :endpoint => "assembly",
        :url => "assembly/task_action_list"
      },
      :exec => {
        :endpoint => "assembly",
        :url => "assembly/list_actions"
      },
      :exec_sync => {
        :endpoint => "assembly",
        :url => "assembly/list_actions"
      }
      # TODO: DEPRECATE execute_workflow
      # :execute_workflow => {
      #   :endpoint => "assembly",
      #   :url => "assembly/task_action_list"
      # }
    }
  }
end
invisible_context() click to toggle source
# File lib/commands/thor/workspace.rb, line 58
def self.invisible_context()
  [:node]
end
multi_context_children() click to toggle source
# File lib/commands/thor/workspace.rb, line 125
def self.multi_context_children()
  [[:utils],[:node, :utils]]
end
override_allowed_methods() click to toggle source

:all => include both for commands with command and identifier :command_only => only on command level :identifier_only => only on identifier level for given entity (command)

# File lib/commands/thor/workspace.rb, line 144
    def self.override_allowed_methods()
      return DTK::Shell::OverrideTasks.new({
        :all => {
          :node      => [
            # ['delete-component',"delete-component COMPONENT-ID [-y]","# Delete component from assembly's node"],
            # ['list-attributes',"list-attributes","# List attributes associated with workspace's node."],
            # ['list-components',"list-components","# List components associated with workspace's node."]
          ],
          :component => [
            ['list-attributes',"list-attributes","# List attributes associated with given component."]
          ]
        },
        :command_only => {
          :attribute => [
            ['list-attributes',"list-attributes","# List attributes."]
          ],
          :node => [
            # ['delete',"delete NAME/ID [-y] ","# Delete component from workspace."],
            ['delete',"delete NODE-NAME/ID [-y] ","# Delete node, terminating it if the node has been spun up."],
            ['list',"list","# List nodes."]
          ],
          :component => [
            ['delete',"delete COMPONENT-NAME/ID [-y] ","# Delete component from workspace."],
            ['list-components',"list-components","# List components."]
          ],
          :utils => [
# TODO: DTK-2027 might subsume by the dtk actions; currently server changes does not support this command
#            ['execute-tests',"execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]","# Execute tests. --component filters execution per component, --timeout changes default execution timeout."],
            ['get-netstats',"get-netstats","# Get netstats."],
            ['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
            ['grep',"grep LOG-PATH NODE-ID-PATTERN GREP-PATTERN [--first]","# Grep log from multiple nodes. --first option returns first match (latest log entry)."],
            ['tail',"tail LOG-PATH NODE-NAME  [REGEX-PATTERN] [--more]","# Tail specified number of lines from log. CTRL+C to quit."]
          ]
        },
        :identifier_only => {
          :node => [
            ['add-component',"add-component COMPONENT","# Add a component to the node."],
            ['delete-component',"delete-component COMPONENT-NAME [-y]","# Delete component from workspace's node"],
            ['info',"info","# Return info about node instance belonging to given workspace."],
            # ['link-attributes', "link-attributes TARGET-ATTR-TERM SOURCE-ATTR-TERM", "# Set TARGET-ATTR-TERM to SOURCE-ATTR-TERM."],
            ['list-attributes',"list-attributes","# List attributes associated with workspace's node."],
            ['list-components',"list-components","# List components associated with workspace's node."],
            ['set-attribute',"set-attribute ATTRIBUTE-NAME [VALUE] [-u]","# (Un)Set attribute value. The option -u will unset the attribute's value."],
            ['start', "start", "# Start node instance."],
            ['stop', "stop", "# Stop node instance."],
            ['ssh', "ssh REMOTE-USER [-i PATH-TO-PEM]","# SSH into node, optional parameters are path to identity file."]
          ],

          :component => [
            ['info',"info","# Return info about component instance belonging to given node."],
            ['edit',"edit","# Edit component module related to given component."],
            # ['edit-dsl',"edit-dsl","# Edit component module dsl file related to given component."],
            ['link-components',"link-components ANTECEDENT-CMP-NAME [DEPENDENCY-NAME]","#Link components to satisfy component dependency relationship."],
            ['list-component-links',"list-component-links","# List component's links to other components."]
            #['unlink-components',"unlink-components SERVICE-TYPE","# Delete service link on component."]
            # ['create-attribute',"create-attribute SERVICE-TYPE DEP-ATTR ARROW BASE-ATTR","# Create an attribute to service link."],
          ],
          :attribute => [
            ['info',"info","# Return info about attribute instance belonging to given component."]
          ]
        }
      }, [:utils])
    end
pretty_print_cols() click to toggle source
# File lib/commands/thor/workspace.rb, line 50
def self.pretty_print_cols()
  PPColumns.get(:assembly)
end
valid_child?(name_of_sub_context) click to toggle source
# File lib/commands/thor/workspace.rb, line 129
def self.valid_child?(name_of_sub_context)
  return Workspace.valid_children().include?(name_of_sub_context.to_sym)
end
valid_children() click to toggle source
# File lib/commands/thor/workspace.rb, line 54
def self.valid_children()
  [:utils]
end
validation_list(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 133
def self.validation_list(context_params)
  get_cached_response(:workspace, "assembly/list_with_workspace", {})
end
whoami() click to toggle source
# File lib/commands/thor/workspace.rb, line 46
def self.whoami()
  return :workspace, "assembly/list", {:subtype  => 'instance'}
end

Public Instance Methods

action_info(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 581
def action_info(context_params)
  action_info_aux(context_params)
end
add_component(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 329
def add_component(context_params)
  response = create_component_aux(context_params)
  return response unless response.ok?

  @@invalidate_map << :service
  @@invalidate_map << :service_node

  response
end
cancel_task(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 209
def cancel_task(context_params)
  cancel_task_aux(context_params)
end
converge(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 254
def converge(context_params)
  opts = {}
  opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
  converge_aux(context_params, opts)
end
create_assembly(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 293
def create_assembly(context_params)
  workspace_id, service_module_full_name, assembly_template_name = context_params.retrieve_arguments([:workspace_id!,:option_1!,:option_2!],method_argument_names)

  # need default_namespace for create-assembly because need to check if local service-module directory existst in promote_assembly_aux
  resp = post rest_url("namespace/default_namespace_name")
  return resp unless resp.ok?
  default_namespace = resp.data

  opts = {:default_namespace => default_namespace}
  opts.merge!(:description => options.description) if options.description
  response = promote_assembly_aux(:create,workspace_id,service_module_full_name,assembly_template_name,opts)
  return response unless response.ok?

  if options.purge?
    response = purge_aux(context_params)
    return response unless response.ok?
  end

  @@invalidate_map << :assembly
  @@invalidate_map << :service

  Response::Ok.new()
end
create_attribute(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 321
def create_attribute(context_params)
  create_attribute_aux(context_params)
end
create_node(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 341
def create_node(context_params)
  response = create_node_aux(context_params)
  return response unless response.ok?

  @@invalidate_map << :assembly
  @@invalidate_map << :assembly_node
  @@invalidate_map << :service
  @@invalidate_map << :service_node
  @@invalidate_map << :workspace
  @@invalidate_map << :workspace_node

  message = "Created node '#{response.data["display_name"]}'."
  DTK::Client::OsUtil.print(message, :yellow)
end
create_node_group(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 358
def create_node_group(context_params)
  response = create_node_group_aux(context_params)
  return response unless response.ok?

  @@invalidate_map << :assembly
  @@invalidate_map << :assembly_node
  @@invalidate_map << :service
  @@invalidate_map << :service_node
  @@invalidate_map << :workspace
  @@invalidate_map << :workspace_node

  message = "Created node group '#{response.data["display_name"]}'."
  DTK::Client::OsUtil.print(message, :yellow)
end
delete(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 380
def delete(context_params)
  if context_params.is_last_command_eql_to?(:node)
    response = delete_node_aux(context_params)
    @@invalidate_map << :service_node

    response
  elsif context_params.is_last_command_eql_to?(:component)
    response = delete_component_aux(context_params)
    return response unless response.ok?
    @@invalidate_map << :service_node_component

    response
  end
  # delete_aux(context_params)
end
delete_component(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 399
def delete_component(context_params)
  response = delete_component_aux(context_params)

  @@invalidate_map << :service
  @@invalidate_map << :service_node
  @@invalidate_map << :service_node_component

  return response
end
delete_node(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 412
def delete_node(context_params)
  response = delete_node_aux(context_params)

  @@invalidate_map << :assembly
  @@invalidate_map << :assembly_node
  @@invalidate_map << :service
  @@invalidate_map << :service_node
  @@invalidate_map << :workspace
  @@invalidate_map << :workspace_node

  return response
end
delete_node_group(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 427
def delete_node_group(context_params)
  response = delete_node_group_aux(context_params)

  @@invalidate_map << :assembly
  @@invalidate_map << :assembly_node
  @@invalidate_map << :service
  @@invalidate_map << :service_node
  @@invalidate_map << :workspace
  @@invalidate_map << :workspace_node

  return response
end
destroy_and_reset_nodes(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 614
def destroy_and_reset_nodes(context_params)
  destroy_and_reset_nodes_aux(context_params)
end
edit_action(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 457
def edit_action(context_params)
  edit_or_create_workflow_aux(context_params)
end
edit_attributes(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 465
def edit_attributes(context_params)
  response = edit_attributes_aux(context_params)

  @@invalidate_map << :assembly
  @@invalidate_map << :assembly_node
  @@invalidate_map << :service
  @@invalidate_map << :service_node
  @@invalidate_map << :workspace
  @@invalidate_map << :workspace_node

  response
end
edit_component_module(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 446
def edit_component_module(context_params)
  edit_module_aux(context_params)
end
exec(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 219
def exec(context_params)
  exec_aux(context_params)
end
exec_sync(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 224
def exec_sync(context_params)
  exec_sync_aux(context_params)
end
get_netstats(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 480
def get_netstats(context_params)
  get_netstats_aux(context_params)
end
get_ps(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 498
def get_ps(context_params)
  get_ps_aux(context_params)
end
get_workspace_name(workspace_id) click to toggle source
# File lib/commands/thor/workspace.rb, line 41
def get_workspace_name(workspace_id)
  get_name_from_id_helper(workspace_id)
end
grant_access(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 511
def grant_access(context_params)
  grant_access_aux(context_params)
end
grep(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 505
def grep(context_params)
  grep_aux(context_params)
end
info(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 527
def info(context_params)
  info_aux(context_params)
end
list(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 537
def list(context_params)
  if context_params.is_last_command_eql_to?(:node)
    list_nodes_aux(context_params)
  end
end
list_actions(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 587
def list_actions(context_params)
  list_actions_aux(context_params)
end
list_attributes(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 550
def list_attributes(context_params)
  list_attributes_aux(context_params)
end
list_component_modules(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 571
def list_component_modules(context_params)
  list_modules_aux(context_params)
end
list_components(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 556
def list_components(context_params)
  list_components_aux(context_params)
end
list_nodes(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 561
def list_nodes(context_params)
  list_nodes_aux(context_params)
end
list_ssh_access(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 522
def list_ssh_access(context_params)
  list_ssh_access_aux(context_params)
end
list_tasks(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 576
def list_tasks(context_params)
  list_tasks_aux(context_params)
end
list_violations(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 597
def list_violations(context_params)
  list_violations_aux(context_params)
end
print_includes(context_params) click to toggle source
pull_base_component_module(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 269
def pull_base_component_module(context_params)
  pull_base_component_module_aux(context_params)
end
purge(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 608
def purge(context_params)
  purge_aux(context_params)
end
push_assembly_updates(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 274
def push_assembly_updates(context_params)
  workspace_id, qualified_assembly_name = context_params.retrieve_arguments([:workspace_id!,:option_1!],method_argument_names)
  if qualified_assembly_name =~ /(^[^\/]*)\/([^\/]*$)/
    service_module_name, assembly_template_name = [$1,$2]
  else
    raise DtkError,"The term (#{qualified_assembly_name}) must have form SERVICE-MODULE-NAME/ASSEMBLY-NAME"
  end
  response = promote_assembly_aux(:update,workspace_id, service_module_name, assembly_template_name)
  return response unless response.ok?
  @@invalidate_map << :assembly
  Response::Ok.new()
end
push_component_module_updates(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 262
def push_component_module_updates(context_params)
  push_module_updates_aux(context_params)
end
revoke_access(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 517
def revoke_access(context_params)
  revoke_access_aux(context_params)
end
set_attribute(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 627
def set_attribute(context_params)
  response = set_attribute_aux(context_params)
  return response unless response.ok?

  @@invalidate_map << :assembly
  @@invalidate_map << :assembly_node
  @@invalidate_map << :service
  @@invalidate_map << :service_node
  @@invalidate_map << :workspace
  @@invalidate_map << :workspace_node

  response
end
set_required_attributes(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 642
def set_required_attributes(context_params)
  workspace_id = context_params.retrieve_arguments([:workspace_id!],method_argument_names)
  set_required_attributes_aux(workspace_id,:assembly,:instance)
end
set_target(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 619
def set_target(context_params)
  set_target_aux(context_params)
end
start(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 649
def start(context_params)
  start_aux(context_params)
end
stop(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 655
def stop(context_params)
  stop_aux(context_params)
end
tail(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 662
def tail(context_params)
  tail_aux(context_params)
end
task_action_detail(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 681
def task_action_detail(context_params)
  task_action_detail_aw_aux(context_params)
end
task_status(context_params) click to toggle source
# File lib/commands/thor/workspace.rb, line 676
def task_status(context_params)
  task_status_aw_aux(context_params)
end