Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 May 2007 21:27:42 GMT
From:      Ivan Voras <ivoras@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 119600 for review
Message-ID:  <200705092127.l49LRg1B077445@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=119600

Change 119600 by ivoras@ivoras_finstall on 2007/05/09 21:27:18

	Started implementing the more easier interfaces

Affected files ...

.. //depot/projects/soc2007/ivoras_finstall/pybackend/globals.py#2 edit
.. //depot/projects/soc2007/ivoras_finstall/pybackend/systoold.py#2 edit
.. //depot/projects/soc2007/ivoras_finstall/pybackend/systoolengine.py#2 edit

Differences ...

==== //depot/projects/soc2007/ivoras_finstall/pybackend/globals.py#2 (text+ko) ====

@@ -29,11 +29,14 @@
 # the caps array. Each caps string corresponds to a group of XML-RPC
 # functions the server claims to support.
 # The caps are:
-#		"systoold"	: Special functions: GetId, GetCaps, SetRoot
+#		"systoold"	: Special functions: GetId, GetCaps, SetDestRoot,
+#				  SetLiveRoot
 #		"rcconf"	: Low-level functions that alter /etc/rc.conf:
 #				  GetConf, SetConf
+#		"disk"		: Low-level drive & file system functions:
+#				  GetDrives, GetMountPoints, Mount
 # These functions are implemented in systoolengine.py
-server_caps = ["systoold", "rcconf"]
+server_caps = ["systoold", "rcconf", "disk"]
 
 # debug level. 0 = no debug
 debug_level = 0

==== //depot/projects/soc2007/ivoras_finstall/pybackend/systoold.py#2 (text+ko) ====


==== //depot/projects/soc2007/ivoras_finstall/pybackend/systoolengine.py#2 (text+ko) ====

@@ -22,36 +22,82 @@
 # SysToolD Engine 
 
 import os, sys
+
 import globals
+import freebsd
 from conffile import ConfFile
 
 
 class SysToolEngine:
 
+
 	def __init__(self):
-		self.root_dir = ""	# self.root_dir is sans final slash
+		self.root_dest = ""	# Config file / "new" root, sans final slash
+		self.root_live = ""	# Live file system root (for binaries!)
+
 
 	def GetId(self):
 		"""Returns server ID string"""
 		return globals.server_id
 
+
 	def GetCaps(self):
 		"""Returns server capabilities array"""
 		return globals.server_caps
 
-	def SetRoot(self, root_dir):
-		"""Sets internal root directory (so Get/SetConf can be used
-		with alternative root"""
-		self.root_dir = root_dir
+
+	def SetDestRoot(self, root_dir):
+		"""Sets internal root directory for installation and config tasks
+		(so Get/SetConf can be used with alternative root)"""
+		self.root_conf = root_dir
+		return True
+
+
+	def SetLiveRoot(self, root_dir):
+		"""Notifies SysTool Engine where to expect utility binaries."""
+		self.root_live = root_dir
 		return True
 
+
 	def GetConf(self, name):
 		"""Returns configuration variable from /etc/rc.conf"""
-		cf = ConfFile("%s/etc/rc.conf" % self.root_dir)
+		cf = ConfFile("%s/etc/rc.conf" % self.root_dest)
 		val = cf.GetConf(name, None)
 		return val
 
-	def SetConf(self, name, value):
+
+	def SetConf(self, name, value, description):
 		"""Sets configuration variable to /etc/rc.conf"""
+		cf = ConfFile("%s/etc/rc.conf" % self.root_dest)
+		cf.SetConf(name, value, description)
+		return True
+
+
+	def GetDrives(self):
+		"""Returns an array of drives the kernel knows about.
+		Examines "kern.drives" sysctl. This is NOT the list of
+		valid GEOM leaves which can be mounted, but a list of
+		found hardware."""
+		return freebsd.get_sysctl("kern.disks").split(" ")
+
+
+	def GetMountPoints(self):
+		"""Returns a list of dictionaries containing information
+		about currently mounted file systems"""
+		raw_mounts = freebsd.get_cmd_output("%s -p" % freebsd.cmd_mount).split("\n")
+		mounts = []
+		for m in raw_mounts:
+			while m.find("\t\t") != -1:
+				m = m.replace("\t\t", "\t")
+			m = m.split("\t")
+			mounts.append({"device" : m[0], "mountpoint" : m[1], "filesystem" : m[2], "flags" : m[3]})
+		return mounts
+
+
+	def Mount(self, device, mountpoint, filesystem, flags):
+		"""Mounts a file system."""
 		return False
 
+
+
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705092127.l49LRg1B077445>