Sha256: 877f2ed0ba1bfec31ac5cdf7293c0ace8fcbc972484c9ebfee593ceed56f14b2

Contents?: true

Size: 876 Bytes

Versions: 3

Compression:

Stored size: 876 Bytes

Contents

require 'rubygems'
require 'json'

class Sfp::Module::OS
	include Sfp::Resource

	def update_state
		@state['running'] = true
		#@state['auto_upgrade'] = @model['auto_upgrade']

		# get memory info
		if `which free`.strip != ''
			mem = `free`.split("\n")[1].split(" ")
			@state["memory_total"] = mem[1].to_i
			@state["memory_free"] = mem[3].to_i
		else
			@state["memory_total"] = @state["memory_free"] = -1
		end

		# get platform, architecture, kernel version
		@state["type"] = `uname -s`.strip
		@state["version"] = `uname -r`.strip
		@state["arch"] = `uname -p`.strip
		@state["platform"] = (File.exist?('/etc/issue') ? `cat /etc/issue`.strip : '')
	end

	def apply(p={})
		self.upgrade if @model['auto_upgrade']
	end

	def upgrade(p={})
		return !!system('apt-get update; apt-get upgrade -y')
	end

	def stop(p={})
		return !!system('/sbin/shutdown -h now')
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nuri-0.5.3 modules/os/os.rb
nuri-0.5.2 modules/os/os.rb
nuri-0.5.1 modules/os/os.rb