Class: Sfp::Module::Shell

Inherits:
Object
  • Object
show all
Includes:
Resource
Defined in:
lib/sfpagent/module.rb

Instance Attribute Summary collapse

Attributes included from Resource

#model, #parent, #path, #state, #synchronized

Instance Method Summary collapse

Methods included from Resource

#init, resolve, #use_http_proxy?

Constructor Details

#initialize(metadata) ⇒ Shell

Returns a new instance of Shell.



173
174
175
176
177
178
179
# File 'lib/sfpagent/module.rb', line 173

def initialize()
	### set module's home directory
	@home = [:home]

	### set main shell command
	@main = @home + '/main'
end

Instance Attribute Details

#homeObject (readonly)

Returns the value of attribute home.



171
172
173
# File 'lib/sfpagent/module.rb', line 171

def home
  @home
end

#mainObject (readonly)

Returns the value of attribute main.



171
172
173
# File 'lib/sfpagent/module.rb', line 171

def main
  @main
end

Instance Method Details

#execute(name, parameters = {}) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/sfpagent/module.rb', line 189

def execute(name, parameters={})
	result = invoke({
		:command => :execute,
		:procedure => name.split('.').last,
		:parameters => parameters,
		:model => @model,
		:path => @path
	})
	if result['status'] != 'ok'
		log.error "Error in executing #{name} - description: #{result['description']}"
		false
	else
		true
	end
end

#update_stateObject



181
182
183
184
185
186
187
# File 'lib/sfpagent/module.rb', line 181

def update_state
	@state = invoke({
		:command => :state,
		:model => @model,
		:path => @path
	})
end