Class: Proxy::RemoteExecution::Ssh::Dispatcher::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_proxy_remote_execution_ssh/dispatcher.rb

Overview

command comming from action

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Command

Returns a new instance of Command.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/smart_proxy_remote_execution_ssh/dispatcher.rb', line 12

def initialize(data)
  validate!(data)

  @id               = data[:id]
  @host             = data[:host]
  @ssh_user         = data[:ssh_user]
  @effective_user   = data[:effective_user]
  @script           = data[:script]
  @host_public_key  = data[:host_public_key]
  @suspended_action = data[:suspended_action]
end

Instance Attribute Details

#effective_userObject (readonly)

Returns the value of attribute effective_user.



10
11
12
# File 'lib/smart_proxy_remote_execution_ssh/dispatcher.rb', line 10

def effective_user
  @effective_user
end

#hostObject (readonly)

Returns the value of attribute host.



10
11
12
# File 'lib/smart_proxy_remote_execution_ssh/dispatcher.rb', line 10

def host
  @host
end

#host_public_keyObject (readonly)

Returns the value of attribute host_public_key.



10
11
12
# File 'lib/smart_proxy_remote_execution_ssh/dispatcher.rb', line 10

def host_public_key
  @host_public_key
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/smart_proxy_remote_execution_ssh/dispatcher.rb', line 10

def id
  @id
end

#scriptObject (readonly)

Returns the value of attribute script.



10
11
12
# File 'lib/smart_proxy_remote_execution_ssh/dispatcher.rb', line 10

def script
  @script
end

#ssh_userObject (readonly)

Returns the value of attribute ssh_user.



10
11
12
# File 'lib/smart_proxy_remote_execution_ssh/dispatcher.rb', line 10

def ssh_user
  @ssh_user
end

#suspended_actionObject (readonly)

Returns the value of attribute suspended_action.



10
11
12
# File 'lib/smart_proxy_remote_execution_ssh/dispatcher.rb', line 10

def suspended_action
  @suspended_action
end

Instance Method Details

#validate!(data) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
27
28
# File 'lib/smart_proxy_remote_execution_ssh/dispatcher.rb', line 24

def validate!(data)
  required_fields = [:id, :host, :ssh_user, :script, :suspended_action]
  missing_fields = required_fields.find_all { |f| !data[f] }
  raise ArgumentError, "Missing fields: #{missing_fields}" unless missing_fields.empty?
end