summaryrefslogtreecommitdiffstats
path: root/lvm2-model.lua
blob: 1a4b6f8472f274db72ad697c27270da5afaebef2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
module(..., package.seeall)

-- Load libraries
require("modelfunctions")
fs = require("acf.fs")
format = require("acf.format")

-- Set variables
local processname = "lvm"
local packagename = "lvm2"

local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "

-- ################################################################################
-- LOCAL FUNCTIONS

-- ################################################################################
-- PUBLIC FUNCTIONS

function get_startstop(self, clientdata)
        return modelfunctions.get_startstop(processname)
end

function startstop_service(self, startstop, action)
        return modelfunctions.startstop_service(startstop, action)
end

function getstatus()
	return modelfunctions.getstatus(processname, packagename, "LVM Status")
end

function getstatusdetails()
	local status = {}
	status.pvdisplay = cfe({ type="longtext", label="Physical Volumes" })
	local cmd = path .. "pvdisplay"
	local f = io.popen(cmd)
	status.pvdisplay.value = f:read("*a") or ""
	f:close()

	status.lvdisplay = cfe({ type="longtext", label="Logical Volumes" })
	cmd = path .. "lvdisplay"
	f = io.popen(cmd)
	status.lvdisplay.value = f:read("*a") or ""
	f:close()
	
	return cfe({ type="group", value=status, label="LVM Status Details" })
end