usr/src/lib/pysmf/rad_dev.py
changeset 801 801fce0dc0e2
parent 800 c7589c9a52a7
child 802 909b2ab3c352
--- a/usr/src/lib/pysmf/rad_dev.py	Tue Feb 07 11:30:56 2012 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
-#
-
-""" A thin wrapper around the SMF support provided by rad """
-
-from __future__ import absolute_import
-import rad.client as client
-import rad.adaptor as adaptor
-import rad.util as util
-import threading
-import smf.fmri
-import os
-
-_RAD_SMF_DOMAIN = "org.opensolaris.os.smf"
-_RAD_SMF_MODULE = "/usr/lib/rad/module/mod_smf_old.so"
-_RAD_SMF_AGGREGATOR = client.Name(_RAD_SMF_DOMAIN, [("type", "aggregator")])
-
-class Repository:
-	""" Represents a connection to the SCF repository """
-
-	def __init__(self, doorpath = None):
-		""" Establishes a connection to the SCF repository """
-		if doorpath:
-			env = os.environ.copy()
-			env["LIBSCF_DOORPATH"] = doorpath
-		else:
-			env = None
-		self._rc = util.connect_private([ _RAD_SMF_MODULE ], env = env)
-		self._lock = threading.Lock()
-		self._aggr = None
-
-	@staticmethod
-	def parts_to_name(service, instance = None):
-		""" Converts service and/or instance to a rad.client.Name """
-		kvs = [("type", "service"), ("service", service)]
-		if instance:
-			kvs.append(("instance", instance))
-		return client.Name(_RAD_SMF_DOMAIN, kvs)
-
-	@staticmethod
-	def fmri_to_name(fmri):
-		""" Converts an FMRI object to a rad.client.Name """
-		if fmri.get_scope() and fmri.get_scope() != "localhost":
-			raise ValueError, "non-localhost scope is unsupported"
-
-		return Repository.parts_to_name(fmri.get_service(),
-		    fmri.get_instance())
-
-	def lookup_byname(self, name):
-		""" Look up a service/instance object by rad.client.Name """
-		return adaptor.RawAdaptor(self._rc.get_object(name))
-	
-	def lookup(self, fmri):
-		""" Look up a service/instance object by FMRI object """
-		return self.lookup_byname(self.fmri_to_name(fmri))
-
-	def lookup_byfmri(self, fmri):
-		""" Look up a service/instance object by svc: FMRI string """
-		return self.lookup(smf.fmri.FMRI.parse(fmri))
-
-	def lookup_byparts(self, service, instance = None):
-		""" Look up a service/instance object by svc and/or inst """
-		return self.lookup(self.parts_to_name(service, instance))
-
-	def get_master(self):
-		""" Returns the SMF master object """
-		with self._lock:
-			if self._aggr == None:
-				self._aggr = self.lookup_byname(
-				    _RAD_SMF_AGGREGATOR)
-		return self._aggr
-
-	def close(self):
-		""" Closes the connection to the SCF repository """
-		self._rc.close()