2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * ============================================== 2N/A * Name Service Switch libscf to python interface 2N/A * ============================================== 2N/A/* Python specific includes */ 2N/A/* libscf and other includes */ 2N/A * =================================== 2N/A * Nssscf Method structure definitions 2N/A * =================================== 2N/A /* Nssscf Type-specific fields go here. */ 2N/A * ======================= 2N/A * Nssscf helper functions 2N/A * ======================= 2N/A * ========================== 2N/A * Nssscf Instance management 2N/A * ========================== 2N/A /* libscf instance cleanup */ 2N/A /* libscf instance generic setup */ 2N/A /* libscf instance specific init */ 2N/A /* python specific */ 2N/A * ================================ 2N/A * Nssscf Instance member functions 2N/A * ================================ 2N/A "Cannot delete the service attribute");
2N/A "The service attribute value must be a string");
2N/A /* libscf instance specific init */ 2N/A /* re-set any libscf instance specific init */ 2N/A * ======================= 2N/A * Nssscf Instance methods 2N/A * ======================= 2N/A /* Get Operations */ 2N/A * Get all Service Property groups 2N/A * OUT: Tuple of property group names and types 2N/A "Unable to build Property group tuple");
2N/A "Unable to build Property group tuple");
2N/A "Unable to build Property group tuple");
2N/A /* ErrStrings (if any) should be set by now */ 2N/A * Get all Properties for a Property group 2N/A * OUT: Tuple of properties and types 2N/A "Property group argument must be a string");
2N/A /* alloc temp storage */ 2N/A /* get property group from service */ 2N/A "Property group does not exist");
2N/A "Service is not an instance");
2N/A "Service is not an instance");
2N/A "Property group does not exist");
2N/A "Cannot create property iterator");
2N/A /* setup and iterate properties in property group */ 2N/A "Unable to build Property tuple");
2N/A "Unable to build Property tuple");
2N/A "Unable to build Property tuple");
2N/A /* ErrStrings (if any) should be set by now */ 2N/A * IN: arg1=pg, arg2=prop 2N/A * OUT: Tuple of properties and types 2N/A "Property group and property names must be strings");
2N/A /* alloc temp storage */ 2N/A /* Always get composed properties using instance name */ 2N/A "Instance name missing");
2N/A "Could not get service instance");
2N/A "Composed property group does not exist");
2N/A /* get property from property group */ 2N/A "Cannot create property value iterator");
2N/A /* setup and iterate properties in property group */ 2N/A "Unable to build Property tuple");
2N/A "Unable to build Property tuple");
2N/A "Unable to build Property tuple");
2N/A /* ErrStrings (if any) should be set by now */ 2N/A * Get Service Property state 2N/A * OUT: String of current property state 2N/A * Get Service instance fmri 2N/A * OUT: String of current instance fmri 2N/A /* Test Operations */ 2N/A * Check Service state 2N/A * Test to see if a property group exists in the service 2N/A * IN: args is a property group string 2N/A "The argument must be a string");
2N/A "Service is not an instance");
2N/A "Service is not an instance");
2N/A /* ensure we have the most recent pg */ 2N/A * Create a property group given a name and type 2N/A * IN: arg1 is a property group name, arg2 is the type 2N/A "The arguments must be strings");
2N/A "Service is not an instance");
2N/A "Service is not an instance");
2N/A * Delete a property group and it's contents 2N/A * IN: arg is a property group string 2N/A "The argument must be a string");
2N/A "Service is not an instance");
2N/A "Service is not an instance");
2N/A ret = 0;
/* true if no property group exists */ 2N/A * Delcust (delete customizations) on a service and instance property group 2N/A * IN: arg is a property group string 2N/A "The argument must be a string");
2N/A /* do instance work - for effect */ 2N/A /* delete it if possible */ 2N/A /* do service work */ 2N/A ret = 0;
/* true if no property group exists */ 2N/A * Create or add a property value given a name, type and value 2N/A * IN: arg1 is a property group name, arg2 is the property 2N/A * arg3 is the type and arg4 is the value. Value may be either 2N/A * created if it does not previously exist. 2N/A * OUT: True or Exception 2N/A int ret = -
1;
/* fail by default */ 2N/A /* examine obj for string or sequence */ 2N/A for (i = 0; i < n; i++) {
2N/A "Tuple value not a string");
2N/A "The value must be a string or tuple of strings");
2N/A "The value must be a string or tuple of strings");
2N/A /* get property group from service */ 2N/A "Property group does not exist");
2N/A "Service is not an instance");
2N/A "Service is not an instance");
2N/A "Property group does not exist");
2N/A /* get property from property group */ 2N/A "Get property error");
2N/A /* setup transaction */ 2N/A "Could not create transaction or transaction entry");
2N/A "Could not start transaction");
2N/A "Invalid property type");
2N/A "Could not create new property transaction");
2N/A "Could not create change property transaction");
2N/A "Cannot create value handle");
2N/A "Cannot create value string");
2N/A "Cannot add string to entry");
2N/A ret = 0;
/* Successful commit */ 2N/A "Cannot commit values to property");
2N/A "Property group update failure");
2N/A /* Admin Operations */ 2N/A * Generic Service state changer 2N/A * IN: fmri and new state (fmri defaults to fmri:default if not an instance) 2N/A "Out of memory.\n");
2N/A "Unknown Validate Error.\n");
2N/A * ===================================== 2N/A * Nssscf Instance structure definitions 2N/A * ===================================== 2N/A /* Get Operations */ 2N/A "Get the list of the services property groups" },
2N/A "Get list of properties for a property group (arg1)" },
2N/A "Get values for property group, property (arg1, arg2)" },
2N/A "Get Service state" },
2N/A "Get Service instance FMRI. (May be identical to service name)" },
2N/A /* Test Operations */ 2N/A "Check if service is enabled" },
2N/A "Add a property group given a pgname and pgtype (arg1,arg2)" },
2N/A "Set pg/prop to value(s): pg, name type, value or (value...)" },
2N/A "Delete a property group [and it's contents]. (arg1)" },
2N/A "Delete customizations on a service property group. (arg1)" },
2N/A /* Admin Operations */ 2N/A "Enable service instance" },
2N/A "Disable service instance" },
2N/A "Refresh service instance" },
2N/A "Restart service instance" },
2N/A "Immediately send service instance to maintenance state" },
2N/A "Immediately send service instance to degraded state" },
2N/A "Restore service instance" },
2N/A "Validate current service instance configuration" },
2N/A "nssscf.Nssscf",
/* tp_name */ 2N/A 0,
/* tp_itemsize */ 2N/A 0,
/* tp_as_number */ 2N/A 0,
/* tp_as_sequence */ 2N/A 0,
/* tp_as_mapping */ 2N/A 0,
/* tp_getattro */ 2N/A 0,
/* tp_setattro */ 2N/A 0,
/* tp_as_buffer */ 2N/A "Nssscf objects",
/* tp_doc */ 2N/A 0,
/* tp_traverse */ 2N/A 0,
/* tp_richcompare */ 2N/A 0,
/* tp_weaklistoffset */ 2N/A 0,
/* tp_iternext */ 2N/A 0,
/* tp_descr_get */ 2N/A 0,
/* tp_descr_set */ 2N/A 0,
/* tp_dictoffset */ 2N/A * ============================= 2N/A * Nssscf library Initialization 2N/A * ============================= 2N/A "SUNW Project Private" },
2N/A /* Create Nsscf Exception */ 2N/A /* Create Nssscf Module */ 2N/A * =============================== 2N/A * Nssscf library helper functions 2N/A * =============================== 2N/A * Get the full AS-IS service name. [svc:/]service[:instance] 2N/A * caller must prune if/as needed. Caller must free string. 2N/A * Get the service name if it is an instance, NULL otherwise 2N/A * Caller must free string. 2N/A return (
svcn);
/* service has an instance name */ 2N/A * Get the service name if it is not and instance, append :default 2N/A * to it's name. Caller must free string. 2N/A return (
svcn);
/* service is an instance name */ 2N/A return (
NULL);
/* storage problem return NULL */ 2N/A * Sets the Python instance's smf service handle 2N/A *
inst =
'\0';
/* trim instance if provided */ 2N/A * Given a service name, if it is an instance, return the 2N/A * current state. If service is not aninstance try fmri:default' 2N/A * Caller must free string. 2N/A "Argument must be a string");
2N/A }
else {
/* encode */