From 18359329c7a1ec413b1263236979b846d087aef7 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 31 Dec 2008 21:59:19 +0000 Subject: Added lvm2 controller with basic functionality. git-svn-id: svn://svn.alpinelinux.org/acf/lvm2/trunk@1660 ab2d0c66-481e-0410-8bed-d214d4d58bed --- Makefile | 44 ++++++++++++++++++++++++++++++++++++++++++++ README | 1 + config.mk | 10 ++++++++++ lvm2-controller.lua | 22 ++++++++++++++++++++++ lvm2-details-html.lsp | 18 ++++++++++++++++++ lvm2-logfile-html.lsp | 7 +++++++ lvm2-model.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ lvm2-startstop-html.lsp | 1 + lvm2-status-html.lsp | 1 + lvm2.menu | 3 +++ lvm2.roles | 2 ++ 11 files changed, 152 insertions(+) create mode 100644 Makefile create mode 100644 README create mode 100644 config.mk create mode 100644 lvm2-controller.lua create mode 100644 lvm2-details-html.lsp create mode 100644 lvm2-logfile-html.lsp create mode 100644 lvm2-model.lua create mode 120000 lvm2-startstop-html.lsp create mode 120000 lvm2-status-html.lsp create mode 100644 lvm2.menu create mode 100644 lvm2.roles diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bad0cb3 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +APP_NAME=lvm2 +PACKAGE=acf-$(APP_NAME) +VERSION=0.1.0 + +APP_DIST=\ + lvm2* \ + + +EXTRA_DIST=README Makefile config.mk + +DISTFILES=$(APP_DIST) $(EXTRA_DIST) + +TAR=tar + +P=$(PACKAGE)-$(VERSION) +tarball=$(P).tar.bz2 +install_dir=$(DESTDIR)/$(appdir)/$(APP_NAME) + +all: +clean: + rm -rf $(tarball) $(P) + +dist: $(tarball) + +install: + mkdir -p "$(install_dir)" + cp -a $(APP_DIST) "$(install_dir)" + +$(tarball): $(DISTFILES) + rm -rf $(P) + mkdir -p $(P) + cp -a $(DISTFILES) $(P) + $(TAR) -jcf $@ $(P) + rm -rf $(P) + +# target that creates a tar package, unpacks is and install from package +dist-install: $(tarball) + $(TAR) -jxf $(tarball) + $(MAKE) -C $(P) install DESTDIR=$(DESTDIR) + rm -rf $(P) + +include config.mk + +.PHONY: all clean dist install dist-install diff --git a/README b/README new file mode 100644 index 0000000..138d5cb --- /dev/null +++ b/README @@ -0,0 +1 @@ +ACF for lvm2 diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..45f4d21 --- /dev/null +++ b/config.mk @@ -0,0 +1,10 @@ +prefix=/usr +datadir=${prefix}/share +sysconfdir=${prefix}/etc +localstatedir=${prefix}/var +acfdir=${datadir}/acf +wwwdir=${acfdir}/www +cgibindir=${acfdir}/cgi-bin +appdir=${acfdir}/app +acflibdir=${acfdir}/lib +sessionsdir=${localstatedir}/lib/acf/sessions diff --git a/lvm2-controller.lua b/lvm2-controller.lua new file mode 100644 index 0000000..38253d8 --- /dev/null +++ b/lvm2-controller.lua @@ -0,0 +1,22 @@ +module(..., package.seeall) + +-- Load libraries +require("controllerfunctions") + +default_action = "status" + +function status(self) + return self.model.getstatus() +end + +function startstop(self) + return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata) +end + +function details(self) + return self.model.getstatusdetails() +end + +function expert(self) + return controllerfunctions.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit LVM2 Config", "Configuration Set") +end diff --git a/lvm2-details-html.lsp b/lvm2-details-html.lsp new file mode 100644 index 0000000..e035905 --- /dev/null +++ b/lvm2-details-html.lsp @@ -0,0 +1,18 @@ +<% local data, viewlibrary = ... +require("viewfunctions") +--[[ DEBUG INFORMATION +io.write("

DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(data)) +io.write("
") +--]] +%> + +<% viewlibrary.dispatch_component("status") %> + +

<%= data.label %>

+
+<% +displayitem(data.value.pvdisplay) +displayitem(data.value.lvdisplay) +%> +
diff --git a/lvm2-logfile-html.lsp b/lvm2-logfile-html.lsp new file mode 100644 index 0000000..048ab36 --- /dev/null +++ b/lvm2-logfile-html.lsp @@ -0,0 +1,7 @@ +<% local data, viewlibrary = ... +require("viewfunctions") +%> + +<% if viewlibrary and viewlibrary.dispatch_component then + viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {name="/var/log/messages", grep="lvm"}) +end %> diff --git a/lvm2-model.lua b/lvm2-model.lua new file mode 100644 index 0000000..2841035 --- /dev/null +++ b/lvm2-model.lua @@ -0,0 +1,43 @@ +module(..., package.seeall) + +-- Load libraries +require("modelfunctions") +require("fs") +require("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 startstop_service(action) + return modelfunctions.startstop_service(processname, 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="Logival 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 diff --git a/lvm2-startstop-html.lsp b/lvm2-startstop-html.lsp new file mode 120000 index 0000000..0ea2627 --- /dev/null +++ b/lvm2-startstop-html.lsp @@ -0,0 +1 @@ +../startstop-html.lsp \ No newline at end of file diff --git a/lvm2-status-html.lsp b/lvm2-status-html.lsp new file mode 120000 index 0000000..b2f8480 --- /dev/null +++ b/lvm2-status-html.lsp @@ -0,0 +1 @@ +../status-html.lsp \ No newline at end of file diff --git a/lvm2.menu b/lvm2.menu new file mode 100644 index 0000000..3f17188 --- /dev/null +++ b/lvm2.menu @@ -0,0 +1,3 @@ +#CAT GROUP/DESC TAB ACTION +Storage 50LVM Status details +Storage 50LVM Logfile logfile diff --git a/lvm2.roles b/lvm2.roles new file mode 100644 index 0000000..9d9f777 --- /dev/null +++ b/lvm2.roles @@ -0,0 +1,2 @@ +USER=lvm2:status,lvm2:logfile,lvm2:details,lvm2:startstop +ADMIN=lvm2:status,lvm2:logfile,lvm2:details,lvm2:startstop -- cgit v1.2.3